My Project
Loading...
Searching...
No Matches
Macros | Typedefs | Functions | Variables
numbers.h File Reference
#include "coeffs/coeffs.h"

Go to the source code of this file.

Macros

#define nCopy(n)   n_Copy(n, currRing->cf)
 
#define nDelete(n)   n_Delete(n, currRing->cf)
 
#define nMult(n1, n2)   n_Mult(n1, n2, currRing->cf)
 
#define nAdd(n1, n2)   n_Add(n1, n2, currRing->cf)
 
#define nIsZero(n)   n_IsZero(n, currRing->cf)
 
#define nEqual(n1, n2)   n_Equal(n1, n2, currRing->cf)
 
#define nInpNeg(n)   n_InpNeg(n, currRing->cf)
 
#define nSub(n1, n2)   n_Sub(n1, n2, currRing->cf)
 
#define nGetChar()   n_GetChar(currRing->cf)
 
#define nInit(i)   n_Init(i, currRing->cf)
 
#define nIsOne(n)   n_IsOne(n, currRing->cf)
 
#define nIsMOne(n)   n_IsMOne(n, currRing->cf)
 
#define nGreaterZero(n)   n_GreaterZero(n, currRing->cf)
 
#define nGreater(a, b)   n_Greater (a,b,currRing->cf)
 
#define nWrite(n)   n_Write(n, currRing->cf, rShortOut(currRing))
 
#define nNormalize(n)   n_Normalize(n,currRing->cf)
 
#define nGcd(a, b)   n_Gcd(a,b,currRing->cf)
 
#define nDiv(a, b)   n_Div(a,b,currRing->cf)
 
#define nInvers(a)   n_Invers(a,currRing->cf)
 
#define nExactDiv(a, b)   n_ExactDiv(a,b,currRing->cf)
 
#define nTest(a)   n_Test(a,currRing->cf)
 
#define nInpMult(a, b)   n_InpMult(a,b,currRing->cf)
 
#define nPower(a, b, res)   n_Power(a,b,res,currRing->cf)
 
#define nSize(n)   n_Size(n,currRing->cf)
 
#define nGetDenom(N)   n_GetDenom((N),currRing->cf)
 
#define nGetNumerator(N)   n_GetNumerator((N),currRing->cf)
 
#define nSetMap(R)   n_SetMap(R,currRing->cf)
 
#define nPrint(a)   n_Print(a,currRing->cf)
 only for debug, over any initalized currRing More...
 
#define SHORT_REAL_LENGTH   6
 

Typedefs

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

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. More...
 
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" More...
 
char * nEati (char *s, int *i, int m)
 divide by the first (leading) number and return it, i.e. make monic More...
 
char * nEati (char *s, long *i, int m)
 
char * nEatLong (char *s, mpz_ptr i)
 extracts a long integer from s, returns the rest More...
 

Variables

const char *const nDivBy0 = "div by 0"
 

Macro Definition Documentation

◆ nAdd

#define nAdd (   n1,
  n2 
)    n_Add(n1, n2, currRing->cf)

Definition at line 18 of file numbers.h.

◆ nCopy

#define nCopy (   n)    n_Copy(n, currRing->cf)

Definition at line 15 of file numbers.h.

◆ nDelete

#define nDelete (   n)    n_Delete(n, currRing->cf)

Definition at line 16 of file numbers.h.

◆ nDiv

#define nDiv (   a,
  b 
)    n_Div(a,b,currRing->cf)

Definition at line 32 of file numbers.h.

◆ nEqual

#define nEqual (   n1,
  n2 
)    n_Equal(n1, n2, currRing->cf)

Definition at line 20 of file numbers.h.

◆ nExactDiv

#define nExactDiv (   a,
  b 
)    n_ExactDiv(a,b,currRing->cf)

Definition at line 34 of file numbers.h.

◆ nGcd

#define nGcd (   a,
  b 
)    n_Gcd(a,b,currRing->cf)

Definition at line 31 of file numbers.h.

◆ nGetChar

#define nGetChar ( )    n_GetChar(currRing->cf)

Definition at line 23 of file numbers.h.

◆ nGetDenom

#define nGetDenom (   N)    n_GetDenom((N),currRing->cf)

Definition at line 40 of file numbers.h.

◆ nGetNumerator

#define nGetNumerator (   N)    n_GetNumerator((N),currRing->cf)

Definition at line 41 of file numbers.h.

◆ nGreater

#define nGreater (   a,
  b 
)    n_Greater (a,b,currRing->cf)

Definition at line 28 of file numbers.h.

◆ nGreaterZero

#define nGreaterZero (   n)    n_GreaterZero(n, currRing->cf)

Definition at line 27 of file numbers.h.

◆ nInit

#define nInit (   i)    n_Init(i, currRing->cf)

Definition at line 24 of file numbers.h.

◆ nInpMult

#define nInpMult (   a,
  b 
)    n_InpMult(a,b,currRing->cf)

Definition at line 37 of file numbers.h.

◆ nInpNeg

#define nInpNeg (   n)    n_InpNeg(n, currRing->cf)

Definition at line 21 of file numbers.h.

◆ nInvers

#define nInvers (   a)    n_Invers(a,currRing->cf)

Definition at line 33 of file numbers.h.

◆ nIsMOne

#define nIsMOne (   n)    n_IsMOne(n, currRing->cf)

Definition at line 26 of file numbers.h.

◆ nIsOne

#define nIsOne (   n)    n_IsOne(n, currRing->cf)

Definition at line 25 of file numbers.h.

◆ nIsZero

#define nIsZero (   n)    n_IsZero(n, currRing->cf)

Definition at line 19 of file numbers.h.

◆ nMult

#define nMult (   n1,
  n2 
)    n_Mult(n1, n2, currRing->cf)

Definition at line 17 of file numbers.h.

◆ nNormalize

#define nNormalize (   n)    n_Normalize(n,currRing->cf)

Definition at line 30 of file numbers.h.

◆ nPower

#define nPower (   a,
  b,
  res 
)    n_Power(a,b,res,currRing->cf)

Definition at line 38 of file numbers.h.

◆ nPrint

#define nPrint (   a)    n_Print(a,currRing->cf)

only for debug, over any initalized currRing

Definition at line 46 of file numbers.h.

◆ nSetMap

#define nSetMap (   R)    n_SetMap(R,currRing->cf)

Definition at line 43 of file numbers.h.

◆ nSize

#define nSize (   n)    n_Size(n,currRing->cf)

Definition at line 39 of file numbers.h.

◆ nSub

#define nSub (   n1,
  n2 
)    n_Sub(n1, n2, currRing->cf)

Definition at line 22 of file numbers.h.

◆ nTest

#define nTest (   a)    n_Test(a,currRing->cf)

Definition at line 35 of file numbers.h.

◆ nWrite

#define nWrite (   n)    n_Write(n, currRing->cf, rShortOut(currRing))

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

174{
175 BOOLEAN ret = n_IsZero(a, r);
176 int c = n_GetChar(r);
177 if (ret || (c==0) || (r->is_field))
178 return ret; /*n_IsZero(a, r)*/
179 number ch = n_Init( c, r );
180 number g = n_Gcd( ch, a, r );
181 ret = !n_IsOne (g, r);
182 n_Delete(&ch, r);
183 n_Delete(&g, r);
184 return ret;
185}
int BOOLEAN
Definition: auxiliary.h:87
g
Definition: cfModGcd.cc:4090
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:661
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:441
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
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:535
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:465

◆ 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
Definition: canonicalform.h:86
Definition: int_poly.h:33
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ ndGcd()

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

Definition at line 189 of file numbers.cc.

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

◆ ndNormalize()

void ndNormalize ( number &  ,
const  coeffs 
)

Definition at line 187 of file numbers.cc.

187{ }

◆ ndQuotRem()

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

Definition at line 357 of file numbers.cc.

359{
360 // implementation for a field: r: 0, result: n_Div
361 if(R->is_field)
362 {
363 *r=n_Init(0,R);
364 return n_Div(a,b,R);
365 }
366 else
367 // implementation for a non-field:
368 {
369 number d=n_Div(a,b,R);
370 number p=n_Mult(b,d,R);
371 *r=n_Sub(a,p,R);
372 n_Delete(&p,R);
373 return d;
374 }
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
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:633
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:612
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:652
#define R
Definition: sirandom.c:27

◆ ndReadFd()

number ndReadFd ( const ssiInfo f,
const coeffs  r 
)

Definition at line 152 of file numbers.cc.

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

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

679{
680
681 if (((*s) >= '0') && ((*s) <= '9'))
682 {
683 unsigned long ii=0L;
684 do
685 {
686 ii *= 10;
687 ii += *s++ - '0';
688 if ((m!=0) && (ii > (MAX_INT_VAL / 10))) ii = ii % m;
689 }
690 while (((*s) >= '0') && ((*s) <= '9'));
691 if ((m!=0) && (ii>=(unsigned)m)) ii=ii%m;
692 *i=(int)ii;
693 }
694 else (*i) = 1;
695 return s;
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
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 697 of file numbers.cc.

699{
700
701 if (((*s) >= '0') && ((*s) <= '9'))
702 {
703 unsigned long ii=0L;
704 do
705 {
706 ii *= 10;
707 ii += *s++ - '0';
708 if ((m!=0) && (ii > (LONG_MAX / 10))) ii = ii % m;
709 }
710 while (((*s) >= '0') && ((*s) <= '9'));
711 if ((m!=0) && (ii>=(long)m)) ii=ii%m;
712 *i=ii;
713 }
714 else (*i) = 1;
715 return s;

◆ nEatLong()

char * nEatLong ( char *  s,
mpz_ptr  i 
)

extracts a long integer from s, returns the rest

Definition at line 718 of file numbers.cc.

720{
721 const char * start=s;
722
723 while (*s >= '0' && *s <= '9') s++;
724 if (*s=='\0')
725 {
726 mpz_set_str(i,start,10);
727 }
728 else
729 {
730 char c=*s;
731 *s='\0';
732 mpz_set_str(i,start,10);
733 *s=c;
734 }
735 return s;

◆ nFindCoeffByName()

coeffs nFindCoeffByName ( char *  n)

find an existing coeff by its "CoeffName"

Definition at line 645 of file numbers.cc.

647{
649 // try existings coeffs:
650 while(n!=NULL)
651 {
652 if ((n->cfCoeffName!=NULL)
653 && (strcmp(cf_name,n->cfCoeffName(n))==0)) return n;
654 n=n->next;
655 }
656 // TODO: parametrized cf, e.g. flint:Z/26[a]
657 // try existing types:
658 nFindCoeffByName_p p=nFindCoeffByName_Root;
659 while(p!=NULL)
660 {
661 coeffs cf=p->p(cf_name,p->n);
662 if (cf!=NULL) return cf;
663 p=p->next;
664 }
665 return NULL;
CanonicalForm cf
Definition: cfModGcd.cc:4083
The main handler for Singular numbers which are suitable for Singular polynomials.
VAR nFindCoeffByName_p nFindCoeffByName_Root
Definition: numbers.cc:635
VAR n_Procs_s * cf_root
Definition: numbers.cc:45
coeffs next
Definition: coeffs.h:125
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitue cfCoeffWrite, cfCoeffString
Definition: coeffs.h:154

◆ nRegister()

n_coeffType nRegister ( n_coeffType  n,
cfInitCharProc  p 
)

Definition at line 595 of file numbers.cc.

597{
598 if (n==n_unknown)
599 {
602 {
604 ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
606 ((int)nLastCoeffs)*sizeof(cfInitCharProc));
607 }
608 else
609 {
611 ((int)nLastCoeffs)*sizeof(cfInitCharProc),
612 (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
613 }
614
616 return nLastCoeffs;
617 }
618 else
619 {
620 if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
621 nInitCharTable[n]=p;
622 return n;
623 }
n_coeffType
Definition: coeffs.h:27
@ n_unknown
Definition: coeffs.h:28
#define Print
Definition: emacs.cc:80
STATIC_VAR n_coeffType nLastCoeffs
Definition: numbers.cc:375
STATIC_VAR cfInitCharProc * nInitCharTable
Definition: numbers.cc:409
VAR cfInitCharProc nInitCharTableDefault[]
Definition: numbers.cc:376
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)
Definition: omAllocDecl.h:220
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ nRegisterCfByName()

void nRegisterCfByName ( cfInitCfByNameProc  p,
n_coeffType  n 
)

Definition at line 636 of file numbers.cc.

638{
639 nFindCoeffByName_p h=(nFindCoeffByName_p)omAlloc0(sizeof(*h));
640 h->p=p;
641 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.