My Project
Loading...
Searching...
No Matches
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 1642 of file algext.cc.

1643{
1644 assume( infoStruct != NULL );
1645
1646 AlgExtInfo *e = (AlgExtInfo *)infoStruct;
1647 /// first check whether cf->extRing != NULL and delete old ring???
1648
1649 assume(e->r != NULL); // extRing;
1650 assume(e->r->cf != NULL); // extRing->cf;
1651
1652 assume( cf != NULL );
1653
1654 rIncRefCnt(e->r); // increase the ref.counter for the ground poly. ring!
1655 const ring R = e->r; // no copy!
1656 cf->extRing = R;
1657
1658 /* propagate characteristic up so that it becomes
1659 directly accessible in cf: */
1660 cf->ch = R->cf->ch;
1661 cf->is_field=FALSE;
1662 cf->is_domain=TRUE;
1663
1664 cf->cfCoeffName = n2pCoeffName;
1665
1666 cf->cfGreaterZero = naGreaterZero;
1667 cf->cfGreater = naGreater;
1668 cf->cfEqual = naEqual;
1669 cf->cfIsZero = naIsZero;
1670 cf->cfIsOne = naIsOne;
1671 cf->cfIsMOne = naIsMOne;
1672 cf->cfInit = naInit;
1673 cf->cfInitMPZ = naInitMPZ;
1674 cf->cfFarey = naFarey;
1675 cf->cfChineseRemainder= naChineseRemainder;
1676 cf->cfInt = naInt;
1677 cf->cfInpNeg = naNeg;
1678 cf->cfAdd = naAdd;
1679 cf->cfInpAdd = naInpAdd;
1680 cf->cfSub = naSub;
1681 cf->cfMult = n2pMult;
1682 cf->cfDiv = n2pDiv;
1683 cf->cfPower = n2pPower;
1684 cf->cfCopy = naCopy;
1685
1686 cf->cfWriteLong = naWriteLong;
1687
1688 if( rCanShortOut(n2pRing) )
1689 cf->cfWriteShort = naWriteShort;
1690 else
1691 cf->cfWriteShort = naWriteLong;
1692
1693 cf->cfRead = n2pRead;
1694 cf->cfDelete = naDelete;
1695 cf->cfSetMap = naSetMap;
1696 //cf->cfGetDenom = naGetDenom; // use nd*
1697 //cf->cfGetNumerator = naGetNumerator; // use nd*
1698 cf->cfRePart = naCopy;
1699 cf->cfCoeffWrite = n2pCoeffWrite;
1700 cf->cfNormalize = n2pNormalize;
1701 cf->cfKillChar = naKillChar;
1702#ifdef LDEBUG
1703 cf->cfDBTest = naDBTest;
1704#endif
1705 cf->cfGcd = naGcd;
1706 cf->cfNormalizeHelper = naLcmContent;
1707 cf->cfSize = naSize;
1708 cf->nCoeffIsEqual = n2pCoeffIsEqual;
1709 cf->cfInvers = n2pInvers;
1710 cf->convFactoryNSingN=naConvFactoryNSingN;
1711 cf->convSingNFactoryN=naConvSingNFactoryN;
1712 cf->cfParDeg = naParDeg;
1713
1714 cf->iNumberOfParameters = rVar(R);
1715 cf->pParameterNames = (const char**)R->names;
1716 cf->cfParameter = naParameter;
1717 cf->has_simple_Inverse=FALSE;
1718 /* cf->has_simple_Alloc= FALSE; */
1719
1720 if( nCoeff_is_Q(R->cf) )
1721 {
1722 cf->cfClearContent = naClearContent;
1723 cf->cfClearDenominators = naClearDenominators;
1724 }
1725
1726 return FALSE;
1727}
static number naInit(long i, const coeffs cf)
Definition: algext.cc:327
number n2pDiv(number a, number b, const coeffs cf)
Definition: algext.cc:1542
static number naSub(number a, number b, const coeffs cf)
Definition: algext.cc:453
static BOOLEAN naEqual(number a, number b, const coeffs cf)
Definition: algext.cc:287
static BOOLEAN naGreaterZero(number a, const coeffs cf)
forward declarations
Definition: algext.cc:372
static CanonicalForm naConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
Definition: algext.cc:771
static void naInpAdd(number &a, number b, const coeffs cf)
Definition: algext.cc:442
static BOOLEAN naIsOne(number a, const coeffs cf)
Definition: algext.cc:303
static number naFarey(number p, number n, const coeffs cf)
Definition: algext.cc:1380
number n2pMult(number a, number b, const coeffs cf)
Definition: algext.cc:1534
const char * n2pRead(const char *s, number *a, const coeffs cf)
Definition: algext.cc:1558
static number naChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
Definition: algext.cc:1368
static number naConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
Definition: algext.cc:765
static BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)
Definition: algext.cc:233
static void naClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1117
static void naWriteShort(number a, const coeffs cf)
Definition: algext.cc:603
static int naSize(number a, const coeffs cf)
Definition: algext.cc:727
static number naAdd(number a, number b, const coeffs cf)
Definition: algext.cc:431
static number naParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given alg. field
Definition: algext.cc:1091
#define n2pRing
Definition: algext.cc:1511
static int naParDeg(number a, const coeffs cf)
Definition: algext.cc:1083
static number naCopy(number a, const coeffs cf)
Definition: algext.cc:296
static void naClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: algext.cc:1322
static number naInitMPZ(mpz_t m, const coeffs r)
Definition: algext.cc:333
static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
Definition: algext.cc:1567
static long naInt(number &a, const coeffs cf)
Definition: algext.cc:339
static number naLcmContent(number a, number b, const coeffs cf)
Definition: algext.cc:658
char * n2pCoeffName(const coeffs cf)
Definition: algext.cc:1587
static number naGcd(number a, number b, const coeffs cf)
Definition: algext.cc:785
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:1032
static void naKillChar(coeffs cf)
Definition: algext.cc:1338
static BOOLEAN naGreater(number a, number b, const coeffs cf)
Definition: algext.cc:352
static BOOLEAN naIsZero(number a, const coeffs cf)
Definition: algext.cc:272
number n2pInvers(number a, const coeffs cf)
Definition: algext.cc:1626
void n2pCoeffWrite(const coeffs cf, BOOLEAN details)
Definition: algext.cc:1614
static void naDelete(number *a, const coeffs cf)
Definition: algext.cc:278
void n2pNormalize(number &a, const coeffs cf)
Definition: algext.cc:1527
static void naWriteLong(number a, const coeffs cf)
Definition: algext.cc:585
void n2pPower(number a, int exp, number *b, const coeffs cf)
Definition: algext.cc:1551
static number naNeg(number a, const coeffs cf)
this is in-place, modifies a
Definition: algext.cc:320
static BOOLEAN naIsMOne(number a, const coeffs cf)
Definition: algext.cc:311
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:803
#define assume(x)
Definition: mod2.h:389
#define NULL
Definition: omList.c:12
static ring rIncRefCnt(ring r)
Definition: ring.h:837
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:586
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
#define R
Definition: sirandom.c:27

◆ naCoeffName()

char * naCoeffName ( const coeffs  r)

Definition at line 1345 of file algext.cc.

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

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

◆ naIsParam()

int naIsParam ( number  m,
const  coeffs 
)

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

Definition at line 1106 of file algext.cc.

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

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

1033{
1034 /* dst is expected to be an algebraic field extension */
1035 assume(getCoeffType(dst) == n_algExt);
1036
1037 int h = 0; /* the height of the extension tower given by dst */
1038 coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
1039 coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
1040
1041 /* for the time being, we only provide maps if h = 1 or 0 */
1042 if (h==0)
1043 {
1044 if ((src->rep==n_rep_gap_rat) && nCoeff_is_Q(bDst))
1045 return naMap00; /// Q or Z --> Q(a)
1046 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Q(bDst))
1047 return naMapZ0; /// Z --> Q(a)
1048 if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
1049 return naMapP0; /// Z/p --> Q(a)
1050 if (nCoeff_is_Q_or_BI(src) && nCoeff_is_Zp(bDst))
1051 return naMap0P; /// Q --> Z/p(a)
1052 if ((src->rep==n_rep_gap_gmp) && nCoeff_is_Zp(bDst))
1053 return naMapZ0; /// Z --> Z/p(a)
1054 if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst))
1055 {
1056 if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a)
1057 else return naMapUP; /// Z/u --> Z/p(a)
1058 }
1059 }
1060 if (h != 1) return NULL;
1061 if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
1062 if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q_or_BI(bSrc))) return NULL;
1063
1064 nMapFunc nMap=n_SetMap(src->extRing->cf,dst->extRing->cf);
1065 if (rSamePolyRep(src->extRing, dst->extRing) && (strcmp(rRingVar(0, src->extRing), rRingVar(0, dst->extRing)) == 0))
1066 {
1067 if (src->type==n_algExt)
1068 return ndCopyMap; // naCopyMap; /// K(a) --> K(a)
1069 else
1070 return naCopyTrans2AlgExt;
1071 }
1072 else if ((nMap!=NULL) && (strcmp(rRingVar(0,src->extRing),rRingVar(0,dst->extRing))==0) && (rVar (src->extRing) == rVar (dst->extRing)))
1073 {
1074 if (src->type==n_algExt)
1075 return naGenMap; // naCopyMap; /// K(a) --> K'(a)
1076 else
1077 return naGenTrans2AlgExt;
1078 }
1079
1080 return NULL; /// default
1081}
static number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:1002
static number naGenMap(number a, const coeffs cf, const coeffs dst)
Definition: algext.cc:987
static number naMapPP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:966
static number naMapZ0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:873
static number naMap0P(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:953
static number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:905
static number naMapUP(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:976
static number naMap00(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:863
static number naMapP0(number a, const coeffs src, const coeffs dst)
Definition: algext.cc:885
static coeffs nCoeff_bottom(const coeffs r, int &height)
Definition: algext.cc:258
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:291
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:697
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:826
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:797
@ 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:577

◆ 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:844