Loading...
Searching...
No Matches
CPolynomialSummator Class Reference

CPolynomialSummator: unifies bucket and polynomial summation as the later is broken 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.

## Private Member Functions

CPolynomialSummator & | operator= (const CPolynomialSummator &)
| no assignment operator yet

## 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 broken 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.

:
m_basering(rBaseRing), m_bUsePolynomial(bUsePolynomial)
{
#ifdef RDEBUG
rTest(rBaseRing);
#endif
if(bUsePolynomial)
m_temp.m_poly = NULL;
else
{
assume(!TEST_OPT_NOT_BUCKETS);
m_temp.m_bucket = sBucketCreate(rBaseRing);
}
}
CPolynomialSummator::m_basering
const ring & m_basering
Definition summator.h:23
CPolynomialSummator::m_temp
union CPolynomialSummator::@171202203372044306230374236371043003006056160311 m_temp
CPolynomialSummator::m_bUsePolynomial
const bool m_bUsePolynomial
Definition summator.h:24
assume
#define assume(x)
Definition mod2.h:389
NULL
#define NULL
Definition omList.c:12
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
rTest
#define rTest(r)
Definition ring.h:794
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96

## ~CPolynomialSummator()

CPolynomialSummator::~CPolynomialSummator | ( |  | ) |

Definition at line 71 of file summator.cc.

{
if(!m_bUsePolynomial)
{
poly out;
int pLength;
sBucketClearAdd(m_temp.m_bucket, &out, &pLength);
sBucketDestroy(&m_temp.m_bucket);
assume(out == NULL); // otherwise wrong usage pattern!
if(out != NULL)
p_Delete(&out, m_basering);
// m_temp.m_bucket = NULL;
}
else
{
assume(m_temp.m_poly == NULL); // otherwise wrong usage pattern!
if(m_temp.m_poly!=NULL)
{
#ifdef PDEBUG
p_Test(m_temp.m_poly, m_basering);
#endif
p_Delete(&m_temp.m_poly, m_basering);
// m_temp.m_poly = NULL;
}
}
}
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_Test
#define p_Test(p, r)
Definition p_polys.h:161
sBucketDestroy
void sBucketDestroy(sBucket_pt *bucket)
Definition sbuckets.cc:103
sBucketClearAdd
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.

:
m_basering(b.m_basering), m_bUsePolynomial(b.m_bUsePolynomial)
{
// try{
if(m_bUsePolynomial)
m_temp.m_poly = p_Copy( b.m_temp.m_poly, m_basering);
else
{
sBucketCanonicalize(b.m_temp.m_bucket);
m_temp.m_bucket = sBucketCopy(b.m_temp.m_bucket);
}
// }
// catch(...)
// {
// assume(false);
// }
}
b
CanonicalForm b
Definition cfModGcd.cc:4111
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
sBucketCopy
sBucket_pt sBucketCopy(const sBucket_pt bucket)
Copy sBucket non-intrusive!!!
Definition sbuckets.cc:70
sBucketCanonicalize
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.

{
AddAndDelete(p_Copy(pSummand, m_basering));
}
CPolynomialSummator::AddAndDelete
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.

{
AddAndDelete(p_Copy(pSummand, m_basering), iLength);
}

## AddAndDelete() [1/2]

void CPolynomialSummator::AddAndDelete | ( | poly | pSummand | ) |

Definition at line 112 of file summator.cc.

{
#ifdef PDEBUG
p_Test(pSummand, m_basering);
#endif
if(m_bUsePolynomial)
m_temp.m_poly = p_Add_q(m_temp.m_poly, pSummand, m_basering);
else
sBucket_Add_p(m_temp.m_bucket, pSummand, 0); // sBucket_Merge_p???
}
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
sBucket_Add_p
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.

{
#ifdef PDEBUG
p_Test(pSummand, m_basering);
#endif
if(m_bUsePolynomial)
m_temp.m_poly = p_Add_q(m_temp.m_poly, pSummand, m_basering);
else
sBucket_Add_p(m_temp.m_bucket, pSummand, iLength); // sBucket_Merge_p???
}

## AddUpAndClear() [1/2]

poly CPolynomialSummator::AddUpAndClear | ( |  | ) |

Definition at line 124 of file summator.cc.

{
poly out = NULL;
if(m_bUsePolynomial)
{
out = m_temp.m_poly;
m_temp.m_poly = NULL;
}
else
{
int pLength;
sBucketClearAdd(m_temp.m_bucket, &out, &pLength);
}
#ifdef PDEBUG
p_Test(out, m_basering);
#endif
return out;
}

## AddUpAndClear() [2/2]

poly CPolynomialSummator::AddUpAndClear | ( | int * | piLength | ) |

Definition at line 147 of file summator.cc.

{
poly out = NULL;
if(m_bUsePolynomial)
{
out = m_temp.m_poly;
m_temp.m_poly = NULL;
*piLength = pLength(out);
}
else
{
*piLength = 0;
sBucketClearAdd(m_temp.m_bucket, &out, piLength);
}
#ifdef PDEBUG
p_Test(out, m_basering);
assume(pLength(out) == *piLength);
#endif
return out;
}

## operator poly()

CPolynomialSummator::operator poly | ( |  | ) |

inline

Definition at line 51 of file summator.h.

{ return AddUpAndClear(); }
CPolynomialSummator::AddUpAndClear
poly AddUpAndClear()
Definition summator.cc:124

## operator+=()

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

inline

Definition at line 40 of file summator.h.

{ 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]

union { ... } CPolynomialSummator::m_temp

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

- libpolys/polys/nc/summator.h
- libpolys/polys/nc/summator.cc