My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
CPolynomialSummator Class Reference

CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(. More...

#include <summator.h>

Public Member Functions

 CPolynomialSummator (const ring &rBaseRing, bool bUsePolynomial=false)
 
 ~CPolynomialSummator ()
 
void AddAndDelete (poly pSummand, int iLength)
 
void AddAndDelete (poly pSummand)
 
void operator+= (poly pSummand)
 
void Add (poly pSummand, int iLength)
 
void Add (poly pSummand)
 
poly AddUpAndClear ()
 
poly AddUpAndClear (int *piLength)
 
 operator poly ()
 
 CPolynomialSummator (const CPolynomialSummator &)
 Copy constructor. More...
 

Private Member Functions

CPolynomialSummatoroperator= (const CPolynomialSummator &)
 no assignment operator yet More...
 

Private Attributes

const ring & m_basering
 
const bool m_bUsePolynomial
 
union {
sBucket_pt m_bucket
 
poly m_poly
 
m_temp
 

Detailed Description

CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(.

Definition at line 20 of file summator.h.

Constructor & Destructor Documentation

◆ CPolynomialSummator() [1/2]

CPolynomialSummator::CPolynomialSummator ( const ring &  rBaseRing,
bool  bUsePolynomial = false 
)

Definition at line 34 of file summator.cc.

34 :
35 m_basering(rBaseRing), m_bUsePolynomial(bUsePolynomial)
36{
37#ifdef RDEBUG
38 rTest(rBaseRing);
39#endif
40
41 if(bUsePolynomial)
42 m_temp.m_poly = NULL;
43 else
44 {
46 m_temp.m_bucket = sBucketCreate(rBaseRing);
47 }
48}
const ring & m_basering
Definition: summator.h:23
const bool m_bUsePolynomial
Definition: summator.h:24
union CPolynomialSummator::@6 m_temp
#define assume(x)
Definition: mod2.h:389
#define NULL
Definition: omList.c:12
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:106
#define rTest(r)
Definition: ring.h:782
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96

◆ ~CPolynomialSummator()

CPolynomialSummator::~CPolynomialSummator ( )

Definition at line 71 of file summator.cc.

72{
74 {
75 poly out;
76 int pLength;
77
78 sBucketClearAdd(m_temp.m_bucket, &out, &pLength);
79 sBucketDestroy(&m_temp.m_bucket);
80
81 assume(out == NULL); // otherwise wrong usage pattern!
82 if(out != NULL)
83 p_Delete(&out, m_basering);
84// m_temp.m_bucket = NULL;
85 }
86 else
87 {
88 assume(m_temp.m_poly == NULL); // otherwise wrong usage pattern!
89 if(m_temp.m_poly!=NULL)
90 {
91#ifdef PDEBUG
92 p_Test(m_temp.m_poly, m_basering);
93#endif
94 p_Delete(&m_temp.m_poly, m_basering);
95// m_temp.m_poly = NULL;
96 }
97 }
98}
static int pLength(poly a)
Definition: p_polys.h:188
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
#define p_Test(p, r)
Definition: p_polys.h:159
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:103
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:275

◆ CPolynomialSummator() [2/2]

CPolynomialSummator::CPolynomialSummator ( const CPolynomialSummator b)

Copy constructor.

Definition at line 185 of file summator.cc.

185 :
186 m_basering(b.m_basering), m_bUsePolynomial(b.m_bUsePolynomial)
187{
188// try{
190 m_temp.m_poly = p_Copy( b.m_temp.m_poly, m_basering);
191 else
192 {
193 sBucketCanonicalize(b.m_temp.m_bucket);
194 m_temp.m_bucket = sBucketCopy(b.m_temp.m_bucket);
195 }
196// }
197// catch(...)
198// {
199// assume(false);
200// }
201}
CanonicalForm b
Definition: cfModGcd.cc:4103
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
sBucket_pt sBucketCopy(const sBucket_pt bucket)
Copy sBucket non-intrusive!!!
Definition: sbuckets.cc:70
void sBucketCanonicalize(sBucket_pt bucket)
Definition: sbuckets.cc:401

Member Function Documentation

◆ Add() [1/2]

void CPolynomialSummator::Add ( poly  pSummand)

Definition at line 178 of file summator.cc.

179{
180 AddAndDelete(p_Copy(pSummand, m_basering));
181}
void AddAndDelete(poly pSummand, int iLength)
Definition: summator.cc:100

◆ Add() [2/2]

void CPolynomialSummator::Add ( poly  pSummand,
int  iLength 
)

Definition at line 173 of file summator.cc.

174{
175 AddAndDelete(p_Copy(pSummand, m_basering), iLength);
176}

◆ AddAndDelete() [1/2]

void CPolynomialSummator::AddAndDelete ( poly  pSummand)

Definition at line 112 of file summator.cc.

113{
114#ifdef PDEBUG
115 p_Test(pSummand, m_basering);
116#endif
117
119 m_temp.m_poly = p_Add_q(m_temp.m_poly, pSummand, m_basering);
120 else
121 sBucket_Add_p(m_temp.m_bucket, pSummand, 0); // sBucket_Merge_p???
122}
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:203

◆ AddAndDelete() [2/2]

void CPolynomialSummator::AddAndDelete ( poly  pSummand,
int  iLength 
)

Definition at line 100 of file summator.cc.

101{
102#ifdef PDEBUG
103 p_Test(pSummand, m_basering);
104#endif
105
107 m_temp.m_poly = p_Add_q(m_temp.m_poly, pSummand, m_basering);
108 else
109 sBucket_Add_p(m_temp.m_bucket, pSummand, iLength); // sBucket_Merge_p???
110}

◆ AddUpAndClear() [1/2]

poly CPolynomialSummator::AddUpAndClear ( )

Definition at line 124 of file summator.cc.

125{
126 poly out = NULL;
127
129 {
130 out = m_temp.m_poly;
131 m_temp.m_poly = NULL;
132 }
133 else
134 {
135 int pLength;
136 sBucketClearAdd(m_temp.m_bucket, &out, &pLength);
137 }
138
139#ifdef PDEBUG
140 p_Test(out, m_basering);
141#endif
142
143 return out;
144}

◆ AddUpAndClear() [2/2]

poly CPolynomialSummator::AddUpAndClear ( int *  piLength)

Definition at line 147 of file summator.cc.

148{
149 poly out = NULL;
150
152 {
153 out = m_temp.m_poly;
154 m_temp.m_poly = NULL;
155 *piLength = pLength(out);
156 }
157 else
158 {
159 *piLength = 0;
160 sBucketClearAdd(m_temp.m_bucket, &out, piLength);
161 }
162
163#ifdef PDEBUG
164 p_Test(out, m_basering);
165 assume(pLength(out) == *piLength);
166#endif
167
168 return out;
169}

◆ operator poly()

CPolynomialSummator::operator poly ( )
inline

Definition at line 51 of file summator.h.

51{ return AddUpAndClear(); }

◆ operator+=()

void CPolynomialSummator::operator+= ( poly  pSummand)
inline

Definition at line 40 of file summator.h.

40{ AddAndDelete(pSummand); }

◆ operator=()

CPolynomialSummator & CPolynomialSummator::operator= ( const CPolynomialSummator )
private

no assignment operator yet

Field Documentation

◆ m_basering

const ring& CPolynomialSummator::m_basering
private

Definition at line 23 of file summator.h.

◆ m_bUsePolynomial

const bool CPolynomialSummator::m_bUsePolynomial
private

Definition at line 24 of file summator.h.

◆ 

union { ... } CPolynomialSummator::m_temp

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