My Project
Loading...
Searching...
No Matches
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)
 
virtual poly MultiplyEE (const poly expLeft, const poly expRight)=0
 
virtual poly MultiplyME (const poly pMonom, const poly expRight)=0
 
virtual poly MultiplyEM (const poly expLeft, const poly pMonom)=0
 

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 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}
CPowerMultiplier * m_powers
Definition: ncSAMult.h:267
const CFormulaPowerMultiplier * m_RingFormulaMultiplier
Definition: ncSAMult.h:268
static CFormulaPowerMultiplier * GetFormulaPowerMultiplier(const ring r)
Definition: ncSAFormula.h:93
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310

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

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}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
int i
Definition: cfEzgcd.cc:132
Enum_ncSAType GetPair(int i, int j) const
Definition: ncSAFormula.h:44
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
int NVars() const
Definition: ncSAMult.h:36
ring GetBasering() const
Definition: ncSAMult.h:35
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:991
poly MultiplyPEDestroy(poly pPoly, const CExponent expRight)
Definition: ncSAMult.h:235
poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
Definition: ncSAMult.h:247
#define Print
Definition: emacs.cc:80
int j
Definition: facHensel.cc:110
Enum_ncSAType
Definition: ncSAFormula.h:16
@ _ncSA_notImplemented
Definition: ncSAFormula.h:17
#define NULL
Definition: omList.c:12
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:342
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:486
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition: p_polys.h:858
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:467

◆ 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}
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight)
Definition: ncSAMult.cc:323

◆ 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 }
poly MultiplyET(const poly 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 assume(x)
Definition: mod2.h:389
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pNext(p)
Definition: monomials.h:36
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:106
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
static int pLength(poly a)
Definition: p_polys.h:188
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:252
void Werror(const char *fmt,...)
Definition: reporter.cc:189

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

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

◆ 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 }
poly MultiplyTE(const poly pTerm, const poly expRight)
Definition: ncSAMult.h:47
#define Warn
Definition: emacs.cc:77

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