1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id$ */ |
---|
3 | |
---|
4 | #include <config.h> |
---|
5 | |
---|
6 | #include "assert.h" |
---|
7 | |
---|
8 | #include "cf_defs.h" |
---|
9 | #include "cf_iter.h" |
---|
10 | #include "int_cf.h" |
---|
11 | #include "int_poly.h" |
---|
12 | |
---|
13 | |
---|
14 | CFIterator::CFIterator() |
---|
15 | { |
---|
16 | data = 0; cursor = 0; |
---|
17 | ispoly = false; hasterms = false; |
---|
18 | } |
---|
19 | |
---|
20 | CFIterator::CFIterator( const CFIterator & i ) |
---|
21 | { |
---|
22 | data = i.data; |
---|
23 | cursor = i.cursor; |
---|
24 | ispoly = i.ispoly; |
---|
25 | hasterms = i.hasterms; |
---|
26 | } |
---|
27 | |
---|
28 | CFIterator::CFIterator( const CanonicalForm & f ) |
---|
29 | { |
---|
30 | if ( f.inBaseDomain() || f.inQuotDomain() ) |
---|
31 | { |
---|
32 | data = f; cursor = 0; |
---|
33 | ispoly = false; hasterms = true; |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | data = f; |
---|
38 | cursor = ((InternalPoly*)(f.value))->firstTerm; |
---|
39 | ispoly = true; hasterms = true; |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | CFIterator::CFIterator( const CanonicalForm & f, const Variable & v ) |
---|
44 | { |
---|
45 | ASSERT( !f.inQuotDomain(), "illegal iterator" ); |
---|
46 | ASSERT( v.level() > 0, "illegal iterator" ); |
---|
47 | if ( f.inBaseDomain() ) |
---|
48 | { |
---|
49 | data = f; cursor = 0; |
---|
50 | ispoly = false; hasterms = true; |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | if ( f.mvar() == v ) |
---|
55 | { |
---|
56 | data = f; |
---|
57 | cursor = ((InternalPoly*)(f.value))->firstTerm; |
---|
58 | ispoly = true; hasterms = true; |
---|
59 | } |
---|
60 | else if ( v > f.mvar() ) |
---|
61 | { |
---|
62 | data = f; cursor = 0; |
---|
63 | ispoly = false; hasterms = true; |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | data = swapvar( f, v, f.mvar().next() ); |
---|
68 | if ( data.mvar() == f.mvar().next() ) |
---|
69 | { |
---|
70 | cursor = ((InternalPoly*)(data.value))->firstTerm; |
---|
71 | ispoly = true; hasterms = true; |
---|
72 | } |
---|
73 | else |
---|
74 | { |
---|
75 | cursor = 0; |
---|
76 | ispoly = false; hasterms = true; |
---|
77 | } |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | CFIterator::~CFIterator() |
---|
83 | { |
---|
84 | data = 0; cursor = 0; |
---|
85 | } |
---|
86 | |
---|
87 | CFIterator& |
---|
88 | CFIterator::operator= ( const CFIterator & i ) |
---|
89 | { |
---|
90 | if ( this != &i ) |
---|
91 | { |
---|
92 | data = i.data; |
---|
93 | cursor = i.cursor; |
---|
94 | ispoly = i.ispoly; |
---|
95 | hasterms = i.hasterms; |
---|
96 | } |
---|
97 | return *this; |
---|
98 | } |
---|
99 | |
---|
100 | CFIterator& |
---|
101 | CFIterator::operator= ( const CanonicalForm & f ) |
---|
102 | { |
---|
103 | if ( f.inBaseDomain() || f.inQuotDomain() ) |
---|
104 | { |
---|
105 | data = f; cursor = 0; |
---|
106 | ispoly = false; hasterms = true; |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | data = f; |
---|
111 | cursor = ((InternalPoly*)(f.value))->firstTerm; |
---|
112 | ispoly = true; hasterms = true; |
---|
113 | } |
---|
114 | return *this; |
---|
115 | } |
---|