/usr/include/singular/singular/polys/nc/ncSAMult.h is in libsingular4-dev-common 1:4.1.0-p3+ds-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | #ifndef GRING_SA_MULT_H
#define GRING_SA_MULT_H
/*****************************************
* Computer Algebra System SINGULAR *
*****************************************/
#ifdef HAVE_PLURAL
// #include <ncSAMult.h> // for CMultiplier etc classes
#include <misc/options.h>
#include <polys/monomials/ring.h>
#include <polys/nc/summator.h>// for CPolynomialSummator class
#include <reporter/reporter.h> // for Print!
#include <polys/monomials/p_polys.h>
#include <polys/operations/p_Mult_q.h>
//#include <polys/nc/ncSACache.h> // for CCacheHash etc classes
#include <polys/nc/ncSAFormula.h> // for CFormulaPowerMultiplier and enum Enum_ncSAType
// //////////////////////////////////////////////////////////////////////// //
//
BOOLEAN ncInitSpecialPairMultiplication(ring r);
template <typename CExponent>
class CMultiplier
{
protected:
const ring m_basering;
const int m_NVars; // N = number of variables
public:
CMultiplier(ring rBaseRing): m_basering(rBaseRing), m_NVars(rBaseRing->N) {};
virtual ~CMultiplier() {};
inline ring GetBasering() const { return m_basering; };
inline int NVars() const { return m_NVars; }
inline poly LM(const poly pTerm, const ring r, int i = 1) const
{
poly pMonom = p_LmInit(pTerm, r);
pSetCoeff0(pMonom, n_Init(i, r->cf));
return pMonom;
}
// Term * Exponent -> Monom * Exponent
inline poly MultiplyTE(const poly pTerm, const CExponent expRight)
{
const ring r = GetBasering();
poly pMonom = LM(pTerm, r);
poly result = p_Mult_nn(MultiplyME(pMonom, expRight), p_GetCoeff(pTerm, r), r);
p_Delete(&pMonom, r);
return result;
}
// Exponent * Term -> Exponent * Monom
inline poly MultiplyET(const CExponent expLeft, const poly pTerm)
{
const ring r = GetBasering();
poly pMonom = LM(pTerm, r);
poly result = p_Mult_nn(MultiplyEM(expLeft, pMonom), p_GetCoeff(pTerm, r), r);
p_Delete(&pMonom, r);
return result;
}
// protected:
// Exponent * Exponent
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight) = 0;
// Monom * Exponent
virtual poly MultiplyME(const poly pMonom, const CExponent expRight) = 0;
// Exponent * Monom
virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom) = 0;
private: // no copy constuctors!
CMultiplier();
CMultiplier(const CMultiplier&);
CMultiplier& operator=(const CMultiplier&);
};
class CSpecialPairMultiplier: public CMultiplier<int>
{
private:
int m_i; // 2-gen subalgebra in these variables...
int m_j;
// poly m_c_ij;
// poly m_d_ij;
public:
// 1 <= i < j <= NVars()
CSpecialPairMultiplier(ring r, int i, int j);
virtual ~CSpecialPairMultiplier();
inline int GetI() const { return m_i; } // X
inline int GetJ() const { return m_j; } // Y > X!
// protected:
typedef int CExponent;
// Exponent * Exponent
// Computes: var(j)^{expLeft} * var(i)^{expRight}
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight) = 0;
// Monom * Exponent
// pMonom must be of the form: var(j)^{n}
virtual poly MultiplyME(const poly pMonom, const CExponent expRight);
// Exponent * Monom
// pMonom must be of the form: var(i)^{m}
virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom);
};
struct CPower // represents var(iVar)^{iPower}
{
int Var;
int Power;
CPower(int i, int n): Var(i), Power(n) {};
/*
inline poly GetPoly(const ring r) const // TODO: search for GetPoly(r, 1) and remove "1"!
{
poly p = p_One(r);
p_SetExp(p, Var, Power, r);
p_Setm(p, r);
return p;
};
inline poly GetPoly(const ring r, int c) const
{
poly p = p_ISet(c, r);
p_SetExp(p, Var, Power, r);
p_Setm(p, r);
return p;
};
*/
};
class CPowerMultiplier: public CMultiplier<CPower>
{
private:
CSpecialPairMultiplier** m_specialpairs; // upper triangular submatrix of pairs 1 <= i < j <= N of a N x N matrix.
public:
CPowerMultiplier(ring r);
virtual ~CPowerMultiplier();
inline CSpecialPairMultiplier* GetPair(int i, int j) const
{
assume( m_specialpairs != NULL );
assume( i > 0 );
assume( i < j );
assume( j <= NVars() );
return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )];
}
inline CSpecialPairMultiplier*& GetPair(int i, int j)
{
assume( m_specialpairs != NULL );
assume( i > 0 );
assume( i < j );
assume( j <= NVars() );
return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )];
}
// protected:
typedef CPower CExponent;
// Exponent * Exponent
// Computes: var(j)^{expLeft} * var(i)^{expRight}
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight);
// Monom * Exponent
// pMonom may NOT be of the form: var(j)^{n}!
virtual poly MultiplyME(const poly pMonom, const CExponent expRight);
// Exponent * Monom
// pMonom may NOT be of the form: var(i)^{m}!
virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom);
// Main templates:
// Poly * Exponent
inline poly MultiplyPE(const poly pPoly, const CExponent expRight)
{
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
for( poly q = pPoly; q !=NULL; q = pNext(q) )
sum += MultiplyTE(q, expRight);
return sum;
}
// Exponent * Poly
inline poly MultiplyEP(const CExponent expLeft, const poly pPoly)
{
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
for( poly q = pPoly; q !=NULL; q = pNext(q) )
sum += MultiplyET(expLeft, q);
return sum;
}
// Poly * Exponent
inline poly MultiplyPEDestroy(poly pPoly, const CExponent expRight)
{
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
for( ; pPoly!=NULL; pPoly = p_LmDeleteAndNext(pPoly, GetBasering()) )
sum += MultiplyTE(pPoly, expRight);
return sum;
}
// Exponent * Poly
inline poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
{
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
for( ; pPoly!=NULL; pPoly = p_LmDeleteAndNext(pPoly, GetBasering()) )
sum += MultiplyET(expLeft, pPoly);
return sum;
}
};
class CGlobalMultiplier: public CMultiplier<poly>
{
private:
// CGlobalCacheHash* m_cache;
CPowerMultiplier* m_powers;
const CFormulaPowerMultiplier* m_RingFormulaMultiplier;
public:
typedef CMultiplier<poly> CBaseType;
CGlobalMultiplier(ring r);
virtual ~CGlobalMultiplier();
// protected:
typedef poly CExponent;
// the following methods are literally equal!
// Exponent * Exponent
// TODO: handle components!!!
virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight);
// Monom * Exponent
virtual poly MultiplyME(const poly pMonom, const CExponent expRight);
// Exponent * Monom
virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom);
// Main templates:
// Poly * Exponent
inline poly MultiplyPE(const poly pPoly, const CExponent expRight)
{
assume( pPoly != NULL ); assume( expRight != NULL );
const int iComponentMonom = p_GetComp(expRight, GetBasering());
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
if( iComponentMonom!=0 )
{
for( poly q = pPoly; q !=NULL; q = pNext(q) )
{
#ifdef PDEBUG
{
const int iComponent = p_GetComp(q, GetBasering());
assume(iComponent == 0);
if( iComponent!=0 )
{
Werror("MultiplyPE: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
// what should we do further?!?
return NULL;
}
}
#endif
sum += MultiplyTE(q, expRight); // NO Component!!!
}
poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
return t;
} // iComponentMonom != 0!
else
{ // iComponentMonom == 0!
for( poly q = pPoly; q !=NULL; q = pNext(q) )
{
const int iComponent = p_GetComp(q, GetBasering());
#ifdef PDEBUG
if( iComponent!=0 )
{
Warn("MultiplyPE: Multiplication in the left module from the right by component %d!\n", iComponent);
// what should we do further?!?
}
#endif
poly t = MultiplyTE(q, expRight); // NO Component!!!
p_SetCompP(t, iComponent, GetBasering());
sum += t;
}
return sum;
} // iComponentMonom == 0!
}
// Exponent * Poly
inline poly MultiplyEP(const CExponent expLeft, const poly pPoly)
{
assume( pPoly != NULL ); assume( expLeft != NULL );
const int iComponentMonom = p_GetComp(expLeft, GetBasering());
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
if( iComponentMonom!=0 )
{
for( poly q = pPoly; q !=NULL; q = pNext(q) )
{
#ifdef PDEBUG
{
const int iComponent = p_GetComp(q, GetBasering());
assume(iComponent == 0);
if( iComponent!=0 )
{
Werror("MultiplyEP: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
// what should we do further?!?
return NULL;
}
}
#endif
sum += MultiplyET(expLeft, q);
}
poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
return t;
} // iComponentMonom != 0!
else
{ // iComponentMonom == 0!
for( poly q = pPoly; q !=NULL; q = pNext(q) )
{
const int iComponent = p_GetComp(q, GetBasering());
poly t = MultiplyET(expLeft, q); // NO Component!!!
p_SetCompP(t, iComponent, GetBasering());
sum += t;
}
return sum;
} // iComponentMonom == 0!
}
// Poly * Exponent
inline poly MultiplyPEDestroy(poly pPoly, const CExponent expRight)
{
assume( pPoly != NULL ); assume( expRight != NULL );
const int iComponentMonom = p_GetComp(expRight, GetBasering());
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
if( iComponentMonom!=0 )
{
for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
{
#ifdef PDEBUG
{
const int iComponent = p_GetComp(q, GetBasering());
assume(iComponent == 0);
if( iComponent!=0 )
{
Werror("MultiplyPEDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
// what should we do further?!?
return NULL;
}
}
#endif
sum += MultiplyTE(q, expRight); // NO Component!!!
}
poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
return t;
} // iComponentMonom != 0!
else
{ // iComponentMonom == 0!
for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
{
const int iComponent = p_GetComp(q, GetBasering());
#ifdef PDEBUG
if( iComponent!=0 )
{
Warn("MultiplyPEDestroy: Multiplication in the left module from the right by component %d!\n", iComponent);
// what should we do further?!?
}
#endif
poly t = MultiplyTE(q, expRight); // NO Component!!!
p_SetCompP(t, iComponent, GetBasering());
sum += t;
}
return sum;
} // iComponentMonom == 0!
}
// Exponent * Poly
inline poly MultiplyEPDestroy(const CExponent expLeft, poly pPoly)
{
assume( pPoly != NULL ); assume( expLeft != NULL );
const int iComponentMonom = p_GetComp(expLeft, GetBasering());
bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
CPolynomialSummator sum(GetBasering(), bUsePolynomial);
if( iComponentMonom!=0 )
{
for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
{
#ifdef PDEBUG
{
const int iComponent = p_GetComp(q, GetBasering());
assume(iComponent == 0);
if( iComponent!=0 )
{
Werror("MultiplyEPDestroy: both sides have non-zero components: %d and %d!\n", iComponent, iComponentMonom);
// what should we do further?!?
return NULL;
}
}
#endif
sum += MultiplyET(expLeft, q);
}
poly t = sum; p_SetCompP(t, iComponentMonom, GetBasering());
return t;
} // iComponentMonom != 0!
else
{ // iComponentMonom == 0!
for(poly q = pPoly ; q!=NULL; q = p_LmDeleteAndNext(q, GetBasering()) )
{
const int iComponent = p_GetComp(q, GetBasering());
poly t = MultiplyET(expLeft, q); // NO Component!!!
p_SetCompP(t, iComponent, GetBasering());
sum += t;
}
return sum;
} // iComponentMonom == 0!
}
};
//////////////////////////////////////////////////////////////////////////
class CCommutativeSpecialPairMultiplier: public CSpecialPairMultiplier
{
public:
CCommutativeSpecialPairMultiplier(ring r, int i, int j);
virtual ~CCommutativeSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
//////////////////////////////////////////////////////////////////////////
class CAntiCommutativeSpecialPairMultiplier: public CSpecialPairMultiplier
{
public:
CAntiCommutativeSpecialPairMultiplier(ring r, int i, int j);
virtual ~CAntiCommutativeSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
//////////////////////////////////////////////////////////////////////////
class CQuasiCommutativeSpecialPairMultiplier: public CSpecialPairMultiplier
{
private:
const number m_q;
// TODO: make cache for some 'good' powers!?
public:
CQuasiCommutativeSpecialPairMultiplier(ring r, int i, int j, number q);
virtual ~CQuasiCommutativeSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
//////////////////////////////////////////////////////////////////////////
class CWeylSpecialPairMultiplier: public CSpecialPairMultiplier
{
private:
const number m_g;
// TODO: make cache for some 'good' powers!?
public:
CWeylSpecialPairMultiplier(ring r, int i, int j, number g);
virtual ~CWeylSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
//////////////////////////////////////////////////////////////////////////
class CHWeylSpecialPairMultiplier: public CSpecialPairMultiplier
{
private:
const int m_k;
// TODO: make cache for some 'good' powers!?
public:
CHWeylSpecialPairMultiplier(ring r, int i, int j, int k);
virtual ~CHWeylSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
//////////////////////////////////////////////////////////////////////////
class CShiftSpecialPairMultiplier: public CSpecialPairMultiplier
{
private:
const number m_shiftCoef;
const int m_shiftVar;
// TODO: make cache for some 'good' powers!?
public:
CShiftSpecialPairMultiplier(ring r, int i, int j, int s, number c);
virtual ~CShiftSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
// need: enum Enum_ncSAType;
//////////////////////////////////////////////////////////////////////////
// Using external 'formula' routins
class CExternalSpecialPairMultiplier: public CSpecialPairMultiplier
{
private:
Enum_ncSAType m_ncSAtype;
public:
CExternalSpecialPairMultiplier(ring r, int i, int j, Enum_ncSAType type);
virtual ~CExternalSpecialPairMultiplier();
// Exponent * Exponent
virtual poly MultiplyEE(const int expLeft, const int expRight);
};
#endif // HAVE_PLURAL :(
#endif //
|