source: git/libpolys/polys/nc/summator.h

spielwiese
Last change on this file was 266ae3, checked in by Hans Schoenemann <hannes@…>, 6 years ago
chg: only one definition for poly/ideal/map/matrix
  • Property mode set to 100644
File size: 1.8 KB
Line 
1#ifndef SUMMATOR_H
2#define SUMMATOR_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6
7#define HAVE_SUMMATOR 1
8
9#ifdef HAVE_SUMMATOR
10#include "polys/monomials/ring.h"
11#include "polys/sbuckets.h"
12
13// TODO: redesign into templates with no extra run-time cost!!!
14// TODO: make several out of CPolynomialSummator with similar (?) usage
15// pattern/interface!!!
16
17// //////////////////////////////////////////////////////////////////////// //
18/// CPolynomialSummator: unifies bucket and polynomial summation as the
19/// later is brocken in buckets :(
20class CPolynomialSummator
21{
22  private:
23    const ring& m_basering;
24    const bool m_bUsePolynomial;
25    union
26    {
27      sBucket_pt m_bucket;
28//      kBucket_pt m_kbucket;
29      poly       m_poly;
30    } m_temp;
31  public:
32    CPolynomialSummator(const ring& rBaseRing, bool bUsePolynomial = false);
33//    CPolynomialSummator(ring rBaseRing, poly pInitialSum, int iLength = 0, bool bUsePolynomial = false);
34    ~CPolynomialSummator();
35
36    // adds and destroes the summand
37    void AddAndDelete(poly pSummand, int iLength);
38    void AddAndDelete(poly pSummand);
39
40    inline void operator +=(poly pSummand){ AddAndDelete(pSummand); }
41
42    // only adds and keeps the summand
43    // please use AddAndDelete instead!
44    void Add(poly pSummand, int iLength);
45    void Add(poly pSummand);
46
47    // get the final result and clear (set to zero) the summator
48    poly AddUpAndClear();
49    poly AddUpAndClear(int *piLength);
50
51    inline operator poly() { return AddUpAndClear(); }
52
53    /// Copy constructor
54    CPolynomialSummator(const CPolynomialSummator&);
55  private:
56
57    /// no assignment operator yet
58    CPolynomialSummator& operator= (const CPolynomialSummator&);
59};
60
61#endif // ifdef HAVE_SUMMATOR
62#endif // ifndef  SUMMATOR_H
63
Note: See TracBrowser for help on using the repository browser.