[6bde67] | 1 | #ifndef SUMMATOR_H |
---|
| 2 | #define SUMMATOR_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
[9d0c2b] | 6 | /* $Id: summator.h,v 1.2 2008-07-08 08:18:27 Singular Exp $ */ |
---|
[6bde67] | 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 :( |
---|
[9d0c2b] | 17 | #ifdef HAVE_PLURAL |
---|
[6bde67] | 18 | class CPolynomialSummator |
---|
| 19 | { |
---|
| 20 | private: |
---|
| 21 | ring m_basering; |
---|
| 22 | bool m_bUsePolynomial; |
---|
[9d0c2b] | 23 | union |
---|
| 24 | { |
---|
[6bde67] | 25 | sBucket_pt m_bucket; |
---|
| 26 | poly m_poly; |
---|
[9d0c2b] | 27 | } m_temp; |
---|
[6bde67] | 28 | public: |
---|
| 29 | CPolynomialSummator(ring rBaseRing, bool bUsePolynomial = false); |
---|
| 30 | // CPolynomialSummator(ring rBaseRing, poly pInitialSum, int iLength = 0, bool bUsePolynomial = false); |
---|
| 31 | ~CPolynomialSummator(); |
---|
| 32 | |
---|
| 33 | // adds and destroes the summand |
---|
| 34 | void AddAndDelete(poly pSummand, int iLength); |
---|
| 35 | void AddAndDelete(poly pSummand); |
---|
[9d0c2b] | 36 | |
---|
[6bde67] | 37 | inline void operator +=(poly pSummand){ AddAndDelete(pSummand); } |
---|
| 38 | |
---|
| 39 | // only adds and keeps the summand |
---|
| 40 | // please use AddAndDelete instead! |
---|
| 41 | void Add(poly pSummand, int iLength); |
---|
| 42 | void Add(poly pSummand); |
---|
[9d0c2b] | 43 | |
---|
[6bde67] | 44 | // get the final result and clear (set to zero) the summator |
---|
| 45 | poly AddUpAndClear(); |
---|
| 46 | poly AddUpAndClear(int *piLength); |
---|
| 47 | |
---|
| 48 | inline operator poly() { return AddUpAndClear(); } |
---|
[9d0c2b] | 49 | |
---|
[6bde67] | 50 | private: // no copies of this object at the moment!!! |
---|
| 51 | CPolynomialSummator(const CPolynomialSummator& m); // Copy constructor |
---|
[9d0c2b] | 52 | CPolynomialSummator& operator= (const CPolynomialSummator& m); // Assignment operator |
---|
[6bde67] | 53 | }; |
---|
| 54 | |
---|
[9d0c2b] | 55 | #endif |
---|
[6bde67] | 56 | #endif // ifndef SUMMATOR_H |
---|
| 57 | |
---|