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

#include <ncSAMult.h>

Public Types

typedef CMultiplier< polyCBaseType
 
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 266 of file ncSAMult.h.

Member Typedef Documentation

◆ CBaseType

Definition at line 274 of file ncSAMult.h.

◆ CExponent

Definition at line 281 of file ncSAMult.h.

Constructor & Destructor Documentation

◆ CGlobalMultiplier()

CGlobalMultiplier::CGlobalMultiplier ( ring  r)

Definition at line 293 of file ncSAMult.cc.

293  :
295 {
296 #if OUTPUT
297  PrintS("CGlobalMultiplier::CGlobalMultiplier(ring)!");
298  PrintLn();
299 #endif
300 
301 // m_cache = new CGlobalCacheHash(r);
302  m_powers = new CPowerMultiplier(r);
303 }
void PrintLn()
Definition: reporter.cc:310
static CFormulaPowerMultiplier * GetFormulaPowerMultiplier(const ring r)
Definition: ncSAFormula.h:95
const CFormulaPowerMultiplier * m_RingFormulaMultiplier
Definition: ncSAMult.h:271
CPowerMultiplier * m_powers
Definition: ncSAMult.h:270
const ring r
Definition: syzextra.cc:208
void PrintS(const char *s)
Definition: reporter.cc:284

◆ ~CGlobalMultiplier()

CGlobalMultiplier::~CGlobalMultiplier ( )
virtual

Definition at line 306 of file ncSAMult.cc.

307 {
308 #if OUTPUT
309  PrintS("CGlobalMultiplier::~CGlobalMultiplier()!");
310  PrintLn();
311 #endif
312 
313 // delete m_cache;
314  delete m_powers;
315 
316  // we cannot delete m_RingFormulaMultiplier as it belongs to the ring!
317 }
void PrintLn()
Definition: reporter.cc:310
CPowerMultiplier * m_powers
Definition: ncSAMult.h:270
void PrintS(const char *s)
Definition: reporter.cc:284

Member Function Documentation

◆ MultiplyEE()

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

Implements CMultiplier< poly >.

Definition at line 323 of file ncSAMult.cc.

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

◆ MultiplyEM()

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

Implements CMultiplier< poly >.

Definition at line 505 of file ncSAMult.cc.

506 {
507 #if OUTPUT
508  PrintS("CGlobalMultiplier::MultiplyEM(expL, monom)!");
509  PrintLn();
510  PrintS("expL: "); p_Write(expLeft, GetBasering());
511  PrintS("Monom: "); p_Write(pMonom, GetBasering());
512 #endif
513 
514  return MultiplyEE(expLeft, pMonom);
515 }
ring GetBasering() const
Definition: ncSAMult.h:38
void PrintLn()
Definition: reporter.cc:310
void PrintS(const char *s)
Definition: reporter.cc:284
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:323
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206

◆ MultiplyEP()

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

Definition at line 352 of file ncSAMult.h.

353  {
354  assume( pPoly != NULL ); assume( expLeft != NULL );
355  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
356 
357  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
358  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
359 
360  if( iComponentMonom!=0 )
361  {
362  for( poly q = pPoly; q !=NULL; q = pNext(q) )
363  {
364 #ifdef PDEBUG
365  {
366  const int iComponent = p_GetComp(q, GetBasering());
367  assume(iComponent == 0);
368  if( iComponent!=0 )
369  {
370  Werror("MultiplyEP: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
371  // what should we do further?!?
372  return NULL;
373  }
374  }
375 #endif
376  sum += MultiplyET(expLeft, q);
377  }
378  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
379  return t;
380  } // iComponentMonom != 0!
381  else
382  { // iComponentMonom == 0!
383  for( poly q = pPoly; q !=NULL; q = pNext(q) )
384  {
385  const int iComponent = p_GetComp(q, GetBasering());
386 
387  poly t = MultiplyET(expLeft, q); // NO Component!!!
388  p_SetCompP(t, iComponent, GetBasering());
389  sum += t;
390  }
391  return sum;
392  } // iComponentMonom == 0!
393  }
ring GetBasering() const
Definition: ncSAMult.h:38
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
#define assume(x)
Definition: mod2.h:394
static unsigned pLength(poly a)
Definition: p_polys.h:189
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
poly MultiplyET(const poly expLeft, const poly pTerm)
Definition: ncSAMult.h:64
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:29
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ MultiplyEPDestroy()

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

Definition at line 450 of file ncSAMult.h.

451  {
452 
453  assume( pPoly != NULL ); assume( expLeft != NULL );
454  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
455 
456  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
457  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
458 
459  if( iComponentMonom!=0 )
460  {
461  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
462  {
463 #ifdef PDEBUG
464  {
465  const int iComponent = p_GetComp(q, GetBasering());
466  assume(iComponent == 0);
467  if( iComponent!=0 )
468  {
469  Werror("MultiplyEPDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
470  // what should we do further?!?
471  return NULL;
472  }
473  }
474 #endif
475  sum += MultiplyET(expLeft, q);
476  }
477  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
478  return t;
479  } // iComponentMonom != 0!
480  else
481  { // iComponentMonom == 0!
482  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
483  {
484  const int iComponent = p_GetComp(q, GetBasering());
485 
486  poly t = MultiplyET(expLeft, q); // NO Component!!!
487  p_SetCompP(t, iComponent, GetBasering());
488  sum += t;
489  }
490  return sum;
491  } // iComponentMonom == 0!
492 
493  }
ring GetBasering() const
Definition: ncSAMult.h:38
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:720
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
#define assume(x)
Definition: mod2.h:394
static unsigned pLength(poly a)
Definition: p_polys.h:189
#define NULL
Definition: omList.c:10
poly MultiplyET(const poly expLeft, const poly pTerm)
Definition: ncSAMult.h:64
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:29
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ MultiplyME()

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

Implements CMultiplier< poly >.

Definition at line 492 of file ncSAMult.cc.

493 {
494 #if OUTPUT
495  PrintS("CGlobalMultiplier::MultiplyME(monom, expR)!");
496  PrintLn();
497  PrintS("Monom: "); p_Write(pMonom, GetBasering());
498  PrintS("expR: "); p_Write(expRight, GetBasering());
499 #endif
500 
501  return MultiplyEE(pMonom, expRight);
502 }
ring GetBasering() const
Definition: ncSAMult.h:38
void PrintLn()
Definition: reporter.cc:310
void PrintS(const char *s)
Definition: reporter.cc:284
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:323
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206

◆ MultiplyPE()

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

Definition at line 299 of file ncSAMult.h.

300  {
301  assume( pPoly != NULL ); assume( expRight != NULL );
302  const int iComponentMonom = p_GetComp(expRight, GetBasering());
303 
304  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
305  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
306 
307 
308  if( iComponentMonom!=0 )
309  {
310  for( poly q = pPoly; q !=NULL; q = pNext(q) )
311  {
312 #ifdef PDEBUG
313  {
314  const int iComponent = p_GetComp(q, GetBasering());
315  assume(iComponent == 0);
316  if( iComponent!=0 )
317  {
318  Werror("MultiplyPE: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
319  // what should we do further?!?
320  return NULL;
321  }
322 
323  }
324 #endif
325  sum += MultiplyTE(q, expRight); // NO Component!!!
326  }
327  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
328  return t;
329  } // iComponentMonom != 0!
330  else
331  { // iComponentMonom == 0!
332  for( poly q = pPoly; q !=NULL; q = pNext(q) )
333  {
334  const int iComponent = p_GetComp(q, GetBasering());
335 
336 #ifdef PDEBUG
337  if( iComponent!=0 )
338  {
339  Warn("MultiplyPE: Multiplication in the left module from the right by component %d!\n", iComponent);
340  // what should we do further?!?
341  }
342 #endif
343  poly t = MultiplyTE(q, expRight); // NO Component!!!
344  p_SetCompP(t, iComponent, GetBasering());
345  sum += t;
346  }
347  return sum;
348  } // iComponentMonom == 0!
349  }
ring GetBasering() const
Definition: ncSAMult.h:38
poly MultiplyTE(const poly pTerm, const poly expRight)
Definition: ncSAMult.h:50
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
#define assume(x)
Definition: mod2.h:394
static unsigned pLength(poly a)
Definition: p_polys.h:189
#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:29
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define Warn
Definition: emacs.cc:80

◆ MultiplyPEDestroy()

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

Definition at line 396 of file ncSAMult.h.

397  {
398  assume( pPoly != NULL ); assume( expRight != NULL );
399  const int iComponentMonom = p_GetComp(expRight, GetBasering());
400 
401  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
402  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
403 
404 
405  if( iComponentMonom!=0 )
406  {
407  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
408  {
409 #ifdef PDEBUG
410  {
411  const int iComponent = p_GetComp(q, GetBasering());
412  assume(iComponent == 0);
413  if( iComponent!=0 )
414  {
415  Werror("MultiplyPEDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
416  // what should we do further?!?
417  return NULL;
418  }
419 
420  }
421 #endif
422  sum += MultiplyTE(q, expRight); // NO Component!!!
423  }
424  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
425  return t;
426  } // iComponentMonom != 0!
427  else
428  { // iComponentMonom == 0!
429  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
430  {
431  const int iComponent = p_GetComp(q, GetBasering());
432 
433 #ifdef PDEBUG
434  if( iComponent!=0 )
435  {
436  Warn("MultiplyPEDestroy: Multiplication in the left module from the right by component %d!\n", iComponent);
437  // what should we do further?!?
438  }
439 #endif
440  poly t = MultiplyTE(q, expRight); // NO Component!!!
441  p_SetCompP(t, iComponent, GetBasering());
442  sum += t;
443  }
444  return sum;
445  } // iComponentMonom == 0!
446 
447  }
ring GetBasering() const
Definition: ncSAMult.h:38
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:720
poly MultiplyTE(const poly pTerm, const poly expRight)
Definition: ncSAMult.h:50
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
#define assume(x)
Definition: mod2.h:394
static unsigned pLength(poly a)
Definition: p_polys.h:189
#define NULL
Definition: omList.c:10
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(...
Definition: summator.h:29
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define Warn
Definition: emacs.cc:80

Field Documentation

◆ m_powers

CPowerMultiplier* CGlobalMultiplier::m_powers
private

Definition at line 270 of file ncSAMult.h.

◆ m_RingFormulaMultiplier

const CFormulaPowerMultiplier* CGlobalMultiplier::m_RingFormulaMultiplier
private

Definition at line 271 of file ncSAMult.h.


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