summator.h
Go to the documentation of this file.
1 #ifndef SUMMATOR_H
2 #define SUMMATOR_H
3 /****************************************
4 * Computer Algebra System SINGULAR *
5 ****************************************/
6 
7 // #include <polys/nc/summator.h> // for CPolynomialSummator class
8 
9 #define HAVE_SUMMATOR 1
10 
11 #ifdef HAVE_SUMMATOR
12 
13 // struct snumber; typedef struct snumber * number;
14 
15 class sBucket; typedef sBucket* sBucket_pt;
16 struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
17 struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
18 
19 
20 class kBucket; typedef kBucket* kBucket_pt;
21 
22 // TODO: redesign into templates with no extra run-time cost!!!
23 // TODO: make several out of CPolynomialSummator with similar (?) usage
24 // pattern/interface!!!
25 
26 // //////////////////////////////////////////////////////////////////////// //
27 /// CPolynomialSummator: unifies bucket and polynomial summation as the
28 /// later is brocken in buckets :(
30 {
31  private:
32  const ring& m_basering;
33  const bool m_bUsePolynomial;
34  union
35  {
36  sBucket_pt m_bucket;
37 // kBucket_pt m_kbucket;
38  poly m_poly;
39  } m_temp;
40  public:
41  CPolynomialSummator(const ring& rBaseRing, bool bUsePolynomial = false);
42 // CPolynomialSummator(ring rBaseRing, poly pInitialSum, int iLength = 0, bool bUsePolynomial = false);
44 
45  // adds and destroes the summand
46  void AddAndDelete(poly pSummand, int iLength);
47  void AddAndDelete(poly pSummand);
48 
49  inline void operator +=(poly pSummand){ AddAndDelete(pSummand); }
50 
51  // only adds and keeps the summand
52  // please use AddAndDelete instead!
53  void Add(poly pSummand, int iLength);
54  void Add(poly pSummand);
55 
56  // get the final result and clear (set to zero) the summator
58  poly AddUpAndClear(int *piLength);
59 
60  inline operator poly() { return AddUpAndClear(); }
61 
62  /// Copy constructor
64  private:
65 
66  /// no assignment operator yet
68 };
69 
70 #endif // ifdef HAVE_SUMMATOR
71 #endif // ifndef SUMMATOR_H
72 
kBucket * kBucket_pt
Definition: summator.h:20
const ring & m_basering
Definition: summator.h:32
Definition: ring.h:255
union CPolynomialSummator::@5 m_temp
CPolynomialSummator(const ring &rBaseRing, bool bUsePolynomial=false)
Definition: summator.cc:37
void Add(poly pSummand, int iLength)
Definition: summator.cc:176
CPolynomialSummator & operator=(const CPolynomialSummator &)
no assignment operator yet
const bool m_bUsePolynomial
Definition: summator.h:33
sBucket * sBucket_pt
Definition: summator.h:15
void AddAndDelete(poly pSummand, int iLength)
Definition: summator.cc:103
void operator+=(poly pSummand)
Definition: summator.h:49
#define const
Definition: fegetopt.c:41
polyrec * poly
Definition: summator.h:16
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:29
polyrec * poly
Definition: hilb.h:10