1 | #ifndef SUMMATOR_H |
---|
2 | #define SUMMATOR_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: summator.h,v 1.1 2008-07-04 14:19:38 motsak Exp $ */ |
---|
7 | |
---|
8 | // #include <summator.h> // for CPolynomialSummator class |
---|
9 | |
---|
10 | #include <structs.h> |
---|
11 | // #include <p_polys.h> // due to p_Copy :( |
---|
12 | |
---|
13 | |
---|
14 | // //////////////////////////////////////////////////////////////////////// // |
---|
15 | // CPolynomialSummator: unifies bucket and polynomial summation as the |
---|
16 | // later is brocken in buckets :( |
---|
17 | |
---|
18 | class CPolynomialSummator |
---|
19 | { |
---|
20 | private: |
---|
21 | ring m_basering; |
---|
22 | bool m_bUsePolynomial; |
---|
23 | union { |
---|
24 | sBucket_pt m_bucket; |
---|
25 | poly m_poly; |
---|
26 | } m_temp; |
---|
27 | public: |
---|
28 | CPolynomialSummator(ring rBaseRing, bool bUsePolynomial = false); |
---|
29 | // CPolynomialSummator(ring rBaseRing, poly pInitialSum, int iLength = 0, bool bUsePolynomial = false); |
---|
30 | ~CPolynomialSummator(); |
---|
31 | |
---|
32 | // adds and destroes the summand |
---|
33 | void AddAndDelete(poly pSummand, int iLength); |
---|
34 | void AddAndDelete(poly pSummand); |
---|
35 | |
---|
36 | inline void operator +=(poly pSummand){ AddAndDelete(pSummand); } |
---|
37 | |
---|
38 | // only adds and keeps the summand |
---|
39 | // please use AddAndDelete instead! |
---|
40 | void Add(poly pSummand, int iLength); |
---|
41 | void Add(poly pSummand); |
---|
42 | |
---|
43 | // get the final result and clear (set to zero) the summator |
---|
44 | poly AddUpAndClear(); |
---|
45 | poly AddUpAndClear(int *piLength); |
---|
46 | |
---|
47 | inline operator poly() { return AddUpAndClear(); } |
---|
48 | |
---|
49 | private: // no copies of this object at the moment!!! |
---|
50 | CPolynomialSummator(const CPolynomialSummator& m); // Copy constructor |
---|
51 | CPolynomialSummator& operator= (const CPolynomialSummator& m); // Assignment operator |
---|
52 | }; |
---|
53 | |
---|
54 | #endif // ifndef SUMMATOR_H |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|