My Project
Data Structures | Functions
algext.h File Reference
#include "coeffs/coeffs.h"
#include "polys/monomials/ring.h"

Go to the source code of this file.

Data Structures

struct  AlgExtInfo
 struct for passing initialization parameters to naInitChar More...
 

Functions

nMapFunc naSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type (n_algExt) More...
 
BOOLEAN naInitChar (coeffs cf, void *infoStruct)
 Initialize the coeffs object. More...
 
BOOLEAN n2pInitChar (coeffs cf, void *infoStruct)
 
int naIsParam (number, const coeffs)
 if m == var(i)/1 => return i, More...
 
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...
 
char * naCoeffName (const coeffs r)
 

Data Structure Documentation

◆ AlgExtInfo

struct AlgExtInfo

struct for passing initialization parameters to naInitChar

Definition at line 37 of file algext.h.

Data Fields
ring r

Function Documentation

◆ n2pInitChar()

BOOLEAN n2pInitChar ( coeffs  cf,
void *  infoStruct 
)

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

Definition at line 1633 of file algext.cc.

1634 {
1635  assume( infoStruct != NULL );
1636 
1637  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1638  /// first check whether cf->extRing != NULL and delete old ring???
1639 
1640  assume(e->r != NULL); // extRing;
1641  assume(e->r->cf != NULL); // extRing->cf;
1642 
1643  assume( cf != NULL );
1644 
1645  rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1646  const ring R = e->r; // no copy!
1647  cf->extRing = R;
1648 
1649  /* propagate characteristic up so that it becomes
1650  directly accessible in cf: */
1651  cf->ch = R->cf->ch;
1652  cf->is_field=FALSE;
1653  cf->is_domain=TRUE;
1654 
1655  cf->cfCoeffName = n2pCoeffName;
1656 
1657  cf->cfGreaterZero = naGreaterZero;
1658  cf->cfGreater = naGreater;
1659  cf->cfEqual = naEqual;
1660  cf->cfIsZero = naIsZero;
1661  cf->cfIsOne = naIsOne;
1662  cf->cfIsMOne = naIsMOne;
1663  cf->cfInit = naInit;
1664  cf->cfInitMPZ = naInitMPZ;
1665  cf->cfFarey = naFarey;
1666  cf->cfChineseRemainder= naChineseRemainder;
1667  cf->cfInt = naInt;
1668  cf->cfInpNeg = naNeg;
1669  cf->cfAdd = naAdd;
1670  cf->cfSub = naSub;
1671  cf->cfMult = n2pMult;
1672  cf->cfDiv = n2pDiv;
1673  cf->cfPower = n2pPower;
1674  cf->cfCopy = naCopy;
1675 
1676  cf->cfWriteLong = naWriteLong;
1677 
1678  if( rCanShortOut(n2pRing) )
1679  cf->cfWriteShort = naWriteShort;
1680  else
1681  cf->cfWriteShort = naWriteLong;
1682 
1683  cf->cfRead = n2pRead;
1684  cf->cfDelete = naDelete;
1685  cf->cfSetMap = naSetMap;
1686  cf->cfGetDenom = naGetDenom;
1687  cf->cfGetNumerator = naGetNumerator;
1688  cf->cfRePart = naCopy;
1689  cf->cfCoeffWrite = n2pCoeffWrite;
1690  cf->cfNormalize = n2pNormalize;
1691  cf->cfKillChar = naKillChar;
1692 #ifdef LDEBUG
1693  cf->cfDBTest = naDBTest;
1694 #endif
1695  cf->cfGcd = naGcd;
1696  cf->cfNormalizeHelper = naLcmContent;
1697  cf->cfSize = naSize;
1698  cf->nCoeffIsEqual = n2pCoeffIsEqual;
1699  cf->cfInvers = n2pInvers;
1700  cf->convFactoryNSingN=naConvFactoryNSingN;
1701  cf->convSingNFactoryN=naConvSingNFactoryN;
1702  cf->cfParDeg = naParDeg;
1703 
1704  cf->iNumberOfParameters = rVar(R);
1705  cf->pParameterNames = (const char**)R->names;
1706  cf->cfParameter = naParameter;
1707  cf->has_simple_Inverse=FALSE;
1708  /* cf->has_simple_Alloc= FALSE; */
1709 
1710  if( nCoeff_is_Q(R->cf) )
1711  {
1712  cf->cfClearContent = naClearContent;
1713  cf->cfClearDenominators = naClearDenominators;
1714  }
1715 
1716  return FALSE;
1717 }
number n2pDiv(number a, number b, const coeffs cf)
Definition: algext.cc:1533
BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition: algext.cc:363
number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: algext.cc:331
number n2pMult(number a, number b, const coeffs cf)
Definition: algext.cc:1525
long naInt(number &a, const coeffs cf)
Definition: algext.cc:350
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:314
CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: algext.cc:761
number naGcd(number a, number b, const coeffs cf)
Definition: algext.cc:775
void naClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1312
BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)
Definition: algext.cc:233
number naInit(long i, const coeffs cf)
Definition: algext.cc:338
BOOLEAN naIsZero(number a, const coeffs cf)
Definition: algext.cc:272
const char * n2pRead(const char *s, number *a, const coeffs cf)
Definition: algext.cc:1549
number naGetNumerator(number &a, const coeffs cf)
Definition: algext.cc:303
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1107
number naSub(number a, number b, const coeffs cf)
Definition: algext.cc:453
BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition: algext.cc:287
void naWriteShort(number a, const coeffs cf)
Definition: algext.cc:593
number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: algext.cc:1358
#define n2pRing
Definition: algext.cc:1502
void naKillChar(coeffs cf)
Definition: algext.cc:1328
void naWriteLong(number a, const coeffs cf)
Definition: algext.cc:575
void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
number naLcmContent(number a, number b, const coeffs cf)
Definition: algext.cc:648
static number naInitMPZ(mpz_t m, const coeffs r)
Definition: algext.cc:344
number naGetDenom(number &a, const coeffs cf)
Definition: algext.cc:308
static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:1558
char * n2pCoeffName(const coeffs cf)
Definition: algext.cc:1578
number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: algext.cc:755
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:1022
number n2pInvers(number a, const coeffs cf)
Definition: algext.cc:1617
int naParDeg(number a, const coeffs cf)
Definition: algext.cc:1073
number naAdd(number a, number b, const coeffs cf)
Definition: algext.cc:442
int naSize(number a, const coeffs cf)
Definition: algext.cc:717
number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition: algext.cc:1081
BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:383
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:1605
void n2pNormalize(number &a, const coeffs cf)
Definition: algext.cc:1518
number naFarey(number p, number n, const coeffs cf)
Definition: algext.cc:1370
BOOLEAN naIsMOne(number a, const coeffs cf)
Definition: algext.cc:322
void n2pPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:1542
ring r
Definition: algext.h:37
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
CanonicalForm cf
Definition: cfModGcd.cc:4083
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:806
#define assume(x)
Definition: mod2.h:387
#define NULL
Definition: omList.c:12
static ring rIncRefCnt(ring r)
Definition: ring.h:843
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:587
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593
#define R
Definition: sirandom.c:27

◆ naCoeffName()

char* naCoeffName ( const coeffs  r)

Definition at line 1335 of file algext.cc.

1336 {
1337  const char* const* p=n_ParameterNames(r);
1338  int l=0;
1339  int i;
1340  for(i=0; i<n_NumberOfParameters(r);i++)
1341  {
1342  l+=(strlen(p[i])+1);
1343  }
1344  STATIC_VAR char s[200];
1345  s[0]='\0';
1346  snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1347  char tt[2];
1348  tt[0]=',';
1349  tt[1]='\0';
1350  for(i=0; i<n_NumberOfParameters(r);i++)
1351  {
1352  strcat(s,tt);
1353  strcat(s,p[i]);
1354  }
1355  return s;
1356 }
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:778
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:774
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define STATIC_VAR
Definition: globaldefs.h:7

◆ naInitChar()

BOOLEAN naInitChar ( coeffs  cf,
void *  infoStruct 
)

Initialize the coeffs object.

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

Definition at line 1378 of file algext.cc.

1379 {
1380  assume( infoStruct != NULL );
1381 
1382  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1383  /// first check whether cf->extRing != NULL and delete old ring???
1384 
1385  assume(e->r != NULL); // extRing;
1386  assume(e->r->cf != NULL); // extRing->cf;
1387 
1388  assume((e->r->qideal != NULL) && // minideal has one
1389  (IDELEMS(e->r->qideal) == 1) && // non-zero generator
1390  (e->r->qideal->m[0] != NULL) ); // at m[0];
1391 
1392  assume( cf != NULL );
1393  assume(getCoeffType(cf) == n_algExt); // coeff type;
1394 
1395  rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1396  const ring R = e->r; // no copy!
1397  cf->extRing = R;
1398 
1399  /* propagate characteristic up so that it becomes
1400  directly accessible in cf: */
1401  cf->ch = R->cf->ch;
1402 
1403  cf->is_field=TRUE;
1404  cf->is_domain=TRUE;
1405  cf->rep=n_rep_poly;
1406 
1407  #ifdef LDEBUG
1408  p_Test((poly)naMinpoly, naRing);
1409  #endif
1410 
1411  cf->cfCoeffName = naCoeffName;
1412 
1413  cf->cfGreaterZero = naGreaterZero;
1414  cf->cfGreater = naGreater;
1415  cf->cfEqual = naEqual;
1416  cf->cfIsZero = naIsZero;
1417  cf->cfIsOne = naIsOne;
1418  cf->cfIsMOne = naIsMOne;
1419  cf->cfInit = naInit;
1420  cf->cfInitMPZ = naInitMPZ;
1421  cf->cfFarey = naFarey;
1422  cf->cfChineseRemainder= naChineseRemainder;
1423  cf->cfInt = naInt;
1424  cf->cfInpNeg = naNeg;
1425  cf->cfAdd = naAdd;
1426  cf->cfSub = naSub;
1427  cf->cfMult = naMult;
1428  cf->cfDiv = naDiv;
1429  cf->cfExactDiv = naDiv;
1430  cf->cfPower = naPower;
1431  cf->cfCopy = naCopy;
1432 
1433  cf->cfWriteLong = naWriteLong;
1434 
1435  if( rCanShortOut(naRing) )
1436  cf->cfWriteShort = naWriteShort;
1437  else
1438  cf->cfWriteShort = naWriteLong;
1439 
1440  cf->cfRead = naRead;
1441  cf->cfDelete = naDelete;
1442  cf->cfSetMap = naSetMap;
1443  cf->cfGetDenom = naGetDenom;
1444  cf->cfGetNumerator = naGetNumerator;
1445  cf->cfRePart = naCopy;
1446  cf->cfCoeffWrite = naCoeffWrite;
1447  cf->cfNormalize = naNormalize;
1448  cf->cfKillChar = naKillChar;
1449 #ifdef LDEBUG
1450  cf->cfDBTest = naDBTest;
1451 #endif
1452  cf->cfGcd = naGcd;
1453  cf->cfNormalizeHelper = naLcmContent;
1454  cf->cfSize = naSize;
1455  cf->nCoeffIsEqual = naCoeffIsEqual;
1456  cf->cfInvers = naInvers;
1457  cf->convFactoryNSingN=naConvFactoryNSingN;
1458  cf->convSingNFactoryN=naConvSingNFactoryN;
1459  cf->cfParDeg = naParDeg;
1460 
1461  cf->iNumberOfParameters = rVar(R);
1462  cf->pParameterNames = (const char**)R->names;
1463  cf->cfParameter = naParameter;
1464  cf->has_simple_Inverse= R->cf->has_simple_Inverse;
1465  /* cf->has_simple_Alloc= FALSE; */
1466 
1467  if( nCoeff_is_Q(R->cf) )
1468  {
1469  cf->cfClearContent = naClearContent;
1470  cf->cfClearDenominators = naClearDenominators;
1471  }
1472 
1473  return FALSE;
1474 }
#define naMinpoly
Definition: algext.cc:70
void naNormalize(number &a, const coeffs cf)
Definition: algext.cc:747
void naPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:498
number naInvers(number a, const coeffs cf)
Definition: algext.cc:823
void naCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:392
number naDiv(number a, number b, const coeffs cf)
Definition: algext.cc:474
char * naCoeffName(const coeffs r)
Definition: algext.cc:1335
number naMult(number a, number b, const coeffs cf)
Definition: algext.cc:464
const char * naRead(const char *s, number *a, const coeffs cf)
Definition: algext.cc:611
static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:683
#define naRing
Definition: algext.cc:61
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:35
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
@ n_rep_poly
(poly), see algext.h
Definition: coeffs.h:113
#define p_Test(p, r)
Definition: p_polys.h:162
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ naIsParam()

int naIsParam ( number  m,
const  coeffs 
)

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

Definition at line 1096 of file algext.cc.

1097 {
1099 
1100  const ring R = cf->extRing;
1101  assume( R != NULL );
1102 
1103  return p_Var( (poly)m, R );
1104 }
int m
Definition: cfEzgcd.cc:128
@ n_polyExt
used to represent polys as coeffcients
Definition: coeffs.h:34
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4721

◆ 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 1022 of file algext.cc.

1023 {
1024  /* dst is expected to be an algebraic field extension */
1025  assume(getCoeffType(dst) == n_algExt);
1026 
1027  int h = 0; /* the height of the extension tower given by dst */
1028  coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1029  coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1030 
1031  /* for the time being, we only provide maps if h = 1 or 0 */
1032  if (h==0)
1033  {
1034  if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1035  return naMap00; /// Q or Z --> Q(a)
1036  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1037  return naMapZ0; /// Z --> Q(a)
1038  if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1039  return naMapP0; /// Z/p --> Q(a)
1040  if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1041  return naMap0P; /// Q --> Z/p(a)
1042  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1043  return naMapZ0; /// Z --> Z/p(a)
1044  if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1045  {
1046  if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1047  else return naMapUP; /// Z/u --> Z/p(a)
1048  }
1049  }
1050  if (h != 1) return NULL;
1051  if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1052  if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1053 
1054  nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1055  if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1056  {
1057  if (src->type==n_algExt)
1058  return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1059  else
1060  return naCopyTrans2AlgExt;
1061  }
1062  else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1063  {
1064  if (src->type==n_algExt)
1065  return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1066  else
1067  return naGenTrans2AlgExt;
1068  }
1069 
1070  return NULL; /// default
1071 }
number naMap00(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:853
number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:977
number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:895
number naMap0P(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:943
number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:992
number naMapPP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:956
number naMapP0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:875
static coeffs nCoeff_bottom(const coeffs r, int &height)
Definition: algext.cc:258
number naMapZ0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:863
number naMapUP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:966
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:255
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:700
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:829
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:800
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:111
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
STATIC_VAR Poly * h
Definition: janet.cc:971
The main handler for Singular numbers which are suitable for Singular polynomials.
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:1799
static char * rRingVar(short i, const ring r)
Definition: ring.h:578

◆ 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 }
static poly p_ExtGcdHelper(poly &p, poly &pFactor, poly &q, poly &qFactor, ring r)
Definition: algext.cc:183
int BOOLEAN
Definition: auxiliary.h:87
CanonicalForm b
Definition: cfModGcd.cc:4103
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:846