29 #define NV_MAX_PRIME 32749 30 #define FACTORY_MAX_PRIME 536870909 34 extern void XGCD(
long& d,
long&
s,
long& t,
long a,
long b);
56 #ifdef HAVE_GENERIC_MULT 57 static inline number
npMultM(number a, number
b,
const coeffs r)
60 ((((
unsigned long) a)*((
unsigned long) b)) % ((
unsigned long) r->ch));
62 static inline void npInpMultM(number &a, number b,
const coeffs r)
65 ((((
unsigned long) a)*((
unsigned long) b)) % ((
unsigned long) r->ch));
68 static inline number
npMultM(number a, number b,
const coeffs r)
70 long x = (long)r->npLogTable[(
long)a]+ r->npLogTable[(long)b];
71 #ifdef HAVE_GENERIC_ADD 72 if (x>=r->npPminus1M) x-=r->npPminus1M;
76 x += (x >> 63) & r->npPminus1M;
78 x += (x >> 31) & r->npPminus1M;
81 return (number)(long)r->npExpTable[x];
83 static inline void npInpMultM(number &a, number b,
const coeffs r)
85 long x = (long)r->npLogTable[(
long)a]+ r->npLogTable[(long)b];
86 #ifdef HAVE_GENERIC_ADD 87 if (x>=r->npPminus1M) x-=r->npPminus1M;
91 x += (x >> 63) & r->npPminus1M;
93 x += (x >> 31) & r->npPminus1M;
96 a=(number)(
long)r->npExpTable[
x];
101 inline number npAddAsm(number a, number b,
int m)
104 asm (
"addl %2, %1; cmpl %3, %1; jb 0f; subl %3, %1; 0:" 106 :
"%0" (a),
"g" (
b),
"g" (m)
110 inline number npSubAsm(number a, number b,
int m)
113 asm (
"subl %2, %1; jnc 0f; addl %3, %1; 0:" 115 :
"%0" (a),
"g" (
b),
"g" (m)
120 #ifdef HAVE_GENERIC_ADD 121 static inline number
npAddM(number a, number b,
const coeffs r)
123 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
124 return (number)(R >= r->ch ? R - r->ch :
R);
126 static inline void npInpAddM(number &a, number b,
const coeffs r)
128 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
129 a=(number)(R >= r->ch ? R - r->ch : R);
131 static inline number
npSubM(number a, number b,
const coeffs r)
133 return (number)((long)a<(
long)b ?
134 r->ch-(long)b+(
long)a : (long)a-(
long)
b);
137 static inline number
npAddM(number a, number b,
const coeffs r)
139 unsigned long res = (long)((
unsigned long)a + (
unsigned long)b);
142 res += ((long)res >> 63) & r->ch;
144 res += ((long)res >> 31) & r->ch;
148 static inline void npInpAddM(number &a, number b,
const coeffs r)
150 unsigned long res = (long)((
unsigned long)a + (
unsigned long)b);
153 res += ((long)res >> 63) & r->ch;
155 res += ((long)res >> 31) & r->ch;
159 static inline number
npSubM(number a, number b,
const coeffs r)
161 long res = ((long)a - (
long)
b);
163 res += (res >> 63) & r->ch;
165 res += (res >> 31) & r->ch;
171 static inline number
npNegM(number a,
const coeffs r)
173 return (number)((long)(r->ch)-(long)(a));
191 XGCD(d, s, t, a, R->ch);
194 long u,
v, u0, v0, u1, u2, q, r;
215 #ifdef HAVE_GENERIC_ADD 222 s += (s >> 63) & R->ch;
224 s += (s >> 31) & R->ch;
230 static inline number
npInversM (number c,
const coeffs r)
233 #ifndef HAVE_GENERIC_MULT 234 #ifndef HAVE_INVTABLE 235 number d = (number)(
long)r->npExpTable[r->npPminus1M - r->npLogTable[(long)c]];
237 long inv=(long)r->npInvTable[(
long)c];
240 inv = (long)r->npExpTable[r->npPminus1M - r->npLogTable[(
long)c]];
241 r->npInvTable[(long)c]=inv;
243 number d = (number)inv;
247 long inv=(long)r->npInvTable[(
long)c];
251 r->npInvTable[(long)c]=inv;
256 number d = (number)inv;
264 long npInt (number &
n,
const coeffs r);
267 number
npMult (number a, number b,
const coeffs r);
271 #define npEqualM(A,B,r) ((A)==(B)) const CanonicalForm int s
static number npInversM(number c, const coeffs r)
static number npMultM(number a, number b, const coeffs r)
'SR_INT' is the type of those integers small enough to fit into 29 bits.
number npMult(number a, number b, const coeffs r)
BOOLEAN npInitChar(coeffs r, void *p)
static number npNegM(number a, const coeffs r)
static number npSubM(number a, number b, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
static BOOLEAN npIsOne(number a, const coeffs)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
static number npAddM(number a, number b, const coeffs r)
static long npInvMod(long a, const coeffs R)
static void npInpAddM(number &a, number b, const coeffs r)
const Variable & v
< [in] a sqrfree bivariate poly
static BOOLEAN npIsZeroM(number a, const coeffs)
long npInt(number &n, const coeffs r)
nMapFunc npSetMap(const coeffs src, const coeffs dst)
static void npInpMultM(number &a, number b, const coeffs r)