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

spielwiese
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
RevLine 
[6bde67]1#ifndef SUMMATOR_H
2#define SUMMATOR_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6
[8179468]7// #include <polys/nc/summator.h> // for CPolynomialSummator class
[6bde67]8
[8179468]9#define HAVE_SUMMATOR 1
[6bde67]10
[8179468]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!!!
[6bde67]25
26// //////////////////////////////////////////////////////////////////////// //
[8179468]27/// CPolynomialSummator: unifies bucket and polynomial summation as the
28/// later is brocken in buckets :(
[6bde67]29class CPolynomialSummator
30{
31  private:
[8179468]32    const ring& m_basering;
33    const bool m_bUsePolynomial;
[9d0c2b]34    union
35    {
[6bde67]36      sBucket_pt m_bucket;
[8179468]37//      kBucket_pt m_kbucket;
[6bde67]38      poly       m_poly;
[9d0c2b]39    } m_temp;
[6bde67]40  public:
[8179468]41    CPolynomialSummator(const ring& rBaseRing, bool bUsePolynomial = false);
[6bde67]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);
[9d0c2b]48
[6bde67]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);
[9d0c2b]55
[6bde67]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(); }
[9d0c2b]61
[a795c77]62    /// Copy constructor
63    CPolynomialSummator(const CPolynomialSummator&);
64  private:
65
66    /// no assignment operator yet
67    CPolynomialSummator& operator= (const CPolynomialSummator&);
[6bde67]68};
69
[8179468]70#endif // ifdef HAVE_SUMMATOR
[6bde67]71#endif // ifndef  SUMMATOR_H
72
Note: See TracBrowser for help on using the repository browser.