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

1641{
1642 assume( infoStruct != NULL );
1643
1644 AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1645 /// first check whether cf->extRing != NULL and delete old ring???
1646
1647 assume(e->r != NULL); // extRing;
1648 assume(e->r->cf != NULL); // extRing->cf;
1649
1650 assume( cf != NULL );
1651
1652 rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1653 const ring R = e->r; // no copy!
1654 cf->extRing = R;
1655
1656 /* propagate characteristic up so that it becomes
1657 directly accessible in cf: */
1658 cf->ch = R->cf->ch;
1659 cf->is_field=FALSE;
1660 cf->is_domain=TRUE;
1661
1662 cf->cfCoeffName = n2pCoeffName;
1663
1664 cf->cfGreaterZero = naGreaterZero;
1665 cf->cfGreater = naGreater;
1666 cf->cfEqual = naEqual;
1667 cf->cfIsZero = naIsZero;
1668 cf->cfIsOne = naIsOne;
1669 cf->cfIsMOne = naIsMOne;
1670 cf->cfInit = naInit;
1671 cf->cfInitMPZ = naInitMPZ;
1672 cf->cfFarey = naFarey;
1673 cf->cfChineseRemainder= naChineseRemainder;
1674 cf->cfInt = naInt;
1675 cf->cfInpNeg = naNeg;
1676 cf->cfAdd = naAdd;
1677 cf->cfInpAdd = naInpAdd;
1678 cf->cfSub = naSub;
1679 cf->cfMult = n2pMult;
1680 cf->cfDiv = n2pDiv;
1681 cf->cfPower = n2pPower;
1682 cf->cfCopy = naCopy;
1683
1684 cf->cfWriteLong = naWriteLong;
1685
1686 if( rCanShortOut(n2pRing) )
1687 cf->cfWriteShort = naWriteShort;
1688 else
1689 cf->cfWriteShort = naWriteLong;
1690
1691 cf->cfRead = n2pRead;
1692 cf->cfDelete = naDelete;
1693 cf->cfSetMap = naSetMap;
1694 //cf->cfGetDenom = naGetDenom; // use nd*
1695 //cf->cfGetNumerator = naGetNumerator; // use nd*
1696 cf->cfRePart = naCopy;
1697 cf->cfCoeffWrite = n2pCoeffWrite;
1698 cf->cfNormalize = n2pNormalize;
1699 cf->cfKillChar = naKillChar;
1700#ifdef LDEBUG
1701 cf->cfDBTest = naDBTest;
1702#endif
1703 cf->cfGcd = naGcd;
1704 cf->cfNormalizeHelper = naLcmContent;
1705 cf->cfSize = naSize;
1706 cf->nCoeffIsEqual = n2pCoeffIsEqual;
1707 cf->cfInvers = n2pInvers;
1708 cf->convFactoryNSingN=naConvFactoryNSingN;
1709 cf->convSingNFactoryN=naConvSingNFactoryN;
1710 cf->cfParDeg = naParDeg;
1711
1712 cf->iNumberOfParameters = rVar(R);
1713 cf->pParameterNames = (const char**)R->names;
1714 cf->cfParameter = naParameter;
1715 cf->has_simple_Inverse=FALSE;
1716 /* cf->has_simple_Alloc= FALSE; */
1717
1718 if( nCoeff_is_Q(R->cf) )
1719 {
1720 cf->cfClearContent = naClearContent;
1721 cf->cfClearDenominators = naClearDenominators;
1722 }
1723
1724 return FALSE;
1725}
static number naInit(long i, const coeffs cf)
Definition algext.cc:325
number n2pDiv(number a, number b, const coeffs cf)
Definition algext.cc:1540
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:1378
number n2pMult(number a, number b, const coeffs cf)
Definition algext.cc:1532
const char * n2pRead(const char *s, number *a, const coeffs cf)
Definition algext.cc:1556
static number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition algext.cc:1366
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:1115
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:1089
#define n2pRing
Definition algext.cc:1509
static int naParDeg(number a, const coeffs cf)
Definition algext.cc:1081
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:1320
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:1565
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:1585
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:1030
static void naKillChar(coeffs cf)
Definition algext.cc:1336
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:1624
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition algext.cc:1612
static void naDelete(number *a, const coeffs cf)
Definition algext.cc:276
void n2pNormalize(number &a, const coeffs cf)
Definition algext.cc:1525
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:1549
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:799
#define assume(x)
Definition mod2.h:389
#define NULL
Definition omList.c:12
static ring rIncRefCnt(ring r)
Definition ring.h:849
static BOOLEAN rCanShortOut(const ring r)
Definition ring.h:592
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
#define R
Definition sirandom.c:27

◆ naCoeffName()

char * naCoeffName ( const coeffs r)

Definition at line 1343 of file algext.cc.

1344{
1345 const char* const* p=n_ParameterNames(r);
1346 int l=0;
1347 int i;
1348 for(i=0; i<n_NumberOfParameters(r);i++)
1349 {
1350 l+=(strlen(p[i])+1);
1351 }
1352 STATIC_VAR char s[200];
1353 s[0]='\0';
1354 snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
1355 char tt[2];
1356 tt[0]=',';
1357 tt[1]='\0';
1358 for(i=0; i<n_NumberOfParameters(r);i++)
1359 {
1360 strcat(s,tt);
1361 strcat(s,p[i]);
1362 }
1363 return s;
1364}
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:771
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition coeffs.h:767
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 1386 of file algext.cc.

1387{
1388 assume( infoStruct != NULL );
1389
1390 AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1391 /// first check whether cf->extRing != NULL and delete old ring???
1392
1393 assume(e->r != NULL); // extRing;
1394 assume(e->r->cf != NULL); // extRing->cf;
1395
1396 assume((e->r->qideal != NULL) && // minideal has one
1397 (IDELEMS(e->r->qideal) == 1) && // non-zero generator
1398 (e->r->qideal->m[0] != NULL) ); // at m[0];
1399
1400 assume( cf != NULL );
1401 assume(getCoeffType(cf) == n_algExt); // coeff type;
1402
1403 rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1404 const ring R = e->r; // no copy!
1405 cf->extRing = R;
1406
1407 /* propagate characteristic up so that it becomes
1408 directly accessible in cf: */
1409 cf->ch = R->cf->ch;
1410
1411 cf->is_field=TRUE;
1412 cf->is_domain=TRUE;
1413 cf->rep=n_rep_poly;
1414
1415 #ifdef LDEBUG
1416 p_Test((poly)naMinpoly, naRing);
1417 #endif
1418
1419 cf->cfCoeffName = naCoeffName;
1420
1421 cf->cfGreaterZero = naGreaterZero;
1422 cf->cfGreater = naGreater;
1423 cf->cfEqual = naEqual;
1424 cf->cfIsZero = naIsZero;
1425 cf->cfIsOne = naIsOne;
1426 cf->cfIsMOne = naIsMOne;
1427 cf->cfInit = naInit;
1428 cf->cfInitMPZ = naInitMPZ;
1429 cf->cfFarey = naFarey;
1430 cf->cfChineseRemainder= naChineseRemainder;
1431 cf->cfInt = naInt;
1432 cf->cfInpNeg = naNeg;
1433 cf->cfAdd = naAdd;
1434 cf->cfSub = naSub;
1435 cf->cfMult = naMult;
1436 cf->cfInpMult = naInpMult;
1437 cf->cfDiv = naDiv;
1438 cf->cfExactDiv = naDiv;
1439 cf->cfPower = naPower;
1440 cf->cfCopy = naCopy;
1441
1442 cf->cfWriteLong = naWriteLong;
1443
1444 if( rCanShortOut(naRing) )
1445 cf->cfWriteShort = naWriteShort;
1446 else
1447 cf->cfWriteShort = naWriteLong;
1448
1449 cf->cfRead = naRead;
1450 cf->cfDelete = naDelete;
1451 cf->cfSetMap = naSetMap;
1452 cf->cfRePart = naCopy;
1453 cf->cfCoeffWrite = naCoeffWrite;
1454 cf->cfNormalize = naNormalize;
1455 cf->cfKillChar = naKillChar;
1456#ifdef LDEBUG
1457 cf->cfDBTest = naDBTest;
1458#endif
1459 cf->cfGcd = naGcd;
1460 cf->cfNormalizeHelper = naLcmContent;
1461 cf->cfSize = naSize;
1462 cf->nCoeffIsEqual = naCoeffIsEqual;
1463 cf->cfInvers = naInvers;
1464 cf->convFactoryNSingN=naConvFactoryNSingN;
1465 cf->convSingNFactoryN=naConvSingNFactoryN;
1466 cf->cfParDeg = naParDeg;
1467
1468 cf->iNumberOfParameters = rVar(R);
1469 cf->pParameterNames = (const char**)R->names;
1470 cf->cfParameter = naParameter;
1471 cf->has_simple_Inverse= R->cf->has_simple_Inverse;
1472 /* cf->has_simple_Alloc= FALSE; */
1473
1474 if( nCoeff_is_Q(R->cf) )
1475 {
1476 cf->cfClearContent = naClearContent;
1477 cf->cfClearDenominators = naClearDenominators;
1478 }
1479
1480 return FALSE;
1481}
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:1343
#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:429
@ 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 1104 of file algext.cc.

1105{
1107
1108 const ring R = cf->extRing;
1109 assume( R != NULL );
1110
1111 return p_Var( (poly)m, R );
1112}
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:4765

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

1031{
1032 /* dst is expected to be an algebraic field extension */
1033 assume(getCoeffType(dst) == n_algExt);
1034
1035 int h = 0; /* the height of the extension tower given by dst */
1036 coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1037 coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1038
1039 /* for the time being, we only provide maps if h = 1 or 0 */
1040 if (h==0)
1041 {
1042 if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1043 return naMap00; /// Q or Z --> Q(a)
1044 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1045 return naMapZ0; /// Z --> Q(a)
1046 if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1047 return naMapP0; /// Z/p --> Q(a)
1048 if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1049 return naMap0P; /// Q --> Z/p(a)
1050 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1051 return naMapZ0; /// Z --> Z/p(a)
1052 if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1053 {
1054 if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1055 else return naMapUP; /// Z/u --> Z/p(a)
1056 }
1057 }
1058 if (h != 1) return NULL;
1059 if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1060 if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1061
1062 nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1063 if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1064 {
1065 if (src->type==n_algExt)
1066 return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1067 else
1068 return naCopyTrans2AlgExt;
1069 }
1070 else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1071 {
1072 if (src->type==n_algExt)
1073 return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1074 else
1075 return naGenTrans2AlgExt;
1076 }
1077
1078 return NULL; /// default
1079}
static number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition algext.cc:1000
static number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition algext.cc:985
static number naMapPP(number a, const coeffs src, const coeffs dst)
Definition algext.cc:964
static number naMapZ0(number a, const coeffs src, const coeffs dst)
Definition algext.cc:871
static number naMap0P(number a, const coeffs src, const coeffs dst)
Definition algext.cc:951
static number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition algext.cc:903
static number naMapUP(number a, const coeffs src, const coeffs dst)
Definition algext.cc:974
static number naMap00(number a, const coeffs src, const coeffs dst)
Definition algext.cc:861
static number naMapP0(number a, const coeffs src, const coeffs dst)
Definition algext.cc:883
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:287
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:701
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition coeffs.h:822
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:793
@ 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:1804
static char * rRingVar(short i, const ring r)
Definition ring.h:583

◆ 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