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 polyexpRight)
 
poly MultiplyET (const polyexpLeft, 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 268 of file ncSAMult.h.

Member Typedef Documentation

Definition at line 276 of file ncSAMult.h.

Definition at line 283 of file ncSAMult.h.

Constructor & Destructor Documentation

CGlobalMultiplier::CGlobalMultiplier ( ring  r)

Definition at line 294 of file ncSAMult.cc.

294  :
296 {
297 #if OUTPUT
298  PrintS("CGlobalMultiplier::CGlobalMultiplier(ring)!");
299  PrintLn();
300 #endif
301 
302 // m_cache = new CGlobalCacheHash(r);
303  m_powers = new CPowerMultiplier(r);
304 }
void PrintLn()
Definition: reporter.cc:327
static CFormulaPowerMultiplier * GetFormulaPowerMultiplier(const ring r)
Definition: ncSAFormula.h:95
const CFormulaPowerMultiplier * m_RingFormulaMultiplier
Definition: ncSAMult.h:273
CPowerMultiplier * m_powers
Definition: ncSAMult.h:272
const ring r
Definition: syzextra.cc:208
void PrintS(const char *s)
Definition: reporter.cc:294
CGlobalMultiplier::~CGlobalMultiplier ( )
virtual

Definition at line 307 of file ncSAMult.cc.

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

Member Function Documentation

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

Implements CMultiplier< poly >.

Definition at line 324 of file ncSAMult.cc.

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

Implements CMultiplier< poly >.

Definition at line 506 of file ncSAMult.cc.

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

Definition at line 354 of file ncSAMult.h.

355  {
356  assume( pPoly != NULL ); assume( expLeft != NULL );
357  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
358 
359  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
360  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
361 
362  if( iComponentMonom!=0 )
363  {
364  for( poly q = pPoly; q !=NULL; q = pNext(q) )
365  {
366 #ifdef PDEBUG
367  {
368  const int iComponent = p_GetComp(q, GetBasering());
369  assume(iComponent == 0);
370  if( iComponent!=0 )
371  {
372  Werror("MultiplyEP: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
373  // what should we do further?!?
374  return NULL;
375  }
376  }
377 #endif
378  sum += MultiplyET(expLeft, q);
379  }
380  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
381  return t;
382  } // iComponentMonom != 0!
383  else
384  { // iComponentMonom == 0!
385  for( poly q = pPoly; q !=NULL; q = pNext(q) )
386  {
387  const int iComponent = p_GetComp(q, GetBasering());
388 
389  poly t = MultiplyET(expLeft, q); // NO Component!!!
390  p_SetCompP(t, iComponent, GetBasering());
391  sum += t;
392  }
393  return sum;
394  } // iComponentMonom == 0!
395  }
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
static int pLength(poly a)
Definition: p_polys.h:189
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:243
#define assume(x)
Definition: mod2.h:405
ring GetBasering() const
Definition: ncSAMult.h:40
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
poly MultiplyET(const polyexpLeft, const poly pTerm)
Definition: ncSAMult.h:66
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:199
poly CGlobalMultiplier::MultiplyEPDestroy ( const CExponent  expLeft,
poly  pPoly 
)
inline

Definition at line 452 of file ncSAMult.h.

453  {
454 
455  assume( pPoly != NULL ); assume( expLeft != NULL );
456  const int iComponentMonom = p_GetComp(expLeft, GetBasering());
457 
458  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
459  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
460 
461  if( iComponentMonom!=0 )
462  {
463  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
464  {
465 #ifdef PDEBUG
466  {
467  const int iComponent = p_GetComp(q, GetBasering());
468  assume(iComponent == 0);
469  if( iComponent!=0 )
470  {
471  Werror("MultiplyEPDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
472  // what should we do further?!?
473  return NULL;
474  }
475  }
476 #endif
477  sum += MultiplyET(expLeft, q);
478  }
479  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
480  return t;
481  } // iComponentMonom != 0!
482  else
483  { // iComponentMonom == 0!
484  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
485  {
486  const int iComponent = p_GetComp(q, GetBasering());
487 
488  poly t = MultiplyET(expLeft, q); // NO Component!!!
489  p_SetCompP(t, iComponent, GetBasering());
490  sum += t;
491  }
492  return sum;
493  } // iComponentMonom == 0!
494 
495  }
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:721
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
static int pLength(poly a)
Definition: p_polys.h:189
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:243
#define assume(x)
Definition: mod2.h:405
ring GetBasering() const
Definition: ncSAMult.h:40
#define NULL
Definition: omList.c:10
poly MultiplyET(const polyexpLeft, const poly pTerm)
Definition: ncSAMult.h:66
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:199
poly CGlobalMultiplier::MultiplyME ( const poly  pMonom,
const CExponent  expRight 
)
virtual

Implements CMultiplier< poly >.

Definition at line 493 of file ncSAMult.cc.

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

Definition at line 301 of file ncSAMult.h.

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

Definition at line 398 of file ncSAMult.h.

399  {
400  assume( pPoly != NULL ); assume( expRight != NULL );
401  const int iComponentMonom = p_GetComp(expRight, GetBasering());
402 
403  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
404  CPolynomialSummator sum(GetBasering(), bUsePolynomial);
405 
406 
407  if( iComponentMonom!=0 )
408  {
409  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
410  {
411 #ifdef PDEBUG
412  {
413  const int iComponent = p_GetComp(q, GetBasering());
414  assume(iComponent == 0);
415  if( iComponent!=0 )
416  {
417  Werror("MultiplyPEDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
418  // what should we do further?!?
419  return NULL;
420  }
421 
422  }
423 #endif
424  sum += MultiplyTE(q, expRight); // NO Component!!!
425  }
426  poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
427  return t;
428  } // iComponentMonom != 0!
429  else
430  { // iComponentMonom == 0!
431  for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
432  {
433  const int iComponent = p_GetComp(q, GetBasering());
434 
435 #ifdef PDEBUG
436  if( iComponent!=0 )
437  {
438  Warn("MultiplyPEDestroy: Multiplication in the left module from the right by component %d!\n", iComponent);
439  // what should we do further?!?
440  }
441 #endif
442  poly t = MultiplyTE(q, expRight); // NO Component!!!
443  p_SetCompP(t, iComponent, GetBasering());
444  sum += t;
445  }
446  return sum;
447  } // iComponentMonom == 0!
448 
449  }
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:721
poly MultiplyTE(const poly pTerm, const polyexpRight)
Definition: ncSAMult.h:52
#define p_GetComp(p, r)
Definition: monomials.h:72
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:22
static int pLength(poly a)
Definition: p_polys.h:189
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:100
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:243
#define assume(x)
Definition: mod2.h:405
ring GetBasering() const
Definition: ncSAMult.h:40
#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:199
#define Warn
Definition: emacs.cc:80

Field Documentation

CPowerMultiplier* CGlobalMultiplier::m_powers
private

Definition at line 272 of file ncSAMult.h.

const CFormulaPowerMultiplier* CGlobalMultiplier::m_RingFormulaMultiplier
private

Definition at line 273 of file ncSAMult.h.


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