source: git/kernel/ncSACache.h @ cfb8edb

spielwiese
Last change on this file since cfb8edb was 03cecc2, checked in by Motsak Oleksandr <motsak@…>, 16 years ago
*motsak: done: main special casescvs update! git-svn-id: file:///usr/local/Singular/svn/trunk@10895 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.4 2008-07-21 00:05:09 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/*
61      Print("//////////////////////////////////////////////////////////////////////////////////////////////");
62      PrintLn();
63      Print("CCacheHash::LookupEE(a, b, *results)!");
64      PrintLn();
65*/
66      History(MULT_LOOKUP, a, b);
67     
68      pItems = NULL;
69      return -1;
70    }
71
72    bool StoreEE(CExponent a, CExponent b, poly pProduct)
73    {
74/*
75      Print("CCacheHash::StoreEE(a, b, Product)!");
76      PrintLn();
77*/
78     
79      History(MULT_STORE, a, b, pProduct);
80
81/*
82      Print("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
83      PrintLn();
84*/
85     
86      return false; // the pair was not stored!
87    };
88   
89    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL)
90    {
91      Print("CCacheHash::History(a, b, [p])!");
92      PrintLn();
93    }
94
95  private: // no copy constuctors!
96    CCacheHash(const CCacheHash&);
97    CCacheHash& operator=(const CCacheHash&);
98};
99
100
101
102class CGlobalCacheHash: public CCacheHash<poly>
103{
104  public:
105    typedef poly CExponent;
106
107    CGlobalCacheHash(ring r): CCacheHash<poly>(r) {};
108
109    virtual ~CGlobalCacheHash() {};
110
111  protected:
112    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
113};
114
115class CSpecialPairCacheHash: public CCacheHash<int>
116{
117  public:
118    typedef int CExponent;
119
120    CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {};
121
122    virtual ~CSpecialPairCacheHash() {};
123
124  protected:
125    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
126};
127
128
129
130#endif // GRING_SA_CACHEHASH_H
131
132
Note: See TracBrowser for help on using the repository browser.