38 unsigned long i2=(
unsigned long)
b->Data();
41 if (i2==(
unsigned long)
IsPrime(i2))
48 mpz_init_set_ui(modBase,i2);
59 mpz_init_set_ui(modBase,i2);
62 if (mpz_popcount((mpz_ptr)modBase)==1)
66 if (i2<(8*
sizeof(
unsigned long)))
74 mpz_set_ui(modBase,2);
91 number i2=(number)
b->Data();
97 info.base= (mpz_ptr)modBase;
99 if (mpz_popcount(modBase)==1)
102 mp_bitcnt_t
l=mpz_scan1 (modBase,0);
103 if ((
l>0) && (
l<=8*
sizeof(
unsigned long)))
109 mpz_set_ui(modBase,2);
127 res->data=(
void*)(
long)(a2==b2);
134 ring r=(ring)a->
Data();
148 number2 a2=(number2)a->
Data();
150 number2 r=(number2)
omAlloc0(
sizeof(*r));
152 n_Power(a2->n,(
int)(
long)
b->Data(),&(r->n),r->cf);
174 a2=(number2)an->
Data();
175 b2=(number2)bn->
Data();
176 if (((a2!=
NULL) && (b2!=
NULL) && (a2->cf!=b2->cf))
184 WerrorS(
"Number not compatible");
189 number2 r=(number2)
omAlloc0(
sizeof(*r));
191 if (r->cf==
NULL) op=0;
194 case '+': r->n=
n_Add(aa,bb,r->cf);
break;
195 case '-': r->n=
n_Sub(aa,bb,r->cf);
break;
196 case '*': r->n=
n_Mult(aa,bb,r->cf);
break;
197 case '/': r->n=
n_Div(aa,bb,r->cf);
break;
198 case '%': r->n=
n_IntMod(aa,bb,r->cf);
break;
215 Werror(
"cannot convert second operand (%s) to Number",
b->Name());
221 Werror(
"cannot convert first operand (%s) to Number",a->
Name());
229 number2 a2=(number2)a->
Data();
230 number2 r=(number2)
omAlloc(
sizeof(*r));
232 if (a2->cf==
NULL) op=0;
235 case '-': r->n=
n_Copy(a2->n,a2->cf);r->n=
n_InpNeg(r->n,a2->cf);
break;
247 poly2 a2=(poly2)a->
Data();
249 poly2 r=(poly2)
omAlloc0(
sizeof(*r));
273 a2=(poly2)an->
Data();
274 b2=(poly2)bn->
Data();
275 if (((a2!=
NULL) && (b2!=
NULL) && (a2->cf!=b2->cf))
283 WerrorS(
"Poly not compatible");
288 poly2 r=(poly2)
omAlloc0(
sizeof(*r));
290 if (r->cf==
NULL) op=0;
314 Werror(
"cannot convert second operand (%s) to Poly",
b->Name());
320 Werror(
"cannot convert first operand (%s) to Poly",a->
Name());
328 poly2 a2=(poly2)a->
Data();
329 poly2 r=(poly2)
omAlloc(
sizeof(*r));
331 if (a2->cf==
NULL) op=0;
334 case '-': r->n=
p_Copy(a2->n,a2->cf);r->n=
p_Neg(r->n,a2->cf);
break;
346 number2 r=(number2)
omAlloc(
sizeof(*r));
369 number2 a2=(number2)a->
Data();
375 r->n=nMap(a2->n,a2->cf,r->cf);
381 default: bo=
TRUE;
break;
395 number2 n=(number2)a->
Data();
397 res->data=(
void*)n->cf;
403 poly2 n=(poly2)a->
Data();
405 res->data=(
void*)n->cf;
424 (
int)(
long)c->
Data(),
432 number2 n2=(number2)a->
Data();
449number2 n2Copy(
const number2 d)
454 r=(number2)
omAlloc(
sizeof(*r));
464void n2Delete(number2 &d)
477char *n2String(number2 d,
BOOLEAN typed)
490void n2Print(number2 d)
492 char *
s=n2String(d,
FALSE);
501poly2 p2Copy(
const poly2 d)
516void p2Delete(poly2 &d)
529char *p2String(poly2 d,
BOOLEAN typed)
544 char *
s=p2String(d,
FALSE);
struct for passing initialization parameters to naInitChar
Class used for (list of) interpreter objects.
void CleanUp(ring r=currRing)
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
@ n_Znm
only used if HAVE_RINGS is defined
@ n_Zn
only used if HAVE_RINGS is defined
@ n_Z2m
only used if HAVE_RINGS is defined
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
@ n_Z
only used if HAVE_RINGS is defined
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
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)
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
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...
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE char * nCoeffName(const coeffs cf)
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
void nKillChar(coeffs r)
undo all initialisations
const CanonicalForm int s
void WerrorS(const char *s)
int iiTestConvert(int inputType, int outputType)
const char * Tok2Cmdname(int tok)
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
const struct sConvertTypes dConvertTypes[]
EXTERN_VAR omBin sleftv_bin
void nlMPZ(mpz_t m, number &n, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
char * crString(coeffs c)
BOOLEAN jjCRING_Zp(leftv res, leftv a, leftv b)
BOOLEAN jjEQUAL_CR(leftv res, leftv a, leftv b)
BOOLEAN jjCRING_Zm(leftv res, leftv a, leftv b)
BOOLEAN jjR2_CR(leftv res, leftv a)
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
poly p_Power(poly p, int i, const ring r)
poly p_Sub(poly p1, poly p2, const ring r)
static poly p_Neg(poly p, const ring r)
static poly p_Add_q(poly p, poly q, const ring r)
static void p_Delete(poly *p, const ring r)
void p_Write0(poly p, ring lmRing, ring tailRing)
static poly pp_Mult_qq(poly p, poly q, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void StringSetS(const char *st)
void StringAppendS(const char *st)
void PrintS(const char *s)
void Werror(const char *fmt,...)
static int SI_LOG2(int v)