source: git/kernel/ncSACache.h @ 4e35a89

spielwiese
Last change on this file since 4e35a89 was 599326, checked in by Kai Krüger <krueger@…>, 14 years ago
Anne, Kai, Frank: - changes to #include "..." statements to allow cleaner build structure - affected directories: omalloc, kernel, Singular - not yet done: IntergerProgramming git-svn-id: file:///usr/local/Singular/svn/trunk@13032 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$ */
7
8// #include <ncSACache.h> // for CCacheHash etc classes
9
10#include <kernel/structs.h>
11#include <kernel/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      PrintS("//////////////////////////////////////////////////////////////////////////////////////////////");
62      PrintLn();
63      PrintS("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      PrintS("CCacheHash::StoreEE(a, b, Product)!");
76      PrintLn();
77*/
78     
79      History(MULT_STORE, a, b, pProduct);
80
81/*
82      PrintS("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
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      PrintS("CCacheHash::History(a, b, [p])!\n");
92    }
93
94  private: // no copy constuctors!
95    CCacheHash(const CCacheHash&);
96    CCacheHash& operator=(const CCacheHash&);
97};
98
99
100
101class CGlobalCacheHash: public CCacheHash<poly>
102{
103  public:
104    typedef poly CExponent;
105
106    CGlobalCacheHash(ring r): CCacheHash<poly>(r) {};
107
108    virtual ~CGlobalCacheHash() {};
109
110  protected:
111    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
112};
113
114class CSpecialPairCacheHash: public CCacheHash<int>
115{
116  public:
117    typedef int CExponent;
118
119    CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {};
120
121    virtual ~CSpecialPairCacheHash() {};
122
123  protected:
124    virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
125};
126
127
128
129#endif // GRING_SA_CACHEHASH_H
130
131
Note: See TracBrowser for help on using the repository browser.