My Project
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 832 of file ncSAMult.cc.

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

◆ ~CPowerMultiplier()

CPowerMultiplier::~CPowerMultiplier ( )
virtual

Definition at line 847 of file ncSAMult.cc.

848 {
849 #if OUTPUT
850  PrintS("CPowerMultiplier::~CPowerMultiplier()!");
851  PrintLn();
852 #endif
853 
854  omFreeSize((ADDRESS)m_specialpairs, ((NVars() * (NVars()-1)) / 2) * sizeof(CSpecialPairMultiplier*) );
855 }
void * ADDRESS
Definition: auxiliary.h:119
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260

Member Function Documentation

◆ GetPair() [1/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  }
#define assume(x)
Definition: mod2.h:387
#define NULL
Definition: omList.c:12

◆ GetPair() [2/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  }

◆ MultiplyEE()

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

Implements CMultiplier< CPower >.

Definition at line 991 of file ncSAMult.cc.

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

◆ MultiplyEM()

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

Implements CMultiplier< CPower >.

Definition at line 924 of file ncSAMult.cc.

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

◆ 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  }
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:21
#define pNext(p)
Definition: monomials.h:36
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:104
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
static unsigned pLength(poly a)
Definition: p_polys.h:191

◆ 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  }
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:725

◆ MultiplyME()

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

Implements CMultiplier< CPower >.

Definition at line 860 of file ncSAMult.cc.

861 {
862  const int j = expRight.Var;
863  const int n = expRight.Power;
864 
865  const ring r = GetBasering();
866 
867 #if OUTPUT
868  Print("CPowerMultiplier::MultiplyME(monom * var(%d)^{%d})!", j, n);
869  PrintLn();
870  PrintS("Monom: "); p_Write(pMonom, r);
871 #endif
872 
873  assume( (j > 0) && (j <= NVars()));
874 
875  if( n == 0 )
876  return p_Head(pMonom, r); // Copy?!?
877 
878 
879  int v = NVars();
880  int e = p_GetExp(pMonom, v, r);
881 
882  while((v > j) && (e == 0))
883  e = p_GetExp(pMonom, --v, r);
884 
885  // TODO: review this!
886  if( v == j )
887  {
888  poly p = p_Head(pMonom, r);
889  p_SetExp(p, v, e + n, r);
890  p_Setm(p, r);
891 
892  return p;
893  }
894 
895  assume( v > j );
896  assume( e > 0 );
897 
898  // And now the General Case: v > j!
899 
900  poly p = MultiplyEE( CPower(v, e), expRight ); // Easy way!
901 
902  --v;
903 
904  while(v > 0)
905  {
906  e = p_GetExp(pMonom, v, GetBasering());
907 
908  if( e > 0 )
909  p = MultiplyEPDestroy(CPower(v, e), p);
910 
911  --v;
912  }
913 
914 #if OUTPUT
915  PrintS("CPowerMultiplier::MultiplyME() ===> ");
916  p_Write(p, GetBasering());
917 #endif
918 
919  return p;
920 }
poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
Definition: ncSAMult.h:247

◆ 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  }
poly MultiplyTE(const poly pTerm, const CPower expRight)
Definition: ncSAMult.h:47

◆ 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  }

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: