Loading...
Searching...
No Matches
ncSACache.h
Go to the documentation of this file.
#ifndef GRING_SA_CACHEHASH_H
#define GRING_SA_CACHEHASH_H
/*****************************************
* Computer Algebra System SINGULAR *
*****************************************/
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "reporter/reporter.h" // for Print!
// //////////////////////////////////////////////////////////////////////// //
//
const int iMaxCacheSize = 20;
template <typename CExponent>
class CCacheHash
{
private:
ring m_basering;
int m_NVars;
public:
CCacheHash(ring r): m_basering(r), m_NVars(r->N){};
ring GetBasering() const { return m_basering; };
inline int NVars() const { return m_NVars; }
virtual ~CCacheHash(){};
enum EHistoryType {
MULT_LOOKUP = 0,
MULT_STORE = 1
};
struct CCacheItem
{
union{
CExponent aExponent;
poly aMonom;
} a;
union{
CExponent bExponent;
poly bMonom;
} b;
poly pProduct;
int iPairType;
long lHits;
};
// -1 means no hits!
int LookupEE(CExponent a, CExponent b, CCacheItem*& pItems)
{
/*
PrintS("//////////////////////////////////////////////////////////////////////////////////////////////");
PrintLn();
PrintS("CCacheHash::LookupEE(a, b, *results)!");
PrintLn();
*/
History(MULT_LOOKUP, a, b);
pItems = NULL;
return -1;
}
bool StoreEE(CExponent a, CExponent b, poly pProduct)
{
/*
PrintS("CCacheHash::StoreEE(a, b, Product)!");
PrintLn();
*/
History(MULT_STORE, a, b, pProduct);
/*
PrintS("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
PrintLn();
*/
return false; // the pair was not stored!
};
virtual void History(const EHistoryType , const CExponent /*a*/, const CExponent /*b*/, const poly = NULL)
{
PrintS("CCacheHash::History(a, b, [p])!\n");
}
private: // no copy constructors!
CCacheHash(const CCacheHash&);
CCacheHash& operator=(const CCacheHash&);
};
class CGlobalCacheHash: public CCacheHash<poly>
{
public:
typedef poly CExponent;
CGlobalCacheHash(ring r): CCacheHash<poly>(r) {};
virtual ~CGlobalCacheHash() {};
protected:
virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
};
class CSpecialPairCacheHash: public CCacheHash<int>
{
public:
typedef int CExponent;
CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {};
virtual ~CSpecialPairCacheHash() {};
protected:
virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p = NULL);
};
#endif // GRING_SA_CACHEHASH_H
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
CCacheHash::NVars
int NVars() const
Definition ncSACache.h:26
CCacheHash::LookupEE
int LookupEE(CExponent a, CExponent b, CCacheItem *&pItems)
Definition ncSACache.h:56
CCacheHash::m_basering
ring m_basering
Definition ncSACache.h:19
CCacheHash::~CCacheHash
virtual ~CCacheHash()
Definition ncSACache.h:28
CCacheHash::CCacheItem::lHits
long lHits
Definition ncSACache.h:51
CCacheHash::CCacheItem.b::bExponent
CExponent bExponent
CCacheHash::m_NVars
int m_NVars
Definition ncSACache.h:20
CCacheHash::CCacheItem::a
union CCacheHash::CCacheItem::@362055051370213063064106300073341224300167350106 a
CCacheHash::CCacheItem.b::bMonom
poly bMonom
CCacheHash::EHistoryType
EHistoryType
Definition ncSACache.h:31
CCacheHash::MULT_STORE
@ MULT_STORE
Definition ncSACache.h:33
CCacheHash::MULT_LOOKUP
@ MULT_LOOKUP
Definition ncSACache.h:32
CCacheHash::operator=
CCacheHash & operator=(const CCacheHash &)
CCacheHash::StoreEE
bool StoreEE(CExponent a, CExponent b, poly pProduct)
Definition ncSACache.h:70
CCacheHash::CCacheItem::iPairType
int iPairType
Definition ncSACache.h:50
CCacheHash::CCacheHash
CCacheHash(const CCacheHash &)
CCacheHash::CCacheHash
CCacheHash(ring r)
Definition ncSACache.h:23
CCacheHash::History
virtual void History(const EHistoryType, const CExponent, const CExponent, const poly=NULL)
Definition ncSACache.h:87
CCacheHash::GetBasering
ring GetBasering() const
Definition ncSACache.h:25
CCacheHash::CCacheItem::pProduct
poly pProduct
Definition ncSACache.h:48
CCacheHash::CCacheItem.a::aExponent
CExponent aExponent
CCacheHash::CCacheItem.a::aMonom
poly aMonom
CCacheHash::CCacheItem
Definition ncSACache.h:37
CGlobalCacheHash::History
virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p=NULL)
Definition ncSACache.cc:46
CGlobalCacheHash::CExponent
poly CExponent
Definition ncSACache.h:102
CGlobalCacheHash::~CGlobalCacheHash
virtual ~CGlobalCacheHash()
Definition ncSACache.h:106
CGlobalCacheHash::CGlobalCacheHash
CGlobalCacheHash(ring r)
Definition ncSACache.h:104
CSpecialPairCacheHash::CSpecialPairCacheHash
CSpecialPairCacheHash(ring r)
Definition ncSACache.h:117
CSpecialPairCacheHash::~CSpecialPairCacheHash
virtual ~CSpecialPairCacheHash()
Definition ncSACache.h:119
CSpecialPairCacheHash::History
virtual void History(const EHistoryType t, const CExponent a, const CExponent b, const poly p=NULL)
Definition ncSACache.cc:61
CSpecialPairCacheHash::CExponent
int CExponent
Definition ncSACache.h:115
iMaxCacheSize
const int iMaxCacheSize
Definition ncSACache.h:13
NULL
#define NULL
Definition omList.c:12
p_polys.h
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
reporter.h
ring.h