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

jengelh-datetimespielwiese
Last change on this file since 8179468 was 8179468, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Better forward declarations and includes for bucket-related stuff TODO: refine?
  • Property mode set to 100644
File size: 2.1 KB
Line 
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
15class  sBucket; typedef sBucket* sBucket_pt;
16struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
17struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
18
19
20class  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 :(
29class CPolynomialSummator
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);
43    ~CPolynomialSummator();
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
57    poly AddUpAndClear();
58    poly AddUpAndClear(int *piLength);
59
60    inline operator poly() { return AddUpAndClear(); }
61
62    /// Copy constructor
63    CPolynomialSummator(const CPolynomialSummator&);
64  private:
65
66    /// no assignment operator yet
67    CPolynomialSummator& operator= (const CPolynomialSummator&);
68};
69
70#endif // ifdef HAVE_SUMMATOR
71#endif // ifndef  SUMMATOR_H
72
Note: See TracBrowser for help on using the repository browser.