My Project
Loading...
Searching...
No Matches
algext.h File Reference

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).
BOOLEAN naInitChar (coeffs cf, void *infoStruct)
 Initialize the coeffs object.
BOOLEAN n2pInitChar (coeffs cf, void *infoStruct)
int naIsParam (number, const coeffs)
 if m == var(i)/1 => return i,
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
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 1687 of file algext.cc.

1688{
1689 assume( infoStruct != NULL );
1690
1691 AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1692 /// first check whether cf->extRing != NULL and delete old ring???
1693
1694 assume(e->r != NULL); // extRing;
1695 assume(e->r->cf != NULL); // extRing->cf;
1696
1697 assume( cf != NULL );
1698
1699 rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1700 const ring R = e->r; // no copy!
1701 cf->extRing = R;
1702
1703 /* propagate characteristic up so that it becomes
1704 directly accessible in cf: */
1705 cf->ch = R->cf->ch;
1706 cf->is_field=FALSE;
1707 cf->is_domain=TRUE;
1708
1709 cf->cfCoeffName = n2pCoeffName;
1710
1711 cf->cfGreaterZero = naGreaterZero;
1712 cf->cfGreater = naGreater;
1713 cf->cfEqual = naEqual;
1714 cf->cfIsZero = naIsZero;
1715 cf->cfIsOne = naIsOne;
1716 cf->cfIsMOne = naIsMOne;
1717 cf->cfInit = naInit;
1718 cf->cfInitMPZ = naInitMPZ;
1719 cf->cfFarey = naFarey;
1720 cf->cfChineseRemainder= naChineseRemainder;
1721 cf->cfInt = naInt;
1722 cf->cfInpNeg = naNeg;
1723 cf->cfAdd = naAdd;
1724 cf->cfInpAdd = naInpAdd;
1725 cf->cfSub = naSub;
1726 cf->cfMult = n2pMult;
1727 cf->cfDiv = n2pDiv;
1728 cf->cfPower = n2pPower;
1729 cf->cfCopy = naCopy;
1730
1731 cf->cfWriteLong = naWriteLong;
1732
1733 if( rCanShortOut(n2pRing) )
1734 cf->cfWriteShort = naWriteShort;
1735 else
1736 cf->cfWriteShort = naWriteLong;
1737
1738 cf->cfRead = n2pRead;
1739 cf->cfDelete = naDelete;
1740 cf->cfSetMap = naSetMap;
1741 //cf->cfGetDenom = naGetDenom; // use nd*
1742 //cf->cfGetNumerator = naGetNumerator; // use nd*
1743 cf->cfRePart = naCopy;
1744 cf->cfCoeffWrite = n2pCoeffWrite;
1745 cf->cfNormalize = n2pNormalize;
1746 cf->cfKillChar = naKillChar;
1747#ifdef LDEBUG
1748 cf->cfDBTest = naDBTest;
1749#endif
1750 cf->cfGcd = naGcd;
1751 cf->cfNormalizeHelper = naLcmContent;
1752 cf->cfSize = naSize;
1753 cf->nCoeffIsEqual = n2pCoeffIsEqual;
1754 cf->cfInvers = n2pInvers;
1755 cf->convFactoryNSingN=naConvFactoryNSingN;
1756 cf->convSingNFactoryN=naConvSingNFactoryN;
1757 cf->cfParDeg = naParDeg;
1758
1759 cf->iNumberOfParameters = rVar(R);
1760 cf->pParameterNames = (const char**)R->names;
1761 cf->cfParameter = naParameter;
1762 cf->has_simple_Inverse=FALSE;
1763 /* cf->has_simple_Alloc= FALSE; */
1764
1765 if( nCoeff_is_Q(R->cf) )
1766 {
1767 cf->cfClearContent = naClearContent;
1768 cf->cfClearDenominators = naClearDenominators;
1769 }
1770
1771 return FALSE;
1772}
static number naInit(long i, const coeffs cf)
Definition algext.cc:325
number n2pDiv(number a, number b, const coeffs cf)
Definition algext.cc:1587
static number naSub(number a, number b, const coeffs cf)
Definition algext.cc:451
static BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition algext.cc:285
static BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition algext.cc:370
static CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition algext.cc:769
static void naInpAdd(number &a, number b, const coeffs cf)
Definition algext.cc:440
static BOOLEAN naIsOne(number a, const coeffs cf)
Definition algext.cc:301
static number naFarey(number p, number n, const coeffs cf)
Definition algext.cc:1425
number n2pMult(number a, number b, const coeffs cf)
Definition algext.cc:1579
const char * n2pRead(const char *s, number *a, const coeffs cf)
Definition algext.cc:1603
static number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition algext.cc:1413
static number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition algext.cc:763
static BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)
Definition algext.cc:231
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition algext.cc:1162
static void naWriteShort(number a, const coeffs cf)
Definition algext.cc:601
static int naSize(number a, const coeffs cf)
Definition algext.cc:725
static number naAdd(number a, number b, const coeffs cf)
Definition algext.cc:429
static number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition algext.cc:1136
#define n2pRing
Definition algext.cc:1556
static int naParDeg(number a, const coeffs cf)
Definition algext.cc:1128
static number naCopy(number a, const coeffs cf)
Definition algext.cc:294
static void naClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition algext.cc:1367
static number naInitMPZ(mpz_t m, const coeffs r)
Definition algext.cc:331
static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition algext.cc:1612
static long naInt(number &a, const coeffs cf)
Definition algext.cc:337
static number naLcmContent(number a, number b, const coeffs cf)
Definition algext.cc:656
char * n2pCoeffName(const coeffs cf)
Definition algext.cc:1632
static number naGcd(number a, number b, const coeffs cf)
Definition algext.cc:783
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:1077
static void naKillChar(coeffs cf)
Definition algext.cc:1383
static BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition algext.cc:350
static BOOLEAN naIsZero(number a, const coeffs cf)
Definition algext.cc:270
number n2pInvers(number a, const coeffs cf)
Definition algext.cc:1671
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition algext.cc:1659
static void naDelete(number *a, const coeffs cf)
Definition algext.cc:276
void n2pNormalize(number &a, const coeffs cf)
Definition algext.cc:1572
static void naWriteLong(number a, const coeffs cf)
Definition algext.cc:583
void n2pPower(number a, int exp, number *b, const coeffs cf)
Definition algext.cc:1596
static number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition algext.cc:318
static BOOLEAN naIsMOne(number a, const coeffs cf)
Definition algext.cc:309
ring r
Definition algext.h:37
struct for passing initialization parameters to naInitChar
Definition algext.h:37
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
CanonicalForm cf
Definition cfModGcd.cc:4091
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition coeffs.h:804
#define assume(x)
Definition mod2.h:389
#define NULL
Definition omList.c:12
static ring rIncRefCnt(ring r)
Definition ring.h:854
static BOOLEAN rCanShortOut(const ring r)
Definition ring.h:597
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603
#define R
Definition sirandom.c:27

◆ naCoeffName()

char * naCoeffName ( const coeffs r)

Definition at line 1390 of file algext.cc.

1391{
1392 const char* const* p=n_ParameterNames(r);
1393 int l=0;
1394 int i;
1395 for(i=0; i<n_NumberOfParameters(r);i++)
1396 {
1397 l+=(strlen(p[i])+1);
1398 }
1399 STATIC_VAR char s[200];
1400 s[0]='\0';
1401 snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1402 char tt[2];
1403 tt[0]=',';
1404 tt[1]='\0';
1405 for(i=0; i<n_NumberOfParameters(r);i++)
1406 {
1407 strcat(s,tt);
1408 strcat(s,p[i]);
1409 }
1410 return s;
1411}
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition coeffs.h:770
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition coeffs.h:766
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 1433 of file algext.cc.

1434{
1435 assume( infoStruct != NULL );
1436
1437 AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1438 /// first check whether cf->extRing != NULL and delete old ring???
1439
1440 assume(e->r != NULL); // extRing;
1441 assume(e->r->cf != NULL); // extRing->cf;
1442
1443 assume((e->r->qideal != NULL) && // minideal has one
1444 (IDELEMS(e->r->qideal) == 1) && // non-zero generator
1445 (e->r->qideal->m[0] != NULL) ); // at m[0];
1446
1447 assume( cf != NULL );
1448 assume(getCoeffType(cf) == n_algExt); // coeff type;
1449
1450 rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1451 const ring R = e->r; // no copy!
1452 cf->extRing = R;
1453
1454 /* propagate characteristic up so that it becomes
1455 directly accessible in cf: */
1456 cf->ch = R->cf->ch;
1457
1458 cf->is_field=TRUE;
1459 cf->is_domain=TRUE;
1460 cf->rep=n_rep_poly;
1461
1462 #ifdef LDEBUG
1463 p_Test((poly)naMinpoly, naRing);
1464 #endif
1465
1466 cf->cfCoeffName = naCoeffName;
1467
1468 cf->cfGreaterZero = naGreaterZero;
1469 cf->cfGreater = naGreater;
1470 cf->cfEqual = naEqual;
1471 cf->cfIsZero = naIsZero;
1472 cf->cfIsOne = naIsOne;
1473 cf->cfIsMOne = naIsMOne;
1474 cf->cfInit = naInit;
1475 cf->cfInitMPZ = naInitMPZ;
1476 cf->cfFarey = naFarey;
1477 cf->cfChineseRemainder= naChineseRemainder;
1478 cf->cfInt = naInt;
1479 cf->cfInpNeg = naNeg;
1480 cf->cfAdd = naAdd;
1481 cf->cfSub = naSub;
1482 cf->cfMult = naMult;
1483 cf->cfInpMult = naInpMult;
1484 cf->cfDiv = naDiv;
1485 cf->cfExactDiv = naDiv;
1486 cf->cfPower = naPower;
1487 cf->cfCopy = naCopy;
1488
1489 cf->cfWriteLong = naWriteLong;
1490
1491 if( rCanShortOut(naRing) )
1492 cf->cfWriteShort = naWriteShort;
1493 else
1494 cf->cfWriteShort = naWriteLong;
1495
1496 cf->cfRead = naRead;
1497 cf->cfDelete = naDelete;
1498 cf->cfSetMap = naSetMap;
1499 cf->cfRePart = naCopy;
1500 cf->cfCoeffWrite = naCoeffWrite;
1501 cf->cfNormalize = naNormalize;
1502 cf->cfKillChar = naKillChar;
1503#ifdef LDEBUG
1504 cf->cfDBTest = naDBTest;
1505#endif
1506 cf->cfGcd = naGcd;
1507 cf->cfNormalizeHelper = naLcmContent;
1508 cf->cfSize = naSize;
1509 cf->nCoeffIsEqual = naCoeffIsEqual;
1510 cf->cfInvers = naInvers;
1511 cf->convFactoryNSingN=naConvFactoryNSingN;
1512 cf->convSingNFactoryN=naConvSingNFactoryN;
1513 cf->cfParDeg = naParDeg;
1514
1515 cf->iNumberOfParameters = rVar(R);
1516 cf->pParameterNames = (const char**)R->names;
1517 cf->cfParameter = naParameter;
1518 cf->has_simple_Inverse= R->cf->has_simple_Inverse;
1519 /* cf->has_simple_Alloc= FALSE; */
1520
1521 if( nCoeff_is_Q(R->cf) )
1522 {
1523 cf->cfClearContent = naClearContent;
1524 cf->cfClearDenominators = naClearDenominators;
1525 }
1526
1527 return FALSE;
1528}
static number naInvers(number a, const coeffs cf)
Definition algext.cc:831
static void naPower(number a, int exp, number *b, const coeffs cf)
Definition algext.cc:506
#define naMinpoly
Definition algext.cc:70
static number naMult(number a, number b, const coeffs cf)
Definition algext.cc:462
static void naInpMult(number &a, number b, const coeffs cf)
Definition algext.cc:472
static const char * naRead(const char *s, number *a, const coeffs cf)
Definition algext.cc:619
static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition algext.cc:691
char * naCoeffName(const coeffs r)
Definition algext.cc:1390
#define naRing
Definition algext.cc:61
static void naNormalize(number &a, const coeffs cf)
Definition algext.cc:755
static number naDiv(number a, number b, const coeffs cf)
Definition algext.cc:482
static void naCoeffWrite(const coeffs cf, BOOLEAN details)
Definition algext.cc:379
@ 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:431
@ n_rep_poly
(poly), see algext.h
Definition coeffs.h:120
#define p_Test(p, r)
Definition p_polys.h:161
#define IDELEMS(i)

◆ naIsParam()

int naIsParam ( number m,
const coeffs cf )

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

Definition at line 1151 of file algext.cc.

1152{
1154
1155 const ring R = cf->extRing;
1156 assume( R != NULL );
1157
1158 return p_Var( (poly)m, R );
1159}
int m
Definition cfEzgcd.cc:128
@ n_polyExt
used to represent polys as coefficients
Definition coeffs.h:34
int p_Var(poly m, const ring r)
Definition p_polys.cc:4823

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

1078{
1079 /* dst is expected to be an algebraic field extension */
1080 assume(getCoeffType(dst) == n_algExt);
1081
1082 int h = 0; /* the height of the extension tower given by dst */
1083 coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1084 coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1085
1086 /* for the time being, we only provide maps if h = 1 or 0 */
1087 if (h==0)
1088 {
1089 if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1090 return naMap00; /// Q or Z --> Q(a)
1091 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1092 return naMapZ0; /// Z --> Q(a)
1093 if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1094 return naMapP0; /// Z/p --> Q(a)
1095 if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1096 return naMap0P; /// Q --> Z/p(a)
1097 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1098 return naMapZ0; /// Z --> Z/p(a)
1099 if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1100 {
1101 if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1102 else return naMapUP; /// Z/u --> Z/p(a)
1103 }
1104 }
1105 if (h != 1) return NULL;
1106 if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1107 if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1108
1109 nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1110 if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1111 {
1112 if (src->type==n_algExt)
1113 return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1114 else
1115 return naCopyTrans2AlgExt;
1116 }
1117 else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1118 {
1119 if (src->type==n_algExt)
1120 return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1121 else
1122 return naGenTrans2AlgExt;
1123 }
1124
1125 return NULL; /// default
1126}
static number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition algext.cc:1047
static number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition algext.cc:1032
static number naMapPP(number a, const coeffs src, const coeffs dst)
Definition algext.cc:1011
static number naMapZ0(number a, const coeffs src, const coeffs dst)
Definition algext.cc:918
static number naMap0P(number a, const coeffs src, const coeffs dst)
Definition algext.cc:998
static number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition algext.cc:950
static number naMapUP(number a, const coeffs src, const coeffs dst)
Definition algext.cc:1021
static number naMap00(number a, const coeffs src, const coeffs dst)
Definition algext.cc:908
static number naMapP0(number a, const coeffs src, const coeffs dst)
Definition algext.cc:930
static coeffs nCoeff_bottom(const coeffs r, int &height)
Definition algext.cc:256
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:293
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:703
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition coeffs.h:827
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:794
@ n_rep_gap_rat
(number), see longrat.h
Definition coeffs.h:118
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition coeffs.h:119
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
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:1805
static char * rRingVar(short i, const ring r)
Definition ring.h:588

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

215{
216 assume((p != NULL) || (q != NULL));
217 poly a = p; poly b = q; BOOLEAN aCorrespondsToP = TRUE;
218 if (p_Deg(a, r) < p_Deg(b, r))
219 { a = q; b = p; aCorrespondsToP = FALSE; }
220 a = p_Copy(a, r); b = p_Copy(b, r);
221 poly aFactor = NULL; poly bFactor = NULL;
222 poly theGcd = p_ExtGcdHelper(a, aFactor, b, bFactor, r);
223 if (aCorrespondsToP) { pFactor = aFactor; qFactor = bFactor; }
224 else { pFactor = bFactor; qFactor = aFactor; }
225 return theGcd;
226}
static poly p_ExtGcdHelper(poly &p, poly &pFactor, poly &q, poly &qFactor, ring r)
Definition algext.cc:181
int BOOLEAN
Definition auxiliary.h:88
CanonicalForm b
Definition cfModGcd.cc:4111
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848