34static const char *
npRead (
const char *
s, number *a,
const coeffs r);
55 int h = (int)((
long)
k);
56 return ((
int)
h !=0) && (
h <= (r->ch>>1));
73 if (((
long)a == 0) || ((
long)
b == 0))
87 if ((
long)n > (((
long)r->ch) >>1))
return ((
long)n -((
long)r->ch));
88 else return ((
long)n);
95 return ((r->npPminus1M == (
long)a) &&(1L!=(
long)a));
108 if ((
long)a==0)
return (number)0L;
111#ifndef HAVE_GENERIC_MULT
112 int s = r->npLogTable[(long)a] - r->npLogTable[(
long)
b];
113 #ifdef HAVE_GENERIC_ADD
118 s += ((long)
s >> 63) & r->npPminus1M;
120 s += ((long)
s >> 31) & r->npPminus1M;
123 d = (number)(
long)r->npExpTable[
s];
152 if ((
long)c==0L)
return c;
171 return ((
long)a) > ((long)
b);
188 if ((
long)a>(((
long)r->ch) >>1))
StringAppend(
"-%d",(
int)(((
long)r->ch)-((
long)a)));
193static void npPower (number a,
int i, number *
result,
const coeffs r)
216 return nEati((
char *)
s,
i,(
int)r->ch);
231 *a = (number)(
long)z;
243 *a =
nvDiv((number)(
long)z,(number)(
long)n,r);
246 *a =
npDiv((number)(
long)z,(number)(
long)n,r);
260 if (r->npInvTable!=
NULL)
262 omFreeSize( (
void *)r->npInvTable, r->ch*
sizeof(
unsigned short) );
266 #ifndef HAVE_GENERIC_MULT
267 if (r->npExpTable!=
NULL)
269 omFreeSize( (
void *)r->npExpTable, r->ch*
sizeof(
unsigned short) );
270 omFreeSize( (
void *)r->npLogTable, r->ch*
sizeof(
unsigned short) );
271 r->npExpTable=
NULL; r->npLogTable=
NULL;
279 return (n==
n_Zp) && (r->ch==(int)(long)parameter);
303 snprintf(npCoeffName_buf,14,
"ZZ/%d",
cf->ch);
304 return npCoeffName_buf;
309 fprintf(d->
f_write,
"%d ",(
int)(
long)n);
322 return (number)(long)dd;
330 return (number)(long)dd;
339#ifndef HAVE_GENERIC_MULT
342 return (number)(long)r->npExpTable[1];
348 return (number)mpz_fdiv_ui(
m, r->ch);
354 const int c = (int) (
long)
p;
365 r->npPminus1M = c - 1;
426 r->has_simple_Alloc=
TRUE;
427 r->has_simple_Inverse=
TRUE;
435 r->npInvTable=(
unsigned short*)
omAlloc0( r->ch*
sizeof(
unsigned short) );
437#ifndef HAVE_GENERIC_MULT
438 r->cfParameter=
npPar;
439 r->npExpTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
440 r->npLogTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
441 r->npExpTable[0] = 1;
442 r->npLogTable[0] = 0;
448 r->npLogTable[1] = 0;
454 r->npExpTable[
i] =(int)(((
long)
w * (
long)r->npExpTable[
i-1]) % r->ch);
455 r->npLogTable[r->npExpTable[
i]] =
i;
456 if ( r->npExpTable[
i] == 1 )
465 r->npExpTable[1] = 1;
466 r->npLogTable[1] = 0;
475 r->cfExactDiv =
nvDiv;
491 if (((
long)a<0L) || ((
long)a>(
long)r->ch))
493 Print(
"wrong mod p number %ld at %s,%d\n",(
long)a,
f,
l);
506 while (
i < 0)
i+=dst_r->ch;
523 size = (*f)[0]._mp_size;
537 e=(*f)[0]._mp_exp-
size;
549 al = dest->_mp_size =
size;
551 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
554 nn = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*bl);
556 for (
i=bl-2;
i>=0;
i--) nn[
i] = 0;
559 ndest->_mp_alloc = ndest->_mp_size = bl;
561 in=mpz_fdiv_ui(ndest,dst_r->ch);
566 al = dest->_mp_size =
size+e;
568 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
570 for (
i=0;
i<e;
i++) dd[
i] = 0;
575 dest->_mp_alloc = al;
576 iz=mpz_fdiv_ui(dest,dst_r->ch);
579 iz=(long)
npDiv((number)iz,(number)in,dst_r);
589 return (number)mpz_fdiv_ui((mpz_ptr) from, dst->ch);
607 long i = (long) (((
unsigned long) from) % dst->ch);
615 return (number) (
f.intval());
671 else if ((
long)
b==0L)
692void nvPower (number a,
int i, number *
result,
const coeffs r)
virtual class for internal CanonicalForm's
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r).
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
@ n_rep_int
(int), see modulop.h
@ n_rep_gmp_float
(gmp_float), see
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
const CanonicalForm int s
factory.h' is the user interface to Factory.
void WerrorS(const char *s)
number nlModP(number q, const coeffs, const coeffs Zp)
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
static const char * npRead(const char *s, number *a, const coeffs r)
static number npInitMPZ(mpz_t m, const coeffs r)
static void npWrite(number a, const coeffs r)
static number npReadFd_S(char **s, const coeffs)
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
static void npWriteFd(number n, const ssiInfo *d, const coeffs)
BOOLEAN npInitChar(coeffs r, void *p)
static number nvDiv(number a, number b, const coeffs r)
static number npDiv(number a, number b, const coeffs r)
static number npMapP(number from, const coeffs src, const coeffs dst_r)
number nvInvers(number c, const coeffs r)
static number npPar(int, coeffs r)
static number npInvers(number c, const coeffs r)
static BOOLEAN npEqual(number a, number b, const coeffs r)
static char * npCoeffName(const coeffs cf)
static number npNeg(number c, const coeffs r)
static BOOLEAN npGreater(number a, number b, const coeffs r)
void npInpMult(number &a, number b, const coeffs r)
static BOOLEAN npIsMOne(number a, const coeffs r)
static BOOLEAN npGreaterZero(number k, const coeffs r)
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
static BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
static nMapFunc npSetMap(const coeffs src, const coeffs dst)
static number npMapZ(number from, const coeffs src, const coeffs dst)
static number npMapGMP(number from, const coeffs, const coeffs dst)
static number npReadFd(const ssiInfo *d, const coeffs)
static const char * npEati(const char *s, int *i, const coeffs r)
static void npWriteFd_S(number n, const coeffs)
static void nvInpMult(number &a, number b, const coeffs r)
static number nvInversM(number c, const coeffs r)
static number npRandom(siRandProc p, number, number, const coeffs cf)
long npInt(number &n, const coeffs r)
void npKillChar(coeffs r)
static number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
static BOOLEAN npIsOne(number a, const coeffs)
static number npAddM(number a, number b, const coeffs r)
static number npMultM(number a, number b, const coeffs r)
static number npNegM(number a, const coeffs r)
#define npEqualM(A, B, r)
static long npInvMod(long a, const coeffs R)
static number npInversM(number c, const coeffs r)
static void npInpAddM(number &a, number b, const coeffs r)
static number npSubM(number a, number b, const coeffs r)
static number npInit(long i, const coeffs r)
static number nvMult(number a, number b, const coeffs r)
static number npMult(number a, number b, const coeffs r)
static BOOLEAN npIsZero(number a, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
const char *const nDivBy0
#define omFreeSize(addr, size)
int s_readint_S(char **s)