My Project
Public Member Functions | Private Attributes
CFIterator Class Reference

class to iterate through CanonicalForm's More...

#include <cf_iter.h>

Public Member Functions

 CFIterator ()
 
 CFIterator (const CFIterator &)
 
 CFIterator (const CanonicalForm &)
 
 CFIterator (const CanonicalForm &, const Variable &)
 
 ~CFIterator ()
 
CFIteratoroperator= (const CFIterator &)
 
CFIteratoroperator= (const CanonicalForm &)
 
CF_NO_INLINE CFIteratoroperator++ ()
 CFIterator::operator ++ (), operator ++ ( int ) More...
 
CF_NO_INLINE CFIteratoroperator++ (int)
 
CF_NO_INLINE int hasTerms () const
 check if iterator has reached the end of CanonicalForm More...
 
CF_NO_INLINE CanonicalForm coeff () const
 get the current coefficient More...
 
CF_NO_INLINE int exp () const
 get the current exponent More...
 

Private Attributes

CanonicalForm data
 
termList cursor
 
bool ispoly
 
bool hasterms
 

Detailed Description

class to iterate through CanonicalForm's

Note
a (multivariate) polynomial is viewed as a univariate poly in its main variable

Definition at line 44 of file cf_iter.h.

Constructor & Destructor Documentation

◆ CFIterator() [1/4]

CFIterator::CFIterator ( )

Definition at line 15 of file cf_iter.cc.

16{
17 data = 0; cursor = 0;
18 ispoly = false; hasterms = false;
19}
bool ispoly
Definition: cf_iter.h:48
CanonicalForm data
Definition: cf_iter.h:46
termList cursor
Definition: cf_iter.h:47
bool hasterms
Definition: cf_iter.h:48

◆ CFIterator() [2/4]

CFIterator::CFIterator ( const CFIterator i)

Definition at line 21 of file cf_iter.cc.

22{
23 data = i.data;
24 cursor = i.cursor;
25 ispoly = i.ispoly;
26 hasterms = i.hasterms;
27}
int i
Definition: cfEzgcd.cc:132

◆ CFIterator() [3/4]

CFIterator::CFIterator ( const CanonicalForm f)

Definition at line 29 of file cf_iter.cc.

30{
31 if ( f.inBaseDomain() || f.inQuotDomain() )
32 {
33 data = f; cursor = 0;
34 ispoly = false; hasterms = true;
35 }
36 else
37 {
38 data = f;
39 cursor = ((InternalPoly*)(f.value))->firstTerm;
40 ispoly = true; hasterms = true;
41 }
42}
FILE * f
Definition: checklibs.c:9
factory's class for polynomials
Definition: int_poly.h:71

◆ CFIterator() [4/4]

CFIterator::CFIterator ( const CanonicalForm f,
const Variable v 
)

Definition at line 44 of file cf_iter.cc.

45{
46 ASSERT( !f.inQuotDomain(), "illegal iterator" );
47 ASSERT( v.level() > 0, "illegal iterator" );
48 if ( f.inBaseDomain() )
49 {
50 data = f; cursor = 0;
51 ispoly = false; hasterms = true;
52 }
53 else
54 {
55 if ( f.mvar() == v )
56 {
57 data = f;
58 cursor = ((InternalPoly*)(f.value))->firstTerm;
59 ispoly = true; hasterms = true;
60 }
61 else if ( v > f.mvar() )
62 {
63 data = f; cursor = 0;
64 ispoly = false; hasterms = true;
65 }
66 else
67 {
68 data = swapvar( f, v, f.mvar().next() );
69 if ( data.mvar() == f.mvar().next() )
70 {
71 cursor = ((InternalPoly*)(data.value))->firstTerm;
72 ispoly = true; hasterms = true;
73 }
74 else
75 {
76 cursor = 0;
77 ispoly = false; hasterms = true;
78 }
79 }
80 }
81}
CanonicalForm FACTORY_PUBLIC swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
#define ASSERT(expression, message)
Definition: cf_assert.h:99
InternalCF * value
Definition: canonicalform.h:88
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
int level() const
Definition: variable.h:49
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ~CFIterator()

CFIterator::~CFIterator ( )

Definition at line 83 of file cf_iter.cc.

84{
85 data = 0; cursor = 0;
86}

Member Function Documentation

◆ coeff()

CF_INLINE CanonicalForm CFIterator::coeff ( ) const

get the current coefficient

CF_INLINE CanonicalForm CFIterator::coeff () const.

coeff() - return coefficient of current term of CO.

CO has to point to a valid term.

Definition at line 88 of file cf_iter_inline.cc.

89{
90 ASSERT( hasterms, "lib error: iterator out of terms" );
91 if ( ispoly )
92 return cursor->coeff;
93 else
94 return data;
95}
CanonicalForm coeff
Definition: int_poly.h:36

◆ exp()

CF_INLINE int CFIterator::exp ( ) const

get the current exponent

CF_INLINE int CFIterator::exp () const.

exp() - return exponent of current term of CO.

CO has to point to a valid term.

Definition at line 105 of file cf_iter_inline.cc.

106{
107 ASSERT( hasterms, "lib error: iterator out of terms" );
108 if ( ispoly )
109 return cursor->exp;
110 else
111 return 0;
112}
int exp
Definition: int_poly.h:37

◆ hasTerms()

CF_INLINE int CFIterator::hasTerms ( ) const

check if iterator has reached the end of CanonicalForm

CF_INLINE int CFIterator::hasTerms () const.

hasTerm() - check whether CO points to a valid term.

Return true if CO points to a valid term, false if CO points to the end of the sequence of terms.

Definition at line 75 of file cf_iter_inline.cc.

76{
77 return hasterms;
78}

◆ operator++() [1/2]

CF_INLINE CFIterator & CFIterator::operator++ ( )

CFIterator::operator ++ (), operator ++ ( int )

operator ++() - advance CO to next term.

Advance current term to next term in the sequence of terms or to end of sequence. CO has to point to a valid term.

The postfix and prefix operator are identical.

Definition at line 126 of file cf_iter_inline.cc.

127{
128 ASSERT( hasterms, "lib error: iterator out of terms" );
129 if ( ispoly ) {
130 cursor = cursor->next;
131 hasterms = cursor != 0;
132 } else
133 hasterms = false;
134
135 return *this;
136}
term * next
Definition: int_poly.h:35

◆ operator++() [2/2]

CF_INLINE CFIterator & CFIterator::operator++ ( int  )
See also
CFIterator::operator

Definition at line 142 of file cf_iter_inline.cc.

143{
144 ASSERT( hasterms, "lib error: iterator out of terms" );
145 if ( ispoly ) {
146 cursor = cursor->next;
147 hasterms = cursor != 0;
148 } else
149 hasterms = false;
150
151 return *this;
152}

◆ operator=() [1/2]

CFIterator & CFIterator::operator= ( const CanonicalForm f)

Definition at line 102 of file cf_iter.cc.

103{
104 if ( f.inBaseDomain() || f.inQuotDomain() )
105 {
106 data = f; cursor = 0;
107 ispoly = false; hasterms = true;
108 }
109 else
110 {
111 data = f;
112 cursor = ((InternalPoly*)(f.value))->firstTerm;
113 ispoly = true; hasterms = true;
114 }
115 return *this;
116}

◆ operator=() [2/2]

CFIterator & CFIterator::operator= ( const CFIterator i)

Definition at line 89 of file cf_iter.cc.

90{
91 if ( this != &i )
92 {
93 data = i.data;
94 cursor = i.cursor;
95 ispoly = i.ispoly;
96 hasterms = i.hasterms;
97 }
98 return *this;
99}

Field Documentation

◆ cursor

termList CFIterator::cursor
private

Definition at line 47 of file cf_iter.h.

◆ data

CanonicalForm CFIterator::data
private

Definition at line 46 of file cf_iter.h.

◆ hasterms

bool CFIterator::hasterms
private

Definition at line 48 of file cf_iter.h.

◆ ispoly

bool CFIterator::ispoly
private

Definition at line 48 of file cf_iter.h.


The documentation for this class was generated from the following files: