Public Types | Public Member Functions | Private Attributes
CPowerMultiplier Class Reference

#include <ncSAMult.h>

Public Types

typedef CPower CExponent
 

Public Member Functions

 CPowerMultiplier (ring r)
 
virtual ~CPowerMultiplier ()
 
CSpecialPairMultiplierGetPair (int i, int j) const
 
CSpecialPairMultiplier *& GetPair (int i, int j)
 
virtual poly MultiplyEE (const CExponent expLeft, const CExponent expRight)
 
virtual poly MultiplyME (const poly pMonom, const CExponent expRight)
 
virtual poly MultiplyEM (const CExponent expLeft, const poly pMonom)
 
poly MultiplyPE (const poly pPoly, const CExponent expRight)
 
poly MultiplyEP (const CExponent expLeft, const poly pPoly)
 
poly MultiplyPEDestroy (poly pPoly, const CExponent expRight)
 
poly MultiplyEPDestroy (const CExponent expLeft, poly pPoly)
 
- Public Member Functions inherited from CMultiplier< CPower >
 CMultiplier (ring rBaseRing)
 
virtual ~CMultiplier ()
 
ring GetBasering () const
 
int NVars () const
 
poly LM (const poly pTerm, const ring r, int i=1) const
 
poly MultiplyTE (const poly pTerm, const CPower expRight)
 
poly MultiplyET (const CPower expLeft, const poly pTerm)
 

Private Attributes

CSpecialPairMultiplier ** m_specialpairs
 

Additional Inherited Members

- Protected Attributes inherited from CMultiplier< CPower >
const ring m_basering
 
const int m_NVars
 

Detailed Description

Definition at line 163 of file ncSAMult.h.

Member Typedef Documentation

◆ CExponent

Definition at line 194 of file ncSAMult.h.

Constructor & Destructor Documentation

◆ CPowerMultiplier()

CPowerMultiplier::CPowerMultiplier ( ring  r)

Definition at line 831 of file ncSAMult.cc.

832 {
833 #if OUTPUT
834  PrintS("CPowerMultiplier::CPowerMultiplier(ring)!");
835  PrintLn();
836 #endif
837 
839 
840  for( int i = 1; i < NVars(); i++ )
841  for( int j = i + 1; j <= NVars(); j++ )
842  GetPair(i, j) = AnalyzePair(GetBasering(), i, j); // factory method!
843 }
CSpecialPairMultiplier * AnalyzePair(const ring r, int i, int j)
Definition: ncSAMult.cc:777
ring GetBasering() const
Definition: ncSAMult.h:35
int j
Definition: facHensel.cc:105
void PrintLn()
Definition: reporter.cc:310
CSpecialPairMultiplier ** m_specialpairs
Definition: ncSAMult.h:166
int NVars() const
Definition: ncSAMult.h:36
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
CSpecialPairMultiplier * GetPair(int i, int j) const
Definition: ncSAMult.h:173
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ ~CPowerMultiplier()

CPowerMultiplier::~CPowerMultiplier ( )
virtual

Definition at line 846 of file ncSAMult.cc.

847 {
848 #if OUTPUT
849  PrintS("CPowerMultiplier::~CPowerMultiplier()!");
850  PrintLn();
851 #endif
852 
853  omFreeSize((ADDRESS)m_specialpairs, ((NVars() * (NVars()-1)) / 2) * sizeof(CSpecialPairMultiplier*) );
854 }
void PrintLn()
Definition: reporter.cc:310
CSpecialPairMultiplier ** m_specialpairs
Definition: ncSAMult.h:166
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:133
int NVars() const
Definition: ncSAMult.h:36
void PrintS(const char *s)
Definition: reporter.cc:284

Member Function Documentation

◆ GetPair() [1/2]

CSpecialPairMultiplier* CPowerMultiplier::GetPair ( int  i,
int  j 
) const
inline

Definition at line 173 of file ncSAMult.h.

174  {
175  assume( m_specialpairs != NULL );
176  assume( i > 0 );
177  assume( i < j );
178  assume( j <= NVars() );
179 
180  return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )];
181  }
int j
Definition: facHensel.cc:105
CSpecialPairMultiplier ** m_specialpairs
Definition: ncSAMult.h:166
#define assume(x)
Definition: mod2.h:390
int NVars() const
Definition: ncSAMult.h:36
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10

◆ GetPair() [2/2]

CSpecialPairMultiplier*& CPowerMultiplier::GetPair ( int  i,
int  j 
)
inline

Definition at line 183 of file ncSAMult.h.

184  {
185  assume( m_specialpairs != NULL );
186  assume( i > 0 );
187  assume( i < j );
188  assume( j <= NVars() );
189 
190  return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )];
191  }
int j
Definition: facHensel.cc:105
CSpecialPairMultiplier ** m_specialpairs
Definition: ncSAMult.h:166
#define assume(x)
Definition: mod2.h:390
int NVars() const
Definition: ncSAMult.h:36
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10

◆ MultiplyEE()

poly CPowerMultiplier::MultiplyEE ( const CExponent  expLeft,
const CExponent  expRight 
)
virtual

Implements CMultiplier< CPower >.

Definition at line 990 of file ncSAMult.cc.

991 {
992 #if OUTPUT
993  PrintS("CPowerMultiplier::MultiplyEE)!");
994  PrintLn();
995 #endif
996 
997  const int i = expRight.Var, j = expLeft.Var;
998  const int ei = expRight.Power, ej = expLeft.Power;
999 
1000 #if OUTPUT
1001  Print("Input: var(%d)^{%d} * var(%d)^{%d}", j, ej, i, ei);
1002  PrintLn();
1003 #endif
1004 
1005  assume(1 <= i);
1006  assume(j <= NVars());
1007  assume(1 <= j);
1008  assume(i <= NVars());
1009  assume(ei > 0);
1010  assume(ej > 0);
1011 
1012  if( i >= j )
1013  {
1014  const ring r = GetBasering();
1015 
1016  poly product = p_One(r);
1017  p_SetExp(product, j, ej, r);
1018  p_SetExp(product, i, ei, r);
1019  p_Setm(product, r);
1020 
1021  return product;
1022 
1023  } else
1024  {
1025  assume(i < j);
1026 
1027  // No Cache Lookup!? :(
1028 
1029  CSpecialPairMultiplier* pSpecialMultiplier = GetPair(i, j);
1030 
1031  // Special case?
1032  if( pSpecialMultiplier != NULL )
1033  {
1034  assume( pSpecialMultiplier->GetI() == i );
1035  assume( pSpecialMultiplier->GetJ() == j );
1036  assume( pSpecialMultiplier->GetBasering() == GetBasering() );
1037 
1038  return pSpecialMultiplier->MultiplyEE(ej, ei);
1039  } else
1040  {
1041  // Perform general NC Multiplication:
1042  // TODO
1043 
1044  WerrorS("Sorry the general case is not implemented this way yet!!!");
1045  assume(0);
1046 
1047  // poly product = NULL;
1048  }
1049  }
1050 
1051  return NULL;
1052 }
ring GetBasering() const
Definition: ncSAMult.h:35
int j
Definition: facHensel.cc:105
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
int GetI() const
Definition: ncSAMult.h:108
void WerrorS(const char *s)
Definition: feFopen.cc:24
int GetJ() const
Definition: ncSAMult.h:109
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define assume(x)
Definition: mod2.h:390
int NVars() const
Definition: ncSAMult.h:36
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:488
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)=0
#define NULL
Definition: omList.c:10
CSpecialPairMultiplier * GetPair(int i, int j) const
Definition: ncSAMult.h:173
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233

◆ MultiplyEM()

poly CPowerMultiplier::MultiplyEM ( const CExponent  expLeft,
const poly  pMonom 
)
virtual

Implements CMultiplier< CPower >.

Definition at line 923 of file ncSAMult.cc.

924 {
925  const ring r = GetBasering();
926 
927  // TODO: as above! (difference due to Left/Right semmantics!)
928  const int j = expLeft.Var;
929  const int n = expLeft.Power;
930 
931 #if OUTPUT
932  Print("CPowerMultiplier::MultiplyEM(var(%d)^{%d} * monom)!", j, n);
933  PrintLn();
934  PrintS("Monom: "); p_Write(pMonom, r);
935 #endif
936 
937  assume( (j > 0) && (j <= NVars()));
938 
939  if( n == 0 )
940  return p_Head(pMonom, r); // Copy?!?
941 
942 
943  int v = 1; // NVars();
944  int e = p_GetExp(pMonom, v, r);
945 
946  while((v < j) && (e == 0))
947  e = p_GetExp(pMonom, ++v, r);
948 
949  if( v == j )
950  {
951  poly p = p_Head(pMonom, r);
952  p_SetExp(p, j, e + n, r);
953  p_Setm(p, r);
954 
955  return p;
956  }
957 
958  assume( v < j );
959  assume( e > 0 );
960 
961 
962  // And now the General Case: v > j!
963 
964  poly p = MultiplyEE( expLeft, CPower(v, e) ); // Easy way!
965 
966  ++v;
967 
968  while(v <= NVars())
969  {
970  e = p_GetExp(pMonom, v, r);
971 
972  if( e > 0 )
973  p = MultiplyPEDestroy(p, CPower(v, e));
974 
975  ++v;
976  }
977 
978 #if OUTPUT
979  PrintS("CPowerMultiplier::MultiplyEM() ===> ");
980  p_Write(p, r);
981 #endif
982 
983  return p;
984 
985 }
ring GetBasering() const
Definition: ncSAMult.h:35
int j
Definition: facHensel.cc:105
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
poly MultiplyPEDestroy(poly pPoly, const CExponent expRight)
Definition: ncSAMult.h:235
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:825
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:469
#define assume(x)
Definition: mod2.h:390
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:990
int NVars() const
Definition: ncSAMult.h:36
void PrintS(const char *s)
Definition: reporter.cc:284
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:204
int p
Definition: cfModGcd.cc:4019

◆ MultiplyEP()

poly CPowerMultiplier::MultiplyEP ( const CExponent  expLeft,
const poly  pPoly 
)
inline

Definition at line 223 of file ncSAMult.h.

224  {
225  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
226  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
227 
228  for( poly q = pPoly; q !=NULL; q = pNext(q) )
229  sum += MultiplyET(expLeft, q);
230 
231  return sum;
232  }
ring GetBasering() const
Definition: ncSAMult.h:35
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:104
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
poly MultiplyET(const CPower expLeft, const poly pTerm)
Definition: ncSAMult.h:61
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:20

◆ MultiplyEPDestroy()

poly CPowerMultiplier::MultiplyEPDestroy ( const CExponent  expLeft,
poly  pPoly 
)
inline

Definition at line 247 of file ncSAMult.h.

248  {
249  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
250  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
251 
252  for( ; pPoly!=NULL; pPoly = p_LmDeleteAndNext(pPoly, GetBasering()) )
253  sum += MultiplyET(expLeft, pPoly);
254 
255  return sum;
256  }
ring GetBasering() const
Definition: ncSAMult.h:35
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:725
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:104
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
poly MultiplyET(const CPower expLeft, const poly pTerm)
Definition: ncSAMult.h:61
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:20

◆ MultiplyME()

poly CPowerMultiplier::MultiplyME ( const poly  pMonom,
const CExponent  expRight 
)
virtual

Implements CMultiplier< CPower >.

Definition at line 859 of file ncSAMult.cc.

860 {
861  const int j = expRight.Var;
862  const int n = expRight.Power;
863 
864  const ring r = GetBasering();
865 
866 #if OUTPUT
867  Print("CPowerMultiplier::MultiplyME(monom * var(%d)^{%d})!", j, n);
868  PrintLn();
869  PrintS("Monom: "); p_Write(pMonom, r);
870 #endif
871 
872  assume( (j > 0) && (j <= NVars()));
873 
874  if( n == 0 )
875  return p_Head(pMonom, r); // Copy?!?
876 
877 
878  int v = NVars();
879  int e = p_GetExp(pMonom, v, r);
880 
881  while((v > j) && (e == 0))
882  e = p_GetExp(pMonom, --v, r);
883 
884  // TODO: review this!
885  if( v == j )
886  {
887  poly p = p_Head(pMonom, r);
888  p_SetExp(p, v, e + n, r);
889  p_Setm(p, r);
890 
891  return p;
892  }
893 
894  assume( v > j );
895  assume( e > 0 );
896 
897  // And now the General Case: v > j!
898 
899  poly p = MultiplyEE( CPower(v, e), expRight ); // Easy way!
900 
901  --v;
902 
903  while(v > 0)
904  {
905  e = p_GetExp(pMonom, v, GetBasering());
906 
907  if( e > 0 )
908  p = MultiplyEPDestroy(CPower(v, e), p);
909 
910  --v;
911  }
912 
913 #if OUTPUT
914  PrintS("CPowerMultiplier::MultiplyME() ===> ");
915  p_Write(p, GetBasering());
916 #endif
917 
918  return p;
919 }
ring GetBasering() const
Definition: ncSAMult.h:35
int j
Definition: facHensel.cc:105
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:825
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:469
#define assume(x)
Definition: mod2.h:390
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:990
int NVars() const
Definition: ncSAMult.h:36
void PrintS(const char *s)
Definition: reporter.cc:284
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
Definition: ncSAMult.h:247
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:204
int p
Definition: cfModGcd.cc:4019

◆ MultiplyPE()

poly CPowerMultiplier::MultiplyPE ( const poly  pPoly,
const CExponent  expRight 
)
inline

Definition at line 211 of file ncSAMult.h.

212  {
213  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
214  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
215 
216  for( poly q = pPoly; q !=NULL; q = pNext(q) )
217  sum += MultiplyTE(q, expRight);
218 
219  return sum;
220  }
ring GetBasering() const
Definition: ncSAMult.h:35
poly MultiplyTE(const poly pTerm, const CPower expRight)
Definition: ncSAMult.h:47
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:104
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:20

◆ MultiplyPEDestroy()

poly CPowerMultiplier::MultiplyPEDestroy ( poly  pPoly,
const CExponent  expRight 
)
inline

Definition at line 235 of file ncSAMult.h.

236  {
237  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
238  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
239 
240  for( ; pPoly!=NULL; pPoly = p_LmDeleteAndNext(pPoly, GetBasering()) )
241  sum += MultiplyTE(pPoly, expRight);
242 
243  return sum;
244  }
ring GetBasering() const
Definition: ncSAMult.h:35
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:725
poly MultiplyTE(const poly pTerm, const CPower expRight)
Definition: ncSAMult.h:47
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:104
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:20

Field Documentation

◆ m_specialpairs

CSpecialPairMultiplier** CPowerMultiplier::m_specialpairs
private

Definition at line 166 of file ncSAMult.h.


The documentation for this class was generated from the following files: