source: git/factory/cf_iter.cc @ 183688

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