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)
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)
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
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:457

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:461

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:618

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:466

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:625

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:667

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:450

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:606

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:611

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:517

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:500

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:541

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:644

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:560

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:567

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:478

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:474

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:470

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:639

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:581

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:635
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:662

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:703
#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:573

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:658

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:715

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:594
static BOOLEAN rShortOut(const ring r)
Definition ring.h:592

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.

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

◆ ndConvSingNFactoryN()

CanonicalForm ndConvSingNFactoryN ( number ,
BOOLEAN ,
const coeffs  )

Definition at line 313 of file numbers.cc.

314{
316 WerrorS("no conversion to factory");
317 return term;
318}
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 193 of file numbers.cc.

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

◆ ndNormalize()

void ndNormalize ( number & ,
const coeffs  )

Definition at line 191 of file numbers.cc.

191{ }

◆ ndQuotRem()

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

Definition at line 356 of file numbers.cc.

358{
359 // implementation for a field: r: 0, result: n_Div
360 if(R->is_field)
361 {
362 *r=n_Init(0,R);
363 return n_Div(a,b,R);
364 }
365 else
366 // implementation for a non-field:
367 {
368 number d=n_Div(a,b,R);
369 number p=n_Mult(b,d,R);
370 *r=n_Sub(a,p,R);
371 n_Delete(&p,R);
372 return d;
373 }
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:431
#define Warn
Definition emacs.cc:77

◆ ndReadFd_S()

number ndReadFd_S ( char ** ,
const coeffs r )

Definition at line 156 of file numbers.cc.

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

◆ 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.

674{
675
676 if (((*s) >= '0') && ((*s) <= '9'))
677 {
678 unsigned long ii=0L;
679 do
680 {
681 ii *= 10;
682 ii += *s++ - '0';
683 if ((m!=0) && (ii > (MAX_INT_VAL / 10))) ii = ii % m;
684 }
685 while (((*s) >= '0') && ((*s) <= '9'));
686 if ((m!=0) && (ii>=(unsigned)m)) ii=ii%m;
687 *i=(int)ii;
688 }
689 else (*i) = 1;
690 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 692 of file numbers.cc.

694{
695
696 if (((*s) >= '0') && ((*s) <= '9'))
697 {
698 unsigned long ii=0L;
699 do
700 {
701 ii *= 10;
702 ii += *s++ - '0';
703 if ((m!=0) && (ii > (LONG_MAX / 10))) ii = ii % m;
704 }
705 while (((*s) >= '0') && ((*s) <= '9'));
706 if ((m!=0) && (ii>=(unsigned long)m)) ii=ii%(unsigned long)m;
707 *i=ii;
708 }
709 else (*i) = 1L;
710 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.

715{
716 const char * start=s;
717
718 while (*s >= '0' && *s <= '9') s++;
719 if (*s=='\0')
720 {
721 mpz_set_str(i,start,10);
722 }
723 else
724 {
725 char c=*s;
726 *s='\0';
727 mpz_set_str(i,start,10);
728 *s=c;
729 }
730 return s;

◆ nFindCoeffByName()

coeffs nFindCoeffByName ( char * n)

find an existing coeff by its "CoeffName"

Definition at line 640 of file numbers.cc.

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

◆ nRegister()

n_coeffType nRegister ( n_coeffType n,
cfInitCharProc p )

Definition at line 590 of file numbers.cc.

592{
593 if (n==n_unknown)
594 {
597 {
599 ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
601 ((int)nLastCoeffs)*sizeof(cfInitCharProc));
602 }
603 else
604 {
606 ((int)nLastCoeffs)*sizeof(cfInitCharProc),
607 (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
608 }
609
611 return nLastCoeffs;
612 }
613 else
614 {
615 //if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
616 nInitCharTable[n]=p;
617 return n;
618 }
n_coeffType
Definition coeffs.h:27
@ n_unknown
Definition coeffs.h:28
STATIC_VAR n_coeffType nLastCoeffs
Definition numbers.cc:374
STATIC_VAR cfInitCharProc * nInitCharTable
Definition numbers.cc:408
VAR cfInitCharProc nInitCharTableDefault[]
Definition numbers.cc:375
BOOLEAN(* cfInitCharProc)(coeffs, void *)
initialize an object of type coeff, return FALSE in case of success
Definition numbers.h:96
#define omReallocSize(addr, o_size, size)
#define omAlloc0(size)

◆ nRegisterCfByName()

void nRegisterCfByName ( cfInitCfByNameProc p,
n_coeffType n )

Definition at line 631 of file numbers.cc.

633{
634 nFindCoeffByName_p h=(nFindCoeffByName_p)omAlloc0(sizeof(*h));
635 h->p=p;
636 h->n=n;
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.