My Project
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)
 
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)
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:651
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:
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455

Definition at line 15 of file numbers.h.

◆ nDelete

#define nDelete ( n)
Value:
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459

Definition at line 16 of file numbers.h.

◆ nDiv

#define nDiv ( a,
b )
Value:
CanonicalForm b
Definition cfModGcd.cc:4111
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:616

Definition at line 32 of file numbers.h.

◆ nEqual

#define nEqual ( n1,
n2 )
Value:
n_Equal(n1, n2, currRing->cf)
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:464

Definition at line 20 of file numbers.h.

◆ nExactDiv

#define nExactDiv ( a,
b )
Value:
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:623

Definition at line 34 of file numbers.h.

◆ nGcd

#define nGcd ( a,
b )
Value:
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:665

Definition at line 31 of file numbers.h.

◆ nGetChar

#define nGetChar ( )
Value:
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:448

Definition at line 23 of file numbers.h.

◆ nGetDenom

#define nGetDenom ( N)
Value:
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
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:604

Definition at line 40 of file numbers.h.

◆ nGetNumerator

#define nGetNumerator ( N)
Value:
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:609

Definition at line 41 of file numbers.h.

◆ nGreater

#define nGreater ( a,
b )
Value:
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:515

Definition at line 28 of file numbers.h.

◆ nGreaterZero

#define nGreaterZero ( n)
Value:
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:498

Definition at line 27 of file numbers.h.

◆ nInit

#define nInit ( i)
Value:
int i
Definition cfEzgcd.cc:132
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:539

Definition at line 24 of file numbers.h.

◆ nInpMult

#define nInpMult ( a,
b )
Value:
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:642

Definition at line 37 of file numbers.h.

◆ nInpNeg

#define nInpNeg ( n)
Value:
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:558

Definition at line 21 of file numbers.h.

◆ nInvers

#define nInvers ( a)
Value:
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:565

Definition at line 33 of file numbers.h.

◆ nIsMOne

#define nIsMOne ( n)
Value:
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:476

Definition at line 26 of file numbers.h.

◆ nIsOne

#define nIsOne ( n)
Value:
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472

Definition at line 25 of file numbers.h.

◆ nIsZero

#define nIsZero ( n)
Value:
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468

Definition at line 19 of file numbers.h.

◆ nMult

#define nMult ( n1,
n2 )
Value:
n_Mult(n1, n2, currRing->cf)
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:637

Definition at line 17 of file numbers.h.

◆ nNormalize

#define nNormalize ( n)
Value:
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579

Definition at line 30 of file numbers.h.

◆ nPower

#define nPower ( a,
b,
res )
Value:
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:633
CanonicalForm res
Definition facAbsFact.cc:60

Definition at line 38 of file numbers.h.

◆ nPrint

#define nPrint ( a)
Value:
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition numbers.cc:655

only for debug, over any initialized currRing

Definition at line 46 of file numbers.h.

◆ nSetMap

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

Definition at line 43 of file numbers.h.

◆ nSize

#define nSize ( n)
Value:
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:571

Definition at line 39 of file numbers.h.

◆ nSub

#define nSub ( n1,
n2 )
Value:
n_Sub(n1, n2, currRing->cf)
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:656

Definition at line 22 of file numbers.h.

◆ nTest

#define nTest ( a)
Value:
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:713

Definition at line 35 of file numbers.h.

◆ nWrite

#define nWrite ( n)
Value:
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:592
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 99 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 95 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 171 of file numbers.cc.

172{
173 BOOLEAN ret = n_IsZero(a, r);
174 int c = n_GetChar(r);
175 if (ret || (c==0) || (r->is_field))
176 return ret; /*n_IsZero(a, r)*/
177 number ch = n_Init( c, r );
178 number g = n_Gcd( ch, a, r );
179 ret = !n_IsOne (g, r);
180 n_Delete(&ch, r);
181 n_Delete(&g, r);
182 return ret;
183}
int BOOLEAN
Definition auxiliary.h:88
g
Definition cfModGcd.cc:4098

◆ ndConvSingNFactoryN()

CanonicalForm ndConvSingNFactoryN ( number ,
BOOLEAN ,
const coeffs  )

Definition at line 307 of file numbers.cc.

308{
310 WerrorS("no conversion to factory");
311 return term;
312}
factory's main class
void WerrorS(const char *s)
Definition feFopen.cc:24

◆ ndGcd()

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

Definition at line 187 of file numbers.cc.

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

◆ ndNormalize()

void ndNormalize ( number & ,
const coeffs  )

Definition at line 185 of file numbers.cc.

185{ }

◆ ndQuotRem()

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

Definition at line 350 of file numbers.cc.

352{
353 // implementation for a field: r: 0, result: n_Div
354 if(R->is_field)
355 {
356 *r=n_Init(0,R);
357 return n_Div(a,b,R);
358 }
359 else
360 // implementation for a non-field:
361 {
362 number d=n_Div(a,b,R);
363 number p=n_Mult(b,d,R);
364 *r=n_Sub(a,p,R);
365 n_Delete(&p,R);
366 return d;
367 }
int p
Definition cfModGcd.cc:4086

◆ ndReadFd()

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

Definition at line 150 of file numbers.cc.

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

◆ 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 665 of file numbers.cc.

667{
668
669 if (((*s) >= '0') && ((*s) <= '9'))
670 {
671 unsigned long ii=0L;
672 do
673 {
674 ii *= 10;
675 ii += *s++ - '0';
676 if ((m!=0) && (ii > (MAX_INT_VAL / 10))) ii = ii % m;
677 }
678 while (((*s) >= '0') && ((*s) <= '9'));
679 if ((m!=0) && (ii>=(unsigned)m)) ii=ii%m;
680 *i=(int)ii;
681 }
682 else (*i) = 1;
683 return s;
int m
Definition cfEzgcd.cc:128
const CanonicalForm int s
Definition facAbsFact.cc:51
const int MAX_INT_VAL
Definition mylimits.h:12

◆ nEati() [2/2]

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

Definition at line 685 of file numbers.cc.

687{
688
689 if (((*s) >= '0') && ((*s) <= '9'))
690 {
691 unsigned long ii=0L;
692 do
693 {
694 ii *= 10;
695 ii += *s++ - '0';
696 if ((m!=0) && (ii > (LONG_MAX / 10))) ii = ii % m;
697 }
698 while (((*s) >= '0') && ((*s) <= '9'));
699 if ((m!=0) && (ii>=(unsigned long)m)) ii=ii%(unsigned long)m;
700 *i=ii;
701 }
702 else (*i) = 1L;
703 return s;

◆ nEatLong()

char * nEatLong ( char * s,
mpz_ptr i )

extracts a long integer from s, returns the rest

Definition at line 706 of file numbers.cc.

708{
709 const char * start=s;
710
711 while (*s >= '0' && *s <= '9') s++;
712 if (*s=='\0')
713 {
714 mpz_set_str(i,start,10);
715 }
716 else
717 {
718 char c=*s;
719 *s='\0';
720 mpz_set_str(i,start,10);
721 *s=c;
722 }
723 return s;

◆ nFindCoeffByName()

coeffs nFindCoeffByName ( char * n)

find an existing coeff by its "CoeffName"

Definition at line 633 of file numbers.cc.

635{
637 // try existings coeffs:
638 while(n!=NULL)
639 {
640 if ((n->cfCoeffName!=NULL)
641 && (strcmp(cf_name,n->cfCoeffName(n))==0)) return n;
642 n=n->next;
643 }
644 // TODO: parametrized cf, e.g. flint:Z/26[a]
645 // try existing types:
646 nFindCoeffByName_p p=nFindCoeffByName_Root;
647 while(p!=NULL)
648 {
649 coeffs cf=p->p(cf_name,p->n);
650 if (cf!=NULL) return cf;
651 p=p->next;
652 }
653 return NULL;
CanonicalForm cf
Definition cfModGcd.cc:4091
coeffs next
Definition coeffs.h:132
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitute cfCoeffWrite, cfCoeffString
Definition coeffs.h:161
The main handler for Singular numbers which are suitable for Singular polynomials.
VAR nFindCoeffByName_p nFindCoeffByName_Root
Definition numbers.cc:623
VAR n_Procs_s * cf_root
Definition numbers.cc:43
#define NULL
Definition omList.c:12

◆ nRegister()

n_coeffType nRegister ( n_coeffType n,
cfInitCharProc p )

Definition at line 583 of file numbers.cc.

585{
586 if (n==n_unknown)
587 {
590 {
592 ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
594 ((int)nLastCoeffs)*sizeof(cfInitCharProc));
595 }
596 else
597 {
599 ((int)nLastCoeffs)*sizeof(cfInitCharProc),
600 (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
601 }
602
604 return nLastCoeffs;
605 }
606 else
607 {
608 //if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
609 nInitCharTable[n]=p;
610 return n;
611 }
n_coeffType
Definition coeffs.h:27
@ n_unknown
Definition coeffs.h:28
STATIC_VAR n_coeffType nLastCoeffs
Definition numbers.cc:368
STATIC_VAR cfInitCharProc * nInitCharTable
Definition numbers.cc:402
VAR cfInitCharProc nInitCharTableDefault[]
Definition numbers.cc:369
BOOLEAN(* cfInitCharProc)(coeffs, void *)
initialize an object of type coeff, return FALSE in case of success
Definition numbers.h:95
#define omReallocSize(addr, o_size, size)
#define omAlloc0(size)

◆ nRegisterCfByName()

void nRegisterCfByName ( cfInitCfByNameProc p,
n_coeffType n )

Definition at line 624 of file numbers.cc.

626{
627 nFindCoeffByName_p h=(nFindCoeffByName_p)omAlloc0(sizeof(*h));
628 h->p=p;
629 h->n=n;
STATIC_VAR Poly * h
Definition janet.cc:971

Variable Documentation

◆ nDivBy0

const char* const nDivBy0 = "div by 0"

Definition at line 89 of file numbers.h.