Data Structures | Macros | Functions | Variables
transext.cc File Reference
#include "misc/auxiliary.h"
#include "omalloc/omalloc.h"
#include "factory/factory.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/longrat.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "polys/clapsing.h"
#include "polys/clapconv.h"
#include "polys/prCopy.h"
#include "transext.h"
#include "algext.h"
#include "polys/PolyEnumerator.h"

Go to the source code of this file.

Data Structures

struct  NTNumConverter
 

Macros

#define TRANSEXT_PRIVATES
 
#define ADD_COMPLEXITY   1
 complexity increase due to + and - More...
 
#define MULT_COMPLEXITY   2
 complexity increase due to * and / More...
 
#define DIFF_COMPLEXITY   2
 complexity increase due to * and / More...
 
#define BOUND_COMPLEXITY   10
 maximum complexity of a number More...
 
#define NUMIS1(f)   (p_IsOne(NUM(f), cf->extRing))
 TRUE iff num. represents 1. More...
 
#define COM(f)   (f)->complexity
 
#define ntTest(a)   n_Test(a, cf)
 
#define ntRing   cf->extRing
 
#define ntCoeffs   cf->extRing->cf
 

Functions

static BOOLEAN ntDBTest (number a, const char *f, const int l, const coeffs r)
 
static void heuristicGcdCancellation (number a, const coeffs cf)
 forward declarations More...
 
static void definiteGcdCancellation (number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
 modifies a More...
 
static coeffs nCoeff_bottom (const coeffs r, int &height)
 
static BOOLEAN ntIsZero (number a, const coeffs cf)
 
static void ntDelete (number *a, const coeffs cf)
 
static BOOLEAN ntEqual (number a, number b, const coeffs cf)
 
static number ntCopy (number a, const coeffs cf)
 
static void handleNestedFractionsOverQ (fraction f, const coeffs cf)
 
static number ntGetNumerator (number &a, const coeffs cf)
 TODO: normalization of a!? More...
 
static number ntGetDenom (number &a, const coeffs cf)
 TODO: normalization of a!? More...
 
static BOOLEAN ntIsOne (number a, const coeffs cf)
 
static BOOLEAN ntIsMOne (number a, const coeffs cf)
 
static number ntNeg (number a, const coeffs cf)
 this is in-place, modifies a More...
 
number ntInit (long i, const coeffs cf)
 
number ntInit (poly p, const coeffs cf)
 
static long ntInt (number &a, const coeffs cf)
 
static BOOLEAN ntGreaterZero (number a, const coeffs cf)
 
static BOOLEAN ntGreater (number a, number b, const coeffs cf)
 
static void ntCoeffWrite (const coeffs cf, BOOLEAN details)
 
number ntDiff (number a, number d, const coeffs cf)
 
static number ntAdd (number a, number b, const coeffs cf)
 
static number ntSub (number a, number b, const coeffs cf)
 
static number ntMult (number a, number b, const coeffs cf)
 
static void ntNormalizeDen (fraction result, const ring R)
 
static number ntDiv (number a, number b, const coeffs cf)
 
static number ntInvers (number a, const coeffs cf)
 
static void ntPower (number a, int exp, number *b, const coeffs cf)
 
static void ntWriteLong (number a, const coeffs cf)
 
static void ntWriteShort (number a, const coeffs cf)
 
static const char * ntRead (const char *s, number *a, const coeffs cf)
 
static void ntNormalize (number &a, const coeffs cf)
 
static BOOLEAN ntCoeffIsEqual (const coeffs cf, n_coeffType n, void *param)
 
static number ntNormalizeHelper (number a, number b, const coeffs cf)
 
static number ntGcd (number a, number b, const coeffs cf)
 
static int ntSize (number a, const coeffs cf)
 
static number ntMap00 (number a, const coeffs src, const coeffs dst)
 
static number ntMapZ0 (number a, const coeffs src, const coeffs dst)
 
static number ntMapP0 (number a, const coeffs src, const coeffs dst)
 
static number ntCopyMap (number a, const coeffs cf, const coeffs dst)
 
static number ntGenMap (number a, const coeffs cf, const coeffs dst)
 
static number ntCopyAlg (number a, const coeffs cf, const coeffs dst)
 
static number ntGenAlg (number a, const coeffs cf, const coeffs dst)
 
static number ntMap0P (number a, const coeffs src, const coeffs dst)
 
static number ntMapPP (number a, const coeffs src, const coeffs dst)
 
static number ntMapUP (number a, const coeffs src, const coeffs dst)
 
nMapFunc ntSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type (n_transExt) More...
 
static void ntKillChar (coeffs cf)
 
static number ntConvFactoryNSingN (const CanonicalForm n, const coeffs cf)
 
static CanonicalForm ntConvSingNFactoryN (number n, BOOLEAN, const coeffs cf)
 
static int ntParDeg (number a, const coeffs cf)
 
static number ntParameter (const int iParameter, const coeffs cf)
 return the specified parameter as a number in the given trans.ext. More...
 
int ntIsParam (number m, const coeffs cf)
 if m == var(i)/1 => return i, More...
 
static void ntClearContent (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
 
static void ntClearDenominators (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
 
static number ntChineseRemainder (number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
 
static number ntFarey (number p, number n, const coeffs cf)
 
BOOLEAN ntInitChar (coeffs cf, void *infoStruct)
 Initialize the coeffs object. More...
 

Variables

omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject))
 

Macro Definition Documentation

◆ ADD_COMPLEXITY

#define ADD_COMPLEXITY   1

complexity increase due to + and -

Definition at line 62 of file transext.cc.

◆ BOUND_COMPLEXITY

#define BOUND_COMPLEXITY   10

maximum complexity of a number

Definition at line 65 of file transext.cc.

◆ COM

#define COM (   f)    (f)->complexity

Definition at line 70 of file transext.cc.

◆ DIFF_COMPLEXITY

#define DIFF_COMPLEXITY   2

complexity increase due to * and /

Definition at line 64 of file transext.cc.

◆ MULT_COMPLEXITY

#define MULT_COMPLEXITY   2

complexity increase due to * and /

Definition at line 63 of file transext.cc.

◆ ntCoeffs

#define ntCoeffs   cf->extRing->cf

Definition at line 87 of file transext.cc.

◆ ntRing

#define ntRing   cf->extRing

Definition at line 81 of file transext.cc.

◆ ntTest

#define ntTest (   a)    n_Test(a, cf)

Definition at line 77 of file transext.cc.

◆ NUMIS1

#define NUMIS1 (   f)    (p_IsOne(NUM(f), cf->extRing))

TRUE iff num. represents 1.

Definition at line 68 of file transext.cc.

◆ TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES

Definition at line 33 of file transext.cc.

Function Documentation

◆ definiteGcdCancellation()

static void definiteGcdCancellation ( number  a,
const coeffs  cf,
BOOLEAN  simpleTestsHaveAlreadyBeenPerformed 
)
static

modifies a

Definition at line 1382 of file transext.cc.

1384 {
1385 // ntTest(a); // !!!!
1386 
1387  fraction f = (fraction)a;
1388 
1389  if (IS0(a)) return;
1390  if (COM(f)==0) return;
1391  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; }
1392  if (!simpleTestsHaveAlreadyBeenPerformed)
1393  {
1394 
1395  /* check whether NUM(f) = DEN(f), and - if so - replace 'a' by 1 */
1396  if (p_EqualPolys(NUM(f), DEN(f), ntRing))
1397  { /* numerator and denominator are both != 1 */
1398  p_Delete(&NUM(f), ntRing); NUM(f) = p_ISet(1, ntRing);
1399  p_Delete(&DEN(f), ntRing); DEN(f) = NULL;
1400  COM(f) = 0;
1401  ntTest(a);
1402  return;
1403  }
1404  }
1405  /*if (rField_is_Q(ntRing))
1406  {
1407  number c=n_Copy(pGetCoeff(NUM(f)),ntCoeffs);
1408  poly p=pNext(NUM(f));
1409  while((p!=NULL)&&(!n_IsOne(c,ntCoeffs)))
1410  {
1411  number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs);
1412  n_Delete(&c,ntCoeffs);
1413  c=cc;
1414  pIter(p);
1415  };
1416  p=DEN(f);
1417  while((p!=NULL)&&(!n_IsOne(c,ntCoeffs)))
1418  {
1419  number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs);
1420  n_Delete(&c,ntCoeffs);
1421  c=cc;
1422  pIter(p);
1423  };
1424  if(!n_IsOne(c,ntCoeffs))
1425  {
1426  p=NUM(f);
1427  do
1428  {
1429  number cc=n_Div(pGetCoeff(p),c,ntCoeffs);
1430  n_Normalize(cc,ntCoeffs);
1431  p_SetCoeff(p,cc,ntRing);
1432  pIter(p);
1433  } while(p!=NULL);
1434  p=DEN(f);
1435  do
1436  {
1437  number cc=n_Div(pGetCoeff(p),c,ntCoeffs);
1438  n_Normalize(cc,ntCoeffs);
1439  p_SetCoeff(p,cc,ntRing);
1440  pIter(p);
1441  } while(p!=NULL);
1442  n_Delete(&c,ntCoeffs);
1443  if(pNext(DEN(f))==NULL)
1444  {
1445  if (p_IsOne(DEN(f),ntRing))
1446  {
1447  p_LmDelete(&DEN(f),ntRing);
1448  COM(f)=0;
1449  return;
1450  }
1451  else
1452  {
1453  return;
1454  }
1455  }
1456  }
1457  }*/
1458 
1459  /* here we assume: NUM(f), DEN(f) !=NULL, in Z_a reqp. Z/p_a */
1460  //StringSetS("");ntWriteLong(a,cf);
1461  poly pGcd = singclap_gcd_and_divide(NUM(f), DEN(f), ntRing);
1462  //PrintS("gcd= ");p_wrp(pGcd,ntRing);PrintLn();
1463  if (p_IsConstant(pGcd, ntRing)
1464  && n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs)
1465  )
1466  { /* gcd = 1; nothing to cancel;
1467  Suppose the given rational function field is over Q. Although the
1468  gcd is 1, we may have produced fractional coefficients in NUM(f),
1469  DEN(f), or both, due to previous arithmetics. The next call will
1470  remove those nested fractions, in case there are any. */
1471  if (nCoeff_is_Zp(ntCoeffs))
1472  {
1473  NUM (f) = p_Div_nn (NUM (f), p_GetCoeff (DEN(f),ntRing), ntRing);
1474  if (p_IsConstant (DEN (f), ntRing))
1475  {
1476  p_Delete(&DEN (f), ntRing);
1477  DEN (f) = NULL;
1478  }
1479  else
1480  {
1481  p_Norm (DEN (f),ntRing);
1482  }
1483  } else if (nCoeff_is_Q(ntCoeffs)) handleNestedFractionsOverQ(f, cf);
1484  }
1485  else
1486  { /* We divide both NUM(f) and DEN(f) by the gcd which is known
1487  to be != 1. */
1488  if (p_IsConstant(DEN(f), ntRing) &&
1489  n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs))
1490  {
1491  /* DEN(f) = 1 needs to be represented by NULL! */
1492  p_Delete(&DEN(f), ntRing);
1493  DEN(f) = NULL;
1494  }
1495  else
1496  {
1497  if (nCoeff_is_Zp(ntCoeffs))
1498  {
1499  NUM (f) = p_Div_nn (NUM (f), p_GetCoeff (DEN(f),ntRing), ntRing);
1500  if (p_IsConstant (DEN (f), ntRing))
1501  {
1502  p_Delete(&DEN (f), ntRing);
1503  DEN (f) = NULL;
1504  }
1505  else
1506  {
1507  p_Norm (DEN (f),ntRing);
1508  }
1509  }
1510  }
1511  }
1512  p_Delete(&pGcd, ntRing);
1513 // StringAppendS(" -> ");ntWriteLong(a,cf);StringAppendS("\n");{ char* s = StringEndS(); Print("%s", s); omFree(s); }
1514  COM(f) = 0;
1515 
1516  if( DEN(f) != NULL )
1517  {
1518  if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) )
1519  {
1520  NUM(f) = p_Neg(NUM(f), ntRing);
1521  DEN(f) = p_Neg(DEN(f), ntRing);
1522  if (p_IsConstant(DEN(f), ntRing) &&
1523  n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs))
1524  {
1525  /* DEN(f) = 1 needs to be represented by NULL! */
1526  p_Delete(&DEN(f), ntRing);
1527  DEN (f) = NULL;
1528  }
1529  }
1530  }
1531  ntTest(a); // !!!!
1532 }
poly singclap_gcd_and_divide(poly &f, poly &g, const ring r)
clears denominators of f and g, divides by gcd(f,g)
Definition: clapsing.cc:96
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:831
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
#define ntTest(a)
Definition: transext.cc:77
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1467
#define COM(f)
Definition: transext.cc:70
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3656
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
#define NUMIS1(f)
TRUE iff num. represents 1.
Definition: transext.cc:68
FILE * f
Definition: checklibs.c:9
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4396
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
static void handleNestedFractionsOverQ(fraction f, const coeffs cf)
Definition: transext.cc:401
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1289

◆ handleNestedFractionsOverQ()

static void handleNestedFractionsOverQ ( fraction  f,
const coeffs  cf 
)
static

Definition at line 401 of file transext.cc.

402 {
404  assume(!IS0(f));
405  assume(!DENIS1(f));
406 
407  { /* step (1); see documentation of this procedure above */
408  number lcmOfDenominators = n_Init(1, ntCoeffs);
409  number c; number tmp;
410  poly p = NUM(f);
411  /* careful when using n_NormalizeHelper!!! It computes the lcm of the numerator
412  of the 1st argument and the denominator of the 2nd!!! */
413  while (p != NULL)
414  {
415  c = p_GetCoeff(p, ntRing);
416  tmp = n_NormalizeHelper(lcmOfDenominators, c, ntCoeffs);
417  n_Delete(&lcmOfDenominators, ntCoeffs);
418  lcmOfDenominators = tmp;
419  pIter(p);
420  }
421  p = DEN(f);
422  while (p != NULL)
423  {
424  c = p_GetCoeff(p, ntRing);
425  tmp = n_NormalizeHelper(lcmOfDenominators, c, ntCoeffs);
426  n_Delete(&lcmOfDenominators, ntCoeffs);
427  lcmOfDenominators = tmp;
428  pIter(p);
429  }
430  if (!n_IsOne(lcmOfDenominators, ntCoeffs))
431  { /* multiply NUM(f) and DEN(f) with lcmOfDenominators */
432  NUM(f) = __p_Mult_nn(NUM(f), lcmOfDenominators, ntRing);
433  p_Normalize(NUM(f), ntRing);
434  DEN(f) = __p_Mult_nn(DEN(f), lcmOfDenominators, ntRing);
435  p_Normalize(DEN(f), ntRing);
436  }
437  n_Delete(&lcmOfDenominators, ntCoeffs);
438  if (DEN(f)!=NULL)
439  { /* step (2); see documentation of this procedure above */
440  p = NUM(f);
441  number gcdOfCoefficients = n_Copy(p_GetCoeff(p, ntRing), ntCoeffs);
442  pIter(p);
443  while ((p != NULL) && (!n_IsOne(gcdOfCoefficients, ntCoeffs)))
444  {
445  c = p_GetCoeff(p, ntRing);
446  tmp = n_Gcd(c, gcdOfCoefficients, ntCoeffs);
447  n_Delete(&gcdOfCoefficients, ntCoeffs);
448  gcdOfCoefficients = tmp;
449  pIter(p);
450  }
451  p = DEN(f);
452  while ((p != NULL) && (!n_IsOne(gcdOfCoefficients, ntCoeffs)))
453  {
454  c = p_GetCoeff(p, ntRing);
455  tmp = n_Gcd(c, gcdOfCoefficients, ntCoeffs);
456  n_Delete(&gcdOfCoefficients, ntCoeffs);
457  gcdOfCoefficients = tmp;
458  pIter(p);
459  }
460  if (!n_IsOne(gcdOfCoefficients, ntCoeffs))
461  { /* divide NUM(f) and DEN(f) by gcdOfCoefficients */
462  number inverseOfGcdOfCoefficients = n_Invers(gcdOfCoefficients,
463  ntCoeffs);
464  NUM(f) = __p_Mult_nn(NUM(f), inverseOfGcdOfCoefficients, ntRing);
465  p_Normalize(NUM(f), ntRing);
466  DEN(f) = __p_Mult_nn(DEN(f), inverseOfGcdOfCoefficients, ntRing);
467  p_Normalize(DEN(f), ntRing);
468  n_Delete(&inverseOfGcdOfCoefficients, ntCoeffs);
469  }
470  n_Delete(&gcdOfCoefficients, ntCoeffs);
471  }
472  }
473 
474  /* Now, due to the above computations, DEN(f) may have become the
475  1-polynomial which needs to be represented by NULL: */
476  if ((DEN(f) != NULL) &&
477  p_IsConstant(DEN(f), ntRing) &&
479  {
480  p_Delete(&DEN(f), ntRing); DEN(f) = NULL;
481  }
482 
483  if( DEN(f) != NULL )
484  if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) )
485  {
486  NUM(f) = p_Neg(NUM(f), ntRing);
487  DEN(f) = p_Neg(DEN(f), ntRing);
488  }
490  ntTest((number)f); // TODO!
491 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:687
#define BOUND_COMPLEXITY
maximum complexity of a number
Definition: transext.cc:65
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1...
Definition: coeffs.h:718
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:565
FILE * f
Definition: checklibs.c:9
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int p
Definition: cfModGcd.cc:4019

◆ heuristicGcdCancellation()

static void heuristicGcdCancellation ( number  a,
const coeffs  cf 
)
static

forward declarations

Definition at line 1297 of file transext.cc.

1298 {
1299  if (IS0(a)) return;
1300 
1301  fraction f = (fraction)a;
1302  p_Normalize(NUM(f),ntRing);
1303  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
1304 
1305  assume( DEN(f) != NULL );
1306  p_Normalize(DEN(f),ntRing);
1307 
1308  /* check whether NUM(f) = DEN(f), and - if so - replace 'a' by 1 */
1309  if (p_EqualPolys(NUM(f), DEN(f), ntRing))
1310  { /* numerator and denominator are both != 1 */
1311  p_Delete(&NUM(f), ntRing); NUM(f) = p_ISet(1, ntRing);
1312  p_Delete(&DEN(f), ntRing); DEN(f) = NULL;
1313  COM(f) = 0;
1314  }
1315  else
1316  {
1317  if (COM(f) > BOUND_COMPLEXITY)
1318  definiteGcdCancellation(a, cf, TRUE);
1319 
1320  // TODO: check if it is enough to put the following into definiteGcdCancellation?!
1321  if( DEN(f) != NULL )
1322  {
1323  if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) )
1324  {
1325  NUM(f) = p_Neg(NUM(f), ntRing);
1326  DEN(f) = p_Neg(DEN(f), ntRing);
1327  }
1328  if (ntCoeffs->has_simple_Inverse)
1329  {
1330  if (!n_IsOne(pGetCoeff(DEN(f)),ntCoeffs))
1331  {
1332  number inv=n_Invers(pGetCoeff(DEN(f)),ntCoeffs);
1333  DEN(f)=__p_Mult_nn(DEN(f),inv,ntRing);
1334  NUM(f)=__p_Mult_nn(NUM(f),inv,ntRing);
1335  }
1336  if(p_LmIsConstant(DEN(f),ntRing))
1337  {
1338  p_Delete(&DEN(f),ntRing);
1339  COM(f)=0;
1340  }
1341  }
1342  if ((DEN(f)!=NULL)
1343  && (pNext(DEN(f))==NULL))
1344  {
1345  poly den_f=DEN(f);
1346  poly h=NUM(f);
1347  loop
1348  {
1349  if (h==NULL)
1350  {
1351  h=NUM(f);
1352  do
1353  {
1354  p_ExpVectorDiff(h,h,den_f,ntRing);
1355  pIter(h);
1356  } while(h!=NULL);
1357  p_ExpVectorDiff(den_f,den_f,den_f,ntRing);
1358  break;
1359  }
1360  int i=0;
1361  do
1362  {
1363  i++;
1364  if (p_GetExp(den_f,i,ntRing) > p_GetExp(h,i,ntRing)) return;
1365  } while(i<ntRing->N);
1366  pIter(h);
1367  }
1368  }
1369  }
1370  }
1371  if ((DEN(f)!=NULL)
1372  && (pNext(DEN(f))==NULL)
1373  && (p_LmIsConstantComp(DEN(f),ntRing))
1374  && (n_IsOne(pGetCoeff(DEN(f)),ntCoeffs)))
1375  {
1376  p_Delete(&DEN(f),ntRing);
1377  COM(f)=0;
1378  }
1379 }
#define BOUND_COMPLEXITY
maximum complexity of a number
Definition: transext.cc:65
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:962
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
#define COM(f)
Definition: transext.cc:70
#define TRUE
Definition: auxiliary.h:98
#define loop
Definition: structs.h:78
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:979
#define pIter(p)
Definition: monomials.h:44
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
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:469
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:565
#define NUMIS1(f)
TRUE iff num. represents 1.
Definition: transext.cc:68
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4396
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1420
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
static Poly * h
Definition: janet.cc:972
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1289

◆ nCoeff_bottom()

static coeffs nCoeff_bottom ( const coeffs  r,
int &  height 
)
static

Definition at line 280 of file transext.cc.

281 {
282  assume(r != NULL);
283  coeffs cf = r;
284  height = 0;
285  while (nCoeff_is_Extension(cf))
286  {
287  assume(cf->extRing != NULL); assume(cf->extRing->cf != NULL);
288  cf = cf->extRing->cf;
289  height++;
290  }
291  return cf;
292 }
#define assume(x)
Definition: mod2.h:390
The main handler for Singular numbers which are suitable for Singular polynomials.
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:10
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:860

◆ ntAdd()

static number ntAdd ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 942 of file transext.cc.

943 {
944  //check_N(a,cf);
945  //check_N(b,cf);
946  ntTest(a);
947  ntTest(b);
948  if (IS0(a)) return ntCopy(b, cf);
949  if (IS0(b)) return ntCopy(a, cf);
950 
951  fraction fa = (fraction)a;
952  fraction fb = (fraction)b;
953 
954  poly g = p_Copy(NUM(fa), ntRing);
955  if (!DENIS1(fb)) g = p_Mult_q(g, p_Copy(DEN(fb), ntRing), ntRing);
956  poly h = p_Copy(NUM(fb), ntRing);
957  if (!DENIS1(fa)) h = p_Mult_q(h, p_Copy(DEN(fa), ntRing), ntRing);
958  g = p_Add_q(g, h, ntRing);
959 
960  if (g == NULL) return NULL;
961 
962  poly f;
963  if (DENIS1(fa) && DENIS1(fb)) f = NULL;
964  else if (!DENIS1(fa) && DENIS1(fb)) f = p_Copy(DEN(fa), ntRing);
965  else if (DENIS1(fa) && !DENIS1(fb)) f = p_Copy(DEN(fb), ntRing);
966  else /* both denom's are != 1 */ f = p_Mult_q(p_Copy(DEN(fa), ntRing),
967  p_Copy(DEN(fb), ntRing),
968  ntRing);
969 
970  fraction result = (fraction)omAllocBin(fractionObjectBin);
971  NUM(result) = g;
972  DEN(result) = f;
973  COM(result) = COM(fa) + COM(fb) + ADD_COMPLEXITY;
974  heuristicGcdCancellation((number)result, cf);
975 
976 // ntTest((number)result);
977 
978  //check_N((number)result,cf);
979  ntTest((number)result);
980  return (number)result;
981 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
FILE * f
Definition: checklibs.c:9
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
#define ADD_COMPLEXITY
complexity increase due to + and -
Definition: transext.cc:62
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntChineseRemainder()

static number ntChineseRemainder ( number *  x,
number *  q,
int  rl,
BOOLEAN  ,
CFArray inv_cache,
const coeffs  cf 
)
static

Definition at line 2452 of file transext.cc.

2453 {
2454  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
2455 
2456  poly *P=(poly*)omAlloc(rl*sizeof(poly*));
2457  number *X=(number *)omAlloc(rl*sizeof(number));
2458 
2459  int i;
2460 
2461  for(i=0;i<rl;i++) P[i]=p_Copy(NUM((fraction)(x[i])),cf->extRing);
2462  NUM(result)=p_ChineseRemainder(P,X,q,rl,inv_cache,cf->extRing);
2463 
2464  for(i=0;i<rl;i++)
2465  {
2466  P[i]=p_Copy(DEN((fraction)(x[i])),cf->extRing);
2467  if (P[i]==NULL) P[i]=p_One(cf->extRing);
2468  }
2469  DEN(result)=p_ChineseRemainder(P,X,q,rl,inv_cache,cf->extRing);
2470 
2471  omFreeSize(X,rl*sizeof(number));
2472  omFreeSize(P,rl*sizeof(poly*));
2473  if (p_IsConstant(DEN(result), ntRing)
2474  && n_IsOne(pGetCoeff(DEN(result)), ntCoeffs))
2475  {
2476  p_Delete(&DEN(result),ntRing);
2477  }
2478  ntTest((number)result);
2479  return ((number)result);
2480 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define ntTest(a)
Definition: transext.cc:77
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define omAlloc(size)
Definition: omAllocDecl.h:210
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly p_One(const ring r)
Definition: p_polys.cc:1305
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
int i
Definition: cfEzgcd.cc:125
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, CFArray &inv_cache, const ring R)
Definition: p_polys.cc:85
Variable x
Definition: cfModGcd.cc:4023
#define ntCoeffs
Definition: transext.cc:87
#define ntRing
Definition: transext.cc:81
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntClearContent()

static void ntClearContent ( ICoeffsEnumerator numberCollectionEnumerator,
number &  c,
const coeffs  cf 
)
static

Definition at line 2219 of file transext.cc.

2220 {
2221  assume(cf != NULL);
2222  assume(getCoeffType(cf) == n_transExt);
2223  // all coeffs are given by fractions of polynomails over integers!!!
2224  // without denominators!!!
2225 
2226  const ring R = cf->extRing;
2227  assume(R != NULL);
2228  const coeffs Q = R->cf;
2229  assume(Q != NULL);
2230  assume(nCoeff_is_Q(Q));
2231 
2232 
2233  numberCollectionEnumerator.Reset();
2234 
2235  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
2236  {
2237  c = ntInit(1, cf);
2238  return;
2239  }
2240 
2241  // all coeffs are given by integers after returning from this routine
2242 
2243  // part 1, collect product of all denominators /gcds
2244  poly cand = NULL;
2245 
2246  do
2247  {
2248  number &n = numberCollectionEnumerator.Current();
2249 
2250  ntNormalize(n, cf);
2251 
2252  fraction f = (fraction)n;
2253 
2254  assume( f != NULL );
2255 
2256  const poly den = DEN(f);
2257 
2258  assume( den == NULL ); // ?? / 1 ?
2259 
2260  const poly num = NUM(f);
2261 
2262  if( cand == NULL )
2263  cand = p_Copy(num, R);
2264  else
2265  cand = singclap_gcd(cand, p_Copy(num, R), R); // gcd(cand, num)
2266 
2267  if( p_IsConstant(cand, R) )
2268  break;
2269  }
2270  while( numberCollectionEnumerator.MoveNext() ) ;
2271 
2272 
2273  // part2: all coeffs = all coeffs * cand
2274  if( cand != NULL )
2275  {
2276  if( !p_IsConstant(cand, R) )
2277  {
2278  c = ntInit(cand, cf);
2279  numberCollectionEnumerator.Reset();
2280  while (numberCollectionEnumerator.MoveNext() )
2281  {
2282  number &n = numberCollectionEnumerator.Current();
2283  const number t = ntDiv(n, c, cf); // TODO: rewrite!?
2284  ntDelete(&n, cf);
2285  n = t;
2286  }
2287  } // else NUM (result) = p_One(R);
2288  else { p_Delete(&cand, R); cand = NULL; }
2289  }
2290 
2291  // Quick and dirty fix for constant content clearing: consider numerators???
2292  CRecursivePolyCoeffsEnumerator<NTNumConverter> itr(numberCollectionEnumerator); // recursively treat the NUM(numbers) as polys!
2293  number cc;
2294 
2295  n_ClearContent(itr, cc, Q);
2296  number g = ntInit(p_NSet(cc, R), cf);
2297 
2298  if( cand != NULL )
2299  {
2300  number gg = ntMult(g, c, cf);
2301  ntDelete(&g, cf);
2302  ntDelete(&c, cf); c = gg;
2303  } else
2304  c = g;
2305  ntTest(c);
2306 }
CanonicalForm num(const CanonicalForm &f)
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
#define ntTest(a)
Definition: transext.cc:77
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:255
g
Definition: cfModGcd.cc:4031
#define Q
Definition: sirandom.c:25
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection...
static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Computes the content and (inplace) divides it out on a collection of numbers number c is the content ...
Definition: coeffs.h:942
static void ntNormalize(number &a, const coeffs cf)
Definition: transext.cc:1594
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
The main handler for Singular numbers which are suitable for Singular polynomials.
virtual reference Current()=0
Gets the current element in the collection (read and write).
static void ntDelete(number *a, const coeffs cf)
Definition: transext.cc:301
FILE * f
Definition: checklibs.c:9
go into polynomials over an alg. extension recursively
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
static number ntMult(number a, number b, const coeffs cf)
Definition: transext.cc:1022
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
#define R
Definition: sirandom.c:26
static number ntDiv(number a, number b, const coeffs cf)
Definition: transext.cc:1117
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
Definition: cfModGcd.cc:69

◆ ntClearDenominators()

static void ntClearDenominators ( ICoeffsEnumerator numberCollectionEnumerator,
number &  c,
const coeffs  cf 
)
static

Definition at line 2308 of file transext.cc.

2309 {
2310  assume(cf != NULL);
2311  assume(getCoeffType(cf) == n_transExt); // both over Q(a) and Zp(a)!
2312  // all coeffs are given by fractions of polynomails over integers!!!
2313 
2314  numberCollectionEnumerator.Reset();
2315 
2316  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
2317  {
2318  c = ntInit(1, cf);
2319  return;
2320  }
2321 
2322  // all coeffs are given by integers after returning from this routine
2323 
2324  // part 1, collect product of all denominators /gcds
2325  poly cand = NULL;
2326 
2327  const ring R = cf->extRing;
2328  assume(R != NULL);
2329 
2330  const coeffs Q = R->cf;
2331  assume(Q != NULL);
2332 // assume(nCoeff_is_Q(Q));
2333 
2334  do
2335  {
2336  number &n = numberCollectionEnumerator.Current();
2337 
2338  ntNormalize(n, cf);
2339 
2340  fraction f = (fraction)ntGetDenom (n, cf);
2341 
2342  assume( f != NULL );
2343 
2344  const poly den = NUM(f);
2345 
2346  if( den == NULL ) // ?? / 1 ?
2347  continue;
2348 
2349  if( cand == NULL )
2350  cand = p_Copy(den, R);
2351  else
2352  {
2353  // cand === LCM( cand, den )!!!!
2354  // NOTE: maybe it's better to make the product and clearcontent afterwards!?
2355  // TODO: move the following to factory?
2356  poly gcd = singclap_gcd(p_Copy(cand, R), p_Copy(den, R), R); // gcd(cand, den) is monic no mater leading coeffs! :((((
2357  if (nCoeff_is_Q (Q))
2358  {
2359  number LcGcd= n_SubringGcd (p_GetCoeff (cand, R), p_GetCoeff(den, R), Q);
2360  gcd = __p_Mult_nn(gcd, LcGcd, R);
2361  n_Delete(&LcGcd,Q);
2362  }
2363 // assume( n_IsOne(pGetCoeff(gcd), Q) ); // TODO: this may be wrong...
2364  cand = p_Mult_q(cand, p_Copy(den, R), R); // cand *= den
2365  const poly t = singclap_pdivide( cand, gcd, R ); // cand' * den / gcd(cand', den)
2366  p_Delete(&cand, R);
2367  p_Delete(&gcd, R);
2368  cand = t;
2369  }
2370  }
2371  while( numberCollectionEnumerator.MoveNext() );
2372 
2373  if( cand == NULL )
2374  {
2375  c = ntInit(1, cf);
2376  return;
2377  }
2378 
2379  c = ntInit(cand, cf);
2380 
2381  numberCollectionEnumerator.Reset();
2382 
2383  number d = NULL;
2384 
2385  while (numberCollectionEnumerator.MoveNext() )
2386  {
2387  number &n = numberCollectionEnumerator.Current();
2388  number t = ntMult(n, c, cf); // TODO: rewrite!?
2389  ntDelete(&n, cf);
2390 
2391  ntNormalize(t, cf); // TODO: needed?
2392  n = t;
2393 
2394  fraction f = (fraction)t;
2395  assume( f != NULL );
2396 
2397  const poly den = DEN(f);
2398 
2399  if( den != NULL ) // ?? / ?? ?
2400  {
2401  assume( p_IsConstant(den, R) );
2402  assume( pNext(den) == NULL );
2403 
2404  if( d == NULL )
2405  d = n_Copy(pGetCoeff(den), Q);
2406  else
2407  {
2408  number g = n_NormalizeHelper(d, pGetCoeff(den), Q);
2409  n_Delete(&d, Q); d = g;
2410  }
2411  }
2412  }
2413 
2414  if( d != NULL )
2415  {
2416  numberCollectionEnumerator.Reset();
2417  while (numberCollectionEnumerator.MoveNext() )
2418  {
2419  number &n = numberCollectionEnumerator.Current();
2420  fraction f = (fraction)n;
2421 
2422  assume( f != NULL );
2423 
2424  const poly den = DEN(f);
2425 
2426  if( den == NULL ) // ?? / 1 ?
2427  NUM(f) = __p_Mult_nn(NUM(f), d, R);
2428  else
2429  {
2430  assume( p_IsConstant(den, R) );
2431  assume( pNext(den) == NULL );
2432 
2433  number ddd = n_Div(d, pGetCoeff(den), Q); // but be an integer now!!!
2434  NUM(f) = __p_Mult_nn(NUM(f), ddd, R);
2435  n_Delete(&ddd, Q);
2436 
2437  p_Delete(&DEN(f), R);
2438  DEN(f) = NULL; // TODO: check if this is needed!?
2439  }
2440 
2441  assume( DEN(f) == NULL );
2442  }
2443 
2444  NUM((fraction)c) = __p_Mult_nn(NUM((fraction)c), d, R);
2445  n_Delete(&d, Q);
2446  }
2447 
2448 
2449  ntTest(c);
2450 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define ntTest(a)
Definition: transext.cc:77
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:255
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1...
Definition: coeffs.h:718
#define Q
Definition: sirandom.c:25
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:577
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection...
static void ntNormalize(number &a, const coeffs cf)
Definition: transext.cc:1594
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
The main handler for Singular numbers which are suitable for Singular polynomials.
virtual reference Current()=0
Gets the current element in the collection (read and write).
static void ntDelete(number *a, const coeffs cf)
Definition: transext.cc:301
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
static number ntMult(number a, number b, const coeffs cf)
Definition: transext.cc:1022
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
CanonicalForm den(const CanonicalForm &f)
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:616
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
int gcd(int a, int b)
Definition: walkSupport.cc:836
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
static number ntGetDenom(number &a, const coeffs cf)
TODO: normalization of a!?
Definition: transext.cc:555
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
Definition: cfModGcd.cc:69

◆ ntCoeffIsEqual()

static BOOLEAN ntCoeffIsEqual ( const coeffs  cf,
n_coeffType  n,
void *  param 
)
static

Definition at line 1613 of file transext.cc.

1614 {
1615  if (n_transExt != n) return FALSE;
1616  TransExtInfo *e = (TransExtInfo *)param;
1617  /* for rational function fields we expect the underlying
1618  polynomial rings to be IDENTICAL, i.e. the SAME OBJECT;
1619  this expectation is based on the assumption that we have properly
1620  registered cf and perform reference counting rather than creating
1621  multiple copies of the same coefficient field/domain/ring */
1622  if (ntRing == e->r)
1623  return TRUE;
1624 
1625  // NOTE: Q(a)[x] && Q(a)[y] should better share the _same_ Q(a)...
1626  if( rEqual(ntRing, e->r, TRUE) )
1627  {
1628  rDelete(e->r);
1629  return TRUE;
1630  }
1631 
1632  return FALSE;
1633 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
struct for passing initialization parameters to naInitChar
Definition: transext.h:88
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise, if qr == 1, then qrideal equality is tested, as well
Definition: ring.cc:1620
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:439
#define ntRing
Definition: transext.cc:81

◆ ntCoeffWrite()

static void ntCoeffWrite ( const coeffs  cf,
BOOLEAN  details 
)
static

Definition at line 844 of file transext.cc.

845 {
846  assume( cf != NULL );
847 
848  const ring A = cf->extRing;
849 
850  assume( A != NULL );
851  assume( A->cf != NULL );
852 
853  n_CoeffWrite(A->cf, details);
854 
855 // rWrite(A);
856 
857  const int P = rVar(A);
858  assume( P > 0 );
859 
860  PrintS("(");
861 
862  for (int nop=0; nop < P; nop ++)
863  {
864  Print("%s", rRingVar(nop, A));
865  if (nop!=P-1) PrintS(", ");
866  }
867 
868  PrintS(")");
869 
870  assume( A->qideal == NULL );
871 
872 /*
873  PrintS("// Coefficients live in the rational function field\n");
874  Print("// K(");
875  for (int i = 0; i < rVar(ntRing); i++)
876  {
877  if (i > 0) PrintS(" ");
878  Print("%s", rRingVar(i, ntRing));
879  }
880  PrintS(") with\n");
881  PrintS("// K: "); n_CoeffWrite(cf->extRing->cf);
882 */
883 }
#define Print
Definition: emacs.cc:80
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#define assume(x)
Definition: mod2.h:390
#define A
Definition: sirandom.c:23
void PrintS(const char *s)
Definition: reporter.cc:284
static char * rRingVar(short i, const ring r)
Definition: ring.h:568
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:742
#define NULL
Definition: omList.c:10

◆ ntConvFactoryNSingN()

static number ntConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  cf 
)
static

Definition at line 2141 of file transext.cc.

2142 {
2143  if (n.isZero()) return NULL;
2144  poly p=convFactoryPSingP(n,ntRing);
2145  p_Normalize(p,ntRing);
2146  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
2147  NUM(result) = p;
2148  //DEN(result) = NULL; // done by omAlloc0Bin
2149  //COM(result) = 0; // done by omAlloc0Bin
2150  ntTest((number)result);
2151  return (number)result;
2152 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
#define ntTest(a)
Definition: transext.cc:77
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
int p
Definition: cfModGcd.cc:4019
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntConvSingNFactoryN()

static CanonicalForm ntConvSingNFactoryN ( number  n,
BOOLEAN  ,
const coeffs  cf 
)
static

Definition at line 2153 of file transext.cc.

2154 {
2155  ntTest(n);
2156  if (IS0(n)) return CanonicalForm(0);
2157 
2158  fraction f = (fraction)n;
2159  return convSingPFactoryP(NUM(f),ntRing);
2160 }
#define ntTest(a)
Definition: transext.cc:77
factory&#39;s main class
Definition: canonicalform.h:77
FILE * f
Definition: checklibs.c:9
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:86
#define ntRing
Definition: transext.cc:81

◆ ntCopy()

static number ntCopy ( number  a,
const coeffs  cf 
)
static

Definition at line 360 of file transext.cc.

361 {
362  //check_N(a,cf);
363  ntTest(a); // !!!
364  if (IS0(a)) return NULL;
365  fraction f = (fraction)a;
366  poly g = NUM(f);
367  poly h = NULL;
368  h =DEN(f);
369  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
370  NUM(result) = p_Copy(g,cf->extRing);
371  DEN(result) = p_Copy(h,cf->extRing);
372  COM(result) = COM(f);
373  ntTest((number)result);
374  return (number)result;
375 }
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
FILE * f
Definition: checklibs.c:9
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:972
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntCopyAlg()

static number ntCopyAlg ( number  a,
const coeffs  cf,
const coeffs  dst 
)
static

Definition at line 1981 of file transext.cc.

1982 {
1983  n_Test(a, cf) ;
1984  if (n_IsZero(a, cf)) return NULL;
1985  return ntInit(prCopyR((poly)a, cf->extRing, dst->extRing),dst);
1986 }
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:35
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define NULL
Definition: omList.c:10

◆ ntCopyMap()

static number ntCopyMap ( number  a,
const coeffs  cf,
const coeffs  dst 
)
static

Definition at line 1873 of file transext.cc.

1874 {
1875  ntTest(a);
1876  if (IS0(a)) return NULL;
1877 
1878  const ring rSrc = cf->extRing;
1879  const ring rDst = dst->extRing;
1880 
1881  if( rSrc == rDst )
1882  return ntCopy(a, dst); // USUALLY WRONG!
1883 
1884  fraction f = (fraction)a;
1885  poly g = prCopyR(NUM(f), rSrc, rDst);
1886 
1887  poly h = NULL;
1888 
1889  if (!DENIS1(f))
1890  h = prCopyR(DEN(f), rSrc, rDst);
1891 
1892  fraction result = (fraction)omAllocBin(fractionObjectBin);
1893 
1894  NUM(result) = g;
1895  DEN(result) = h;
1896  COM(result) = COM(f);
1897  //check_N((number)result,dst);
1898  n_Test((number)result, dst);
1899  return (number)result;
1900 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:35
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:972
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntDBTest()

static BOOLEAN ntDBTest ( number  a,
const char *  f,
const int  l,
const coeffs  r 
)
static

< t != 0 ==> numerator(t) != 0

Definition at line 141 of file transext.cc.

142 {
144 
145  if (IS0(a)) return TRUE;
146 
147  const fraction t = (fraction)a;
148 
149  //check_N(a,cf);
150  const poly num = NUM(t);
151  assume(num != NULL); ///< t != 0 ==> numerator(t) != 0
152 
153  p_Test(num, ntRing);
154 
155  if (getCoeffType(ntCoeffs)==n_Q)
156  for( poly p = num; p != NULL; pIter(p) )
157  if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
158  {
159  Print("ERROR in %s:%d: non-integer Q coeff in num. poly\n",f,l);
160  Print("TERM: "); p_wrp(p, ntRing); PrintLn();
161  return FALSE;
162  }
163 
164  const poly den = DEN(t);
165 
166  if (den != NULL) // !DENIS1(f)
167  {
168  p_Test(den, ntRing);
169 
170  if (getCoeffType(ntCoeffs)==n_Q)
171  for( poly p = den; p != NULL; pIter(p) )
172  if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
173  {
174  Print("ERROR in %s:%d: non-integer Q coeff in den. poly\n",f,l);
175  Print("TERM: "); p_wrp(p, ntRing); PrintLn();
176  return FALSE;
177  }
178 
179  if (getCoeffType(ntCoeffs)==n_Zp)
180  {
181  if( p_IsConstant(den, ntRing) )
182  {
183  Print("ERROR in %s:%d: constant den. poly / Zp\n",f,l);
184  PrintS("NUM: "); p_Write(num, ntRing);
185  PrintS("DEN: "); p_Write(den, ntRing);
186  return FALSE;
187  }
188 
189  if( !n_IsOne(pGetCoeff(den), ntCoeffs) )
190  {
191  Print("ERROR in %s:%d: non-monic den. poly / Zp\n",f,l);
192  PrintS("NUM: "); p_Write(num, ntRing);
193  PrintS("DEN: "); p_Write(den, ntRing);
194  return FALSE;
195  }
196  }
197 
198  if (COM(t)==0)
199  {
200  poly gcd = singclap_gcd_r( num, den, ntRing );
201  if(gcd!=NULL)
202  {
203  if((gcd!=NULL) && !p_IsOne(gcd, ntRing) )
204  {
205  Print("ERROR in %s:%d: 1 != GCD between num. & den. poly\n",f,l);
206  PrintS("GCD: "); p_Write(gcd, ntRing);
207  PrintS("NUM: "); p_Write(num, ntRing);
208  PrintS("DEN: "); p_Write(den, ntRing);
209  return FALSE;
210  }
211  p_Delete( &gcd, ntRing );
212  }
213  }
214  return TRUE;
215 
216  if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs)))
217  {
218  Print("?/1 in %s:%d\n",f,l);
219  return FALSE;
220  }
221  if( !n_GreaterZero(pGetCoeff(den), ntCoeffs) )
222  {
223  Print("negative sign of DEN. of a fraction in %s:%d\n",f,l);
224  return FALSE;
225  }
226  // test that den is over integers!?
227  }
228  else
229  {
230  return TRUE;
231 
232  // num != NULL // den == NULL
233 // if( COM(t) != 0 )
234 // {
235 // Print("?//NULL with non-zero complexity: %d in %s:%d\n", COM(t), f, l);
236 // return FALSE;
237 // }
238  // test that nume is over integers!?
239  }
240  if (getCoeffType(ntCoeffs)==n_Q)
241  {
242  poly p=num; // !=NULL
243  do
244  {
245  number n=pGetCoeff(p);
246  n_Test(n,ntCoeffs);
247  if ((!(SR_HDL(n) & SR_INT))&&(n->s==0))
248  /* not normalized, just do for the following test*/
249  {
251  n=pGetCoeff(p);
252  }
253  if (!(SR_HDL(n) & SR_INT))
254  {
255  if (n->s<2)
256  Print("rational coeff in num: %s:%d\n",f,l);
257  }
258  pIter(p);
259  } while(p!=NULL);
260  p=den;
261  while(p!=NULL)
262  {
263  number n=pGetCoeff(p);
264  if (!(SR_HDL(n) & SR_INT))
265  {
266  if (n->s!=3)
267  Print("rational coeff in den.:%s:%d\n",f,l);
268  }
269  pIter(p);
270  }
271  }
272  return TRUE;
273 }
poly singclap_gcd_r(poly f, poly g, const ring r)
Definition: clapsing.cc:43
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
CanonicalForm num(const CanonicalForm &f)
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define FALSE
Definition: auxiliary.h:94
static FORCE_INLINE BOOLEAN nlIsInteger(number q, const coeffs r)
Definition: longrat.h:95
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
rational (GMP) numbers
Definition: coeffs.h:31
{p < 2^31}
Definition: coeffs.h:30
#define COM(f)
Definition: transext.cc:70
#define TRUE
Definition: auxiliary.h:98
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition: p_polys.h:1931
void PrintS(const char *s)
Definition: reporter.cc:284
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define p_Test(p, r)
Definition: p_polys.h:163
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
int gcd(int a, int b)
Definition: walkSupport.cc:836
#define SR_INT
Definition: longrat.h:68
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
#define SR_HDL(A)
Definition: tgb.cc:35
#define ntRing
Definition: transext.cc:81
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:235
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:204
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int p
Definition: cfModGcd.cc:4019
int l
Definition: cfEzgcd.cc:93

◆ ntDelete()

static void ntDelete ( number *  a,
const coeffs  cf 
)
static

Definition at line 301 of file transext.cc.

302 {
303  //check_N(*a,cf);
304  ntTest(*a); // !!!
305 
306  fraction f = (fraction)(*a);
307  if (IS0(f)) return;
308  p_Delete(&NUM(f), ntRing);
309  if (!DENIS1(f)) p_Delete(&DEN(f), ntRing);
311  *a = NULL;
312 }
#define ntTest(a)
Definition: transext.cc:77
void * ADDRESS
Definition: auxiliary.h:133
FILE * f
Definition: checklibs.c:9
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntDiff()

number ntDiff ( number  a,
number  d,
const coeffs  cf 
)

Definition at line 885 of file transext.cc.

886 {
887  //check_N(a,cf);
888  //check_N(d,cf);
889  ntTest(a);
890  ntTest(d);
891 
892  if (IS0(d))
893  {
894  WerrorS("ringvar expected");
895  return NULL;
896  }
897  fraction t = (fraction) d;
898  if (!DENIS1(t))
899  {
900  WerrorS("expected differentiation by a variable");
901  return NULL;
902  }
903  int k=p_Var(NUM(t),ntRing);
904  if (k==0)
905  {
906  WerrorS("expected differentiation by a variable");
907  return NULL;
908  }
909 
910  if (IS0(a)) return ntCopy(a, cf);
911 
912  fraction fa = (fraction)a;
913  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
914  if (DENIS1(fa))
915  {
916  NUM(result) = p_Diff(NUM(fa),k,ntRing);
917  //DEN(result) = NULL; // done by ..Alloc0..
918  if (NUM(result)==NULL)
919  {
921  return(NULL);
922  }
923  COM(result) = COM(fa)+DIFF_COMPLEXITY;
924  //check_N((number)result,cf);
925  ntTest((number)result);
926  return (number)result;
927  }
928 
929  poly fg = p_Mult_q(p_Copy(DEN(fa),ntRing),p_Diff(NUM(fa),k,ntRing),ntRing);
930  poly gf = p_Mult_q(p_Copy(NUM(fa),ntRing),p_Diff(DEN(fa),k,ntRing),ntRing);
931  NUM(result) = p_Sub(fg,gf,ntRing);
932  if (NUM(result)==NULL) return(NULL);
933  DEN(result) = pp_Mult_qq(DEN(fa), DEN(fa), ntRing);
934  COM(result) = COM(fa) + COM(fa) + DIFF_COMPLEXITY;
935  heuristicGcdCancellation((number)result, cf);
936 
937  //check_N((number)result,cf);
938  ntTest((number)result);
939  return (number)result;
940 }
poly p_Diff(poly a, int k, const ring r)
Definition: p_polys.cc:1845
#define DIFF_COMPLEXITY
complexity increase due to * and /
Definition: transext.cc:64
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
void * ADDRESS
Definition: auxiliary.h:133
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:92
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1937
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4540
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntDiv()

static number ntDiv ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 1117 of file transext.cc.

1118 {
1119  //check_N(a,cf);
1120  //check_N(b,cf);
1121  ntTest(a);
1122  ntTest(b);
1123  if (IS0(a)) return NULL;
1124  if (IS0(b)) WerrorS(nDivBy0);
1125 
1126  fraction fa = (fraction)a;
1127  fraction fb = (fraction)b;
1128 
1129  poly g = p_Copy(NUM(fa), ntRing);
1130  if (!DENIS1(fb)) g = p_Mult_q(g, p_Copy(DEN(fb), ntRing), ntRing);
1131 
1132  if (g == NULL) return NULL; /* may happen due to zero divisors */
1133 
1134  poly f = p_Copy(NUM(fb), ntRing);
1135  if (!DENIS1(fa)) f = p_Mult_q(f, p_Copy(DEN(fa), ntRing), ntRing);
1136 
1137  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
1138  NUM(result) = g;
1139  if (!n_GreaterZero(pGetCoeff(f),ntCoeffs))
1140  {
1141  g=p_Neg(g,ntRing);
1142  f=p_Neg(f,ntRing);
1143  NUM(result) = g;
1144  }
1145  if (!p_IsConstant(f,ntRing) || !n_IsOne(pGetCoeff(f),ntCoeffs))
1146  {
1147  DEN(result) = f;
1148  }
1149  else
1150  {
1151  p_Delete(&f, ntRing);
1152  }
1153  COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY;
1154 // definiteGcdCancellation((number)result, cf,FALSE);
1155  heuristicGcdCancellation((number)result, cf);
1156 // ntTest((number)result);
1157  //check_N((number)result,cf);
1158  ntNormalizeDen(result,ntRing);
1159  ntTest((number)result);
1160  return (number)result;
1161 }
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
static void ntNormalizeDen(fraction result, const ring R)
Definition: transext.cc:1093
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
const char *const nDivBy0
Definition: numbers.h:89
FILE * f
Definition: checklibs.c:9
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
#define NULL
Definition: omList.c:10
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
#define MULT_COMPLEXITY
complexity increase due to * and /
Definition: transext.cc:63
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntEqual()

static BOOLEAN ntEqual ( number  a,
number  b,
const coeffs  cf 
)
static

simple tests

cheap test if gcd's have been cancelled in both numbers

Definition at line 314 of file transext.cc.

315 {
316  //check_N(a,cf);
317  //check_N(b,cf);
318  ntTest(a);
319  ntTest(b);
320 
321  /// simple tests
322  if (a == b) return TRUE;
323  if ((IS0(a)) && (!IS0(b))) return FALSE;
324  if ((IS0(b)) && (!IS0(a))) return FALSE;
325 
326  /// cheap test if gcd's have been cancelled in both numbers
327  fraction fa = (fraction)a;
328  fraction fb = (fraction)b;
329  if ((COM(fa) == 1) && (COM(fb) == 1))
330  {
331  poly f = p_Add_q(p_Copy(NUM(fa), ntRing),
332  p_Neg(p_Copy(NUM(fb), ntRing), ntRing),
333  ntRing);
334  if (f != NULL) { p_Delete(&f, ntRing); return FALSE; }
335  if (DENIS1(fa) && DENIS1(fb)) return TRUE;
336  if (DENIS1(fa) && !DENIS1(fb)) return FALSE;
337  if (!DENIS1(fa) && DENIS1(fb)) return FALSE;
338  f = p_Add_q(p_Copy(DEN(fa), ntRing),
339  p_Neg(p_Copy(DEN(fb), ntRing), ntRing),
340  ntRing);
341  if (f != NULL) { p_Delete(&f, ntRing); return FALSE; }
342  return TRUE;
343  }
344 
345  /* default: the more expensive multiplication test
346  a/b = c/d <==> a*d = b*c */
347  poly f = p_Copy(NUM(fa), ntRing);
348  if (!DENIS1(fb)) f = p_Mult_q(f, p_Copy(DEN(fb), ntRing), ntRing);
349  poly g = p_Copy(NUM(fb), ntRing);
350  if (!DENIS1(fa)) g = p_Mult_q(g, p_Copy(DEN(fa), ntRing), ntRing);
351  poly h = p_Add_q(f, p_Neg(g, ntRing), ntRing);
352  if (h == NULL) return TRUE;
353  else
354  {
355  p_Delete(&h, ntRing);
356  return FALSE;
357  }
358 }
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define FALSE
Definition: auxiliary.h:94
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
#define TRUE
Definition: auxiliary.h:98
g
Definition: cfModGcd.cc:4031
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
FILE * f
Definition: checklibs.c:9
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050

◆ ntFarey()

static number ntFarey ( number  p,
number  n,
const coeffs  cf 
)
static

Definition at line 2482 of file transext.cc.

2483 {
2484  // n is really a bigint
2485  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
2486  NUM(result)=p_Farey(p_Copy(NUM((fraction)p),cf->extRing),n,cf->extRing);
2487  DEN(result)=p_Farey(p_Copy(DEN((fraction)p),cf->extRing),n,cf->extRing);
2488  ntTest((number)result);
2489  return ((number)result);
2490 }
#define ntTest(a)
Definition: transext.cc:77
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly p_Farey(poly p, number N, const ring r)
Definition: p_polys.cc:52
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
int p
Definition: cfModGcd.cc:4019
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntGcd()

static number ntGcd ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 1718 of file transext.cc.

1719 {
1720  ntTest(a);
1721  ntTest(b);
1722  if (a==NULL) return ntCopy(b,cf);
1723  if (b==NULL) return ntCopy(a,cf);
1724  fraction fa = (fraction)a;
1725  fraction fb = (fraction)b;
1726 
1727 
1728  poly pGcd;
1729  if (nCoeff_is_Q(ntCoeffs))
1730  {
1731  poly pa = NUM(fa);
1732  poly pb = NUM(fb);
1733  if (p_IsConstant(pa,ntRing) && p_IsConstant(pb,ntRing))
1734  {
1735  pGcd = p_Copy(pa,ntRing);
1736  p_SetCoeff (pGcd, n_SubringGcd (pGetCoeff(pGcd), pGetCoeff(pb), ntCoeffs), ntRing);
1737  }
1738  else
1739  {
1740  number contentpa, contentpb, tmp;
1741 
1742  contentpb= n_Copy(p_GetCoeff(pb, ntRing),ntCoeffs);
1743  pIter(pb);
1744  while (pb != NULL)
1745  {
1746  tmp = n_SubringGcd(contentpb, p_GetCoeff(pb, ntRing) , ntCoeffs);
1747  n_Delete(&contentpb, ntCoeffs);
1748  contentpb = tmp;
1749  pIter(pb);
1750  }
1751 
1752  contentpa= n_Copy(p_GetCoeff(pa, ntRing),ntCoeffs);
1753  pIter(pa);
1754  while (pa != NULL)
1755  {
1756  tmp = n_SubringGcd(contentpa, p_GetCoeff(pa, ntRing), ntCoeffs);
1757  n_Delete(&contentpa, ntCoeffs);
1758  contentpa = tmp;
1759  pIter(pa);
1760  }
1761 
1762  tmp= n_SubringGcd (contentpb, contentpa, ntCoeffs);
1763  n_Delete(&contentpa, ntCoeffs);
1764  n_Delete(&contentpb, ntCoeffs);
1765  contentpa= tmp;
1766 
1767  /* singclap_gcd destroys its arguments; we hence need copies: */
1768  pGcd = singclap_gcd(p_Copy(NUM(fa),ntRing), p_Copy(NUM(fb),ntRing), ntRing);
1769  pGcd= __p_Mult_nn (pGcd, contentpa, ntRing);
1770  n_Delete(&contentpa, ntCoeffs);
1771  }
1772  }
1773  else
1774  pGcd = singclap_gcd(p_Copy(NUM(fa),ntRing), p_Copy(NUM(fb),ntRing), ntRing);
1775  /* Note that, over Q, singclap_gcd will remove the denominators in all
1776  rational coefficients of pa and pb, before starting to compute
1777  the gcd. Thus, we do not need to ensure that the coefficients of
1778  pa and pb live in Z; they may well be elements of Q\Z. */
1779 
1780  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
1781  NUM(result) = pGcd;
1782  ntTest((number)result); // !!!!
1783  return (number)result;
1784 }
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define ntTest(a)
Definition: transext.cc:77
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:255
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
#define pIter(p)
Definition: monomials.h:44
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntGenAlg()

static number ntGenAlg ( number  a,
const coeffs  cf,
const coeffs  dst 
)
static

Definition at line 1988 of file transext.cc.

1989 {
1990  n_Test(a, cf) ;
1991  if (n_IsZero(a, cf)) return NULL;
1992 
1993  const nMapFunc nMap=n_SetMap(cf->extRing->cf,dst->extRing->cf);
1994  return ntInit(prMapR((poly)a, nMap, cf->extRing, dst->extRing),dst);
1995 }
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:46
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
#define NULL
Definition: omList.c:10

◆ ntGenMap()

static number ntGenMap ( number  a,
const coeffs  cf,
const coeffs  dst 
)
static

Definition at line 1902 of file transext.cc.

1903 {
1904  ntTest(a);
1905  if (IS0(a)) return NULL;
1906 
1907  const ring rSrc = cf->extRing;
1908  const ring rDst = dst->extRing;
1909 
1910  const nMapFunc nMap=n_SetMap(rSrc->cf,rDst->cf);
1911  fraction f = (fraction)a;
1912  poly g = prMapR(NUM(f), nMap, rSrc, rDst);
1913  /* g may contain summands with coeff 0 */
1914  poly hh=g;
1915  poly prev=NULL;
1916  while(hh!=NULL)
1917  {
1918  if (n_IsZero(pGetCoeff(hh),rDst->cf))
1919  {
1920  if (prev==NULL)
1921  {
1922  g=p_LmFreeAndNext(g,rDst);
1923  hh=g;
1924  }
1925  else
1926  {
1927  prev->next=p_LmFreeAndNext(prev->next,rDst);
1928  hh=prev->next;
1929  }
1930  }
1931  else
1932  {
1933  prev=hh;
1934  pIter(hh);
1935  }
1936  }
1937  if (g==NULL) return NULL;
1938 
1939  poly h = NULL;
1940 
1941  if (!DENIS1(f))
1942  {
1943  h = prMapR(DEN(f), nMap, rSrc, rDst);
1944  /* h may contain summands with coeff 0 */
1945  hh=h;
1946  prev=NULL;
1947  while(hh!=NULL)
1948  {
1949  if (n_IsZero(pGetCoeff(hh),rDst->cf))
1950  {
1951  if (prev==NULL)
1952  {
1953  h=p_LmFreeAndNext(h,rDst);
1954  hh=h;
1955  }
1956  else
1957  {
1958  prev->next=p_LmFreeAndNext(prev->next,rDst);
1959  hh=prev->next;
1960  }
1961  }
1962  else
1963  {
1964  prev=hh;
1965  pIter(hh);
1966  }
1967  }
1968  if (h==NULL) WerrorS("mapping to */0");
1969  }
1970 
1971  fraction result = (fraction)omAllocBin(fractionObjectBin);
1972 
1973  NUM(result) = g;
1974  DEN(result) = h;
1975  COM(result) = COM(f);
1976  //check_N((number)result,dst);
1977  n_Test((number)result, dst);
1978  return (number)result;
1979 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:46
#define pIter(p)
Definition: monomials.h:44
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:972
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntGetDenom()

static number ntGetDenom ( number &  a,
const coeffs  cf 
)
static

TODO: normalization of a!?

Definition at line 555 of file transext.cc.

556 {
557  //check_N(a,cf);
558  ntTest(a);
559 
560  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
561  //DEN (result)= NULL; // done by ..Alloc0..
562  //COM (result)= 0; // done by ..Alloc0..
563 
564  if (IS0(a))
565  {
566  NUM (result) = p_One(ntRing);
567  return (number)result;
568  }
569 
571 
572  fraction f = (fraction)a;
573 
574  assume( !IS0(f) );
575 
576  const BOOLEAN denis1 = DENIS1 (f);
577 
578  if( denis1 && (getCoeffType (ntCoeffs) != n_Q) ) // */1 or 0
579  {
580  NUM (result)= p_One(ntRing);
581  ntTest((number)result);
582  return (number)result;
583  }
584 
585  if (!denis1) // */* / Q
586  {
587  assume( DEN (f) != NULL );
588 
589  if (getCoeffType (ntCoeffs) == n_Q)
591 
592  ntTest(a);
593 
594  if( DEN (f) != NULL ) // is it ?? // 1 now???
595  {
596  assume( !p_IsOne(DEN (f), ntRing) );
597 
598  NUM (result) = p_Copy (DEN (f), ntRing);
599  ntTest((number)result);
600  return (number)result;
601  }
602 // NUM (result) = p_One(ntRing); // NOTE: just in order to be sure...
603  }
604 
605  // */1 / Q
607  assume( DEN (f) == NULL );
608 
609  number g;
610 // poly num= p_Copy (NUM (f), ntRing); // ???
611 
612 
613  // TODO/NOTE: the following should not be necessary (due to
614  // Hannes!) as NUM (f) should be over Z!!!
615  CPolyCoeffsEnumerator itr(NUM(f));
616 
617  n_ClearDenominators(itr, g, ntCoeffs); // may return -1 :(((
618 
619  if( !n_GreaterZero(g, ntCoeffs) )
620  {
621 // NUM (f) = p_Neg(NUM (f), ntRing); // Ugly :(((
622 // g = n_InpNeg(g, ntCoeffs);
623  NUM (f) = p_Neg(NUM (f), ntRing); // Ugly :(((
624  g = n_InpNeg(g, ntCoeffs);
625  }
626 
627  // g should be a positive integer now!
629 
630  if( !n_IsOne(g, ntCoeffs) )
631  {
633  assume( !n_IsOne(g, ntCoeffs) );
634 
635  DEN (f) = p_NSet(g, ntRing); // update COM(f)???
636  assume( DEN (f) != NULL );
637  COM (f) ++;
638 
639  NUM (result)= p_Copy (DEN (f), ntRing);
640  }
641  else
642  { // common denom == 1?
643  NUM (result)= p_NSet(g, ntRing); // p_Copy (DEN (f), ntRing);
644 // n_Delete(&g, ntCoeffs);
645  }
646 
647 // if (!p_IsConstant (num, ntRing) && pNext(num) != NULL)
648 // else
649 // g= p_GetAllDenom (num, ntRing);
650 // result= (fraction) ntSetMap (ntCoeffs, cf) (g, ntCoeffs, cf);
651 
652  ntTest((number)result);
653  //check_N((number)result,cf);
654  return (number)result;
655 }
#define FALSE
Definition: auxiliary.h:94
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
rational (GMP) numbers
Definition: coeffs.h:31
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly p_One(const ring r)
Definition: p_polys.cc:1305
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
FILE * f
Definition: checklibs.c:9
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition: p_polys.h:1931
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static void handleNestedFractionsOverQ(fraction f, const coeffs cf)
Definition: transext.cc:401
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition: coeffs.h:949
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntGetNumerator()

static number ntGetNumerator ( number &  a,
const coeffs  cf 
)
static

TODO: normalization of a!?

Definition at line 494 of file transext.cc.

495 {
496  //check_N(a,cf);
497  ntTest(a);
498  if (IS0(a)) return NULL;
499 
501 
502  fraction f = (fraction)a;
503  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
504 
505  const BOOLEAN denis1= DENIS1 (f);
506 
507  if (getCoeffType (ntCoeffs) == n_Q && !denis1)
509 
510  if (getCoeffType (ntCoeffs) == n_Q && denis1)
511  {
512  assume( DEN (f) == NULL );
513 
514  number g;
515  // TODO/NOTE: the following should not be necessary (due to
516  // Hannes!) as NUM (f) should be over Z!!!
517  CPolyCoeffsEnumerator itr(NUM(f));
518 
519 
520  n_ClearDenominators(itr, g, ntCoeffs);
521 
522  if( !n_GreaterZero(g, ntCoeffs) )
523  {
524  NUM (f) = p_Neg(NUM (f), ntRing);
525  g = n_InpNeg(g, ntCoeffs);
526  }
527 
528  // g should be a positive integer now!
530 
531  if( !n_IsOne(g, ntCoeffs) )
532  {
533  DEN (f) = p_NSet(g, ntRing);
534  COM (f) ++;
535  assume( DEN (f) != NULL );
536  }
537  else
538  n_Delete(&g, ntCoeffs);
539 
540  ntTest(a);
541  }
542 
543  // Call ntNormalize instead of above?!?
544 
545  NUM (result) = p_Copy (NUM (f), ntRing); // ???
546  //DEN (result) = NULL; // done by ..Alloc0..
547  //COM (result) = 0; // done by ..Alloc0..
548 
549  ntTest((number)result);
550  //check_N((number)result,cf);
551  return (number)result;
552 }
#define FALSE
Definition: auxiliary.h:94
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
rational (GMP) numbers
Definition: coeffs.h:31
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static void handleNestedFractionsOverQ(fraction f, const coeffs cf)
Definition: transext.cc:401
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition: coeffs.h:949
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntGreater()

static BOOLEAN ntGreater ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 794 of file transext.cc.

795 {
796  //check_N(a,cf);
797  //check_N(b,cf);
798  ntTest(a);
799  ntTest(b);
800  if (IS0(a))
801  {
802  if (IS0(b)) return FALSE;
803  fraction fb = (fraction)b;
804  return (!n_GreaterZero(pGetCoeff(NUM(fb)), ntCoeffs));
805  }
806  if (IS0(b))
807  {
808  fraction fa = (fraction)a;
809  return (n_GreaterZero(pGetCoeff(NUM(fa)), ntCoeffs));
810  }
811  // now: a!=0, b!=0
812  fraction fa = (fraction)a;
813  number aNumCoeff = p_GetCoeff(NUM(fa), ntRing);
814  int aNumDeg = p_Totaldegree(NUM(fa), ntRing);
815  number aDenCoeff = NULL; int aDenDeg = 0;
816  if (DEN(fa)!=NULL)
817  {
818  aDenCoeff=p_GetCoeff(DEN(fa),ntRing);
819  aDenDeg = p_Totaldegree(DEN(fa), ntRing);
820  }
821  fraction fb = (fraction)b;
822  number bNumCoeff = p_GetCoeff(NUM(fb), ntRing);
823  int bNumDeg = p_Totaldegree(NUM(fb), ntRing);
824  number bDenCoeff = NULL; int bDenDeg = 0;
825  if (DEN(fb)!=NULL)
826  {
827  bDenCoeff=p_GetCoeff(DEN(fb),ntRing);
828  bDenDeg = p_Totaldegree(DEN(fb), ntRing);
829  }
830  if (aNumDeg-aDenDeg > bNumDeg-bDenDeg) return TRUE;
831  if (aNumDeg-aDenDeg < bNumDeg-bDenDeg) return FALSE;
832  number aa;
833  number bb;
834  if (bDenCoeff==NULL) aa=n_Copy(aNumCoeff,ntCoeffs);
835  else aa=n_Mult(aNumCoeff,bDenCoeff,ntCoeffs);
836  if (aDenCoeff==NULL) bb=n_Copy(bNumCoeff,ntCoeffs);
837  else bb=n_Mult(bNumCoeff,aDenCoeff,ntCoeffs);
838  BOOLEAN rr= n_Greater(aa, bb, ntCoeffs);
839  n_Delete(&aa,ntCoeffs);
840  n_Delete(&bb,ntCoeffs);
841  return rr;
842 }
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff &#39;a&#39; is larger than &#39;b&#39;; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:512
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define FALSE
Definition: auxiliary.h:94
#define ntTest(a)
Definition: transext.cc:77
#define TRUE
Definition: auxiliary.h:98
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1453
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:637
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int BOOLEAN
Definition: auxiliary.h:85

◆ ntGreaterZero()

static BOOLEAN ntGreaterZero ( number  a,
const coeffs  cf 
)
static

Definition at line 784 of file transext.cc.

785 {
786  //check_N(a,cf);
787  ntTest(a);
788  if (IS0(a)) return FALSE;
789  fraction f = (fraction)a;
790  poly g = NUM(f);
792 }
#define FALSE
Definition: auxiliary.h:94
#define ntTest(a)
Definition: transext.cc:77
g
Definition: cfModGcd.cc:4031
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:979
FILE * f
Definition: checklibs.c:9
#define ntCoeffs
Definition: transext.cc:87
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495

◆ ntInit() [1/2]

number ntInit ( long  i,
const coeffs  cf 
)

Definition at line 692 of file transext.cc.

693 {
694  if (i != 0)
695  {
696  poly p=p_ISet(i, ntRing);
697  if (p!=NULL)
698  {
699  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
700  NUM(result) = p;
701  //DEN(result) = NULL; // done by omAlloc0Bin
702  //COM(result) = 0; // done by omAlloc0Bin
703  ntTest((number)result);
704  //check_N((number)result,cf);
705  return (number)result;
706  }
707  }
708  return NULL;
709 }
#define ntTest(a)
Definition: transext.cc:77
int i
Definition: cfEzgcd.cc:125
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
int p
Definition: cfModGcd.cc:4019
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1289
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntInit() [2/2]

number ntInit ( poly  p,
const coeffs  cf 
)

Definition at line 713 of file transext.cc.

714 {
715  if (p == NULL) return NULL;
716 
717  p_Test( p, ntRing);
718  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
719 
720  if (nCoeff_is_Q(ntCoeffs))
721  {
722  number g;
723  // the following is necessary because
724  // NUM (f) should be over Z,
725  // while p may be over Q
727 
728  n_ClearDenominators(itr, g, ntCoeffs);
729 
730  if( !n_GreaterZero(g, ntCoeffs) )
731  {
732  p = p_Neg(p, ntRing);
733  g = n_InpNeg(g, ntCoeffs);
734  }
735 
736  // g should be a positive integer now!
738 
739  if( !n_IsOne(g, ntCoeffs) )
740  {
741  DEN (f) = p_NSet(g, ntRing);
742  p_Normalize(DEN(f), ntRing);
743  assume( DEN (f) != NULL );
744  }
745  else
746  {
747  //DEN(f) = NULL; // done by omAlloc0
748  n_Delete(&g, ntCoeffs);
749  }
750  }
751 
752  p_Normalize(p, ntRing);
753  NUM(f) = p;
754  //COM(f) = 0; // done by omAlloc0
755 
756  //check_N((number)f,cf);
757  ntTest((number)f);
758  return (number)f;
759 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
#define ntTest(a)
Definition: transext.cc:77
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
FILE * f
Definition: checklibs.c:9
#define p_Test(p, r)
Definition: p_polys.h:163
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition: coeffs.h:949
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntInitChar()

BOOLEAN ntInitChar ( coeffs  cf,
void *  infoStruct 
)

Initialize the coeffs object.

Definition at line 2492 of file transext.cc.

2493 {
2494 
2495  assume( infoStruct != NULL );
2496 
2497  TransExtInfo *e = (TransExtInfo *)infoStruct;
2498 
2499  assume( e->r != NULL); // extRing;
2500  assume( e->r->cf != NULL); // extRing->cf;
2501  assume( e->r->qideal == NULL );
2502 
2503  assume( cf != NULL );
2504  assume(getCoeffType(cf) == n_transExt); // coeff type;
2505 
2506  ring R = e->r;
2507  assume(R != NULL);
2508 
2509  R->ref ++; // increase the ref.counter for the ground poly. ring!
2510 
2511  cf->extRing = R;
2512  /* propagate characteristic up so that it becomes
2513  directly accessible in cf: */
2514  cf->ch = R->cf->ch;
2515 
2516  cf->is_field=TRUE;
2517  cf->is_domain=TRUE;
2518  cf->rep=n_rep_rat_fct;
2519 
2520  cf->factoryVarOffset = R->cf->factoryVarOffset + rVar(R);
2521 
2522  cf->cfCoeffString = naCoeffString; // FIXME? TODO? // extern char* naCoeffString(const coeffs r);
2523  cf->cfCoeffName = naCoeffName; // FIXME? TODO? // extern char* naCoeffString(const coeffs r);
2524 
2525  cf->cfGreaterZero = ntGreaterZero;
2526  cf->cfGreater = ntGreater;
2527  cf->cfEqual = ntEqual;
2528  cf->cfIsZero = ntIsZero;
2529  cf->cfIsOne = ntIsOne;
2530  cf->cfIsMOne = ntIsMOne;
2531  cf->cfInit = ntInit;
2532  cf->cfFarey = ntFarey;
2533  cf->cfChineseRemainder = ntChineseRemainder;
2534  cf->cfInt = ntInt;
2535  cf->cfInpNeg = ntNeg;
2536  cf->cfAdd = ntAdd;
2537  cf->cfSub = ntSub;
2538  cf->cfMult = ntMult;
2539  cf->cfDiv = ntDiv;
2540  cf->cfExactDiv = ntDiv;
2541  cf->cfPower = ntPower;
2542  cf->cfCopy = ntCopy;
2543  cf->cfWriteLong = ntWriteLong;
2544  cf->cfRead = ntRead;
2545  cf->cfNormalize = ntNormalize;
2546  cf->cfDelete = ntDelete;
2547  cf->cfSetMap = ntSetMap;
2548  cf->cfGetDenom = ntGetDenom;
2549  cf->cfGetNumerator = ntGetNumerator;
2550  //cf->cfRePart = ntCopy;
2551  //cf->cfImPart = ntImPart;
2552  cf->cfCoeffWrite = ntCoeffWrite;
2553 #ifdef LDEBUG
2554  cf->cfDBTest = ntDBTest;
2555 #endif
2556  //cf->cfGcd = ntGcd_dummy;
2557  cf->cfSubringGcd = ntGcd;
2558  cf->cfNormalizeHelper = ntNormalizeHelper;
2559  cf->cfSize = ntSize;
2560  cf->nCoeffIsEqual = ntCoeffIsEqual;
2561  cf->cfInvers = ntInvers;
2562  cf->cfKillChar = ntKillChar;
2563 
2564  if( rCanShortOut(ntRing) )
2565  cf->cfWriteShort = ntWriteShort;
2566  else
2567  cf->cfWriteShort = ntWriteLong;
2568 
2569  cf->convFactoryNSingN =ntConvFactoryNSingN;
2570  cf->convSingNFactoryN =ntConvSingNFactoryN;
2571  cf->cfParDeg = ntParDeg;
2572 
2573  cf->iNumberOfParameters = rVar(R);
2574  cf->pParameterNames = (const char**)R->names;
2575  cf->cfParameter = ntParameter;
2576  cf->has_simple_Inverse= FALSE;
2577  /* cf->has_simple_Alloc= FALSE; */
2578 
2579 
2580  if( nCoeff_is_Q(R->cf) )
2581  cf->cfClearContent = ntClearContent;
2582 
2583  cf->cfClearDenominators = ntClearDenominators;
2584 
2585  return FALSE;
2586 }
static BOOLEAN ntIsMOne(number a, const coeffs cf)
Definition: transext.cc:666
static BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs r)
Definition: transext.cc:141
char * naCoeffName(const coeffs r)
Definition: algext.cc:1352
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
static BOOLEAN ntIsOne(number a, const coeffs cf)
Definition: transext.cc:657
#define FALSE
Definition: auxiliary.h:94
static void ntPower(number a, int exp, number *b, const coeffs cf)
Definition: transext.cc:1229
static BOOLEAN ntIsZero(number a, const coeffs cf)
Definition: transext.cc:294
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#define TRUE
Definition: auxiliary.h:98
static number ntFarey(number p, number n, const coeffs cf)
Definition: transext.cc:2482
(fraction), see transext.h
Definition: coeffs.h:115
nMapFunc ntSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type (n_transExt)
Definition: transext.cc:2059
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
char * naCoeffString(const coeffs r)
Definition: algext.cc:1329
static BOOLEAN ntGreaterZero(number a, const coeffs cf)
Definition: transext.cc:784
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:577
static number ntConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: transext.cc:2141
static void ntWriteShort(number a, const coeffs cf)
Definition: transext.cc:1559
static number ntGcd(number a, number b, const coeffs cf)
Definition: transext.cc:1718
static int ntParDeg(number a, const coeffs cf)
Definition: transext.cc:2162
static void ntClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: transext.cc:2308
static void ntNormalize(number &a, const coeffs cf)
Definition: transext.cc:1594
static number ntAdd(number a, number b, const coeffs cf)
Definition: transext.cc:942
static void ntWriteLong(number a, const coeffs cf)
Definition: transext.cc:1534
static long ntInt(number &a, const coeffs cf)
Definition: transext.cc:761
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define assume(x)
Definition: mod2.h:390
static void ntKillChar(coeffs cf)
Definition: transext.cc:2136
static BOOLEAN ntEqual(number a, number b, const coeffs cf)
Definition: transext.cc:314
static void ntDelete(number *a, const coeffs cf)
Definition: transext.cc:301
static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: transext.cc:1613
struct for passing initialization parameters to naInitChar
Definition: transext.h:88
static void ntCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: transext.cc:844
static const char * ntRead(const char *s, number *a, const coeffs cf)
Definition: transext.cc:1584
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static number ntChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: transext.cc:2452
static void ntClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: transext.cc:2219
static number ntNormalizeHelper(number a, number b, const coeffs cf)
Definition: transext.cc:1635
static number ntMult(number a, number b, const coeffs cf)
Definition: transext.cc:1022
#define NULL
Definition: omList.c:10
static number ntParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given trans.ext.
Definition: transext.cc:2171
static int ntSize(number a, const coeffs cf)
Definition: transext.cc:1792
static number ntInvers(number a, const coeffs cf)
Definition: transext.cc:1163
#define R
Definition: sirandom.c:26
static number ntNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: transext.cc:679
static number ntDiv(number a, number b, const coeffs cf)
Definition: transext.cc:1117
static number ntGetDenom(number &a, const coeffs cf)
TODO: normalization of a!?
Definition: transext.cc:555
#define ntRing
Definition: transext.cc:81
static number ntSub(number a, number b, const coeffs cf)
Definition: transext.cc:983
static CanonicalForm ntConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: transext.cc:2153
static BOOLEAN ntGreater(number a, number b, const coeffs cf)
Definition: transext.cc:794
static number ntGetNumerator(number &a, const coeffs cf)
TODO: normalization of a!?
Definition: transext.cc:494

◆ ntInt()

static long ntInt ( number &  a,
const coeffs  cf 
)
static

Definition at line 761 of file transext.cc.

762 {
763  //check_N(a,cf);
764  ntTest(a);
765  if (IS0(a)) return 0;
767  fraction f = (fraction)a;
768  if (!DENIS1(f)) return 0;
769 
770  const poly aAsPoly = NUM(f);
771 
772  if(aAsPoly == NULL)
773  return 0;
774 
775  if (!p_IsConstant(aAsPoly, ntRing))
776  return 0;
777 
778  assume( aAsPoly != NULL );
779 
780  return n_Int(p_GetCoeff(aAsPoly, ntRing), ntCoeffs);
781 }
#define FALSE
Definition: auxiliary.h:94
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
#define ntTest(a)
Definition: transext.cc:77
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:548
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
FILE * f
Definition: checklibs.c:9
#define NULL
Definition: omList.c:10
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
#define ntRing
Definition: transext.cc:81

◆ ntInvers()

static number ntInvers ( number  a,
const coeffs  cf 
)
static

Definition at line 1163 of file transext.cc.

1164 {
1165  //check_N(a,cf);
1166  ntTest(a);
1167  if (IS0(a))
1168  {
1169  WerrorS(nDivBy0);
1170  return NULL;
1171  }
1172  fraction f = (fraction)a;
1173  assume( f != NULL );
1174 
1175  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
1176 
1177  assume( NUM(f) != NULL );
1178  const poly den = DEN(f);
1179 
1180  if (den == NULL)
1181  NUM(result) = p_One(ntRing);
1182  else
1183  NUM(result) = p_Copy(den, ntRing);
1184 
1185  if( !NUMIS1(f) )
1186  {
1187  poly num_f=NUM(f);
1188  BOOLEAN neg= !n_GreaterZero(pGetCoeff(num_f),ntCoeffs);
1189  if (neg)
1190  {
1191  num_f=p_Neg(p_Copy(num_f, ntRing), ntRing);
1192  NUM(result)=p_Neg(NUM(result), ntRing);
1193  }
1194  else
1195  {
1196  num_f=p_Copy(num_f, ntRing);
1197  }
1198  DEN(result) = num_f;
1199  COM(result) = COM(f);
1200  if (neg)
1201  {
1202  if (p_IsOne(num_f, ntRing))
1203  {
1204  DEN(result)=NULL;
1205  //COM(result) = 0;
1206  p_Delete(&num_f,ntRing);
1207  }
1208  }
1209  }
1210  //else// Alloc0
1211  //{
1212  // DEN(result) = NULL;
1213  // COM(result) = 0;
1214  //}
1215  ntNormalizeDen(result,ntRing);
1216  ntTest((number)result); // !!!!
1217  //check_N((number)result,cf);
1218  return (number)result;
1219 }
static void ntNormalizeDen(fraction result, const ring R)
Definition: transext.cc:1093
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define assume(x)
Definition: mod2.h:390
#define NUMIS1(f)
TRUE iff num. represents 1.
Definition: transext.cc:68
const char *const nDivBy0
Definition: numbers.h:89
FILE * f
Definition: checklibs.c:9
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition: p_polys.h:1931
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntIsMOne()

static BOOLEAN ntIsMOne ( number  a,
const coeffs  cf 
)
static

Definition at line 666 of file transext.cc.

667 {
668  //check_N(a,cf);
669  ntTest(a);
671  fraction f = (fraction)a;
672  if ((f==NULL) || (!DENIS1(f))) return FALSE;
673  poly g = NUM(f);
674  if (!p_IsConstant(g, ntRing)) return FALSE;
675  return n_IsMOne(p_GetCoeff(g, ntRing), ntCoeffs);
676 }
#define FALSE
Definition: auxiliary.h:94
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
#define ntTest(a)
Definition: transext.cc:77
g
Definition: cfModGcd.cc:4031
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
FILE * f
Definition: checklibs.c:9
#define NULL
Definition: omList.c:10
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the additive inverse of the one element, i.e. -1.
Definition: coeffs.h:473

◆ ntIsOne()

static BOOLEAN ntIsOne ( number  a,
const coeffs  cf 
)
static

Definition at line 657 of file transext.cc.

658 {
659  //check_N(a,cf);
660  ntTest(a); // !!!
662  fraction f = (fraction)a;
663  return (f!=NULL) && DENIS1(f) && NUMIS1(f);
664 }
#define FALSE
Definition: auxiliary.h:94
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
#define ntTest(a)
Definition: transext.cc:77
#define NUMIS1(f)
TRUE iff num. represents 1.
Definition: transext.cc:68
FILE * f
Definition: checklibs.c:9
#define NULL
Definition: omList.c:10

◆ ntIsParam()

int ntIsParam ( number  m,
const coeffs  cf 
)

if m == var(i)/1 => return i,

Definition at line 2193 of file transext.cc.

2194 {
2195  ntTest(m);
2196  assume(getCoeffType(cf) == n_transExt);
2197 
2198  const ring R = cf->extRing;
2199  assume( R != NULL );
2200 
2201  fraction f = (fraction)m;
2202 
2203  if( DEN(f) != NULL )
2204  return 0;
2205 
2206  return p_Var( NUM(f), R );
2207 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define ntTest(a)
Definition: transext.cc:77
#define assume(x)
Definition: mod2.h:390
int m
Definition: cfEzgcd.cc:121
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4540

◆ ntIsZero()

static BOOLEAN ntIsZero ( number  a,
const coeffs  cf 
)
static

Definition at line 294 of file transext.cc.

295 {
296  //check_N(a,cf);
297  ntTest(a); // !!!
298  return (IS0(a));
299 }
#define ntTest(a)
Definition: transext.cc:77

◆ ntKillChar()

static void ntKillChar ( coeffs  cf)
static

Definition at line 2136 of file transext.cc.

2137 {
2138  if ((--cf->extRing->ref) == 0)
2139  rDelete(cf->extRing);
2140 }
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:439

◆ ntMap00()

static number ntMap00 ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 1819 of file transext.cc.

1820 {
1821  n_Test(a, src);
1822 
1823  if (n_IsZero(a, src)) return NULL;
1824  assume(src->rep == dst->extRing->cf->rep);
1825  if ((SR_HDL(a) & SR_INT) || (a->s==3))
1826  {
1827  number res=ntInit(p_NSet(n_Copy(a, src), dst->extRing), dst);
1828  n_Test(res, dst);
1829  return res;
1830  }
1831  number nn=n_GetDenom(a,src);
1832  number zz=n_GetNumerator(a,src);
1833  number res=ntInit(p_NSet(zz,dst->extRing), dst);
1834  fraction ff=(fraction)res;
1835  if (n_IsOne(nn,src)) DEN(ff)=NULL;
1836  else DEN(ff)=p_NSet(nn,dst->extRing);
1837 
1838  n_Test((number)ff,dst);
1839  //check_N((number)ff,dst);
1840  return (number)ff;
1841 }
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n) ...
Definition: coeffs.h:609
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
CanonicalForm res
Definition: facAbsFact.cc:64
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define assume(x)
Definition: mod2.h:390
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define SR_INT
Definition: longrat.h:68
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1) ...
Definition: coeffs.h:604
#define SR_HDL(A)
Definition: tgb.cc:35

◆ ntMap0P()

static number ntMap0P ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 1998 of file transext.cc.

1999 {
2000  n_Test(a, src) ;
2001  if (n_IsZero(a, src)) return NULL;
2002  // int p = rChar(dst->extRing);
2003 
2004  number q = nlModP(a, src, dst->extRing->cf); // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp
2005 
2006  if (n_IsZero(q, dst->extRing->cf))
2007  {
2008  n_Delete(&q, dst->extRing->cf);
2009  return NULL;
2010  }
2011 
2012  poly g = p_NSet(q, dst->extRing);
2013 
2014  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
2015  NUM(f) = g; // DEN(f) = NULL; COM(f) = 0;
2016  n_Test((number)f, dst);
2017  //check_N((number)f,dst);
2018  return (number)f;
2019 }
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1436
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
g
Definition: cfModGcd.cc:4031
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntMapP0()

static number ntMapP0 ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 1857 of file transext.cc.

1858 {
1859  n_Test(a, src);
1860  if (n_IsZero(a, src)) return NULL;
1861  /* mapping via intermediate int: */
1862  int n = n_Int(a, src);
1863  number q = n_Init(n, dst->extRing->cf);
1864  if (n_IsZero(q, dst->extRing->cf))
1865  {
1866  n_Delete(&q, dst->extRing->cf);
1867  return NULL;
1868  }
1869  return ntInit(p_NSet(q, dst->extRing), dst);
1870 }
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:548
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define NULL
Definition: omList.c:10
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456

◆ ntMapPP()

static number ntMapPP ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 2022 of file transext.cc.

2023 {
2024  n_Test(a, src) ;
2025  if (n_IsZero(a, src)) return NULL;
2026  assume(src == dst->extRing->cf);
2027  poly p = p_One(dst->extRing);
2028  p_SetCoeff(p, n_Copy(a, src), dst->extRing);
2029  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
2030  NUM(f) = p; // DEN(f) = NULL; COM(f) = 0;
2031  n_Test((number)f, dst);
2032  //check_N((number)f,dst);
2033  return (number)f;
2034 }
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define assume(x)
Definition: mod2.h:390
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
int p
Definition: cfModGcd.cc:4019
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntMapUP()

static number ntMapUP ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 2037 of file transext.cc.

2038 {
2039  n_Test(a, src) ;
2040  if (n_IsZero(a, src)) return NULL;
2041  /* mapping via intermediate int: */
2042  int n = n_Int(a, src);
2043  number q = n_Init(n, dst->extRing->cf);
2044  poly p;
2045  if (n_IsZero(q, dst->extRing->cf))
2046  {
2047  n_Delete(&q, dst->extRing->cf);
2048  return NULL;
2049  }
2050  p = p_One(dst->extRing);
2051  p_SetCoeff(p, q, dst->extRing);
2052  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
2053  NUM(f) = p; // DEN(f) = NULL; COM(f) = 0;
2054  n_Test((number)f, dst);
2055  //check_N((number)f,dst);
2056  return (number)f;
2057 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:548
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
int p
Definition: cfModGcd.cc:4019
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntMapZ0()

static number ntMapZ0 ( number  a,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 1843 of file transext.cc.

1844 {
1845  n_Test(a, src);
1846  if (n_IsZero(a, src)) return NULL;
1847  nMapFunc nMap=n_SetMap(src,dst->extRing->cf);
1848  poly p=p_NSet(nMap(a, src,dst->extRing->cf), dst->extRing);
1849  if (n_IsZero(pGetCoeff(p),dst->extRing->cf))
1850  p_Delete(&p,dst->extRing);
1851  number res=ntInit(p, dst);
1852  n_Test(res,dst);
1853  return res;
1854 }
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
CanonicalForm res
Definition: facAbsFact.cc:64
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
int p
Definition: cfModGcd.cc:4019

◆ ntMult()

static number ntMult ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 1022 of file transext.cc.

1023 {
1024  //check_N(a,cf);
1025  //check_N(b,cf);
1026  ntTest(a); // !!!?
1027  ntTest(b); // !!!?
1028 
1029  if (IS0(a) || IS0(b)) return NULL;
1030 
1031  fraction fa = (fraction)a;
1032  fraction fb = (fraction)b;
1033 
1034  const poly g = pp_Mult_qq(NUM(fa), NUM(fb), ntRing);
1035 
1036  if (g == NULL) return NULL; // may happen due to zero divisors???
1037 
1038  fraction result = (fraction)omAllocBin(fractionObjectBin);
1039 
1040  NUM(result) = g;
1041 
1042  const poly da = DEN(fa);
1043  const poly db = DEN(fb);
1044 
1045 
1046  //check_N((number)result,cf);
1047  if (db == NULL)
1048  {
1049  // b = ? // NULL
1050 
1051  if(da == NULL)
1052  { // both fa && fb are ?? // NULL!
1053  assume (da == NULL && db == NULL);
1054  DEN(result) = NULL;
1055  COM(result) = 0;
1056  }
1057  else
1058  {
1059  assume (da != NULL && db == NULL);
1060  DEN(result) = p_Copy(da, ntRing);
1061  COM(result) = COM(fa) + MULT_COMPLEXITY;
1062  heuristicGcdCancellation((number)result, cf);
1063  //check_N((number)result,cf);
1064  }
1065  }
1066  else
1067  { // b = ?? / ??
1068  if (da == NULL)
1069  { // a == ? // NULL
1070  assume( db != NULL && da == NULL);
1071  DEN(result) = p_Copy(db, ntRing);
1072  COM(result) = COM(fb) + MULT_COMPLEXITY;
1073  heuristicGcdCancellation((number)result, cf);
1074  //check_N((number)result,cf);
1075  }
1076  else /* both den's are != 1 */
1077  {
1078  assume (da != NULL && db != NULL);
1079  DEN(result) = pp_Mult_qq(da, db, ntRing);
1080  COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY;
1081  heuristicGcdCancellation((number)result, cf);
1082  //check_N((number)result,cf);
1083  }
1084  }
1085 
1086 // ntTest((number)result);
1087 
1088  //check_N((number)result,cf);
1089  ntTest((number)result);
1090  return (number)result;
1091 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
#define assume(x)
Definition: mod2.h:390
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
#define MULT_COMPLEXITY
complexity increase due to * and /
Definition: transext.cc:63
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntNeg()

static number ntNeg ( number  a,
const coeffs  cf 
)
static

this is in-place, modifies a

Definition at line 679 of file transext.cc.

680 {
681  //check_N(a,cf);
682  ntTest(a);
683  if (!IS0(a))
684  {
685  fraction f = (fraction)a;
686  NUM(f) = p_Neg(NUM(f), ntRing);
687  }
688  ntTest(a);
689  return a;
690 }
#define ntTest(a)
Definition: transext.cc:77
FILE * f
Definition: checklibs.c:9
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81

◆ ntNormalize()

static void ntNormalize ( number &  a,
const coeffs  cf 
)
static

Definition at line 1594 of file transext.cc.

1595 {
1596  if ( /*(*/ a!=NULL /*)*/ )
1597  {
1598  //PrintS("num=");p_wrp(NUM(a),ntRing);
1599  //PrintS(" den=");p_wrp(DEN(a),ntRing);PrintLn();
1600  if (COM((fraction)a)>0) definiteGcdCancellation(a, cf, FALSE);
1601  if ((DEN((fraction)a)!=NULL)
1602  &&(!n_GreaterZero(pGetCoeff(DEN((fraction)a)),ntCoeffs)))
1603  {
1604  NUM((fraction)a)=p_Neg(NUM((fraction)a),ntRing);
1605  DEN((fraction)a)=p_Neg(DEN((fraction)a),ntRing);
1606  }
1607  }
1608  ntNormalizeDen((fraction)a,ntRing);
1609  ntTest(a); // !!!!
1610 }
static void ntNormalizeDen(fraction result, const ring R)
Definition: transext.cc:1093
#define FALSE
Definition: auxiliary.h:94
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
Definition: transext.cc:1382
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define NULL
Definition: omList.c:10
#define ntCoeffs
Definition: transext.cc:87
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495

◆ ntNormalizeDen()

static void ntNormalizeDen ( fraction  result,
const ring  R 
)
static

Definition at line 1093 of file transext.cc.

1094 {
1095  if ((nCoeff_has_simple_inverse(R->cf))
1096  && (result!=NULL)
1097  && (DEN(result)!=NULL))
1098  {
1099  poly n=DEN(result);
1100  if (!n_IsOne(pGetCoeff(n),R->cf))
1101  {
1102  number inv=n_Invers(pGetCoeff(n),R->cf);
1103  DEN(result)=__p_Mult_nn(n,inv,R);
1104  NUM(result)=__p_Mult_nn(NUM(result),inv,R);
1105  n_Delete(&inv,R->cf);
1106  if (p_IsOne(DEN(result), R))
1107  {
1108  n=DEN(result);
1109  DEN(result)=NULL;
1110  COM(result) = 0;
1111  p_Delete(&n,R);
1112  }
1113  }
1114  }
1115 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static FORCE_INLINE BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
TRUE, if the computation of the inverse is fast, i.e. prefer leading coeff. 1 over content...
Definition: coeffs.h:916
#define COM(f)
Definition: transext.cc:70
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:565
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition: p_polys.h:1931
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
return result
Definition: facAbsBiFact.cc:76

◆ ntNormalizeHelper()

static number ntNormalizeHelper ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 1635 of file transext.cc.

1636 {
1637  ntTest(a);
1638  ntTest(b);
1639  fraction fb = (fraction)b;
1640  if ((b==NULL)||(DEN(fb)==NULL)) return ntCopy(a,cf);
1641  fraction fa = (fraction)a;
1642 
1643  poly pGcd;
1644  if (nCoeff_is_Q(ntCoeffs))
1645  {
1646  poly pa = NUM(fa);
1647  poly pb = DEN(fb);
1648  if (p_IsConstant(pa,ntRing) && p_IsConstant(pb,ntRing))
1649  {
1650  pGcd = p_Copy(pa,ntRing);
1651  p_SetCoeff (pGcd, n_Gcd (pGetCoeff(pGcd), pGetCoeff(pb), ntCoeffs), ntRing);
1652  }
1653  else
1654  {
1655  number contentpa, contentpb, tmp;
1656 
1657  contentpb= n_Copy(p_GetCoeff(pb, ntRing),ntCoeffs);
1658  pIter(pb);
1659  while (pb != NULL)
1660  {
1661  tmp = n_SubringGcd(contentpb, p_GetCoeff(pb, ntRing) , ntCoeffs);
1662  n_Delete(&contentpb, ntCoeffs);
1663  contentpb = tmp;
1664  pIter(pb);
1665  }
1666 
1667  contentpa= n_Copy(p_GetCoeff(pa, ntRing),ntCoeffs);
1668  pIter(pa);
1669  while (pa != NULL)
1670  {
1671  tmp = n_SubringGcd(contentpa, p_GetCoeff(pa, ntRing), ntCoeffs);
1672  n_Delete(&contentpa, ntCoeffs);
1673  contentpa = tmp;
1674  pIter(pa);
1675  }
1676 
1677  tmp= n_SubringGcd (contentpb, contentpa, ntCoeffs);
1678  n_Delete(&contentpa, ntCoeffs);
1679  n_Delete(&contentpb, ntCoeffs);
1680  contentpa= tmp;
1681 
1682  /* singclap_gcd destroys its arguments; we hence need copies: */
1683  pGcd = singclap_gcd(p_Copy(NUM(fa),ntRing), p_Copy(DEN(fb),ntRing), ntRing);
1684  pGcd= __p_Mult_nn (pGcd, contentpa, ntRing);
1685  n_Delete(&contentpa, ntCoeffs);
1686  }
1687  }
1688  else
1689  /* singclap_gcd destroys its arguments; we hence need copies: */
1690  pGcd = singclap_gcd(p_Copy(NUM(fa),ntRing), p_Copy(DEN(fb),ntRing), cf->extRing);
1691 
1692  /* Note that, over Q, singclap_gcd will remove the denominators in all
1693  rational coefficients of pa and pb, before starting to compute
1694  the gcd. Thus, we do not need to ensure that the coefficients of
1695  pa and pb live in Z; they may well be elements of Q\Z. */
1696 
1697  if (p_IsConstant(pGcd, ntRing) &&
1698  n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs))
1699  { /* gcd = 1; return pa*pb*/
1700  p_Delete(&pGcd,ntRing);
1701  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
1702  NUM(result) = pp_Mult_qq(NUM(fa),DEN(fb),ntRing);
1703 
1704  ntTest((number)result); // !!!!
1705 
1706  return (number)result;
1707  }
1708 
1709  /* return pa*pb/gcd */
1710  poly newNum = singclap_pdivide(NUM(fa), pGcd, ntRing);
1711  p_Delete(&pGcd,ntRing);
1712  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
1713  NUM(result) = p_Mult_q(p_Copy(DEN(fb),ntRing),newNum,ntRing);
1714  ntTest((number)result); // !!!!
1715  return (number)result;
1716 }
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:687
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
#define ntTest(a)
Definition: transext.cc:77
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:255
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:577
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
#define pIter(p)
Definition: monomials.h:44
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define ntCoeffs
Definition: transext.cc:87
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define ntRing
Definition: transext.cc:81
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntParameter()

static number ntParameter ( const int  iParameter,
const coeffs  cf 
)
static

return the specified parameter as a number in the given trans.ext.

Definition at line 2171 of file transext.cc.

2172 {
2173  assume(getCoeffType(cf) == n_transExt);
2174 
2175  const ring R = cf->extRing;
2176  assume( R != NULL );
2177  assume( 0 < iParameter && iParameter <= rVar(R) );
2178 
2179  poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
2180  p_Test(p,R);
2181 
2182  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
2183  NUM(f) = p;
2184  //DEN(f) = NULL;
2185  //COM(f) = 0;
2186 
2187  ntTest((number)f);
2188 
2189  return (number)f;
2190 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define ntTest(a)
Definition: transext.cc:77
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define assume(x)
Definition: mod2.h:390
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define p_Test(p, r)
Definition: p_polys.h:163
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
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:488
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
int p
Definition: cfModGcd.cc:4019
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntParDeg()

static int ntParDeg ( number  a,
const coeffs  cf 
)
static

Definition at line 2162 of file transext.cc.

2163 {
2164  ntTest(a);
2165  if (IS0(a)) return -1;
2166  fraction fa = (fraction)a;
2167  return cf->extRing->pFDeg(NUM(fa),cf->extRing);
2168 }
#define ntTest(a)
Definition: transext.cc:77
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007

◆ ntPower()

static void ntPower ( number  a,
int  exp,
number *  b,
const coeffs  cf 
)
static

Definition at line 1229 of file transext.cc.

1230 {
1231  ntTest(a);
1232 
1233  /* special cases first */
1234  if (IS0(a))
1235  {
1236  if (exp >= 0) *b = NULL;
1237  else WerrorS(nDivBy0);
1238  }
1239  else if (exp == 0) { *b = ntInit(1, cf); return;}
1240  else if (exp == 1) { *b = ntCopy(a, cf); return;}
1241  else if (exp == -1) { *b = ntInvers(a, cf); return;}
1242 
1243  int expAbs = exp; if (expAbs < 0) expAbs = -expAbs;
1244 
1245  /* now compute a^expAbs */
1246  number pow; number t;
1247  if (expAbs <= 7)
1248  {
1249  pow = ntCopy(a, cf);
1250  for (int i = 2; i <= expAbs; i++)
1251  {
1252  t = ntMult(pow, a, cf);
1253  ntDelete(&pow, cf);
1254  pow = t;
1255  heuristicGcdCancellation(pow, cf);
1256  }
1257  }
1258  else
1259  {
1260  pow = ntInit(1, cf);
1261  number factor = ntCopy(a, cf);
1262  while (expAbs != 0)
1263  {
1264  if (expAbs & 1)
1265  {
1266  t = ntMult(pow, factor, cf);
1267  ntDelete(&pow, cf);
1268  pow = t;
1269  heuristicGcdCancellation(pow, cf);
1270  }
1271  expAbs = expAbs / 2;
1272  if (expAbs != 0)
1273  {
1274  t = ntMult(factor, factor, cf);
1275  ntDelete(&factor, cf);
1276  factor = t;
1277  heuristicGcdCancellation(factor, cf);
1278  }
1279  }
1280  ntDelete(&factor, cf);
1281  }
1282 
1283  /* invert if original exponent was negative */
1284  if (exp < 0)
1285  {
1286  t = ntInvers(pow, cf);
1287  ntDelete(&pow, cf);
1288  pow = t;
1289  }
1290  *b = pow;
1291  ntTest(*b);
1292  //check_N(*b,cf);
1293 }
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
#define ntTest(a)
Definition: transext.cc:77
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
CanonicalForm b
Definition: cfModGcd.cc:4044
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
static void ntDelete(number *a, const coeffs cf)
Definition: transext.cc:301
const char *const nDivBy0
Definition: numbers.h:89
int i
Definition: cfEzgcd.cc:125
CanonicalForm factor
Definition: facAbsFact.cc:101
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
static number ntMult(number a, number b, const coeffs cf)
Definition: transext.cc:1022
#define NULL
Definition: omList.c:10
static number ntInvers(number a, const coeffs cf)
Definition: transext.cc:1163
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:414

◆ ntRead()

static const char* ntRead ( const char *  s,
number *  a,
const coeffs  cf 
)
static

Definition at line 1584 of file transext.cc.

1585 {
1586  poly p;
1587  const char * result = p_Read(s, p, ntRing);
1588  if (p == NULL) *a = NULL;
1589  else *a = ntInit(p, cf);
1590  ntTest(*a);
1591  return result;
1592 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define ntTest(a)
Definition: transext.cc:77
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1340
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
int p
Definition: cfModGcd.cc:4019
return result
Definition: facAbsBiFact.cc:76

◆ ntSetMap()

nMapFunc ntSetMap ( const coeffs  src,
const coeffs  dst 
)

Get a mapping function from src into the domain of this type (n_transExt)

Q or Z –> Q(T)

Z –> K(T)

Z/p –> Q(T)

Q –> Z/p(T)

Z/p –> Z/p(T)

Z/u –> Z/p(T)

K(T') –> K(T)

K(T') –> K'(T)

K(T') –> K(T)

K(T') –> K'(T)

default

Definition at line 2059 of file transext.cc.

2060 {
2061  /* dst is expected to be a rational function field */
2062  assume(getCoeffType(dst) == n_transExt);
2063 
2064  if( src == dst ) return ndCopyMap;
2065 
2066  int h = 0; /* the height of the extension tower given by dst */
2067  coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
2068  coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
2069 
2070  /* for the time being, we only provide maps if h = 1 and if b is Q or
2071  some field Z/pZ: */
2072  if (h==0)
2073  {
2074  if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
2075  return ntMap00; /// Q or Z --> Q(T)
2076  if (src->rep==n_rep_gap_gmp)
2077  return ntMapZ0; /// Z --> K(T)
2078  if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
2079  return ntMapP0; /// Z/p --> Q(T)
2080  if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
2081  return ntMap0P; /// Q --> Z/p(T)
2082  if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
2083  {
2084  if (src->ch == dst->ch) return ntMapPP; /// Z/p --> Z/p(T)
2085  else return ntMapUP; /// Z/u --> Z/p(T)
2086  }
2087  }
2088  if (h != 1) return NULL;
2089  //if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
2090 
2091  /* Let T denote the sequence of transcendental extension variables, i.e.,
2092  K[t_1, ..., t_s] =: K[T];
2093  Let moreover, for any such sequence T, T' denote any subsequence of T
2094  of the form t_1, ..., t_w with w <= s. */
2095 
2096  if (rVar(src->extRing) > rVar(dst->extRing))
2097  return NULL;
2098 
2099  for (int i = 0; i < rVar(src->extRing); i++)
2100  if (strcmp(rRingVar(i, src->extRing), rRingVar(i, dst->extRing)) != 0)
2101  return NULL;
2102 
2103  if (src->type==n_transExt)
2104  {
2105  if (src->extRing->cf==dst->extRing->cf)
2106  return ntCopyMap; /// K(T') --> K(T)
2107  else
2108  return ntGenMap; /// K(T') --> K'(T)
2109  }
2110  else
2111  {
2112  if (src->extRing->cf==dst->extRing->cf)
2113  return ntCopyAlg; /// K(T') --> K(T)
2114  else
2115  return ntGenAlg; /// K(T') --> K'(T)
2116  }
2117 
2118  return NULL; /// default
2119 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:831
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:843
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
(), see rinteger.h, new impl.
Definition: coeffs.h:113
static number ntCopyMap(number a, const coeffs cf, const coeffs dst)
Definition: transext.cc:1873
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
static coeffs nCoeff_bottom(const coeffs r, int &height)
Definition: transext.cc:280
static number ntMap00(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:1819
#define assume(x)
Definition: mod2.h:390
The main handler for Singular numbers which are suitable for Singular polynomials.
static number ntMapZ0(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:1843
static number ntMapUP(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:2037
int i
Definition: cfEzgcd.cc:125
static char * rRingVar(short i, const ring r)
Definition: ring.h:568
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
(number), see longrat.h
Definition: coeffs.h:112
#define NULL
Definition: omList.c:10
static number ntMap0P(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:1998
static number ntMapP0(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:1857
static number ntGenAlg(number a, const coeffs cf, const coeffs dst)
Definition: transext.cc:1988
static Poly * h
Definition: janet.cc:972
static number ntGenMap(number a, const coeffs cf, const coeffs dst)
Definition: transext.cc:1902
static number ntCopyAlg(number a, const coeffs cf, const coeffs dst)
Definition: transext.cc:1981
static number ntMapPP(number a, const coeffs src, const coeffs dst)
Definition: transext.cc:2022

◆ ntSize()

static int ntSize ( number  a,
const coeffs  cf 
)
static

Definition at line 1792 of file transext.cc.

1793 {
1794  ntTest(a);
1795  if (IS0(a)) return 0;
1796  fraction f = (fraction)a;
1797  poly p = NUM(f);
1798  unsigned long noOfTerms = 0;
1799  unsigned long numDegree = 0;
1800  if (p!=NULL)
1801  {
1802  numDegree = p_Totaldegree(p,ntRing);
1803  noOfTerms = pLength(p);
1804  }
1805  unsigned long denDegree = 0;
1806  if (!DENIS1(f))
1807  {
1808  denDegree = p_Totaldegree(DEN(f),ntRing);
1809  noOfTerms += pLength(DEN(f));
1810  }
1811  ntTest(a); // !!!!
1812  // avoid int overflow:
1813  unsigned long t= ((numDegree + denDegree)*(numDegree + denDegree) + 1) * noOfTerms; // must be >0
1814  if (t>INT_MAX) return INT_MAX;
1815  else return (int)t;
1816 }
#define ntTest(a)
Definition: transext.cc:77
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1453
FILE * f
Definition: checklibs.c:9
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
#define ntRing
Definition: transext.cc:81
int p
Definition: cfModGcd.cc:4019

◆ ntSub()

static number ntSub ( number  a,
number  b,
const coeffs  cf 
)
static

Definition at line 983 of file transext.cc.

984 {
985  //check_N(a,cf);
986  //check_N(b,cf);
987  ntTest(a);
988  ntTest(b);
989  if (IS0(a)) return ntNeg(ntCopy(b, cf), cf);
990  if (IS0(b)) return ntCopy(a, cf);
991 
992  fraction fa = (fraction)a;
993  fraction fb = (fraction)b;
994 
995  poly g = p_Copy(NUM(fa), ntRing);
996  if (!DENIS1(fb)) g = p_Mult_q(g, p_Copy(DEN(fb), ntRing), ntRing);
997  poly h = p_Copy(NUM(fb), ntRing);
998  if (!DENIS1(fa)) h = p_Mult_q(h, p_Copy(DEN(fa), ntRing), ntRing);
999  g = p_Add_q(g, p_Neg(h, ntRing), ntRing);
1000 
1001  if (g == NULL) return NULL;
1002 
1003  poly f;
1004  if (DENIS1(fa) && DENIS1(fb)) f = NULL;
1005  else if (!DENIS1(fa) && DENIS1(fb)) f = p_Copy(DEN(fa), ntRing);
1006  else if (DENIS1(fa) && !DENIS1(fb)) f = p_Copy(DEN(fb), ntRing);
1007  else /* both den's are != 1 */ f = p_Mult_q(p_Copy(DEN(fa), ntRing),
1008  p_Copy(DEN(fb), ntRing),
1009  ntRing);
1010 
1011  fraction result = (fraction)omAllocBin(fractionObjectBin);
1012  NUM(result) = g;
1013  DEN(result) = f;
1014  COM(result) = COM(fa) + COM(fb) + ADD_COMPLEXITY;
1015  heuristicGcdCancellation((number)result, cf);
1016 // ntTest((number)result);
1017  //check_N((number)result,cf);
1018  ntTest((number)result);
1019  return (number)result;
1020 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
#define ntTest(a)
Definition: transext.cc:77
#define COM(f)
Definition: transext.cc:70
g
Definition: cfModGcd.cc:4031
static number ntCopy(number a, const coeffs cf)
Definition: transext.cc:360
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
FILE * f
Definition: checklibs.c:9
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
Definition: transext.cc:1297
#define NULL
Definition: omList.c:10
static number ntNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: transext.cc:679
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
#define ntRing
Definition: transext.cc:81
#define ADD_COMPLEXITY
complexity increase due to + and -
Definition: transext.cc:62
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
return result
Definition: facAbsBiFact.cc:76
omBin fractionObjectBin
Definition: transext.cc:90

◆ ntWriteLong()

static void ntWriteLong ( number  a,
const coeffs  cf 
)
static

Definition at line 1534 of file transext.cc.

1535 {
1536  ntTest(a);
1537  if (IS0(a))
1538  StringAppendS("0");
1539  else
1540  {
1541  fraction f = (fraction)a;
1542  // stole logic from napWrite from kernel/longtrans.cc of legacy singular
1543  BOOLEAN omitBrackets = p_IsConstant(NUM(f), ntRing);
1544  if (!omitBrackets) StringAppendS("(");
1545  p_String0Long(NUM(f), ntRing, ntRing);
1546  if (!omitBrackets) StringAppendS(")");
1547  if (!DENIS1(f))
1548  {
1549  StringAppendS("/");
1550  omitBrackets = p_IsConstant(DEN(f), ntRing);
1551  if (!omitBrackets) StringAppendS("(");
1552  p_String0Long(DEN(f), ntRing, ntRing);
1553  if (!omitBrackets) StringAppendS(")");
1554  }
1555  }
1556  ntTest(a); // !!!!
1557 }
void p_String0Long(const poly p, ring lmRing, ring tailRing)
print p in a long way
Definition: polys0.cc:114
#define ntTest(a)
Definition: transext.cc:77
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
void StringAppendS(const char *st)
Definition: reporter.cc:107
FILE * f
Definition: checklibs.c:9
#define ntRing
Definition: transext.cc:81
int BOOLEAN
Definition: auxiliary.h:85

◆ ntWriteShort()

static void ntWriteShort ( number  a,
const coeffs  cf 
)
static

Definition at line 1559 of file transext.cc.

1560 {
1561  ntTest(a);
1562  if (IS0(a))
1563  StringAppendS("0");
1564  else
1565  {
1566  fraction f = (fraction)a;
1567  // stole logic from napWrite from kernel/longtrans.cc of legacy singular
1568  BOOLEAN omitBrackets = p_IsConstant(NUM(f), ntRing);
1569  if (!omitBrackets) StringAppendS("(");
1570  p_String0Short(NUM(f), ntRing, ntRing);
1571  if (!omitBrackets) StringAppendS(")");
1572  if (!DENIS1(f))
1573  {
1574  StringAppendS("/");
1575  omitBrackets = p_IsConstant(DEN(f), ntRing);
1576  if (!omitBrackets) StringAppendS("(");
1577  p_String0Short(DEN(f), ntRing, ntRing);
1578  if (!omitBrackets) StringAppendS(")");
1579  }
1580  }
1581  ntTest(a);
1582 }
#define ntTest(a)
Definition: transext.cc:77
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
void StringAppendS(const char *st)
Definition: reporter.cc:107
FILE * f
Definition: checklibs.c:9
#define ntRing
Definition: transext.cc:81
int BOOLEAN
Definition: auxiliary.h:85
void p_String0Short(const poly p, ring lmRing, ring tailRing)
print p in a short way, if possible
Definition: polys0.cc:95

Variable Documentation

◆ fractionObjectBin

omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject))

Definition at line 90 of file transext.cc.