Macros | Functions
algext.cc File Reference
#include "misc/auxiliary.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/PolyEnumerator.h"
#include "factory/factory.h"
#include "polys/clapconv.h"
#include "polys/clapsing.h"
#include "polys/prCopy.h"
#include "polys/ext_fields/algext.h"
#include "polys/ext_fields/transext.h"

Go to the source code of this file.

Macros

#define TRANSEXT_PRIVATES   1
 ABSTRACT: numbers in an algebraic extension field K[a] / < f(a) > Assuming that we have a coeffs object cf, then these numbers are polynomials in the polynomial ring K[a] represented by cf->extRing. More...
 
#define naTest(a)   naDBTest(a,__FILE__,__LINE__,cf)
 
#define naRing   cf->extRing
 
#define naCoeffs   cf->extRing->cf
 
#define naMinpoly   naRing->qideal->m[0]
 
#define n2pTest(a)   n2pDBTest(a,__FILE__,__LINE__,cf)
 ABSTRACT: numbers as polys in the ring K[a] Assuming that we have a coeffs object cf, then these numbers are polynomials in the polynomial ring K[a] represented by cf->extRing. More...
 
#define n2pRing   cf->extRing
 
#define n2pCoeffs   cf->extRing->cf
 

Functions

BOOLEAN naDBTest (number a, const char *f, const int l, const coeffs r)
 
BOOLEAN naGreaterZero (number a, const coeffs cf)
 forward declarations More...
 
BOOLEAN naGreater (number a, number b, const coeffs cf)
 
BOOLEAN naEqual (number a, number b, const coeffs cf)
 
BOOLEAN naIsOne (number a, const coeffs cf)
 
BOOLEAN naIsMOne (number a, const coeffs cf)
 
number naInit (long i, const coeffs cf)
 
number naNeg (number a, const coeffs cf)
 this is in-place, modifies a More...
 
number naInvers (number a, const coeffs cf)
 
number naAdd (number a, number b, const coeffs cf)
 
number naSub (number a, number b, const coeffs cf)
 
number naMult (number a, number b, const coeffs cf)
 
number naDiv (number a, number b, const coeffs cf)
 
void naPower (number a, int exp, number *b, const coeffs cf)
 
number naCopy (number a, const coeffs cf)
 
void naWriteLong (number a, const coeffs cf)
 
void naWriteShort (number a, const coeffs cf)
 
number naGetDenom (number &a, const coeffs cf)
 
number naGetNumerator (number &a, const coeffs cf)
 
number naGcd (number a, number b, const coeffs cf)
 
void naDelete (number *a, const coeffs cf)
 
void naCoeffWrite (const coeffs cf, BOOLEAN details)
 
const char * naRead (const char *s, number *a, const coeffs cf)
 
static BOOLEAN naCoeffIsEqual (const coeffs cf, n_coeffType n, void *param)
 
static void p_Monic (poly p, const ring r)
 returns NULL if p == NULL, otherwise makes p monic by dividing by its leading coefficient (only done if this is not already 1); this assumes that we are over a ground field so that division is well-defined; modifies p More...
 
static poly p_GcdHelper (poly &p, poly &q, const ring r)
 see p_Gcd; additional assumption: deg(p) >= deg(q); must destroy p and q (unless one of them is returned) More...
 
static poly p_Gcd (const poly p, const poly q, const ring r)
 
static poly p_ExtGcdHelper (poly &p, poly &pFactor, poly &q, poly &qFactor, ring r)
 
poly p_ExtGcd (poly p, poly &pFactor, poly q, poly &qFactor, ring r)
 assumes that p and q are univariate polynomials in r, mentioning the same variable; assumes a global monomial ordering in r; assumes that not both p and q are NULL; returns the gcd of p and q; moreover, afterwards pFactor and qFactor contain appropriate factors such that gcd(p, q) = p * pFactor + q * qFactor; leaves p and q unmodified More...
 
void heuristicReduce (poly &p, poly reducer, const coeffs cf)
 
void definiteReduce (poly &p, poly reducer, const coeffs cf)
 
static coeffs nCoeff_bottom (const coeffs r, int &height)
 
BOOLEAN naIsZero (number a, const coeffs cf)
 
long naInt (number &a, const coeffs cf)
 
number napNormalizeHelper (number b, const coeffs cf)
 
number naLcmContent (number a, number b, const coeffs cf)
 
int naSize (number a, const coeffs cf)
 
void naNormalize (number &a, const coeffs cf)
 
number naConvFactoryNSingN (const CanonicalForm n, const coeffs cf)
 
CanonicalForm naConvSingNFactoryN (number n, BOOLEAN, const coeffs cf)
 
number naMap00 (number a, const coeffs src, const coeffs dst)
 
number naMapZ0 (number a, const coeffs src, const coeffs dst)
 
number naMapP0 (number a, const coeffs src, const coeffs dst)
 
number naCopyTrans2AlgExt (number a, const coeffs src, const coeffs dst)
 
number naMap0P (number a, const coeffs src, const coeffs dst)
 
number naMapPP (number a, const coeffs src, const coeffs dst)
 
number naMapUP (number a, const coeffs src, const coeffs dst)
 
number naGenMap (number a, const coeffs cf, const coeffs dst)
 
number naGenTrans2AlgExt (number a, const coeffs cf, const coeffs dst)
 
nMapFunc naSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type (n_algExt) More...
 
int naParDeg (number a, const coeffs cf)
 
number naParameter (const int iParameter, const coeffs cf)
 return the specified parameter as a number in the given alg. field More...
 
int naIsParam (number m, const coeffs cf)
 if m == var(i)/1 => return i, More...
 
static void naClearContent (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
 
void naClearDenominators (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
 
void naKillChar (coeffs cf)
 
char * naCoeffString (const coeffs r)
 
char * naCoeffName (const coeffs r)
 
number naChineseRemainder (number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
 
number naFarey (number p, number n, const coeffs cf)
 
BOOLEAN naInitChar (coeffs cf, void *infoStruct)
 Initialize the coeffs object. More...
 
BOOLEAN n2pDBTest (number a, const char *f, const int l, const coeffs r)
 
void n2pNormalize (number &a, const coeffs cf)
 
number n2pMult (number a, number b, const coeffs cf)
 
number n2pDiv (number a, number b, const coeffs cf)
 
void n2pPower (number a, int exp, number *b, const coeffs cf)
 
const char * n2pRead (const char *s, number *a, const coeffs cf)
 
static BOOLEAN n2pCoeffIsEqual (const coeffs cf, n_coeffType n, void *param)
 
char * n2pCoeffString (const coeffs cf)
 
char * n2pCoeffName (const coeffs cf)
 
void n2pCoeffWrite (const coeffs cf, BOOLEAN details)
 
number n2pInvers (number a, const coeffs cf)
 
BOOLEAN n2pInitChar (coeffs cf, void *infoStruct)
 

Macro Definition Documentation

◆ n2pCoeffs

#define n2pCoeffs   cf->extRing->cf

Definition at line 1527 of file algext.cc.

◆ n2pRing

#define n2pRing   cf->extRing

Definition at line 1521 of file algext.cc.

◆ n2pTest

#define n2pTest (   a)    n2pDBTest(a,__FILE__,__LINE__,cf)

ABSTRACT: numbers as polys in the ring K[a] Assuming that we have a coeffs object cf, then these numbers are polynomials in the polynomial ring K[a] represented by cf->extRing.

IMPORTANT ASSUMPTIONS: 1.) So far we assume that cf->extRing is a valid polynomial ring

Definition at line 1514 of file algext.cc.

◆ naCoeffs

#define naCoeffs   cf->extRing->cf

Definition at line 67 of file algext.cc.

◆ naMinpoly

#define naMinpoly   naRing->qideal->m[0]

Definition at line 70 of file algext.cc.

◆ naRing

#define naRing   cf->extRing

Definition at line 61 of file algext.cc.

◆ naTest

#define naTest (   a)    naDBTest(a,__FILE__,__LINE__,cf)

Definition at line 54 of file algext.cc.

◆ TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES   1

ABSTRACT: numbers in an algebraic extension field K[a] / < f(a) > Assuming that we have a coeffs object cf, then these numbers are polynomials in the polynomial ring K[a] represented by cf->extRing.

IMPORTANT ASSUMPTIONS: 1.) So far we assume that cf->extRing is a valid polynomial ring in exactly one variable, i.e., K[a], where K is allowed to be any field (representable in SINGULAR and which may itself be some extension field, thus allowing for extension towers). 2.) Moreover, this implementation assumes that cf->extRing->qideal is not NULL but an ideal with at least one non-zero generator which may be accessed by cf->extRing->qideal->m[0] and which represents the minimal polynomial f(a) of the extension variable 'a' in K[a]. 3.) As soon as an std method for polynomial rings becomes availabe, all reduction steps modulo f(a) should be replaced by a call to std. Moreover, in this situation one can finally move from K[a] / < f(a) > to K[a_1, ..., a_s] / I, with I some zero-dimensional ideal in K[a_1, ..., a_s] given by a lex Gröbner basis. The code in algext.h and algext.cc is then capable of computing in K[a_1, ..., a_s] / I.

Definition at line 50 of file algext.cc.

Function Documentation

◆ definiteReduce()

void definiteReduce ( poly &  p,
poly  reducer,
const coeffs  cf 
)

Definition at line 730 of file algext.cc.

731 {
732  #ifdef LDEBUG
733  p_Test((poly)p, naRing);
734  p_Test((poly)reducer, naRing);
735  #endif
736  if ((p!=NULL) && (p_GetExp(p,1,naRing)>=p_GetExp(reducer,1,naRing)))
737  {
738  p_PolyDiv(p, reducer, FALSE, naRing);
739  }
740 }
#define FALSE
Definition: auxiliary.h:96
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:468
poly p_PolyDiv(poly &p, const poly divisor, const BOOLEAN needResult, const ring r)
assumes that p and divisor are univariate polynomials in r, mentioning the same variable; assumes div...
Definition: p_polys.cc:1845
#define p_Test(p, r)
Definition: p_polys.h:162
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
int p
Definition: cfModGcd.cc:4019

◆ heuristicReduce()

void heuristicReduce ( poly &  p,
poly  reducer,
const coeffs  cf 
)

Definition at line 560 of file algext.cc.

561 {
562  #ifdef LDEBUG
563  p_Test((poly)p, naRing);
564  p_Test((poly)reducer, naRing);
565  #endif
566  if (p_Totaldegree(p, naRing) > 10 * p_Totaldegree(reducer, naRing))
567  definiteReduce(p, reducer, cf);
568 }
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446
#define p_Test(p, r)
Definition: p_polys.h:162
#define naRing
Definition: algext.cc:61
int p
Definition: cfModGcd.cc:4019
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730

◆ n2pCoeffIsEqual()

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

Definition at line 1577 of file algext.cc.

1578 {
1579  if (n_polyExt != n) return FALSE;
1580  AlgExtInfo *e = (AlgExtInfo *)param;
1581  /* for extension coefficient fields we expect the underlying
1582  polynomial rings to be IDENTICAL, i.e. the SAME OBJECT;
1583  this expectation is based on the assumption that we have properly
1584  registered cf and perform reference counting rather than creating
1585  multiple copies of the same coefficient field/domain/ring */
1586  if (n2pRing == e->r)
1587  return TRUE;
1588  // NOTE: Q(a)[x] && Q(a)[y] should better share the _same_ Q(a)...
1589  if( rEqual(n2pRing, e->r, TRUE) ) // also checks the equality of qideals
1590  {
1591  rDelete(e->r);
1592  return TRUE;
1593  }
1594  return FALSE;
1595 }
ring r
Definition: algext.h:37
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
#define n2pRing
Definition: algext.cc:1521
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:1660
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
used to represent polys as coeffcients
Definition: coeffs.h:35

◆ n2pCoeffName()

char* n2pCoeffName ( const coeffs  cf)

Definition at line 1625 of file algext.cc.

1626 {
1627  const char* const* p=n_ParameterNames(cf);
1628  int l=0;
1629  int i;
1630  for(i=0; i<rVar(n2pRing);i++)
1631  {
1632  l+=(strlen(p[i])+1);
1633  }
1634  char *cf_s=nCoeffString(n2pRing->cf);
1635  STATIC_VAR char s[200];
1636  s[0]='\0';
1637  snprintf(s,strlen(cf_s)+2,"%s",cf_s);
1638  omFree(cf_s);
1639  char tt[2];
1640  tt[0]='[';
1641  tt[1]='\0';
1642  strcat(s,tt);
1643  tt[0]=',';
1644  for(i=0; i<rVar(n2pRing);i++)
1645  {
1646  strcat(s,p[i]);
1647  if (i+1!=rVar(n2pRing)) strcat(s,tt);
1648  else { tt[0]=']'; strcat(s,tt); }
1649  }
1650  return s;
1651 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
#define n2pRing
Definition: algext.cc:1521
#define omFree(addr)
Definition: omAllocDecl.h:261
#define STATIC_VAR
Definition: globaldefs.h:7
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar...
Definition: coeffs.h:981
int l
Definition: cfEzgcd.cc:93

◆ n2pCoeffString()

char* n2pCoeffString ( const coeffs  cf)

Definition at line 1597 of file algext.cc.

1598 {
1599  const char* const* p=n_ParameterNames(cf);
1600  int l=0;
1601  int i;
1602  for(i=0; i<rVar(n2pRing);i++)
1603  {
1604  l+=(strlen(p[i])+1);
1605  }
1606  char *cf_s=nCoeffString(n2pRing->cf);
1607  char *s=(char *)omAlloc(l+5+strlen(cf_s));
1608  s[0]='\0';
1609  snprintf(s,strlen(cf_s)+2,"%s",cf_s);
1610  omFree(cf_s);
1611  char tt[2];
1612  tt[0]='[';
1613  tt[1]='\0';
1614  strcat(s,tt);
1615  tt[0]=',';
1616  for(i=0; i<rVar(n2pRing);i++)
1617  {
1618  strcat(s,p[i]);
1619  if (i+1!=rVar(n2pRing)) strcat(s,tt);
1620  else { tt[0]=']'; strcat(s,tt); }
1621  }
1622  return s;
1623 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
#define n2pRing
Definition: algext.cc:1521
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar...
Definition: coeffs.h:981
int l
Definition: cfEzgcd.cc:93

◆ n2pCoeffWrite()

void n2pCoeffWrite ( const coeffs  cf,
BOOLEAN  details 
)

Definition at line 1653 of file algext.cc.

1654 {
1655  assume( cf != NULL );
1656 
1657  const ring A = cf->extRing;
1658 
1659  assume( A != NULL );
1660  PrintS("// polynomial ring as coefficient ring :\n");
1661  rWrite(A);
1662  PrintLn();
1663 }
void PrintLn()
Definition: reporter.cc:310
#define assume(x)
Definition: mod2.h:390
#define A
Definition: sirandom.c:24
void PrintS(const char *s)
Definition: reporter.cc:284
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
#define NULL
Definition: omList.c:12

◆ n2pDBTest()

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

Definition at line 1530 of file algext.cc.

1531 {
1532  if (a == NULL) return TRUE;
1533  return p_Test((poly)a, n2pRing);
1534 }
#define TRUE
Definition: auxiliary.h:100
#define n2pRing
Definition: algext.cc:1521
#define p_Test(p, r)
Definition: p_polys.h:162
#define NULL
Definition: omList.c:12

◆ n2pDiv()

number n2pDiv ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 1552 of file algext.cc.

1553 {
1554  n2pTest(a); n2pTest(b);
1555  if (b == NULL) WerrorS(nDivBy0);
1556  if (a == NULL) return NULL;
1557  poly p=singclap_pdivide((poly)a,(poly)b,n2pRing);
1558  return (number)p;
1559 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define n2pRing
Definition: algext.cc:1521
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:558
#define n2pTest(a)
ABSTRACT: numbers as polys in the ring K[a] Assuming that we have a coeffs object cf...
Definition: algext.cc:1514
CanonicalForm b
Definition: cfModGcd.cc:4044
const char *const nDivBy0
Definition: numbers.h:88
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ n2pInitChar()

BOOLEAN n2pInitChar ( coeffs  cf,
void *  infoStruct 
)

first check whether cf->extRing != NULL and delete old ring???

Definition at line 1681 of file algext.cc.

1682 {
1683  assume( infoStruct != NULL );
1684 
1685  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1686  /// first check whether cf->extRing != NULL and delete old ring???
1687 
1688  assume(e->r != NULL); // extRing;
1689  assume(e->r->cf != NULL); // extRing->cf;
1690 
1691  assume( cf != NULL );
1692 
1693  e->r->ref ++; // increase the ref.counter for the ground poly. ring!
1694  const ring R = e->r; // no copy!
1695  cf->extRing = R;
1696 
1697  /* propagate characteristic up so that it becomes
1698  directly accessible in cf: */
1699  cf->ch = R->cf->ch;
1700  cf->is_field=FALSE;
1701  cf->is_domain=TRUE;
1702 
1703  cf->cfCoeffString = n2pCoeffString;
1704  cf->cfCoeffName = n2pCoeffName;
1705 
1706  cf->cfGreaterZero = naGreaterZero;
1707  cf->cfGreater = naGreater;
1708  cf->cfEqual = naEqual;
1709  cf->cfIsZero = naIsZero;
1710  cf->cfIsOne = naIsOne;
1711  cf->cfIsMOne = naIsMOne;
1712  cf->cfInit = naInit;
1713  cf->cfFarey = naFarey;
1714  cf->cfChineseRemainder= naChineseRemainder;
1715  cf->cfInt = naInt;
1716  cf->cfInpNeg = naNeg;
1717  cf->cfAdd = naAdd;
1718  cf->cfSub = naSub;
1719  cf->cfMult = n2pMult;
1720  cf->cfDiv = n2pDiv;
1721  cf->cfPower = n2pPower;
1722  cf->cfCopy = naCopy;
1723 
1724  cf->cfWriteLong = naWriteLong;
1725 
1726  if( rCanShortOut(n2pRing) )
1727  cf->cfWriteShort = naWriteShort;
1728  else
1729  cf->cfWriteShort = naWriteLong;
1730 
1731  cf->cfRead = n2pRead;
1732  cf->cfDelete = naDelete;
1733  cf->cfSetMap = naSetMap;
1734  cf->cfGetDenom = naGetDenom;
1735  cf->cfGetNumerator = naGetNumerator;
1736  cf->cfRePart = naCopy;
1737  cf->cfCoeffWrite = n2pCoeffWrite;
1738  cf->cfNormalize = n2pNormalize;
1739  cf->cfKillChar = naKillChar;
1740 #ifdef LDEBUG
1741  cf->cfDBTest = naDBTest;
1742 #endif
1743  cf->cfGcd = naGcd;
1744  cf->cfNormalizeHelper = naLcmContent;
1745  cf->cfSize = naSize;
1746  cf->nCoeffIsEqual = n2pCoeffIsEqual;
1747  cf->cfInvers = n2pInvers;
1748  cf->convFactoryNSingN=naConvFactoryNSingN;
1749  cf->convSingNFactoryN=naConvSingNFactoryN;
1750  cf->cfParDeg = naParDeg;
1751 
1752  cf->iNumberOfParameters = rVar(R);
1753  cf->pParameterNames = (const char**)R->names;
1754  cf->cfParameter = naParameter;
1755  cf->has_simple_Inverse=FALSE;
1756  /* cf->has_simple_Alloc= FALSE; */
1757 
1758  if( nCoeff_is_Q(R->cf) )
1759  {
1760  cf->cfClearContent = naClearContent;
1761  cf->cfClearDenominators = naClearDenominators;
1762  }
1763 
1764  return FALSE;
1765 }
void n2pNormalize(number &a, const coeffs cf)
Definition: algext.cc:1537
void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
ring r
Definition: algext.h:37
BOOLEAN naIsZero(number a, const coeffs cf)
Definition: algext.cc:272
#define FALSE
Definition: auxiliary.h:96
number n2pInvers(number a, const coeffs cf)
Definition: algext.cc:1665
number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: algext.cc:1377
void naKillChar(coeffs cf)
Definition: algext.cc:1325
const char * n2pRead(const char *s, number *a, const coeffs cf)
Definition: algext.cc:1568
number naSub(number a, number b, const coeffs cf)
Definition: algext.cc:448
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
nMapFunc naSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type (n_algExt)
Definition: algext.cc:1017
number naInit(long i, const coeffs cf)
Definition: algext.cc:339
#define TRUE
Definition: auxiliary.h:100
number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition: algext.cc:1078
long naInt(number &a, const coeffs cf)
Definition: algext.cc:345
BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition: algext.cc:358
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
#define n2pRing
Definition: algext.cc:1521
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:581
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:1653
int naParDeg(number a, const coeffs cf)
Definition: algext.cc:1070
BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:378
char * n2pCoeffName(const coeffs cf)
Definition: algext.cc:1625
number naFarey(number p, number n, const coeffs cf)
Definition: algext.cc:1389
int naSize(number a, const coeffs cf)
Definition: algext.cc:712
BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition: algext.cc:287
number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: algext.cc:750
number naGetDenom(number &a, const coeffs cf)
Definition: algext.cc:309
BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)
Definition: algext.cc:233
#define assume(x)
Definition: mod2.h:390
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1104
number n2pMult(number a, number b, const coeffs cf)
Definition: algext.cc:1544
char * n2pCoeffString(const coeffs cf)
Definition: algext.cc:1597
number n2pDiv(number a, number b, const coeffs cf)
Definition: algext.cc:1552
void naWriteLong(number a, const coeffs cf)
Definition: algext.cc:570
static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:1577
number naLcmContent(number a, number b, const coeffs cf)
Definition: algext.cc:643
void n2pPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:1561
#define NULL
Definition: omList.c:12
number naAdd(number a, number b, const coeffs cf)
Definition: algext.cc:437
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: algext.cc:756
#define R
Definition: sirandom.c:27
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
number naGcd(number a, number b, const coeffs cf)
Definition: algext.cc:770
void naClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1309
number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: algext.cc:332
BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:315
BOOLEAN naIsMOne(number a, const coeffs cf)
Definition: algext.cc:323
void naWriteShort(number a, const coeffs cf)
Definition: algext.cc:588
number naGetNumerator(number &a, const coeffs cf)
Definition: algext.cc:304

◆ n2pInvers()

number n2pInvers ( number  a,
const coeffs  cf 
)

Definition at line 1665 of file algext.cc.

1666 {
1667  poly aa=(poly)a;
1668  if(p_IsConstant(aa, n2pRing))
1669  {
1670  poly p=p_Init(n2pRing);
1672  return (number)p;
1673  }
1674  else
1675  {
1676  WerrorS("not invertible");
1677  return NULL;
1678  }
1679 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define n2pRing
Definition: algext.cc:1521
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
#define n2pCoeffs
Definition: algext.cc:1527
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
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:564
#define NULL
Definition: omList.c:12
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:60
int p
Definition: cfModGcd.cc:4019
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1259

◆ n2pMult()

number n2pMult ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 1544 of file algext.cc.

1545 {
1546  n2pTest(a); n2pTest(b);
1547  if ((a == NULL)||(b == NULL)) return NULL;
1548  poly aTimesB = pp_Mult_qq((poly)a, (poly)b, n2pRing);
1549  return (number)aTimesB;
1550 }
#define n2pRing
Definition: algext.cc:1521
#define n2pTest(a)
ABSTRACT: numbers as polys in the ring K[a] Assuming that we have a coeffs object cf...
Definition: algext.cc:1514
CanonicalForm b
Definition: cfModGcd.cc:4044
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1090
#define NULL
Definition: omList.c:12

◆ n2pNormalize()

void n2pNormalize ( number &  a,
const coeffs  cf 
)

Definition at line 1537 of file algext.cc.

1538 {
1539  poly aa=(poly)a;
1540  p_Normalize(aa,n2pRing);
1541 }
#define n2pRing
Definition: algext.cc:1521
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732

◆ n2pPower()

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

Definition at line 1561 of file algext.cc.

1562 {
1563  n2pTest(a);
1564 
1565  *b= (number)p_Power((poly)a,exp,n2pRing);
1566 }
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
#define n2pRing
Definition: algext.cc:1521
#define n2pTest(a)
ABSTRACT: numbers as polys in the ring K[a] Assuming that we have a coeffs object cf...
Definition: algext.cc:1514
CanonicalForm b
Definition: cfModGcd.cc:4044
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2172

◆ n2pRead()

const char* n2pRead ( const char *  s,
number *  a,
const coeffs  cf 
)

Definition at line 1568 of file algext.cc.

1569 {
1570  poly aAsPoly;
1571  const char * result = p_Read(s, aAsPoly, n2pRing);
1572  *a = (number)aAsPoly;
1573  return result;
1574 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define n2pRing
Definition: algext.cc:1521
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1360
return result
Definition: facAbsBiFact.cc:76

◆ naAdd()

number naAdd ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 437 of file algext.cc.

438 {
439  naTest(a); naTest(b);
440  if (a == NULL) return naCopy(b, cf);
441  if (b == NULL) return naCopy(a, cf);
442  poly aPlusB = p_Add_q(p_Copy((poly)a, naRing),
443  p_Copy((poly)b, naRing), naRing);
444  //definiteReduce(aPlusB, naMinpoly, cf);
445  return (number)aPlusB;
446 }
#define naTest(a)
Definition: algext.cc:54
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
#define NULL
Definition: omList.c:12
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
#define naRing
Definition: algext.cc:61
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895

◆ naChineseRemainder()

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

Definition at line 1377 of file algext.cc.

1378 {
1379  poly *P=(poly*)omAlloc(rl*sizeof(poly*));
1380  number *X=(number *)omAlloc(rl*sizeof(number));
1381  int i;
1382  for(i=0;i<rl;i++) P[i]=p_Copy((poly)(x[i]),cf->extRing);
1383  poly result=p_ChineseRemainder(P,X,q,rl,inv_cache,cf->extRing);
1384  omFreeSize(X,rl*sizeof(number));
1385  omFreeSize(P,rl*sizeof(poly*));
1386  return ((number)result);
1387 }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#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:811
int i
Definition: cfEzgcd.cc:125
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, CFArray &inv_cache, const ring R)
Definition: p_polys.cc:83
Variable x
Definition: cfModGcd.cc:4023
return result
Definition: facAbsBiFact.cc:76

◆ naClearContent()

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

Definition at line 1104 of file algext.cc.

1105 {
1106  assume(cf != NULL);
1107  assume(getCoeffType(cf) == n_algExt);
1108  assume(nCoeff_is_Q_algext(cf)); // only over (Q[a]/m(a)), while the default impl. is used over Zp[a]/m(a) !
1109 
1110  const ring R = cf->extRing;
1111  assume(R != NULL);
1112  const coeffs Q = R->cf;
1113  assume(Q != NULL);
1114  assume(nCoeff_is_Q(Q));
1115 
1116  numberCollectionEnumerator.Reset();
1117 
1118  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
1119  {
1120  c = n_Init(1, cf);
1121  return;
1122  }
1123 
1124  naTest(numberCollectionEnumerator.Current());
1125 
1126  // part 1, find a small candidate for gcd
1127  int s1; int s=2147483647; // max. int
1128 
1129  const BOOLEAN lc_is_pos=naGreaterZero(numberCollectionEnumerator.Current(),cf);
1130 
1131  int normalcount = 0;
1132 
1133  poly cand1, cand;
1134 
1135  do
1136  {
1137  number& n = numberCollectionEnumerator.Current();
1138  naNormalize(n, cf); ++normalcount;
1139 
1140  naTest(n);
1141 
1142  cand1 = (poly)n;
1143 
1144  s1 = p_Deg(cand1, R); // naSize?
1145  if (s>s1)
1146  {
1147  cand = cand1;
1148  s = s1;
1149  }
1150  } while (numberCollectionEnumerator.MoveNext() );
1151 
1152 // assume( nlGreaterZero(cand,cf) ); // cand may be a negative integer!
1153 
1154  cand = p_Copy(cand, R);
1155  // part 2: compute gcd(cand,all coeffs)
1156 
1157  numberCollectionEnumerator.Reset();
1158 
1159  int length = 0;
1160  while (numberCollectionEnumerator.MoveNext() )
1161  {
1162  number& n = numberCollectionEnumerator.Current();
1163  ++length;
1164 
1165  if( (--normalcount) <= 0)
1166  naNormalize(n, cf);
1167 
1168  naTest(n);
1169 
1170 // p_InpGcd(cand, (poly)n, R);
1171 
1172  { // R->cf is QQ
1173  poly tmp=gcd_over_Q(cand,(poly)n,R);
1174  p_Delete(&cand,R);
1175  cand=tmp;
1176  }
1177 
1178 // cand1 = p_Gcd(cand,(poly)n, R); p_Delete(&cand, R); cand = cand1;
1179 
1180  assume( naGreaterZero((number)cand, cf) ); // ???
1181 /*
1182  if(p_IsConstant(cand,R))
1183  {
1184  c = cand;
1185 
1186  if(!lc_is_pos)
1187  {
1188  // make the leading coeff positive
1189  c = nlNeg(c, cf);
1190  numberCollectionEnumerator.Reset();
1191 
1192  while (numberCollectionEnumerator.MoveNext() )
1193  {
1194  number& nn = numberCollectionEnumerator.Current();
1195  nn = nlNeg(nn, cf);
1196  }
1197  }
1198  return;
1199  }
1200 */
1201 
1202  }
1203 
1204 
1205  // part3: all coeffs = all coeffs / cand
1206  if (!lc_is_pos)
1207  cand = p_Neg(cand, R);
1208 
1209  c = (number)cand; naTest(c);
1210 
1211  poly cInverse = (poly)naInvers(c, cf);
1212  assume(cInverse != NULL); // c is non-zero divisor!?
1213 
1214 
1215  numberCollectionEnumerator.Reset();
1216 
1217 
1218  while (numberCollectionEnumerator.MoveNext() )
1219  {
1220  number& n = numberCollectionEnumerator.Current();
1221 
1222  assume( length > 0 );
1223 
1224  if( --length > 0 )
1225  {
1226  assume( cInverse != NULL );
1227  n = (number) p_Mult_q(p_Copy(cInverse, R), (poly)n, R);
1228  }
1229  else
1230  {
1231  n = (number) p_Mult_q(cInverse, (poly)n, R);
1232  cInverse = NULL;
1233  assume(length == 0);
1234  }
1235 
1236  definiteReduce((poly &)n, naMinpoly, cf);
1237  }
1238 
1239  assume(length == 0);
1240  assume(cInverse == NULL); // p_Delete(&cInverse, R);
1241 
1242  // Quick and dirty fix for constant content clearing... !?
1243  CRecursivePolyCoeffsEnumerator<NAConverter> itr(numberCollectionEnumerator); // recursively treat the numbers as polys!
1244 
1245  number cc;
1246 
1247  n_ClearContent(itr, cc, Q); // TODO: get rid of (-LC) normalization!?
1248 
1249  // over alg. ext. of Q // takes over the input number
1250  c = (number) __p_Mult_nn( (poly)c, cc, R);
1251 // p_Mult_q(p_NSet(cc, R), , R);
1252 
1253  n_Delete(&cc, Q);
1254 
1255  // TODO: the above is not enough! need GCD's of polynomial coeffs...!
1256 /*
1257  // old and wrong part of p_Content
1258  if (rField_is_Q_a(r) && !CLEARENUMERATORS) // should not be used anymore if CLEARENUMERATORS is 1
1259  {
1260  // we only need special handling for alg. ext.
1261  if (getCoeffType(r->cf)==n_algExt)
1262  {
1263  number hzz = n_Init(1, r->cf->extRing->cf);
1264  p=ph;
1265  while (p!=NULL)
1266  { // each monom: coeff in Q_a
1267  poly c_n_n=(poly)pGetCoeff(p);
1268  poly c_n=c_n_n;
1269  while (c_n!=NULL)
1270  { // each monom: coeff in Q
1271  d=n_NormalizeHelper(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
1272  n_Delete(&hzz,r->cf->extRing->cf);
1273  hzz=d;
1274  pIter(c_n);
1275  }
1276  pIter(p);
1277  }
1278  // hzz contains the 1/lcm of all denominators in c_n_n
1279  h=n_Invers(hzz,r->cf->extRing->cf);
1280  n_Delete(&hzz,r->cf->extRing->cf);
1281  n_Normalize(h,r->cf->extRing->cf);
1282  if(!n_IsOne(h,r->cf->extRing->cf))
1283  {
1284  p=ph;
1285  while (p!=NULL)
1286  { // each monom: coeff in Q_a
1287  poly c_n=(poly)pGetCoeff(p);
1288  while (c_n!=NULL)
1289  { // each monom: coeff in Q
1290  d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
1291  n_Normalize(d,r->cf->extRing->cf);
1292  n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
1293  pGetCoeff(c_n)=d;
1294  pIter(c_n);
1295  }
1296  pIter(p);
1297  }
1298  }
1299  n_Delete(&h,r->cf->extRing->cf);
1300  }
1301  }
1302 */
1303 
1304 
1305 // c = n_Init(1, cf); assume(FALSE); // TODO: NOT YET IMPLEMENTED!!!
1306 }
STATIC_VAR jList * Q
Definition: janet.cc:30
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define naTest(a)
Definition: algext.cc:54
poly gcd_over_Q(poly f, poly g, const ring r)
helper routine for calling singclap_gcd_r
Definition: transext.cc:275
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:538
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:378
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:950
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
#define assume(x)
Definition: mod2.h:390
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).
number naInvers(number a, const coeffs cf)
Definition: algext.cc:818
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:421
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define naMinpoly
Definition: algext.cc:70
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:930
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
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:27
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
static FORCE_INLINE BOOLEAN nCoeff_is_Q_algext(const coeffs r)
is it an alg. ext. of Q?
Definition: coeffs.h:936
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730
int BOOLEAN
Definition: auxiliary.h:87
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1053
void naNormalize(number &a, const coeffs cf)
Definition: algext.cc:742
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
Definition: cfModGcd.cc:69

◆ naClearDenominators()

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

Definition at line 1309 of file algext.cc.

1310 {
1311  assume(cf != NULL);
1312  assume((getCoeffType(cf) == n_algExt)||(getCoeffType(cf) == n_polyExt));
1313  assume(nCoeff_is_Q_algext(cf)); // only over (Q[a]/m(a)), while the default impl. is used over Zp[a]/m(a) !
1314 
1315  assume(cf->extRing != NULL);
1316  const coeffs Q = cf->extRing->cf;
1317  assume(Q != NULL);
1318  assume(nCoeff_is_Q(Q));
1319  number n;
1320  CRecursivePolyCoeffsEnumerator<NAConverter> itr(numberCollectionEnumerator); // recursively treat the numbers as polys!
1321  n_ClearDenominators(itr, n, Q); // this should probably be fine...
1322  c = (number)p_NSet(n, cf->extRing); // over alg. ext. of Q // takes over the input number
1323 }
STATIC_VAR jList * Q
Definition: janet.cc:30
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1455
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
#define assume(x)
Definition: mod2.h:390
The main handler for Singular numbers which are suitable for Singular polynomials.
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:421
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
static FORCE_INLINE BOOLEAN nCoeff_is_Q_algext(const coeffs r)
is it an alg. ext. of Q?
Definition: coeffs.h:936
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:957
used to represent polys as coeffcients
Definition: coeffs.h:35

◆ naCoeffIsEqual()

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

Definition at line 678 of file algext.cc.

679 {
680  if (n_algExt != n) return FALSE;
681  AlgExtInfo *e = (AlgExtInfo *)param;
682  /* for extension coefficient fields we expect the underlying
683  polynomial rings to be IDENTICAL, i.e. the SAME OBJECT;
684  this expectation is based on the assumption that we have properly
685  registered cf and perform reference counting rather than creating
686  multiple copies of the same coefficient field/domain/ring */
687  if (naRing == e->r)
688  return TRUE;
689  /* (Note that then also the minimal ideals will necessarily be
690  the same, as they are attached to the ring.) */
691 
692  // NOTE: Q(a)[x] && Q(a)[y] should better share the _same_ Q(a)...
693  if( rEqual(naRing, e->r, TRUE) ) // also checks the equality of qideals
694  {
695  const ideal mi = naRing->qideal;
696  assume( IDELEMS(mi) == 1 );
697  const ideal ii = e->r->qideal;
698  assume( IDELEMS(ii) == 1 );
699 
700  // TODO: the following should be extended for 2 *equal* rings...
701  assume( p_EqualPolys(mi->m[0], ii->m[0], naRing, e->r) );
702 
703  rDelete(e->r);
704 
705  return TRUE;
706  }
707 
708  return FALSE;
709 
710 }
ring r
Definition: algext.h:37
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
#define assume(x)
Definition: mod2.h:390
#define IDELEMS(i)
Definition: simpleideals.h:23
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:1660
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4418
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
#define naRing
Definition: algext.cc:61

◆ naCoeffName()

char* naCoeffName ( const coeffs  r)

Definition at line 1354 of file algext.cc.

1355 {
1356  const char* const* p=n_ParameterNames(r);
1357  int l=0;
1358  int i;
1359  for(i=0; i<n_NumberOfParameters(r);i++)
1360  {
1361  l+=(strlen(p[i])+1);
1362  }
1363  STATIC_VAR char s[200];
1364  s[0]='\0';
1365  snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1366  char tt[2];
1367  tt[0]=',';
1368  tt[1]='\0';
1369  for(i=0; i<n_NumberOfParameters(r);i++)
1370  {
1371  strcat(s,tt);
1372  strcat(s,p[i]);
1373  }
1374  return s;
1375 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:796
#define STATIC_VAR
Definition: globaldefs.h:7
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
int l
Definition: cfEzgcd.cc:93

◆ naCoeffString()

char* naCoeffString ( const coeffs  r)

Definition at line 1331 of file algext.cc.

1332 {
1333  const char* const* p=n_ParameterNames(r);
1334  int l=0;
1335  int i;
1336  for(i=0; i<n_NumberOfParameters(r);i++)
1337  {
1338  l+=(strlen(p[i])+1);
1339  }
1340  char *s=(char *)omAlloc(l+10+1);
1341  s[0]='\0';
1342  snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1343  char tt[2];
1344  tt[0]=',';
1345  tt[1]='\0';
1346  for(i=0; i<n_NumberOfParameters(r);i++)
1347  {
1348  strcat(s,tt);
1349  strcat(s,p[i]);
1350  }
1351  return s;
1352 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:796
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
int l
Definition: cfEzgcd.cc:93

◆ naCoeffWrite()

void naCoeffWrite ( const coeffs  cf,
BOOLEAN  details 
)

Definition at line 387 of file algext.cc.

388 {
389  assume( cf != NULL );
390 
391  const ring A = cf->extRing;
392 
393  assume( A != NULL );
394  assume( A->cf != NULL );
395 
396  n_CoeffWrite(A->cf, details);
397 
398 // rWrite(A);
399 
400  const int P = rVar(A);
401  assume( P > 0 );
402 
403  PrintS("[");
404 
405  for (int nop=0; nop < P; nop ++)
406  {
407  Print("%s", rRingVar(nop, A));
408  if (nop!=P-1) PrintS(", ");
409  }
410 
411  PrintS("]/(");
412 
413  const ideal I = A->qideal;
414 
415  assume( I != NULL );
416  assume( IDELEMS(I) == 1 );
417 
418 
419  if ( details )
420  {
421  p_Write0( I->m[0], A);
422  PrintS(")");
423  }
424  else
425  PrintS("...)");
426 
427 /*
428  char *x = rRingVar(0, A);
429 
430  Print("// Coefficients live in the extension field K[%s]/<f(%s)>\n", x, x);
431  Print("// with the minimal polynomial f(%s) = %s\n", x,
432  p_String(A->qideal->m[0], A));
433  PrintS("// and K: ");
434 */
435 }
#define Print
Definition: emacs.cc:80
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
#define assume(x)
Definition: mod2.h:390
#define A
Definition: sirandom.c:24
void PrintS(const char *s)
Definition: reporter.cc:284
static char * rRingVar(short i, const ring r)
Definition: ring.h:572
#define IDELEMS(i)
Definition: simpleideals.h:23
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:332
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:741
#define NULL
Definition: omList.c:12

◆ naConvFactoryNSingN()

number naConvFactoryNSingN ( const CanonicalForm  n,
const coeffs  cf 
)

Definition at line 750 of file algext.cc.

751 {
752  if (n.isZero()) return NULL;
753  poly p=convFactoryPSingP(n,naRing);
754  return (number)p;
755 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:40
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
int p
Definition: cfModGcd.cc:4019

◆ naConvSingNFactoryN()

CanonicalForm naConvSingNFactoryN ( number  n,
BOOLEAN  ,
const coeffs  cf 
)

Definition at line 756 of file algext.cc.

757 {
758  naTest(n);
759  if (n==NULL) return CanonicalForm(0);
760 
761  return convSingPFactoryP((poly)n,naRing);
762 }
#define naTest(a)
Definition: algext.cc:54
factory&#39;s main class
Definition: canonicalform.h:77
#define NULL
Definition: omList.c:12
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:85
#define naRing
Definition: algext.cc:61

◆ naCopy()

number naCopy ( number  a,
const coeffs  cf 
)

Definition at line 296 of file algext.cc.

297 {
298  naTest(a);
299  if (a == NULL) return NULL;
300  if (((poly)a)==naMinpoly) return a;
301  return (number)p_Copy((poly)a, naRing);
302 }
#define naTest(a)
Definition: algext.cc:54
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61

◆ naCopyTrans2AlgExt()

number naCopyTrans2AlgExt ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 890 of file algext.cc.

891 {
892  assume (nCoeff_is_transExt (src));
893  assume (nCoeff_is_algExt (dst));
894  fraction fa=(fraction)a;
895  poly p, q;
896  if (rSamePolyRep(src->extRing, dst->extRing))
897  {
898  p = p_Copy(NUM(fa),src->extRing);
899  if (!DENIS1(fa))
900  {
901  q = p_Copy(DEN(fa),src->extRing);
902  assume (q != NULL);
903  }
904  }
905  else
906  {
907  assume ((strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)));
908 
909  nMapFunc nMap= n_SetMap (src->extRing->cf, dst->extRing->cf);
910 
911  assume (nMap != NULL);
912  p= p_PermPoly (NUM (fa), NULL, src->extRing, dst->extRing,nMap, NULL,rVar (src->extRing));
913  if (!DENIS1(fa))
914  {
915  q= p_PermPoly (DEN (fa), NULL, src->extRing, dst->extRing,nMap, NULL,rVar (src->extRing));
916  assume (q != NULL);
917  }
918  }
919  definiteReduce(p, dst->extRing->qideal->m[0], dst);
920  p_Test (p, dst->extRing);
921  if (!DENIS1(fa))
922  {
923  definiteReduce(q, dst->extRing->qideal->m[0], dst);
924  p_Test (q, dst->extRing);
925  if (q != NULL)
926  {
927  number t= naDiv ((number)p,(number)q, dst);
928  p_Delete (&p, dst->extRing);
929  p_Delete (&q, dst->extRing);
930  return t;
931  }
932  WerrorS ("mapping denominator to zero");
933  }
934  return (number) p;
935 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
void WerrorS(const char *s)
Definition: feFopen.cc:24
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4036
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:932
number naDiv(number a, number b, const coeffs cf)
Definition: algext.cc:469
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:4392
#define assume(x)
Definition: mod2.h:390
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition: ring.cc:1712
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:940
static char * rRingVar(short i, const ring r)
Definition: ring.h:572
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:721
#define p_Test(p, r)
Definition: p_polys.h:162
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730

◆ naDBTest()

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

Definition at line 233 of file algext.cc.

234 {
235  if (a == NULL) return TRUE;
236  p_Test((poly)a, naRing);
237  if (getCoeffType(cf)==n_algExt)
238  {
239  if((((poly)a)!=naMinpoly)
241  && (p_Totaldegree((poly)a, naRing)> 1)) // allow to output par(1)
242  {
243  dReportError("deg >= deg(minpoly) in %s:%d\n",f,l);
244  return FALSE;
245  }
246  }
247  return TRUE;
248 }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define p_Test(p, r)
Definition: p_polys.h:162
#define naMinpoly
Definition: algext.cc:70
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
int dReportError(const char *fmt,...)
Definition: dError.cc:43
#define naRing
Definition: algext.cc:61
int l
Definition: cfEzgcd.cc:93

◆ naDelete()

void naDelete ( number *  a,
const coeffs  cf 
)

Definition at line 278 of file algext.cc.

279 {
280  if (*a == NULL) return;
281  if (((poly)*a)==naMinpoly) { *a=NULL;return;}
282  poly aAsPoly = (poly)(*a);
283  p_Delete(&aAsPoly, naRing);
284  *a = NULL;
285 }
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61

◆ naDiv()

number naDiv ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 469 of file algext.cc.

470 {
471  naTest(a); naTest(b);
472  if (b == NULL) WerrorS(nDivBy0);
473  if (a == NULL) return NULL;
474  poly bInverse = (poly)naInvers(b, cf);
475  if(bInverse != NULL) // b is non-zero divisor!
476  {
477  poly aDivB = p_Mult_q(p_Copy((poly)a, naRing), bInverse, naRing);
478  definiteReduce(aDivB, naMinpoly, cf);
479  p_Normalize(aDivB,naRing);
480  return (number)aDivB;
481  }
482  return NULL;
483 }
#define naTest(a)
Definition: algext.cc:54
void WerrorS(const char *s)
Definition: feFopen.cc:24
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
const char *const nDivBy0
Definition: numbers.h:88
number naInvers(number a, const coeffs cf)
Definition: algext.cc:818
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1053

◆ naEqual()

BOOLEAN naEqual ( number  a,
number  b,
const coeffs  cf 
)

simple tests

Definition at line 287 of file algext.cc.

288 {
289  naTest(a); naTest(b);
290  /// simple tests
291  if (a == NULL) return (b == NULL);
292  if (b == NULL) return (a == NULL);
293  return p_EqualPolys((poly)a,(poly)b,naRing);
294 }
#define naTest(a)
Definition: algext.cc:54
CanonicalForm b
Definition: cfModGcd.cc:4044
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4418
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61

◆ naFarey()

number naFarey ( number  p,
number  n,
const coeffs  cf 
)

Definition at line 1389 of file algext.cc.

1390 {
1391  // n is really a bigint
1392  poly result=p_Farey(p_Copy((poly)p,cf->extRing),n,cf->extRing);
1393  return ((number)result);
1394 }
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
poly p_Farey(poly p, number N, const ring r)
Definition: p_polys.cc:50
int p
Definition: cfModGcd.cc:4019
return result
Definition: facAbsBiFact.cc:76

◆ naGcd()

number naGcd ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 770 of file algext.cc.

771 {
772  if (a==NULL) return naCopy(b,cf);
773  if (b==NULL) return naCopy(a,cf);
774 
775  poly ax=(poly)a;
776  poly bx=(poly)b;
777  if (pNext(ax)!=NULL)
778  return (number)p_Copy(ax, naRing);
779  else
780  {
781  if(nCoeff_is_Zp(naRing->cf))
782  return naInit(1,cf);
783  else
784  {
785  number x = n_Copy(pGetCoeff((poly)a),naRing->cf);
786  if (n_IsOne(x,naRing->cf))
787  return (number)p_NSet(x,naRing);
788  while (pNext(ax)!=NULL)
789  {
790  pIter(ax);
791  number y = n_SubringGcd(x, pGetCoeff(ax), naRing->cf);
792  n_Delete(&x,naRing->cf);
793  x = y;
794  if (n_IsOne(x,naRing->cf))
795  return (number)p_NSet(x,naRing);
796  }
797  do
798  {
799  number y = n_SubringGcd(x, pGetCoeff(bx), naRing->cf);
800  n_Delete(&x,naRing->cf);
801  x = y;
802  if (n_IsOne(x,naRing->cf))
803  return (number)p_NSet(x,naRing);
804  pIter(bx);
805  }
806  while (bx!=NULL);
807  return (number)p_NSet(x,naRing);
808  }
809  }
810 #if 0
811  naTest(a); naTest(b);
812  const ring R = naRing;
813  return (number) singclap_gcd_r((poly)a, (poly)b, R);
814 #endif
815 // return (number)p_Gcd((poly)a, (poly)b, naRing);
816 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
poly singclap_gcd_r(poly f, poly g, const ring r)
Definition: clapsing.cc:42
#define naTest(a)
Definition: algext.cc:54
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:822
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:468
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1455
number naInit(long i, const coeffs cf)
Definition: algext.cc:339
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
#define pIter(p)
Definition: monomials.h:37
CanonicalForm b
Definition: cfModGcd.cc:4044
#define NULL
Definition: omList.c:12
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:451
#define R
Definition: sirandom.c:27
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
Variable x
Definition: cfModGcd.cc:4023
#define pNext(p)
Definition: monomials.h:36
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:688
#define naRing
Definition: algext.cc:61
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455

◆ naGenMap()

number naGenMap ( number  a,
const coeffs  cf,
const coeffs  dst 
)

Definition at line 972 of file algext.cc.

973 {
974  if (a==NULL) return NULL;
975 
976  const ring rSrc = cf->extRing;
977  const ring rDst = dst->extRing;
978 
979  const nMapFunc nMap=n_SetMap(rSrc->cf,rDst->cf);
980  poly f = (poly)a;
981  poly g = prMapR(f, nMap, rSrc, rDst);
982 
983  n_Test((number)g, dst);
984  return (number)g;
985 }
g
Definition: cfModGcd.cc:4031
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:45
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:738
FILE * f
Definition: checklibs.c:9
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:721
#define NULL
Definition: omList.c:12

◆ naGenTrans2AlgExt()

number naGenTrans2AlgExt ( number  a,
const coeffs  cf,
const coeffs  dst 
)

Definition at line 987 of file algext.cc.

988 {
989  if (a==NULL) return NULL;
990 
991  const ring rSrc = cf->extRing;
992  const ring rDst = dst->extRing;
993 
994  const nMapFunc nMap=n_SetMap(rSrc->cf,rDst->cf);
995  fraction f = (fraction)a;
996  poly g = prMapR(NUM(f), nMap, rSrc, rDst);
997 
998  number result=NULL;
999  poly h = NULL;
1000 
1001  if (!DENIS1(f))
1002  h = prMapR(DEN(f), nMap, rSrc, rDst);
1003 
1004  if (h!=NULL)
1005  {
1006  result=naDiv((number)g,(number)h,dst);
1007  p_Delete(&g,dst->extRing);
1008  p_Delete(&h,dst->extRing);
1009  }
1010  else
1011  result=(number)g;
1012 
1013  n_Test((number)result, dst);
1014  return (number)result;
1015 }
g
Definition: cfModGcd.cc:4031
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:45
number naDiv(number a, number b, const coeffs cf)
Definition: algext.cc:469
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:738
FILE * f
Definition: checklibs.c:9
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:721
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
STATIC_VAR Poly * h
Definition: janet.cc:971
#define NULL
Definition: omList.c:12
return result
Definition: facAbsBiFact.cc:76

◆ naGetDenom()

number naGetDenom ( number &  a,
const coeffs  cf 
)

Definition at line 309 of file algext.cc.

310 {
311  naTest(a);
312  return naInit(1, cf);
313 }
#define naTest(a)
Definition: algext.cc:54
number naInit(long i, const coeffs cf)
Definition: algext.cc:339

◆ naGetNumerator()

number naGetNumerator ( number &  a,
const coeffs  cf 
)

Definition at line 304 of file algext.cc.

305 {
306  return naCopy(a, cf);
307 }
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296

◆ naGreater()

BOOLEAN naGreater ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 358 of file algext.cc.

359 {
360  naTest(a); naTest(b);
361  if (naIsZero(a, cf))
362  {
363  if (naIsZero(b, cf)) return FALSE;
364  return !n_GreaterZero(pGetCoeff((poly)b),naCoeffs);
365  }
366  if (naIsZero(b, cf))
367  {
368  return n_GreaterZero(pGetCoeff((poly)a),naCoeffs);
369  }
370  int aDeg = p_Totaldegree((poly)a, naRing);
371  int bDeg = p_Totaldegree((poly)b, naRing);
372  if (aDeg>bDeg) return TRUE;
373  if (aDeg<bDeg) return FALSE;
374  return n_Greater(pGetCoeff((poly)a),pGetCoeff((poly)b),naCoeffs);
375 }
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:511
#define naTest(a)
Definition: algext.cc:54
BOOLEAN naIsZero(number a, const coeffs cf)
Definition: algext.cc:272
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
CanonicalForm b
Definition: cfModGcd.cc:4044
#define naCoeffs
Definition: algext.cc:67
#define naRing
Definition: algext.cc:61
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:494

◆ naGreaterZero()

BOOLEAN naGreaterZero ( number  a,
const coeffs  cf 
)

forward declarations

Definition at line 378 of file algext.cc.

379 {
380  naTest(a);
381  if (a == NULL) return FALSE;
382  if (n_GreaterZero(p_GetCoeff((poly)a, naRing), naCoeffs)) return TRUE;
383  if (p_Totaldegree((poly)a, naRing) > 0) return TRUE;
384  return FALSE;
385 }
#define naTest(a)
Definition: algext.cc:54
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446
#define naCoeffs
Definition: algext.cc:67
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define naRing
Definition: algext.cc:61
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:494

◆ naInit()

number naInit ( long  i,
const coeffs  cf 
)

Definition at line 339 of file algext.cc.

340 {
341  if (i == 0) return NULL;
342  else return (number)p_ISet(i, naRing);
343 }
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287

◆ naInitChar()

BOOLEAN naInitChar ( coeffs  cf,
void *  infoStruct 
)

Initialize the coeffs object.

first check whether cf->extRing != NULL and delete old ring???

Definition at line 1397 of file algext.cc.

1398 {
1399  assume( infoStruct != NULL );
1400 
1401  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1402  /// first check whether cf->extRing != NULL and delete old ring???
1403 
1404  assume(e->r != NULL); // extRing;
1405  assume(e->r->cf != NULL); // extRing->cf;
1406 
1407  assume((e->r->qideal != NULL) && // minideal has one
1408  (IDELEMS(e->r->qideal) == 1) && // non-zero generator
1409  (e->r->qideal->m[0] != NULL) ); // at m[0];
1410 
1411  assume( cf != NULL );
1412  assume(getCoeffType(cf) == n_algExt); // coeff type;
1413 
1414  e->r->ref ++; // increase the ref.counter for the ground poly. ring!
1415  const ring R = e->r; // no copy!
1416  cf->extRing = R;
1417 
1418  /* propagate characteristic up so that it becomes
1419  directly accessible in cf: */
1420  cf->ch = R->cf->ch;
1421 
1422  cf->is_field=TRUE;
1423  cf->is_domain=TRUE;
1424  cf->rep=n_rep_poly;
1425 
1426  #ifdef LDEBUG
1427  p_Test((poly)naMinpoly, naRing);
1428  #endif
1429 
1430  cf->cfCoeffString = naCoeffString;
1431  cf->cfCoeffName = naCoeffName;
1432 
1433  cf->cfGreaterZero = naGreaterZero;
1434  cf->cfGreater = naGreater;
1435  cf->cfEqual = naEqual;
1436  cf->cfIsZero = naIsZero;
1437  cf->cfIsOne = naIsOne;
1438  cf->cfIsMOne = naIsMOne;
1439  cf->cfInit = naInit;
1440  cf->cfFarey = naFarey;
1441  cf->cfChineseRemainder= naChineseRemainder;
1442  cf->cfInt = naInt;
1443  cf->cfInpNeg = naNeg;
1444  cf->cfAdd = naAdd;
1445  cf->cfSub = naSub;
1446  cf->cfMult = naMult;
1447  cf->cfDiv = naDiv;
1448  cf->cfExactDiv = naDiv;
1449  cf->cfPower = naPower;
1450  cf->cfCopy = naCopy;
1451 
1452  cf->cfWriteLong = naWriteLong;
1453 
1454  if( rCanShortOut(naRing) )
1455  cf->cfWriteShort = naWriteShort;
1456  else
1457  cf->cfWriteShort = naWriteLong;
1458 
1459  cf->cfRead = naRead;
1460  cf->cfDelete = naDelete;
1461  cf->cfSetMap = naSetMap;
1462  cf->cfGetDenom = naGetDenom;
1463  cf->cfGetNumerator = naGetNumerator;
1464  cf->cfRePart = naCopy;
1465  cf->cfCoeffWrite = naCoeffWrite;
1466  cf->cfNormalize = naNormalize;
1467  cf->cfKillChar = naKillChar;
1468 #ifdef LDEBUG
1469  cf->cfDBTest = naDBTest;
1470 #endif
1471  cf->cfGcd = naGcd;
1472  cf->cfNormalizeHelper = naLcmContent;
1473  cf->cfSize = naSize;
1474  cf->nCoeffIsEqual = naCoeffIsEqual;
1475  cf->cfInvers = naInvers;
1476  cf->convFactoryNSingN=naConvFactoryNSingN;
1477  cf->convSingNFactoryN=naConvSingNFactoryN;
1478  cf->cfParDeg = naParDeg;
1479 
1480  cf->iNumberOfParameters = rVar(R);
1481  cf->pParameterNames = (const char**)R->names;
1482  cf->cfParameter = naParameter;
1483  cf->has_simple_Inverse= R->cf->has_simple_Inverse;
1484  /* cf->has_simple_Alloc= FALSE; */
1485 
1486  if( nCoeff_is_Q(R->cf) )
1487  {
1488  cf->cfClearContent = naClearContent;
1489  cf->cfClearDenominators = naClearDenominators;
1490  }
1491 
1492  return FALSE;
1493 }
void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
ring r
Definition: algext.h:37
BOOLEAN naIsZero(number a, const coeffs cf)
Definition: algext.cc:272
char * naCoeffName(const coeffs r)
Definition: algext.cc:1354
#define FALSE
Definition: auxiliary.h:96
number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: algext.cc:1377
void naKillChar(coeffs cf)
Definition: algext.cc:1325
void naPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:493
number naSub(number a, number b, const coeffs cf)
Definition: algext.cc:448
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
const char * naRead(const char *s, number *a, const coeffs cf)
Definition: algext.cc:606
nMapFunc naSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type (n_algExt)
Definition: algext.cc:1017
number naInit(long i, const coeffs cf)
Definition: algext.cc:339
#define TRUE
Definition: auxiliary.h:100
number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition: algext.cc:1078
long naInt(number &a, const coeffs cf)
Definition: algext.cc:345
BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition: algext.cc:358
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
char * naCoeffString(const coeffs r)
Definition: algext.cc:1331
static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:678
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:581
int naParDeg(number a, const coeffs cf)
Definition: algext.cc:1070
(poly), see algext.h
Definition: coeffs.h:113
BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:378
number naFarey(number p, number n, const coeffs cf)
Definition: algext.cc:1389
int naSize(number a, const coeffs cf)
Definition: algext.cc:712
BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition: algext.cc:287
number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: algext.cc:750
number naDiv(number a, number b, const coeffs cf)
Definition: algext.cc:469
number naGetDenom(number &a, const coeffs cf)
Definition: algext.cc:309
BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)
Definition: algext.cc:233
#define assume(x)
Definition: mod2.h:390
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1104
number naMult(number a, number b, const coeffs cf)
Definition: algext.cc:459
void naWriteLong(number a, const coeffs cf)
Definition: algext.cc:570
#define IDELEMS(i)
Definition: simpleideals.h:23
number naInvers(number a, const coeffs cf)
Definition: algext.cc:818
void naCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:387
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define p_Test(p, r)
Definition: p_polys.h:162
number naLcmContent(number a, number b, const coeffs cf)
Definition: algext.cc:643
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
number naAdd(number a, number b, const coeffs cf)
Definition: algext.cc:437
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: algext.cc:756
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
#define R
Definition: sirandom.c:27
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
number naGcd(number a, number b, const coeffs cf)
Definition: algext.cc:770
void naClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1309
number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: algext.cc:332
#define naRing
Definition: algext.cc:61
BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:315
BOOLEAN naIsMOne(number a, const coeffs cf)
Definition: algext.cc:323
void naWriteShort(number a, const coeffs cf)
Definition: algext.cc:588
void naNormalize(number &a, const coeffs cf)
Definition: algext.cc:742
number naGetNumerator(number &a, const coeffs cf)
Definition: algext.cc:304

◆ naInt()

long naInt ( number &  a,
const coeffs  cf 
)

Definition at line 345 of file algext.cc.

346 {
347  naTest(a);
348  poly aAsPoly = (poly)a;
349  if(aAsPoly == NULL)
350  return 0;
351  if (!p_IsConstant(aAsPoly, naRing))
352  return 0;
353  assume( aAsPoly != NULL );
354  return n_Int(p_GetCoeff(aAsPoly, naRing), naCoeffs);
355 }
#define naTest(a)
Definition: algext.cc:54
#define naCoeffs
Definition: algext.cc:67
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:547
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define naRing
Definition: algext.cc:61

◆ naInvers()

number naInvers ( number  a,
const coeffs  cf 
)

Definition at line 818 of file algext.cc.

819 {
820  naTest(a);
821  if (a == NULL) WerrorS(nDivBy0);
822 
823  poly aFactor = NULL; poly mFactor = NULL; poly theGcd = NULL;
824 // singclap_extgcd!
825  const BOOLEAN ret = singclap_extgcd ((poly)a, naMinpoly, theGcd, aFactor, mFactor, naRing);
826 
827  assume( !ret );
828 
829 // if( ret ) theGcd = p_ExtGcd((poly)a, aFactor, naMinpoly, mFactor, naRing);
830 
831  naTest((number)theGcd); naTest((number)aFactor); naTest((number)mFactor);
832  p_Delete(&mFactor, naRing);
833 
834  // /* the gcd must be 1 since naMinpoly is irreducible and a != NULL: */
835  // assume(naIsOne((number)theGcd, cf));
836 
837  if( !naIsOne((number)theGcd, cf) )
838  {
839  WerrorS("zero divisor found - your minpoly is not irreducible");
840  p_Delete(&aFactor, naRing); aFactor = NULL;
841  }
842  p_Delete(&theGcd, naRing);
843 
844  return (number)(aFactor);
845 }
#define naTest(a)
Definition: algext.cc:54
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define assume(x)
Definition: mod2.h:390
const char *const nDivBy0
Definition: numbers.h:88
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition: clapsing.cc:423
#define naRing
Definition: algext.cc:61
BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:315
int BOOLEAN
Definition: auxiliary.h:87

◆ naIsMOne()

BOOLEAN naIsMOne ( number  a,
const coeffs  cf 
)

Definition at line 323 of file algext.cc.

324 {
325  naTest(a);
326  poly aAsPoly = (poly)a;
327  if ((a==NULL) || (!p_IsConstant(aAsPoly, naRing))) return FALSE;
328  return n_IsMOne(p_GetCoeff(aAsPoly, naRing), naCoeffs);
329 }
#define naTest(a)
Definition: algext.cc:54
#define FALSE
Definition: auxiliary.h:96
#define naCoeffs
Definition: algext.cc:67
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define naRing
Definition: algext.cc:61
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:472

◆ naIsOne()

BOOLEAN naIsOne ( number  a,
const coeffs  cf 
)

Definition at line 315 of file algext.cc.

316 {
317  naTest(a);
318  poly aAsPoly = (poly)a;
319  if ((a==NULL) || (!p_IsConstant(aAsPoly, naRing))) return FALSE;
320  return n_IsOne(p_GetCoeff(aAsPoly, naRing), naCoeffs);
321 }
#define naTest(a)
Definition: algext.cc:54
#define FALSE
Definition: auxiliary.h:96
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:468
#define naCoeffs
Definition: algext.cc:67
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define naRing
Definition: algext.cc:61

◆ naIsParam()

int naIsParam ( number  m,
const coeffs  cf 
)

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

Definition at line 1093 of file algext.cc.

1094 {
1095  assume((getCoeffType(cf) == n_algExt)||(getCoeffType(cf) == n_polyExt));
1096 
1097  const ring R = cf->extRing;
1098  assume( R != NULL );
1099 
1100  return p_Var( (poly)m, R );
1101 }
#define assume(x)
Definition: mod2.h:390
int m
Definition: cfEzgcd.cc:121
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
#define R
Definition: sirandom.c:27
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4562
used to represent polys as coeffcients
Definition: coeffs.h:35

◆ naIsZero()

BOOLEAN naIsZero ( number  a,
const coeffs  cf 
)

Definition at line 272 of file algext.cc.

273 {
274  naTest(a);
275  return (a == NULL);
276 }
#define naTest(a)
Definition: algext.cc:54
#define NULL
Definition: omList.c:12

◆ naKillChar()

void naKillChar ( coeffs  cf)

Definition at line 1325 of file algext.cc.

1326 {
1327  if ((--cf->extRing->ref) == 0)
1328  rDelete(cf->extRing);
1329 }
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448

◆ naLcmContent()

number naLcmContent ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 643 of file algext.cc.

644 {
645  if (nCoeff_is_Zp(naRing->cf)) return naCopy(a,cf);
646 #if 0
647  else {
648  number g = ndGcd(a, b, cf);
649  return g;
650  }
651 #else
652  {
653  a=(number)p_Copy((poly)a,naRing);
654  number t=napNormalizeHelper(b,cf);
655  if(!n_IsOne(t,naRing->cf))
656  {
657  number bt, rr;
658  poly xx=(poly)a;
659  while (xx!=NULL)
660  {
661  bt = n_SubringGcd(t, pGetCoeff(xx), naRing->cf);
662  rr = n_Mult(t, pGetCoeff(xx), naRing->cf);
663  n_Delete(&pGetCoeff(xx),naRing->cf);
664  pGetCoeff(xx) = n_Div(rr, bt, naRing->cf);
665  n_Normalize(pGetCoeff(xx),naRing->cf);
666  n_Delete(&bt,naRing->cf);
667  n_Delete(&rr,naRing->cf);
668  pIter(xx);
669  }
670  }
671  n_Delete(&t,naRing->cf);
672  return (number) a;
673  }
674 #endif
675 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:822
number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:161
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:468
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
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:44
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
#define pIter(p)
Definition: monomials.h:37
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:636
CanonicalForm b
Definition: cfModGcd.cc:4044
number napNormalizeHelper(number b, const coeffs cf)
Definition: algext.cc:629
#define NULL
Definition: omList.c:12
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:615
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:688
#define naRing
Definition: algext.cc:61
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455

◆ naMap00()

number naMap00 ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 848 of file algext.cc.

849 {
850  if (n_IsZero(a, src)) return NULL;
851  assume(src->rep == dst->extRing->cf->rep);
852  poly result = p_One(dst->extRing);
853  p_SetCoeff(result, n_Copy(a, src), dst->extRing);
854  return (number)result;
855 }
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
poly p_One(const ring r)
Definition: p_polys.cc:1303
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:12
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:451
return result
Definition: facAbsBiFact.cc:76

◆ naMap0P()

number naMap0P ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 938 of file algext.cc.

939 {
940  if (n_IsZero(a, src)) return NULL;
941  // int p = rChar(dst->extRing);
942 
943  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 pZ
944 
945  poly result = p_NSet(q, dst->extRing);
946 
947  return (number)result;
948 }
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1435
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1455
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:12
return result
Definition: facAbsBiFact.cc:76

◆ naMapP0()

number naMapP0 ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 870 of file algext.cc.

871 {
872  if (n_IsZero(a, src)) return NULL;
873  /* mapping via intermediate int: */
874  int n = n_Int(a, src);
875  number q = n_Init(n, dst->extRing->cf);
876  poly result = p_One(dst->extRing);
877  p_SetCoeff(result, q, dst->extRing);
878  return (number)result;
879 }
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:538
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
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:547
poly p_One(const ring r)
Definition: p_polys.cc:1303
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:12
return result
Definition: facAbsBiFact.cc:76

◆ naMapPP()

number naMapPP ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 951 of file algext.cc.

952 {
953  if (n_IsZero(a, src)) return NULL;
954  assume(src == dst->extRing->cf);
955  poly result = p_One(dst->extRing);
956  p_SetCoeff(result, n_Copy(a, src), dst->extRing);
957  return (number)result;
958 }
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
poly p_One(const ring r)
Definition: p_polys.cc:1303
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:12
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:451
return result
Definition: facAbsBiFact.cc:76

◆ naMapUP()

number naMapUP ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 961 of file algext.cc.

962 {
963  if (n_IsZero(a, src)) return NULL;
964  /* mapping via intermediate int: */
965  int n = n_Int(a, src);
966  number q = n_Init(n, dst->extRing->cf);
967  poly result = p_One(dst->extRing);
968  p_SetCoeff(result, q, dst->extRing);
969  return (number)result;
970 }
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:538
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
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:547
poly p_One(const ring r)
Definition: p_polys.cc:1303
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:12
return result
Definition: facAbsBiFact.cc:76

◆ naMapZ0()

number naMapZ0 ( number  a,
const coeffs  src,
const coeffs  dst 
)

Definition at line 858 of file algext.cc.

859 {
860  if (n_IsZero(a, src)) return NULL;
861  poly result = p_One(dst->extRing);
862  nMapFunc nMap=n_SetMap(src,dst->extRing->cf);
863  p_SetCoeff(result, nMap(a, src, dst->extRing->cf), dst->extRing);
864  if (n_IsZero(pGetCoeff(result),dst->extRing->cf))
865  p_Delete(&result,dst->extRing);
866  return (number)result;
867 }
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
poly p_One(const ring r)
Definition: p_polys.cc:1303
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
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:721
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define NULL
Definition: omList.c:12
return result
Definition: facAbsBiFact.cc:76

◆ naMult()

number naMult ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 459 of file algext.cc.

460 {
461  naTest(a); naTest(b);
462  if ((a == NULL)||(b == NULL)) return NULL;
463  poly aTimesB = pp_Mult_qq((poly)a, (poly)b, naRing);
464  definiteReduce(aTimesB, naMinpoly, cf);
465  p_Normalize(aTimesB,naRing);
466  return (number)aTimesB;
467 }
#define naTest(a)
Definition: algext.cc:54
CanonicalForm b
Definition: cfModGcd.cc:4044
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1090
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730

◆ naNeg()

number naNeg ( number  a,
const coeffs  cf 
)

this is in-place, modifies a

Definition at line 332 of file algext.cc.

333 {
334  naTest(a);
335  if (a != NULL) a = (number)p_Neg((poly)a, naRing);
336  return a;
337 }
#define naTest(a)
Definition: algext.cc:54
#define NULL
Definition: omList.c:12
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
#define naRing
Definition: algext.cc:61

◆ naNormalize()

void naNormalize ( number &  a,
const coeffs  cf 
)

Definition at line 742 of file algext.cc.

743 {
744  poly aa=(poly)a;
745  if (aa!=naMinpoly)
746  definiteReduce(aa,naMinpoly,cf);
747  a=(number)aa;
748 }
#define naMinpoly
Definition: algext.cc:70
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730

◆ naParameter()

number naParameter ( const int  iParameter,
const coeffs  cf 
)

return the specified parameter as a number in the given alg. field

Definition at line 1078 of file algext.cc.

1079 {
1080  assume(getCoeffType(cf) == n_algExt);
1081 
1082  const ring R = cf->extRing;
1083  assume( R != NULL );
1084  assume( 0 < iParameter && iParameter <= rVar(R) );
1085 
1086  poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
1087 
1088  return (number) p;
1089 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
poly p_One(const ring r)
Definition: p_polys.cc:1303
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
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:487
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
#define R
Definition: sirandom.c:27
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
int p
Definition: cfModGcd.cc:4019

◆ naParDeg()

int naParDeg ( number  a,
const coeffs  cf 
)

Definition at line 1070 of file algext.cc.

1071 {
1072  if (a == NULL) return -1;
1073  poly aa=(poly)a;
1074  return cf->extRing->pFDeg(aa,cf->extRing);
1075 }
#define NULL
Definition: omList.c:12

◆ napNormalizeHelper()

number napNormalizeHelper ( number  b,
const coeffs  cf 
)

Definition at line 629 of file algext.cc.

630 {
631  number h=n_Init(1,naRing->cf);
632  poly bb=(poly)b;
633  number d;
634  while(bb!=NULL)
635  {
636  d=n_NormalizeHelper(h,pGetCoeff(bb), naRing->cf);
637  n_Delete(&h,naRing->cf);
638  h=d;
639  pIter(bb);
640  }
641  return h;
642 }
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:538
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:717
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
#define pIter(p)
Definition: monomials.h:37
CanonicalForm b
Definition: cfModGcd.cc:4044
STATIC_VAR Poly * h
Definition: janet.cc:971
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455

◆ naPower()

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

Definition at line 493 of file algext.cc.

494 {
495  naTest(a);
496 
497  /* special cases first */
498  if (a == NULL)
499  {
500  if (exp >= 0) *b = NULL;
501  else WerrorS(nDivBy0);
502  return;
503  }
504  else if (exp == 0) { *b = naInit(1, cf); return; }
505  else if (exp == 1) { *b = naCopy(a, cf); return; }
506  else if (exp == -1) { *b = naInvers(a, cf); return; }
507 
508  int expAbs = exp; if (expAbs < 0) expAbs = -expAbs;
509 
510  /* now compute a^expAbs */
511  poly pow; poly aAsPoly = (poly)a;
512  if (expAbs <= 7)
513  {
514  pow = p_Copy(aAsPoly, naRing);
515  for (int i = 2; i <= expAbs; i++)
516  {
517  pow = p_Mult_q(pow, p_Copy(aAsPoly, naRing), naRing);
518  heuristicReduce(pow, naMinpoly, cf);
519  }
520  definiteReduce(pow, naMinpoly, cf);
521  }
522  else
523  {
524  pow = p_ISet(1, naRing);
525  poly factor = p_Copy(aAsPoly, naRing);
526  while (expAbs != 0)
527  {
528  if (expAbs & 1)
529  {
530  pow = p_Mult_q(pow, p_Copy(factor, naRing), naRing);
531  heuristicReduce(pow, naMinpoly, cf);
532  }
533  expAbs = expAbs / 2;
534  if (expAbs != 0)
535  {
536  factor = p_Mult_q(factor, p_Copy(factor, naRing), naRing);
537  heuristicReduce(factor, naMinpoly, cf);
538  }
539  }
540  p_Delete(&factor, naRing);
541  definiteReduce(pow, naMinpoly, cf);
542  }
543 
544  /* invert if original exponent was negative */
545  number n = (number)pow;
546  if (exp < 0)
547  {
548  number m = naInvers(n, cf);
549  naDelete(&n, cf);
550  n = m;
551  }
552  *b = n;
553 }
void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
#define naTest(a)
Definition: algext.cc:54
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
number naInit(long i, const coeffs cf)
Definition: algext.cc:339
void WerrorS(const char *s)
Definition: feFopen.cc:24
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
int m
Definition: cfEzgcd.cc:121
const char *const nDivBy0
Definition: numbers.h:88
void heuristicReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:560
int i
Definition: cfEzgcd.cc:125
CanonicalForm factor
Definition: facAbsFact.cc:101
number naInvers(number a, const coeffs cf)
Definition: algext.cc:818
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
#define naRing
Definition: algext.cc:61
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1053

◆ naRead()

const char * naRead ( const char *  s,
number *  a,
const coeffs  cf 
)

Definition at line 606 of file algext.cc.

607 {
608  poly aAsPoly;
609  const char * result = p_Read(s, aAsPoly, naRing);
610  if (aAsPoly!=NULL) definiteReduce(aAsPoly, naMinpoly, cf);
611  *a = (number)aAsPoly;
612  return result;
613 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1360
#define naMinpoly
Definition: algext.cc:70
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
void definiteReduce(poly &p, poly reducer, const coeffs cf)
Definition: algext.cc:730
return result
Definition: facAbsBiFact.cc:76

◆ naSetMap()

nMapFunc naSetMap ( const coeffs  src,
const coeffs  dst 
)

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

Q or Z –> Q(a)

Z –> Q(a)

Z/p –> Q(a)

Q –> Z/p(a)

Z –> Z/p(a)

Z/p –> Z/p(a)

Z/u –> Z/p(a)

default

Definition at line 1017 of file algext.cc.

1018 {
1019  /* dst is expected to be an algebraic field extension */
1020  assume(getCoeffType(dst) == n_algExt);
1021 
1022  if( src == dst ) return ndCopyMap;
1023 
1024  int h = 0; /* the height of the extension tower given by dst */
1025  coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1026  coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1027 
1028  /* for the time being, we only provide maps if h = 1 or 0 */
1029  if (h==0)
1030  {
1031  if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1032  return naMap00; /// Q or Z --> Q(a)
1033  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1034  return naMapZ0; /// Z --> Q(a)
1035  if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1036  return naMapP0; /// Z/p --> Q(a)
1037  if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1038  return naMap0P; /// Q --> Z/p(a)
1039  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1040  return naMapZ0; /// Z --> Z/p(a)
1041  if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1042  {
1043  if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1044  else return naMapUP; /// Z/u --> Z/p(a)
1045  }
1046  }
1047  if (h != 1) return NULL;
1048  if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1049  if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1050 
1051  nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1052  if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1053  {
1054  if (src->type==n_algExt)
1055  return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1056  else
1057  return naCopyTrans2AlgExt;
1058  }
1059  else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1060  {
1061  if (src->type==n_algExt)
1062  return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1063  else
1064  return naGenTrans2AlgExt;
1065  }
1066 
1067  return NULL; /// default
1068 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:822
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
number naMapZ0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:858
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:851
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number naMap00(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:848
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
number naMapP0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:870
number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:890
number naMapPP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:951
#define assume(x)
Definition: mod2.h:390
The main handler for Singular numbers which are suitable for Singular polynomials.
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:972
number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:987
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition: ring.cc:1712
static char * rRingVar(short i, const ring r)
Definition: ring.h:572
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:721
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
static coeffs nCoeff_bottom(const coeffs r, int &height)
Definition: algext.cc:258
(number), see longrat.h
Definition: coeffs.h:111
STATIC_VAR Poly * h
Definition: janet.cc:971
#define NULL
Definition: omList.c:12
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
number naMap0P(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:938
number naMapUP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:961

◆ naSize()

int naSize ( number  a,
const coeffs  cf 
)

Definition at line 712 of file algext.cc.

713 {
714  if (a == NULL) return 0;
715  poly aAsPoly = (poly)a;
716  int theDegree = 0; int noOfTerms = 0;
717  while (aAsPoly != NULL)
718  {
719  noOfTerms++;
720  int d = p_GetExp(aAsPoly, 1, naRing);
721  if (d > theDegree) theDegree = d;
722  pIter(aAsPoly);
723  }
724  return (theDegree +1) * noOfTerms;
725 }
#define pIter(p)
Definition: monomials.h:37
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:468
STATIC_VAR int theDegree
Definition: cf_char.cc:21
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61

◆ naSub()

number naSub ( number  a,
number  b,
const coeffs  cf 
)

Definition at line 448 of file algext.cc.

449 {
450  naTest(a); naTest(b);
451  if (b == NULL) return naCopy(a, cf);
452  poly minusB = p_Neg(p_Copy((poly)b, naRing), naRing);
453  if (a == NULL) return (number)minusB;
454  poly aMinusB = p_Add_q(p_Copy((poly)a, naRing), minusB, naRing);
455  //definiteReduce(aMinusB, naMinpoly, cf);
456  return (number)aMinusB;
457 }
#define naTest(a)
Definition: algext.cc:54
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
#define NULL
Definition: omList.c:12
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
#define naRing
Definition: algext.cc:61
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895

◆ naWriteLong()

void naWriteLong ( number  a,
const coeffs  cf 
)

Definition at line 570 of file algext.cc.

571 {
572  naTest(a);
573  if (a == NULL)
574  StringAppendS("0");
575  else
576  {
577  poly aAsPoly = (poly)a;
578  /* basically, just write aAsPoly using p_Write,
579  but use brackets around the output, if a is not
580  a constant living in naCoeffs = cf->extRing->cf */
581  BOOLEAN useBrackets = !(p_IsConstant(aAsPoly, naRing));
582  if (useBrackets) StringAppendS("(");
583  p_String0Long(aAsPoly, naRing, naRing);
584  if (useBrackets) StringAppendS(")");
585  }
586 }
#define naTest(a)
Definition: algext.cc:54
void p_String0Long(const poly p, ring lmRing, ring tailRing)
print p in a long way
Definition: polys0.cc:203
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
int BOOLEAN
Definition: auxiliary.h:87

◆ naWriteShort()

void naWriteShort ( number  a,
const coeffs  cf 
)

Definition at line 588 of file algext.cc.

589 {
590  naTest(a);
591  if (a == NULL)
592  StringAppendS("0");
593  else
594  {
595  poly aAsPoly = (poly)a;
596  /* basically, just write aAsPoly using p_Write,
597  but use brackets around the output, if a is not
598  a constant living in naCoeffs = cf->extRing->cf */
599  BOOLEAN useBrackets = !(p_IsConstant(aAsPoly, naRing));
600  if (useBrackets) StringAppendS("(");
601  p_String0Short(aAsPoly, naRing, naRing);
602  if (useBrackets) StringAppendS(")");
603  }
604 }
#define naTest(a)
Definition: algext.cc:54
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define NULL
Definition: omList.c:12
#define naRing
Definition: algext.cc:61
int BOOLEAN
Definition: auxiliary.h:87
void p_String0Short(const poly p, ring lmRing, ring tailRing)
print p in a short way, if possible
Definition: polys0.cc:184

◆ nCoeff_bottom()

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

Definition at line 258 of file algext.cc.

259 {
260  assume(r != NULL);
261  coeffs cf = r;
262  height = 0;
263  while (nCoeff_is_Extension(cf))
264  {
265  assume(cf->extRing != NULL); assume(cf->extRing->cf != NULL);
266  cf = cf->extRing->cf;
267  height++;
268  }
269  return cf;
270 }
#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:12
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:868

◆ p_ExtGcd()

poly p_ExtGcd ( poly  p,
poly &  pFactor,
poly  q,
poly &  qFactor,
ring  r 
)

assumes that p and q are univariate polynomials in r, mentioning the same variable; assumes a global monomial ordering in r; assumes that not both p and q are NULL; returns the gcd of p and q; moreover, afterwards pFactor and qFactor contain appropriate factors such that gcd(p, q) = p * pFactor + q * qFactor; leaves p and q unmodified

Definition at line 216 of file algext.cc.

217 {
218  assume((p != NULL) || (q != NULL));
219  poly a = p; poly b = q; BOOLEAN aCorrespondsToP = TRUE;
220  if (p_Deg(a, r) < p_Deg(b, r))
221  { a = q; b = p; aCorrespondsToP = FALSE; }
222  a = p_Copy(a, r); b = p_Copy(b, r);
223  poly aFactor = NULL; poly bFactor = NULL;
224  poly theGcd = p_ExtGcdHelper(a, aFactor, b, bFactor, r);
225  if (aCorrespondsToP) { pFactor = aFactor; qFactor = bFactor; }
226  else { pFactor = bFactor; qFactor = aFactor; }
227  return theGcd;
228 }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
static poly p_ExtGcdHelper(poly &p, poly &pFactor, poly &q, poly &qFactor, ring r)
Definition: algext.cc:183
CanonicalForm b
Definition: cfModGcd.cc:4044
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
#define assume(x)
Definition: mod2.h:390
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:87

◆ p_ExtGcdHelper()

static poly p_ExtGcdHelper ( poly &  p,
poly &  pFactor,
poly &  q,
poly &  qFactor,
ring  r 
)
inlinestatic

Definition at line 183 of file algext.cc.

185 {
186  if (q == NULL)
187  {
188  qFactor = NULL;
189  pFactor = p_ISet(1, r);
190  p_SetCoeff(pFactor, n_Invers(p_GetCoeff(p, r), r->cf), r);
191  p_Monic(p, r);
192  return p;
193  }
194  else
195  {
196  poly pDivQ = p_PolyDiv(p, q, TRUE, r);
197  poly ppFactor = NULL; poly qqFactor = NULL;
198  poly theGcd = p_ExtGcdHelper(q, qqFactor, p, ppFactor, r);
199  pFactor = ppFactor;
200  qFactor = p_Add_q(qqFactor,
201  p_Neg(p_Mult_q(pDivQ, p_Copy(ppFactor, r), r), r),
202  r);
203  return theGcd;
204  }
205 }
static void p_Monic(poly p, const ring r)
returns NULL if p == NULL, otherwise makes p monic by dividing by its leading coefficient (only done ...
Definition: algext.cc:120
#define TRUE
Definition: auxiliary.h:100
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
static poly p_ExtGcdHelper(poly &p, poly &pFactor, poly &q, poly &qFactor, ring r)
Definition: algext.cc:183
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:564
poly p_PolyDiv(poly &p, const poly divisor, const BOOLEAN needResult, const ring r)
assumes that p and divisor are univariate polynomials in r, mentioning the same variable; assumes div...
Definition: p_polys.cc:1845
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1053

◆ p_Gcd()

static poly p_Gcd ( const poly  p,
const poly  q,
const ring  r 
)
inlinestatic

Definition at line 165 of file algext.cc.

166 {
167  assume((p != NULL) || (q != NULL));
168 
169  poly a = p; poly b = q;
170  if (p_Deg(a, r) < p_Deg(b, r)) { a = q; b = p; }
171  a = p_Copy(a, r); b = p_Copy(b, r);
172 
173  /* We have to make p monic before we return it, so that if the
174  gcd is a unit in the ground field, we will actually return 1. */
175  a = p_GcdHelper(a, b, r);
176  p_Monic(a, r);
177  return a;
178 }
static void p_Monic(poly p, const ring r)
returns NULL if p == NULL, otherwise makes p monic by dividing by its leading coefficient (only done ...
Definition: algext.cc:120
static poly p_GcdHelper(poly &p, poly &q, const ring r)
see p_Gcd; additional assumption: deg(p) >= deg(q); must destroy p and q (unless one of them is retur...
Definition: algext.cc:145
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
#define assume(x)
Definition: mod2.h:390
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ p_GcdHelper()

static poly p_GcdHelper ( poly &  p,
poly &  q,
const ring  r 
)
inlinestatic

see p_Gcd; additional assumption: deg(p) >= deg(q); must destroy p and q (unless one of them is returned)

Definition at line 145 of file algext.cc.

146 {
147  while (q != NULL)
148  {
149  p_PolyDiv(p, q, FALSE, r);
150  // swap p and q:
151  poly& t = q;
152  q = p;
153  p = t;
154 
155  }
156  return p;
157 }
#define FALSE
Definition: auxiliary.h:96
poly p_PolyDiv(poly &p, const poly divisor, const BOOLEAN needResult, const ring r)
assumes that p and divisor are univariate polynomials in r, mentioning the same variable; assumes div...
Definition: p_polys.cc:1845
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ p_Monic()

static void p_Monic ( poly  p,
const ring  r 
)
inlinestatic

returns NULL if p == NULL, otherwise makes p monic by dividing by its leading coefficient (only done if this is not already 1); this assumes that we are over a ground field so that division is well-defined; modifies p

assumes that p and q are univariate polynomials in r, mentioning the same variable; assumes a global monomial ordering in r; assumes that not both p and q are NULL; returns the gcd of p and q; leaves p and q unmodified

Definition at line 120 of file algext.cc.

121 {
122  if (p == NULL) return;
123  number n = n_Init(1, r->cf);
124  if (p->next==NULL) { p_SetCoeff(p,n,r); return; }
125  poly pp = p;
126  number lc = p_GetCoeff(p, r);
127  if (n_IsOne(lc, r->cf)) return;
128  number lcInverse = n_Invers(lc, r->cf);
129  p_SetCoeff(p, n, r); // destroys old leading coefficient!
130  pIter(p);
131  while (p != NULL)
132  {
133  number n = n_Mult(p_GetCoeff(p, r), lcInverse, r->cf);
134  n_Normalize(n,r->cf);
135  p_SetCoeff(p, n, r); // destroys old leading coefficient!
136  pIter(p);
137  }
138  n_Delete(&lcInverse, r->cf);
139  p = pp;
140 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:468
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:538
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
CanonicalForm lc(const CanonicalForm &f)
#define pIter(p)
Definition: monomials.h:37
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:636
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
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:564
#define NULL
Definition: omList.c:12
#define p_GetCoeff(p, r)
Definition: monomials.h:50
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455
int p
Definition: cfModGcd.cc:4019