1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | #ifdef HAVE_CONFIG_H |
---|
4 | #include "config.h" |
---|
5 | #endif /* HAVE_CONFIG_H */ |
---|
6 | |
---|
7 | #include "cf_assert.h" |
---|
8 | |
---|
9 | #include "cf_defs.h" |
---|
10 | #include "cf_iter.h" |
---|
11 | #include "int_cf.h" |
---|
12 | #include "int_poly.h" |
---|
13 | |
---|
14 | |
---|
15 | CFIterator::CFIterator() |
---|
16 | { |
---|
17 | data = 0; cursor = 0; |
---|
18 | ispoly = false; hasterms = false; |
---|
19 | } |
---|
20 | |
---|
21 | CFIterator::CFIterator( const CFIterator & i ) |
---|
22 | { |
---|
23 | data = i.data; |
---|
24 | cursor = i.cursor; |
---|
25 | ispoly = i.ispoly; |
---|
26 | hasterms = i.hasterms; |
---|
27 | } |
---|
28 | |
---|
29 | CFIterator::CFIterator( const CanonicalForm & f ) |
---|
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 | } |
---|
43 | |
---|
44 | CFIterator::CFIterator( const CanonicalForm & f, const Variable & v ) |
---|
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 | } |
---|
82 | |
---|
83 | CFIterator::~CFIterator() |
---|
84 | { |
---|
85 | data = 0; cursor = 0; |
---|
86 | } |
---|
87 | |
---|
88 | CFIterator& |
---|
89 | CFIterator::operator= ( const CFIterator & i ) |
---|
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 | } |
---|
100 | |
---|
101 | CFIterator& |
---|
102 | CFIterator::operator= ( const CanonicalForm & f ) |
---|
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 | } |
---|