My Project  debian-1:4.1.1-p2+ds-4build1
Public Types | Public Member Functions | Private Attributes
CGlobalMultiplier Class Reference

#include <ncSAMult.h>

Public Types

typedef CMultiplier< poly > CBaseType
 
typedef poly CExponent
 

Public Member Functions

 CGlobalMultiplier (ring r)
 
virtual ~CGlobalMultiplier ()
 
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< poly >
 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 poly expRight)
 
poly MultiplyET (const poly expLeft, const poly pTerm)
 

Private Attributes

CPowerMultiplierm_powers
 
const CFormulaPowerMultiplierm_RingFormulaMultiplier
 

Additional Inherited Members

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

Detailed Description

Definition at line 263 of file ncSAMult.h.

Member Typedef Documentation

◆ CBaseType

Definition at line 271 of file ncSAMult.h.

◆ CExponent

Definition at line 278 of file ncSAMult.h.

Constructor & Destructor Documentation

◆ CGlobalMultiplier()

CGlobalMultiplier::CGlobalMultiplier ( ring  r)

Definition at line 290 of file ncSAMult.cc.

292  :
294 {
295 #if OUTPUT
296  PrintS("CGlobalMultiplier::CGlobalMultiplier(ring)!");
297  PrintLn();
298 #endif
299 
300 // m_cache = new CGlobalCacheHash(r);

◆ ~CGlobalMultiplier()

CGlobalMultiplier::~CGlobalMultiplier ( )
virtual

Definition at line 303 of file ncSAMult.cc.

306 {
307 #if OUTPUT
308  PrintS("CGlobalMultiplier::~CGlobalMultiplier()!");
309  PrintLn();
310 #endif
311 
312 // delete m_cache;
313  delete m_powers;
314 

Member Function Documentation

◆ MultiplyEE()

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

Implements CMultiplier< poly >.

Definition at line 320 of file ncSAMult.cc.

323 {
324 
325  const ring r = GetBasering();
326 
327 #if OUTPUT
328  PrintS("CGlobalMultiplier::MultiplyEE(expLeft, expRight)!");
329  PrintLn();
330  PrintS("expL: "); p_Write(expLeft, GetBasering());
331  PrintS("expR: "); p_Write(expRight, GetBasering());
332 #endif
333 
334 // CCacheHash<poly>::CCacheItem* pLookup;
335 //
336 // int b = m_cache->LookupEE(expLeft, expRight, pLookup);
337 // // TODO!!!
338 //
339 // // up to now:
340 // assume( b == -1 );
341 
342  // TODO: use PowerMultiplier!!!!
343 
344  poly product = NULL;
345 
346  const int N = NVars();
347  int j = N;
348  int i = 1;
349 
350  int ej = p_GetExp(expLeft, j, r);
351  int ei = p_GetExp(expRight, i, r);
352 
353  while( (i < j) && !((ej != 0) && (ei != 0)) )
354  {
355  if( ei == 0 )
356  ei = p_GetExp(expRight, ++i, r);
357 
358  if( ej == 0 )
359  ej = p_GetExp(expLeft, --j, r);
360  }
361 
362 
363 #if OUTPUT
364  PrintS("<CGlobalMultiplier::MultiplyEE>");
365  PrintLn();
366  Print("i: %d, j: %d", i, j);
367  PrintLn();
368  Print("ei: %d, ej: %d", ei, ej);
369  PrintLn();
370 #endif
371 
372 
373  // | expLeft | * | expRight |
374  // |<<<< ej 0..0| , |0..0 ei >>>>|
375  // |<<<< j <<<N| , |1>>> i >>>>|
376 
377  if( i >= j ) // BUG here!!!???
378  {
379  // either i == j or i = j + 1 => commutative multiple!
380  // TODO: it can be done more efficiently! ()
381  product = p_Head(expRight, r);
382 
383  // | expLeft | * | expRight |
384  // |<<<< ej 0....0| , |0..00 ei >>>>|
385  // |<<<< j i <<<N| , |1>>>j i >>>>|
386 
387  if(i > j)
388  {
389  --i;
390  ei = 0;
391  }
392 
393  if( i == j )
394  {
395  if( ej != 0 )
396  p_SetExp(product, i, ei + ej, r);
397  }
398 
399  --i;
400 
401  for(; i > 0; --i)
402  {
403  const int e = p_GetExp(expLeft, i, r);
404 
405  if( e > 0 )
406  p_SetExp(product, i, e, r);
407  }
408 
409  p_Setm(product, r);
410 
411  } else
412  { // i < j, ei != 0, ej != 0
413 
415 
417  PairType = m_RingFormulaMultiplier->GetPair(i, j);
418 
419 
420  if( PairType == _ncSA_notImplemented )
421  product = m_powers->MultiplyEE( CPower(j, ej), CPower(i, ei) );
422 // return ggnc_uu_Mult_ww_vert(i, a, j, b, r);
423  else
424  // return m_RingFormulaMultiplier->Multiply(j, i, b, a);
425  product = CFormulaPowerMultiplier::Multiply( PairType, i, j, ei, ej, GetBasering());
426 
427 
428 #if OUTPUT
429  PrintS("<CGlobalMultiplier::MultiplyEE> ==> ");
430  PrintLn();
431  Print("i: %d, j: %d", i, j);
432  PrintLn();
433  Print("ei: %d, ej: %d", ei, ej);
434  PrintLn();
435  PrintS("<product>: "); p_Write(product, GetBasering());
436 #endif
437 
438 
439  // TODO: Choose some multiplication strategy!!!
440 
441  while( (product != NULL) && !((i == NVars()) && (j == 1)) )
442  {
443 
444  // make some choice here!:
445 
446  if( i < NVars() )
447  {
448  ei = p_GetExp(expRight, ++i, r);
449 
450  while( (ei == 0) && (i < NVars()) )
451  ei = p_GetExp(expRight, ++i, r);
452 
453  if( ei != 0 )
454  product = m_powers->MultiplyPEDestroy(product, CPower(i, ei));
455  }
456 
457  if( j > 1 )
458  {
459  ej = p_GetExp(expLeft, --j, r);
460 
461  while( (ej == 0) && (1 < j) )
462  ej = p_GetExp(expLeft, --j, r);
463 
464  if( ej != 0 )
465  product = m_powers->MultiplyEPDestroy(CPower(j, ej), product);
466  }
467 
468 
469 #if OUTPUT
470  PrintS("<CGlobalMultiplier::MultiplyEE> ==> ");
471  PrintLn();
472  Print("i: %d, j: %d", i, j);
473  PrintLn();
474  Print("ei: %d, ej: %d", ei, ej);
475  PrintLn();
476  PrintS("<product>: "); p_Write(product, GetBasering());
477 #endif
478 
479  }
480 
481  }
482 
483 // // TODO!
484 //
485 // m_cache->StoreEE( expLeft, expRight, product);
486 // // up to now:

◆ MultiplyEM()

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

Implements CMultiplier< poly >.

Definition at line 502 of file ncSAMult.cc.

505 {
506 #if OUTPUT
507  PrintS("CGlobalMultiplier::MultiplyEM(expL, monom)!");
508  PrintLn();
509  PrintS("expL: "); p_Write(expLeft, GetBasering());
510  PrintS("Monom: "); p_Write(pMonom, GetBasering());
511 #endif
512 

◆ MultiplyEP()

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

Definition at line 349 of file ncSAMult.h.

350  {
351  assume( pPoly != NULL ); assume( expLeft != NULL );
352  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
353 
354  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
355  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
356 
357  if( iComponentMonom!=0 )
358  {
359  for( poly q = pPoly; q !=NULL; q = pNext(q) )
360  {
361 #ifdef PDEBUG
362  {
363  const int iComponent = p_GetComp(q, GetBasering());
364  assume(iComponent == 0);
365  if( iComponent!=0 )
366  {
367  Werror("MultiplyEP: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
368  // what should we do further?!?
369  return NULL;
370  }
371  }
372 #endif
373  sum += MultiplyET(expLeft, q);
374  }
375  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
376  return t;
377  } // iComponentMonom != 0!
378  else
379  { // iComponentMonom == 0!
380  for( poly q = pPoly; q !=NULL; q = pNext(q) )
381  {
382  const int iComponent = p_GetComp(q, GetBasering());
383 
384  poly t = MultiplyET(expLeft, q); // NO Component!!!
385  p_SetCompP(t, iComponent, GetBasering());
386  sum += t;
387  }
388  return sum;
389  } // iComponentMonom == 0!
390  }

◆ MultiplyEPDestroy()

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

Definition at line 447 of file ncSAMult.h.

448  {
449 
450  assume( pPoly != NULL ); assume( expLeft != NULL );
451  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
452 
453  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
454  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
455 
456  if( iComponentMonom!=0 )
457  {
458  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
459  {
460 #ifdef PDEBUG
461  {
462  const int iComponent = p_GetComp(q, GetBasering());
463  assume(iComponent == 0);
464  if( iComponent!=0 )
465  {
466  Werror("MultiplyEPDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
467  // what should we do further?!?
468  return NULL;
469  }
470  }
471 #endif
472  sum += MultiplyET(expLeft, q);
473  }
474  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
475  return t;
476  } // iComponentMonom != 0!
477  else
478  { // iComponentMonom == 0!
479  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
480  {
481  const int iComponent = p_GetComp(q, GetBasering());
482 
483  poly t = MultiplyET(expLeft, q); // NO Component!!!
484  p_SetCompP(t, iComponent, GetBasering());
485  sum += t;
486  }
487  return sum;
488  } // iComponentMonom == 0!
489 
490  }

◆ MultiplyME()

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

Implements CMultiplier< poly >.

Definition at line 489 of file ncSAMult.cc.

492 {
493 #if OUTPUT
494  PrintS("CGlobalMultiplier::MultiplyME(monom, expR)!");
495  PrintLn();
496  PrintS("Monom: "); p_Write(pMonom, GetBasering());
497  PrintS("expR: "); p_Write(expRight, GetBasering());
498 #endif
499 

◆ MultiplyPE()

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

Definition at line 296 of file ncSAMult.h.

297  {
298  assume( pPoly != NULL ); assume( expRight != NULL );
299  const int iComponentMonom = p_GetComp(expRight, GetBasering());
300 
301  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
302  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
303 
304 
305  if( iComponentMonom!=0 )
306  {
307  for( poly q = pPoly; q !=NULL; q = pNext(q) )
308  {
309 #ifdef PDEBUG
310  {
311  const int iComponent = p_GetComp(q, GetBasering());
312  assume(iComponent == 0);
313  if( iComponent!=0 )
314  {
315  Werror("MultiplyPE: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
316  // what should we do further?!?
317  return NULL;
318  }
319 
320  }
321 #endif
322  sum += MultiplyTE(q, expRight); // NO Component!!!
323  }
324  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
325  return t;
326  } // iComponentMonom != 0!
327  else
328  { // iComponentMonom == 0!
329  for( poly q = pPoly; q !=NULL; q = pNext(q) )
330  {
331  const int iComponent = p_GetComp(q, GetBasering());
332 
333 #ifdef PDEBUG
334  if( iComponent!=0 )
335  {
336  Warn("MultiplyPE: Multiplication in the left module from the right by component %d!\n", iComponent);
337  // what should we do further?!?
338  }
339 #endif
340  poly t = MultiplyTE(q, expRight); // NO Component!!!
341  p_SetCompP(t, iComponent, GetBasering());
342  sum += t;
343  }
344  return sum;
345  } // iComponentMonom == 0!
346  }

◆ MultiplyPEDestroy()

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

Definition at line 393 of file ncSAMult.h.

394  {
395  assume( pPoly != NULL ); assume( expRight != NULL );
396  const int iComponentMonom = p_GetComp(expRight, GetBasering());
397 
398  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
399  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
400 
401 
402  if( iComponentMonom!=0 )
403  {
404  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
405  {
406 #ifdef PDEBUG
407  {
408  const int iComponent = p_GetComp(q, GetBasering());
409  assume(iComponent == 0);
410  if( iComponent!=0 )
411  {
412  Werror("MultiplyPEDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
413  // what should we do further?!?
414  return NULL;
415  }
416 
417  }
418 #endif
419  sum += MultiplyTE(q, expRight); // NO Component!!!
420  }
421  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
422  return t;
423  } // iComponentMonom != 0!
424  else
425  { // iComponentMonom == 0!
426  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
427  {
428  const int iComponent = p_GetComp(q, GetBasering());
429 
430 #ifdef PDEBUG
431  if( iComponent!=0 )
432  {
433  Warn("MultiplyPEDestroy: Multiplication in the left module from the right by component %d!\n", iComponent);
434  // what should we do further?!?
435  }
436 #endif
437  poly t = MultiplyTE(q, expRight); // NO Component!!!
438  p_SetCompP(t, iComponent, GetBasering());
439  sum += t;
440  }
441  return sum;
442  } // iComponentMonom == 0!
443 
444  }

Field Documentation

◆ m_powers

CPowerMultiplier* CGlobalMultiplier::m_powers
private

Definition at line 267 of file ncSAMult.h.

◆ m_RingFormulaMultiplier

const CFormulaPowerMultiplier* CGlobalMultiplier::m_RingFormulaMultiplier
private

Definition at line 268 of file ncSAMult.h.


The documentation for this class was generated from the following files:
p_LmDeleteAndNext
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:712
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:68
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
p_SetCompP
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:245
_ncSA_notImplemented
Definition: ncSAFormula.h:16
CGlobalMultiplier::m_RingFormulaMultiplier
const CFormulaPowerMultiplier * m_RingFormulaMultiplier
Definition: ncSAMult.h:268
CFormulaPowerMultiplier::Multiply
static poly Multiply(Enum_ncSAType type, const int i, const int j, const int n, const int m, const ring r)
Definition: ncSAFormula.cc:694
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
CMultiplier< poly >::MultiplyTE
poly MultiplyTE(const poly pTerm, const poly expRight)
Definition: ncSAMult.h:47
Enum_ncSAType
Enum_ncSAType
Definition: ncSAFormula.h:14
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
CGlobalMultiplier::m_powers
CPowerMultiplier * m_powers
Definition: ncSAMult.h:267
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:183
i
int i
Definition: cfEzgcd.cc:125
CMultiplier< poly >::NVars
int NVars() const
Definition: ncSAMult.h:36
CFormulaPowerMultiplier::GetPair
Enum_ncSAType GetPair(int i, int j) const
Definition: ncSAFormula.h:43
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< poly >
CPower
Definition: ncSAMult.h:132
Print
#define Print
Definition: emacs.cc:79
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
GetFormulaPowerMultiplier
static CFormulaPowerMultiplier * GetFormulaPowerMultiplier(const ring r)
Definition: ncSAFormula.h:92
assume
#define assume(x)
Definition: mod2.h:384
CMultiplier< poly >::MultiplyET
poly MultiplyET(const poly expLeft, const poly pTerm)
Definition: ncSAMult.h:61
NULL
#define NULL
Definition: omList.c:9
p_Setm
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:224
Warn
#define Warn
Definition: emacs.cc:76
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
CMultiplier< poly >::GetBasering
ring GetBasering() const
Definition: ncSAMult.h:35