Loading...
Searching...
No Matches
numbers.h File Reference
`#include "coeffs/coeffs.h"`

Go to the source code of this file.

## Macros

#define | nCopy(n)
#define | nDelete(n)
#define | nMult(n1, n2)
#define | nAdd(n1, n2)
#define | nIsZero(n)
#define | nEqual(n1, n2)
#define | nInpNeg(n)
#define | nSub(n1, n2)
#define | nGetChar()
#define | nInit(i)
#define | nIsOne(n)
#define | nIsMOne(n)
#define | nGreaterZero(n)
#define | nGreater(a, b)
#define | nWrite(n)
#define | nNormalize(n)
#define | nGcd(a, b)
#define | nDiv(a, b)
#define | nInvers(a)
#define | nExactDiv(a, b)
#define | nTest(a)
#define | nInpMult(a, b)
#define | nPower(a, b, res)
#define | nSize(n)
#define | nGetDenom(N)
#define | nGetNumerator(N)
#define | nSetMap(R)
#define | nPrint(a)
| only for debug, over any initialized currRing
#define | SHORT_REAL_LENGTH 6

## Typedefs

typedef BOOLEAN(* | cfInitCharProc) (coeffs, void *)
| initialize an object of type coeff, return FALSE in case of success
typedef coeffs(* | cfInitCfByNameProc) (char *s, n_coeffType n)
| initialize an object of type coeffs by its name, return NULL otherwise

## Functions

number | ndGcd (number a, number b, const coeffs)
number | ndQuotRem (number a, number b, number *r, const coeffs R)
CanonicalForm | ndConvSingNFactoryN (number, BOOLEAN, const coeffs)
number | ndReadFd (const ssiInfo *f, const coeffs r)
number | ndReadFd_S (char **, const coeffs r)
BOOLEAN | n_IsZeroDivisor (number a, const coeffs r)
| Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementation: should ONLY be used for debug stuff /tests.
void | ndNormalize (number &, const coeffs)
n_coeffType | nRegister (n_coeffType n, cfInitCharProc p)
void | nRegisterCfByName (cfInitCfByNameProc p, n_coeffType n)
coeffs | nFindCoeffByName (char *n)
| find an existing coeff by its "CoeffName"
char * | nEati (char *s, int *i, int m)
| divide by the first (leading) number and return it, i.e. make monic
char * | nEati (char *s, long *i, int m)
char * | nEatLong (char *s, mpz_ptr i)
| extracts a long integer from s, returns the rest

## Variables

const char *const | nDivBy0 = "div by 0"

## Macro Definition Documentation

## nAdd

#define nAdd | ( |  | n1,
|  |  | n2 )

Value:
n_Add(n1, n2, currRing->cf)
n_Add
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:653
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13

Definition at line 18 of file numbers.h.

## nCopy

#define nCopy | ( |  | n | ) |

Value:
n_Copy(n, currRing->cf)
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457

Definition at line 15 of file numbers.h.

## nDelete

#define nDelete | ( |  | n | ) |

Value:
n_Delete(n, currRing->cf)
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461

Definition at line 16 of file numbers.h.

## nDiv

#define nDiv | ( |  | a,
|  |  | b )

Value:
n_Div(a,b,currRing->cf)
b
CanonicalForm b
Definition cfModGcd.cc:4111
n_Div
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:618

Definition at line 32 of file numbers.h.

## nEqual

#define nEqual | ( |  | n1,
|  |  | n2 )

Value:
n_Equal(n1, n2, currRing->cf)
n_Equal
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:466

Definition at line 20 of file numbers.h.

## nExactDiv

#define nExactDiv | ( |  | a,
|  |  | b )

Value:
n_ExactDiv(a,b,currRing->cf)
n_ExactDiv
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition coeffs.h:625

Definition at line 34 of file numbers.h.

## nGcd

#define nGcd | ( |  | a,
|  |  | b )

Value:
n_Gcd(a,b,currRing->cf)
n_Gcd
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667

Definition at line 31 of file numbers.h.

## nGetChar

#define nGetChar | ( |  | ) |

Value:
n_GetChar(currRing->cf)
n_GetChar
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:450

Definition at line 23 of file numbers.h.

## nGetDenom

#define nGetDenom | ( |  | N | ) |

Value:
n_GetDenom((N),currRing->cf)
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
n_GetDenom
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition coeffs.h:606

Definition at line 40 of file numbers.h.

## nGetNumerator

#define nGetNumerator | ( |  | N | ) |

Value:
n_GetNumerator((N),currRing->cf)
n_GetNumerator
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:611

Definition at line 41 of file numbers.h.

## nGreater

#define nGreater | ( |  | a,
|  |  | b )

Value:
n_Greater (a,b,currRing->cf)
n_Greater
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition coeffs.h:517

Definition at line 28 of file numbers.h.

## nGreaterZero

#define nGreaterZero | ( |  | n | ) |

Value:
n_GreaterZero(n, currRing->cf)
n_GreaterZero
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:500

Definition at line 27 of file numbers.h.

## nInit

#define nInit | ( |  | i | ) |

Value:
n_Init(i, currRing->cf)
i
int i
Definition cfEzgcd.cc:132
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541

Definition at line 24 of file numbers.h.

## nInpMult

#define nInpMult | ( |  | a,
|  |  | b )

Value:
n_InpMult(a,b,currRing->cf)
n_InpMult
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition coeffs.h:644

Definition at line 37 of file numbers.h.

## nInpNeg

#define nInpNeg | ( |  | n | ) |

Value:
n_InpNeg(n, currRing->cf)
n_InpNeg
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:560

Definition at line 21 of file numbers.h.

## nInvers

#define nInvers | ( |  | a | ) |

Value:
n_Invers(a,currRing->cf)
n_Invers
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
Definition coeffs.h:567

Definition at line 33 of file numbers.h.

## nIsMOne

#define nIsMOne | ( |  | n | ) |

Value:
n_IsMOne(n, currRing->cf)
n_IsMOne
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
Definition coeffs.h:478

Definition at line 26 of file numbers.h.

## nIsOne

#define nIsOne | ( |  | n | ) |

Value:
n_IsOne(n, currRing->cf)
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474

Definition at line 25 of file numbers.h.

## nIsZero

#define nIsZero | ( |  | n | ) |

Value:
n_IsZero(n, currRing->cf)
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470

Definition at line 19 of file numbers.h.

## nMult

#define nMult | ( |  | n1,
|  |  | n2 )

Value:
n_Mult(n1, n2, currRing->cf)
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639

Definition at line 17 of file numbers.h.

## nNormalize

#define nNormalize | ( |  | n | ) |

Value:
n_Normalize(n,currRing->cf)
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:581

Definition at line 30 of file numbers.h.

## nPower

#define nPower | ( |  | a,
|  |  | b,
|  |  | res )

Value:
n_Power(a,b,res,currRing->cf)
n_Power
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:635
res
CanonicalForm res
Definition facAbsFact.cc:60

Definition at line 38 of file numbers.h.

## nPrint

#define nPrint | ( |  | a | ) |

Value:
n_Print(a,currRing->cf)
n_Print
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition numbers.cc:662

only for debug, over any initialized currRing

Definition at line 46 of file numbers.h.

## nSetMap

#define nSetMap | ( |  | R | ) |

Value:
n_SetMap(R,currRing->cf)
n_SetMap
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
R
#define R
Definition sirandom.c:27

Definition at line 43 of file numbers.h.

## nSize

#define nSize | ( |  | n | ) |

Value:
n_Size(n,currRing->cf)
n_Size
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:573

Definition at line 39 of file numbers.h.

## nSub

#define nSub | ( |  | n1,
|  |  | n2 )

Value:
n_Sub(n1, n2, currRing->cf)
n_Sub
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:658

Definition at line 22 of file numbers.h.

## nTest

#define nTest | ( |  | a | ) |

Value:
n_Test(a,currRing->cf)
n_Test
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r).
Definition coeffs.h:715

Definition at line 35 of file numbers.h.

## nWrite

#define nWrite | ( |  | n | ) |

Value:
n_Write(n, currRing->cf, rShortOut(currRing))
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
rShortOut
static BOOLEAN rShortOut(const ring r)
Definition ring.h:587

Definition at line 29 of file numbers.h.

## SHORT_REAL_LENGTH

#define SHORT_REAL_LENGTH 6

Definition at line 57 of file numbers.h.

## Typedef Documentation

## cfInitCfByNameProc

typedef coeffs(* cfInitCfByNameProc) (char *s, n_coeffType n)

initialize an object of type coeffs by its name, return NULL otherwise

Definition at line 100 of file numbers.h.

## cfInitCharProc

typedef BOOLEAN(* cfInitCharProc) (coeffs, void *)

initialize an object of type coeff, return FALSE in case of success

Definition at line 96 of file numbers.h.

## Function Documentation

## n_IsZeroDivisor()

BOOLEAN n_IsZeroDivisor | ( | number | a,
|  | const coeffs | r )

Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementation: should ONLY be used for debug stuff /tests.

Definition at line 177 of file numbers.cc.

{
BOOLEAN ret = n_IsZero(a, r);
int c = n_GetChar(r);
if (ret || (c==0) || (r->is_field))
return ret; /*n_IsZero(a, r)*/
number ch = n_Init( c, r );
number g = n_Gcd( ch, a, r );
ret = !n_IsOne (g, r);
n_Delete(&ch, r);
n_Delete(&g, r);
return ret;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
g
g
Definition cfModGcd.cc:4098

## ndConvSingNFactoryN()

CanonicalForm ndConvSingNFactoryN | ( | number | ,
|  | BOOLEAN | ,
|  | const coeffs | )

Definition at line 313 of file numbers.cc.

{
CanonicalForm term(0);
WerrorS("no conversion to factory");
return term;
}
CanonicalForm
factory's main class
Definition canonicalform.h:86
term
Definition int_poly.h:33
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24

## ndGcd()

number ndGcd | ( | number | a,
|  | number | b,
|  | const coeffs | r )

Definition at line 193 of file numbers.cc.

{ return r->cfInit(1,r); }

## ndNormalize()

void ndNormalize | ( | number & | ,
|  | const coeffs | )

Definition at line 191 of file numbers.cc.

{ }

## ndQuotRem()

number ndQuotRem | ( | number | a,
|  | number | b,
|  | number * | r,
|  | const coeffs | R )

Definition at line 356 of file numbers.cc.

{
// implementation for a field: r: 0, result: n_Div
if(R->is_field)
{
*r=n_Init(0,R);
return n_Div(a,b,R);
}
else
// implementation for a non-field:
{
number d=n_Div(a,b,R);
number p=n_Mult(b,d,R);
*r=n_Sub(a,p,R);
n_Delete(&p,R);
return d;
}
p
int p
Definition cfModGcd.cc:4086

## ndReadFd()

number ndReadFd | ( | const ssiInfo * | f,
|  | const coeffs | r )

Definition at line 150 of file numbers.cc.

{
Warn("ReadFd not implemented for %s (c=%d)",r->cfCoeffName(r),getCoeffType(r));
return n_Init(0,r);
}
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:431
Warn
#define Warn
Definition emacs.cc:77

## ndReadFd_S()

number ndReadFd_S | ( | char ** | ,
|  | const coeffs | r )

Definition at line 156 of file numbers.cc.

{
Warn("ReadFd_S not implemented for %s (c=%d)",r->cfCoeffName(r),getCoeffType(r));
return n_Init(0,r);
}

## nEati() [1/2]

char * nEati | ( | char * | s,
|  | int * | i,
|  | int | m )

divide by the first (leading) number and return it, i.e. make monic

does nothing (just returns a dummy one number) helper routine: read an int from a string (mod m), return a pointer to the rest

Definition at line 672 of file numbers.cc.

{
if (((*s) >= '0') && ((*s) <= '9'))
{
unsigned long ii=0L;
do
{
ii *= 10;
ii += *s++ - '0';
if ((m!=0) && (ii > (MAX_INT_VAL / 10))) ii = ii % m;
}
while (((*s) >= '0') && ((*s) <= '9'));
if ((m!=0) && (ii>=(unsigned)m)) ii=ii%m;
*i=(int)ii;
}
else (*i) = 1;
return s;
m
int m
Definition cfEzgcd.cc:128
s
const CanonicalForm int s
Definition facAbsFact.cc:51
MAX_INT_VAL
const int MAX_INT_VAL
Definition mylimits.h:12

## nEati() [2/2]

char * nEati | ( | char * | s,
|  | long * | i,
|  | int | m )

Definition at line 692 of file numbers.cc.

{
if (((*s) >= '0') && ((*s) <= '9'))
{
unsigned long ii=0L;
do
{
ii *= 10;
ii += *s++ - '0';
if ((m!=0) && (ii > (LONG_MAX / 10))) ii = ii % m;
}
while (((*s) >= '0') && ((*s) <= '9'));
if ((m!=0) && (ii>=(unsigned long)m)) ii=ii%(unsigned long)m;
*i=ii;
}
else (*i) = 1L;
return s;

## nEatLong()

char * nEatLong | ( | char * | s,
|  | mpz_ptr | i )

extracts a long integer from s, returns the rest

Definition at line 713 of file numbers.cc.

{
const char * start=s;
while (*s >= '0' && *s <= '9') s++;
if (*s=='\0')
{
mpz_set_str(i,start,10);
}
else
{
char c=*s;
*s='\0';
mpz_set_str(i,start,10);
*s=c;
}
return s;

## nFindCoeffByName()

coeffs nFindCoeffByName | ( | char * | n | ) |

find an existing coeff by its "CoeffName"

Definition at line 640 of file numbers.cc.

{
n_Procs_s* n=cf_root;
// try existings coeffs:
while(n!=NULL)
{
if ((n->cfCoeffName!=NULL)
&& (strcmp(cf_name,n->cfCoeffName(n))==0)) return n;
n=n->next;
}
// TODO: parametrized cf, e.g. flint:Z/26[a]
// try existing types:
nFindCoeffByName_p p=nFindCoeffByName_Root;
while(p!=NULL)
{
coeffs cf=p->p(cf_name,p->n);
if (cf!=NULL) return cf;
p=p->next;
}
return NULL;
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
n_Procs_s::next
coeffs next
Definition coeffs.h:132
n_Procs_s::cfCoeffName
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitute cfCoeffWrite, cfCoeffString
Definition coeffs.h:161
n_Procs_s
Definition coeffs.h:130
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
nFindCoeffByName_Root
VAR nFindCoeffByName_p nFindCoeffByName_Root
Definition numbers.cc:630
cf_root
VAR n_Procs_s * cf_root
Definition numbers.cc:43
NULL
#define NULL
Definition omList.c:12

## nRegister()

n_coeffType nRegister | ( | n_coeffType | n,
|  | cfInitCharProc | p )

Definition at line 590 of file numbers.cc.

{
if (n==n_unknown)
{
nLastCoeffs=(n_coeffType)(int(nLastCoeffs)+1);
if (nInitCharTable==nInitCharTableDefault)
{
nInitCharTable=(cfInitCharProc*)omAlloc0(
((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
memcpy(nInitCharTable,nInitCharTableDefault,
((int)nLastCoeffs)*sizeof(cfInitCharProc));
}
else
{
nInitCharTable=(cfInitCharProc*)omReallocSize(nInitCharTable,
((int)nLastCoeffs)*sizeof(cfInitCharProc),
(((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
}
nInitCharTable[nLastCoeffs]=p;
return nLastCoeffs;
}
else
{
//if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
nInitCharTable[n]=p;
return n;
}
n_coeffType
n_coeffType
Definition coeffs.h:27
n_unknown
@ n_unknown
Definition coeffs.h:28
nLastCoeffs
STATIC_VAR n_coeffType nLastCoeffs
Definition numbers.cc:374
nInitCharTable
STATIC_VAR cfInitCharProc * nInitCharTable
Definition numbers.cc:408
nInitCharTableDefault
VAR cfInitCharProc nInitCharTableDefault[]
Definition numbers.cc:375
cfInitCharProc
BOOLEAN(* cfInitCharProc)(coeffs, void *)
initialize an object of type coeff, return FALSE in case of success
Definition numbers.h:96
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition omAllocDecl.h:220
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## nRegisterCfByName()

void nRegisterCfByName | ( | cfInitCfByNameProc | p,
|  | n_coeffType | n )

Definition at line 631 of file numbers.cc.

{
nFindCoeffByName_p h=(nFindCoeffByName_p)omAlloc0(sizeof(*h));
h->p=p;
h->n=n;
h->next=nFindCoeffByName_Root;
nFindCoeffByName_Root=h;
h
STATIC_VAR Poly * h
Definition janet.cc:971

## Variable Documentation

## nDivBy0

const char* const nDivBy0 = "div by 0"

Definition at line 90 of file numbers.h.