10#include "factory/factory.h"
13 #include <NTL/config.h>
14 #ifdef NTL_AVOID_BRANCHING
15 #undef HAVE_GENERIC_ADD
37#define NV_MAX_PRIME 32749
38#define FACTORY_MAX_PRIME 536870909
59#ifdef HAVE_GENERIC_MULT
63 ((((
unsigned long) a)*((
unsigned long)
b)) % ((
unsigned long) r->ch));
68 ((((
unsigned long) a)*((
unsigned long)
b)) % ((
unsigned long) r->ch));
73 long x = (
long)r->npLogTable[(
long)a]+ r->npLogTable[(
long)
b];
74 #ifdef HAVE_GENERIC_ADD
75 if (
x>=r->npPminus1M)
x-=r->npPminus1M;
79 x += (
x >> 63) & r->npPminus1M;
81 x += (
x >> 31) & r->npPminus1M;
88 long x = (
long)r->npLogTable[(
long)a]+ r->npLogTable[(
long)
b];
89 #ifdef HAVE_GENERIC_ADD
90 if (
x>=r->npPminus1M)
x-=r->npPminus1M;
94 x += (
x >> 63) & r->npPminus1M;
96 x += (
x >> 31) & r->npPminus1M;
99 a=(
number)(
long)r->npExpTable[
x];
107 asm (
"addl %2, %1; cmpl %3, %1; jb 0f; subl %3, %1; 0:"
109 :
"%0" (a),
"g" (
b),
"g" (
m)
116 asm (
"subl %2, %1; jnc 0f; addl %3, %1; 0:"
118 :
"%0" (a),
"g" (
b),
"g" (
m)
123#ifdef HAVE_GENERIC_ADD
126 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
127 return (
number)(
R >= (
unsigned long)r->ch ?
R - (
unsigned long)r->ch :
R);
131 unsigned long R = (
unsigned long)a + (
unsigned long)
b;
132 a=(
number)(
R >= (
unsigned long)r->ch ?
R - (
unsigned long)r->ch :
R);
142 unsigned long res = ((
unsigned long)a + (
unsigned long)
b);
153 unsigned long res = ((
unsigned long)a + (
unsigned long)
b);
166 res += (
res >> 63) & r->ch;
168 res += (
res >> 31) & r->ch;
208#ifdef HAVE_GENERIC_ADD
215 s += (
s >> 63) &
R->ch;
217 s += (
s >> 31) &
R->ch;
226#ifndef HAVE_GENERIC_MULT
227 #ifndef HAVE_INVTABLE
228 number d = (
number)(
long)r->npExpTable[r->npPminus1M - r->npLogTable[(
long)c]];
230 long inv=(
long)r->npInvTable[(
long)c];
233 inv = (
long)r->npExpTable[r->npPminus1M - r->npLogTable[(
long)c]];
240 long inv=(
long)r->npInvTable[(
long)c];
259#define npEqualM(A,B,r) ((A)==(B))
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
'SR_INT' is the type of those integers small enough to fit into 29 bits.
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)
BOOLEAN npInitChar(coeffs r, void *p)
static number npNegM(number a, const coeffs r)
static void npInpMultM(number &a, number b, const coeffs r)
static long npInvMod(long a, const coeffs R)
static number npInversM(number c, const coeffs r)
long npInt(number &n, const coeffs r)
static void npInpAddM(number &a, number b, 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.