source: git/kernel/ncSACache.h @ 1495df4

spielwiese
Last change on this file since 1495df4 was 1495df4, checked in by Motsak Oleksandr <motsak@…>, 16 years ago
*motsak: special multiplication git-svn-id: file:///usr/local/Singular/svn/trunk@10868 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.2 KB
Line 
1#ifndef GRING_SA_CACHEHASH_H
2#define GRING_SA_CACHEHASH_H
3/*****************************************
4 *  Computer Algebra System SINGULAR     *
5 *****************************************/
6/* $Id: ncSACache.h,v 1.2 2008-07-15 16:27:58 motsak Exp $ */
7
8// #include <ncSACache.h> // for CCacheHash etc classes
9
10#include <structs.h>
11#include <febase.h> // for Print!
12// //////////////////////////////////////////////////////////////////////// //
13//
14
15const int iMaxCacheSize = 20;
16
17template <typename CExponent>
18class CCacheHash
19{
20  private:
21    ring m_basering;
22    int m_NVars;
23   
24  public:
25    CCacheHash(ring r): m_basering(r), m_NVars(r->N){};
26
27    const ring GetBasering() const { return m_basering; };
28    inline int NVars() const { return m_NVars; }
29   
30    virtual ~CCacheHash(){};
31   
32    enum EHistoryType {
33      MULT_LOOKUP
34    };
35
36    struct CCacheItem
37    {
38      union{
39        CExponent aExponent;
40        poly aMonom;
41      } a;
42
43      union{
44        CExponent bExponent;
45        poly bMonom;
46      } b;
47
48      poly pProduct;
49
50      int iPairType;
51      long lHits;
52    };
53
54   
55    // -1 means no hits!
56    int LookupEE(CExponent a, CExponent b, CCacheItem*& pItems)
57    {
58      History(a, b, MULT_LOOKUP);
59      pItems = NULL;
60      return -1;
61    }
62
63    bool StoreEE(CExponent a, CExponent b, poly pProduct)
64    {
65      Print("StoreEE!\n");
66      return false; // the pair was not stored!
67    };
68   
69    virtual void History(const CExponent a, const CExponent b, const EHistoryType t)
70    {
71      Print("MultHistory!\n");
72    }
73
74  private: // no copy constuctors!
75    CCacheHash(const CCacheHash&);
76    CCacheHash& operator=(const CCacheHash&);
77};
78
79
80
81class CGlobalCacheHash: public CCacheHash<poly>
82{
83  public:
84    typedef poly CExponent;
85
86    CGlobalCacheHash(ring r): CCacheHash<poly>(r) {};
87
88    virtual ~CGlobalCacheHash() {};
89
90  protected:
91    virtual void History(CExponent a, CExponent b, const EHistoryType t);
92};
93
94class CSpecialPairCacheHash: public CCacheHash<int>
95{
96  public:
97    typedef int CExponent;
98
99    CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {};
100
101    virtual ~CSpecialPairCacheHash() {};
102
103  protected:
104    virtual void History(const CExponent a, const CExponent b, const EHistoryType t);
105};
106
107
108
109#endif // GRING_SA_CACHEHASH_H
110
111
Note: See TracBrowser for help on using the repository browser.