source: git/kernel/ncSACache.h @ 3664c9a

spielwiese
Last change on this file since 3664c9a was f78891, checked in by Motsak Oleksandr <motsak@…>, 16 years ago
*motsak: special mult. - comm. case done! git-svn-id: file:///usr/local/Singular/svn/trunk@10890 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.8 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.3 2008-07-18 17:12:37 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   
33    enum EHistoryType {
34      MULT_LOOKUP = 0,
35      MULT_STORE  = 1
36    };
37
38    struct CCacheItem
39    {
40      union{
41        CExponent aExponent;
42        poly aMonom;
43      } a;
44
45      union{
46        CExponent bExponent;
47        poly bMonom;
48      } b;
49
50      poly pProduct;
51
52      int iPairType;
53      long lHits;
54    };
55
56   
57    // -1 means no hits!
58    int LookupEE(CExponent a, CExponent b, CCacheItem*& pItems)
59    {
60      Print("//////////////////////////////////////////////////////////////////////////////////////////////");
61      PrintLn();
62      Print("CCacheHash::LookupEE(a, b, *results)!");
63      PrintLn();
64
65      History(MULT_LOOKUP, a, b);
66     
67      pItems = NULL;
68      return -1;
69    }
70
71    bool StoreEE(CExponent a, CExponent b, poly pProduct)
72    {
73      Print("CCacheHash::StoreEE(a, b, Product)!");
74      PrintLn();
75
76      History(MULT_STORE, a, b, pProduct);
77
78      Print("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
79      PrintLn();
80
81      return false; // the pair was not stored!
82    };
83   
84    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL)
85    {
86      Print("CCacheHash::History(a, b, [p])!");
87      PrintLn();
88    }
89
90  private: // no copy constuctors!
91    CCacheHash(const CCacheHash&);
92    CCacheHash& operator=(const CCacheHash&);
93};
94
95
96
97class CGlobalCacheHash: public CCacheHash<poly>
98{
99  public:
100    typedef poly CExponent;
101
102    CGlobalCacheHash(ring r): CCacheHash<poly>(r) {};
103
104    virtual ~CGlobalCacheHash() {};
105
106  protected:
107    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
108};
109
110class CSpecialPairCacheHash: public CCacheHash<int>
111{
112  public:
113    typedef int CExponent;
114
115    CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {};
116
117    virtual ~CSpecialPairCacheHash() {};
118
119  protected:
120    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
121};
122
123
124
125#endif // GRING_SA_CACHEHASH_H
126
127
Note: See TracBrowser for help on using the repository browser.