29 #define NV_MAX_PRIME 32749 30 #define FACTORY_MAX_PRIME 536870909 51 #ifdef HAVE_GENERIC_MULT 52 static inline number
npMultM(number a, number
b,
const coeffs r)
55 ((((
unsigned long) a)*((
unsigned long) b)) % ((
unsigned long) r->ch));
57 static inline void npInpMultM(number &a, number b,
const coeffs r)
60 ((((
unsigned long) a)*((
unsigned long) b)) % ((
unsigned long) r->ch));
63 static inline number
npMultM(number a, number b,
const coeffs r)
65 long x = (long)r->npLogTable[(
long)a]+ r->npLogTable[(long)b];
66 #ifdef HAVE_GENERIC_ADD 67 if (x>r->npPminus1M) x-=r->npPminus1M;
71 x += (x >> 63) & r->npPminus1M;
73 x += (x >> 31) & r->npPminus1M;
76 return (number)(long)r->npExpTable[x];
78 static inline void npInpMultM(number &a, number b,
const coeffs r)
80 long x = (long)r->npLogTable[(
long)a]+ r->npLogTable[(long)b];
81 #ifdef HAVE_GENERIC_ADD 82 if (x>r->npPminus1M) x-=r->npPminus1M;
86 x += (x >> 63) & r->npPminus1M;
88 x += (x >> 31) & r->npPminus1M;
91 a=(number)(
long)r->npExpTable[
x];
96 inline number npAddAsm(number a, number b,
int m)
99 asm (
"addl %2, %1; cmpl %3, %1; jb 0f; subl %3, %1; 0:" 101 :
"%0" (a),
"g" (
b),
"g" (m)
105 inline number npSubAsm(number a, number b,
int m)
108 asm (
"subl %2, %1; jnc 0f; addl %3, %1; 0:" 110 :
"%0" (a),
"g" (
b),
"g" (m)
115 #ifdef HAVE_GENERIC_ADD 116 static inline number
npAddM(number a, number b,
const coeffs r)
118 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
119 return (number)(R >= r->ch ? R - r->ch :
R);
121 static inline void npInpAddM(number &a, number b,
const coeffs r)
123 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
124 a=(number)(R >= r->ch ? R - r->ch : R);
126 static inline number
npSubM(number a, number b,
const coeffs r)
128 return (number)((long)a<(
long)b ?
129 r->ch-(long)b+(
long)a : (long)a-(
long)
b);
132 static inline number
npAddM(number a, number b,
const coeffs r)
134 unsigned long res = (long)((
unsigned long)a + (
unsigned long)b);
137 res += ((long)res >> 63) & r->ch;
139 res += ((long)res >> 31) & r->ch;
143 static inline void npInpAddM(number &a, number b,
const coeffs r)
145 unsigned long res = (long)((
unsigned long)a + (
unsigned long)b);
148 res += ((long)res >> 63) & r->ch;
150 res += ((long)res >> 31) & r->ch;
154 static inline number
npSubM(number a, number b,
const coeffs r)
156 long res = ((long)a - (
long)
b);
158 res += (res >> 63) & r->ch;
160 res += (res >> 31) & r->ch;
166 static inline number
npNegM(number a,
const coeffs r)
168 return (number)((long)(r->ch)-(long)(a));
182 long npInt (number &
n,
const coeffs r);
187 #define npEqualM(A,B,r) ((A)==(B)) 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.
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.
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static number npAddM(number a, number b, const coeffs r)
static void npInpAddM(number &a, number b, const coeffs r)
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)