My Project
Loading...
Searching...
No Matches
PowerSeries.h
Go to the documentation of this file.
1#ifndef POWER_SERIES_HEADER
2#define POWER_SERIES_HEADER
3#include "kernel/mod2.h"
4#include "Poly.h"
5template <class traits> class PowerSeriesInputIterator:
6public std::
7iterator<
8 std::input_iterator_tag,
9 typename traits::expansion_type,
10 int,
11 shared_ptr<const typename traits::expansion_type>,
12 const typename traits::expansion_type
13 >
14{
15 private:
16 typedef typename traits::denominator_type denominator_type;
17 typedef typename traits::numerator_type numerator_type;
18 typedef typename traits::expansion_type expansion_type;
22 int state;
25 public:
27 denominator_type den_arg):
28 data(den_arg.getRing()),
29 lastPot(den_arg.getRing()),
30 numerator(num_arg),
31 denominator(den_arg)
32 {
33 ring r=denominator.getRing();
34 //not the lead coef Number c=denominator.leadCoef();
35 Number c(1,r);
36 typename traits::denominator_type::iterator it=denominator.begin();
37 typename traits::denominator_type::iterator end=denominator.end();
38 while(it!=end)
39 {
40 if ((*it).isConstant())
41 {
42 //change this type
43 c=denominator_type(*it).leadCoef();
44 break;
45 }
46 ++it;
47 }
48 c=Number(1,r)/c;
49 numerator*=c;
50 denominator*=c;
52 toPot*=Number(-1,r);
53 //change this type
56 state=0;
57 }
59 {
60 state=-1;
61 }
62 void shorten()
63 {
64 typename expansion_type::iterator it=data.begin();
65 typename expansion_type::iterator end=data.end();
66 ring r=data.getRing();
67 expansion_type remove(r);
68 while(it!=end)
69 {
70 if(it->lmTotalDegree()<state)
71 {
72 remove+=expansion_type(*it);
73 }
74 it++;
75 }
76 remove*=Number(-1,r);
77 data+=remove;
78 }
80 {
81 typename expansion_type::iterator it=data.begin();
82 typename expansion_type::iterator end=data.end();
83 ring r=data.getRing();
85 while(it!=end)
86 {
87 if(it->lmTotalDegree()==state)
88 {
89 res+=expansion_type(*it);
90 }
91 it++;
92 }
93 return res;
94 }
96 {
97 state++;
98 shorten();
101 return *this;
102 }
103 //bad if this are iterators for different PowerSeries
105 {
106 return state==t2.state;
107 }
109 {
110 return state!=t2.state;
111 }
113 {
114 PowerSeriesInputIterator it(*this);
115 ++(*this);
116 return it;
117 }
119 {
120 return expansion_type(getValue());
121 }
122 shared_ptr<const expansion_type> operator->()
123 {
124 return shared_ptr<const expansion_type>(new expansion_type(getValue()));
125 }
126};
127
128
129template<class traits> class PowerSeriesBase
130{
131 public:
132 typedef typename traits::denominator_type denominator_type;
133 typedef typename traits::numerator_type numerator_type;
134 protected:
137 public:
140 {
141 assume(a.getRing()==b.getRing());
142 //asume b!=NULL
143 }
146 {
148 }
150 {
151 return iterator();
152 }
153};
159{
160 public:
165};
167{
168 public:
173};
174
175#endif
PowerSeriesBase< PowerSeriesPolyTraits > PowerSeries
Definition: PowerSeries.h:156
PowerSeriesBase< PowerSeriesVectorTraits > VectorPowerSeries
Definition: PowerSeries.h:157
VectorPowerSeries create_type
Definition: PowerSeries.h:171
PowerSeries create_type
Definition: PowerSeries.h:163
CanonicalForm b
Definition: cfModGcd.cc:4103
Definition: Number.h:34
denominator_type denominator
Definition: PowerSeries.h:135
traits::numerator_type numerator_type
Definition: PowerSeries.h:133
traits::denominator_type denominator_type
Definition: PowerSeries.h:132
numerator_type numerator
Definition: PowerSeries.h:136
iterator begin()
Definition: PowerSeries.h:145
PowerSeriesInputIterator< traits > iterator
Definition: PowerSeries.h:144
PowerSeriesBase(const numerator_type &a, const denominator_type &b)
Definition: PowerSeries.h:139
iterator end()
Definition: PowerSeries.h:149
bool operator==(const PowerSeriesInputIterator &t2)
Definition: PowerSeries.h:104
const expansion_type operator*()
Definition: PowerSeries.h:118
expansion_type getValue()
Definition: PowerSeries.h:79
traits::denominator_type denominator_type
Definition: PowerSeries.h:16
PowerSeriesInputIterator(numerator_type num_arg, denominator_type den_arg)
Definition: PowerSeries.h:26
traits::expansion_type expansion_type
Definition: PowerSeries.h:18
expansion_type data
Definition: PowerSeries.h:23
bool operator!=(const PowerSeriesInputIterator &t2)
Definition: PowerSeries.h:108
traits::numerator_type numerator_type
Definition: PowerSeries.h:17
PowerSeriesInputIterator & operator++()
Definition: PowerSeries.h:95
denominator_type lastPot
Definition: PowerSeries.h:24
numerator_type numerator
Definition: PowerSeries.h:20
PowerSeriesInputIterator operator++(int)
Definition: PowerSeries.h:112
denominator_type toPot
Definition: PowerSeries.h:21
shared_ptr< const expansion_type > operator->()
Definition: PowerSeries.h:122
denominator_type denominator
Definition: PowerSeries.h:19
Definition: Poly.h:509
CanonicalForm res
Definition: facAbsFact.cc:60
#define assume(x)
Definition: mod2.h:389
Definition: janet.h:15