My Project  debian-1:4.1.1-p2+ds-4
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 829 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++ )

◆ ~CPowerMultiplier()

CPowerMultiplier::~CPowerMultiplier ( )
virtual

Definition at line 844 of file ncSAMult.cc.

847 {
848 #if OUTPUT
849  PrintS("CPowerMultiplier::~CPowerMultiplier()!");
850  PrintLn();
851 #endif
852 

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  }

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

◆ MultiplyEM()

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

Implements CMultiplier< CPower >.

Definition at line 921 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;

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

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

◆ MultiplyME()

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

Implements CMultiplier< CPower >.

Definition at line 857 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 

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

◆ 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:
CPowerMultiplier::GetPair
CSpecialPairMultiplier * GetPair(int i, int j) const
Definition: ncSAMult.h:173
p_LmDeleteAndNext
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:712
CSpecialPairMultiplier::MultiplyEE
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)=0
p_GetExp
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:457
j
int j
Definition: facHensel.cc:105
CPowerMultiplier::MultiplyEE
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:988
p_Head
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:810
MIN_LENGTH_BUCKET
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:19
CMultiplier< CPower >::MultiplyTE
poly MultiplyTE(const poly pTerm, const CPower expRight)
Definition: ncSAMult.h:47
p_SetExp
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:476
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:183
i
int i
Definition: cfEzgcd.cc:125
CMultiplier< CPower >::NVars
int NVars() const
Definition: ncSAMult.h:36
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:103
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
CPowerMultiplier::MultiplyPEDestroy
poly MultiplyPEDestroy(poly pPoly, const CExponent expRight)
Definition: ncSAMult.h:235
CPowerMultiplier::MultiplyEPDestroy
poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
Definition: ncSAMult.h:247
p_Write
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:203
CMultiplier< CPower >
CSpecialPairMultiplier::GetI
int GetI() const
Definition: ncSAMult.h:108
CPower
Definition: ncSAMult.h:132
p_One
poly p_One(const ring r)
Definition: p_polys.cc:1302
Print
#define Print
Definition: emacs.cc:79
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
assume
#define assume(x)
Definition: mod2.h:384
CMultiplier< CPower >::MultiplyET
poly MultiplyET(const CPower expLeft, const poly pTerm)
Definition: ncSAMult.h:61
NULL
#define NULL
Definition: omList.c:9
CSpecialPairMultiplier
Definition: ncSAMult.h:93
CSpecialPairMultiplier::GetJ
int GetJ() const
Definition: ncSAMult.h:109
p_Setm
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:224
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
PrintLn
void PrintLn()
Definition: reporter.cc:309
CPolynomialSummator
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(.
Definition: summator.h:19
pNext
#define pNext(p)
Definition: monomials.h:40
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
CPowerMultiplier::m_specialpairs
CSpecialPairMultiplier ** m_specialpairs
Definition: ncSAMult.h:166
CMultiplier< CPower >::GetBasering
ring GetBasering() const
Definition: ncSAMult.h:35