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

1628 {
1629  assume( infoStruct != NULL );
1630 
1631  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1632  /// first check whether cf->extRing != NULL and delete old ring???
1633 
1634  assume(e->r != NULL); // extRing;
1635  assume(e->r->cf != NULL); // extRing->cf;
1636 
1637  assume( cf != NULL );
1638 
1639  rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1640  const ring R = e->r; // no copy!
1641  cf->extRing = R;
1642 
1643  /* propagate characteristic up so that it becomes
1644  directly accessible in cf: */
1645  cf->ch = R->cf->ch;
1646  cf->is_field=FALSE;
1647  cf->is_domain=TRUE;
1648 
1649  cf->cfCoeffName = n2pCoeffName;
1650 
1651  cf->cfGreaterZero = naGreaterZero;
1652  cf->cfGreater = naGreater;
1653  cf->cfEqual = naEqual;
1654  cf->cfIsZero = naIsZero;
1655  cf->cfIsOne = naIsOne;
1656  cf->cfIsMOne = naIsMOne;
1657  cf->cfInit = naInit;
1658  cf->cfFarey = naFarey;
1659  cf->cfChineseRemainder= naChineseRemainder;
1660  cf->cfInt = naInt;
1661  cf->cfInpNeg = naNeg;
1662  cf->cfAdd = naAdd;
1663  cf->cfSub = naSub;
1664  cf->cfMult = n2pMult;
1665  cf->cfDiv = n2pDiv;
1666  cf->cfPower = n2pPower;
1667  cf->cfCopy = naCopy;
1668 
1669  cf->cfWriteLong = naWriteLong;
1670 
1671  if( rCanShortOut(n2pRing) )
1672  cf->cfWriteShort = naWriteShort;
1673  else
1674  cf->cfWriteShort = naWriteLong;
1675 
1676  cf->cfRead = n2pRead;
1677  cf->cfDelete = naDelete;
1678  cf->cfSetMap = naSetMap;
1679  cf->cfGetDenom = naGetDenom;
1680  cf->cfGetNumerator = naGetNumerator;
1681  cf->cfRePart = naCopy;
1682  cf->cfCoeffWrite = n2pCoeffWrite;
1683  cf->cfNormalize = n2pNormalize;
1684  cf->cfKillChar = naKillChar;
1685 #ifdef LDEBUG
1686  cf->cfDBTest = naDBTest;
1687 #endif
1688  cf->cfGcd = naGcd;
1689  cf->cfNormalizeHelper = naLcmContent;
1690  cf->cfSize = naSize;
1691  cf->nCoeffIsEqual = n2pCoeffIsEqual;
1692  cf->cfInvers = n2pInvers;
1693  cf->convFactoryNSingN=naConvFactoryNSingN;
1694  cf->convSingNFactoryN=naConvSingNFactoryN;
1695  cf->cfParDeg = naParDeg;
1696 
1697  cf->iNumberOfParameters = rVar(R);
1698  cf->pParameterNames = (const char**)R->names;
1699  cf->cfParameter = naParameter;
1700  cf->has_simple_Inverse=FALSE;
1701  /* cf->has_simple_Alloc= FALSE; */
1702 
1703  if( nCoeff_is_Q(R->cf) )
1704  {
1705  cf->cfClearContent = naClearContent;
1706  cf->cfClearDenominators = naClearDenominators;
1707  }
1708 
1709  return FALSE;
1710 }
number n2pDiv(number a, number b, const coeffs cf)
Definition: algext.cc:1527
BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition: algext.cc:358
number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: algext.cc:332
number n2pMult(number a, number b, const coeffs cf)
Definition: algext.cc:1519
long naInt(number &a, const coeffs cf)
Definition: algext.cc:345
number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:315
CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: algext.cc:756
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:1307
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:339
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:1543
number naGetNumerator(number &a, const coeffs cf)
Definition: algext.cc:304
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1102
number naSub(number a, number b, const coeffs cf)
Definition: algext.cc:448
BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition: algext.cc:287
void naWriteShort(number a, const coeffs cf)
Definition: algext.cc:588
number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: algext.cc:1353
#define n2pRing
Definition: algext.cc:1496
void naKillChar(coeffs cf)
Definition: algext.cc:1323
void naWriteLong(number a, const coeffs cf)
Definition: algext.cc:570
void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
number naLcmContent(number a, number b, const coeffs cf)
Definition: algext.cc:643
number naGetDenom(number &a, const coeffs cf)
Definition: algext.cc:309
static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:1552
char * n2pCoeffName(const coeffs cf)
Definition: algext.cc:1572
number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: algext.cc:750
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 n2pInvers(number a, const coeffs cf)
Definition: algext.cc:1611
int naParDeg(number a, const coeffs cf)
Definition: algext.cc:1068
number naAdd(number a, number b, const coeffs cf)
Definition: algext.cc:437
int naSize(number a, const coeffs cf)
Definition: algext.cc:712
number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition: algext.cc:1076
BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:378
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:1599
void n2pNormalize(number &a, const coeffs cf)
Definition: algext.cc:1512
number naFarey(number p, number n, const coeffs cf)
Definition: algext.cc:1365
BOOLEAN naIsMOne(number a, const coeffs cf)
Definition: algext.cc:323
void n2pPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:1536
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:4085
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:830
#define assume(x)
Definition: mod2.h:387
#define NULL
Definition: omList.c:12
static ring rIncRefCnt(ring r)
Definition: ring.h:844
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:588
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:594
#define R
Definition: sirandom.c:27

◆ naCoeffName()

char* naCoeffName ( const coeffs  r)

Definition at line 1330 of file algext.cc.

1331 {
1332  const char* const* p=n_ParameterNames(r);
1333  int l=0;
1334  int i;
1335  for(i=0; i<n_NumberOfParameters(r);i++)
1336  {
1337  l+=(strlen(p[i])+1);
1338  }
1339  STATIC_VAR char s[200];
1340  s[0]='\0';
1341  snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1342  char tt[2];
1343  tt[0]=',';
1344  tt[1]='\0';
1345  for(i=0; i<n_NumberOfParameters(r);i++)
1346  {
1347  strcat(s,tt);
1348  strcat(s,p[i]);
1349  }
1350  return s;
1351 }
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4080
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:802
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:798
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 1373 of file algext.cc.

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

1092 {
1094 
1095  const ring R = cf->extRing;
1096  assume( R != NULL );
1097 
1098  return p_Var( (poly)m, R );
1099 }
int m
Definition: cfEzgcd.cc:128
@ n_polyExt
used to represent polys as coeffcients
Definition: coeffs.h:35
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4684

◆ 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  int h = 0; /* the height of the extension tower given by dst */
1023  coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1024  coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1025 
1026  /* for the time being, we only provide maps if h = 1 or 0 */
1027  if (h==0)
1028  {
1029  if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1030  return naMap00; /// Q or Z --> Q(a)
1031  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1032  return naMapZ0; /// Z --> Q(a)
1033  if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1034  return naMapP0; /// Z/p --> Q(a)
1035  if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1036  return naMap0P; /// Q --> Z/p(a)
1037  if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1038  return naMapZ0; /// Z --> Z/p(a)
1039  if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1040  {
1041  if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1042  else return naMapUP; /// Z/u --> Z/p(a)
1043  }
1044  }
1045  if (h != 1) return NULL;
1046  if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1047  if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1048 
1049  nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1050  if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1051  {
1052  if (src->type==n_algExt)
1053  return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1054  else
1055  return naCopyTrans2AlgExt;
1056  }
1057  else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1058  {
1059  if (src->type==n_algExt)
1060  return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1061  else
1062  return naGenTrans2AlgExt;
1063  }
1064 
1065  return NULL; /// default
1066 }
number naMap00(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:848
number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:972
number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:890
number naMap0P(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:938
number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:987
number naMapPP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:951
number naMapP0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:870
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:858
number naMapUP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:961
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:259
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:723
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:853
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:824
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:112
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:113
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
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:1713
static char * rRingVar(short i, const ring r)
Definition: ring.h:579

◆ 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:4105
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:582
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812