 |
My Project
debian-1:4.1.2-p1+ds-2
|
Go to the documentation of this file.
10 #include "factory/factory.h"
41 const char *
npRead (
const char *
s, number *a,
const coeffs r);
51 #pragma GCC diagnostic ignored "-Wlong-long"
57 #define ULONG64 (unsigned long long)(unsigned long)
59 #define ULONG64 (unsigned long)
74 int h = (int)((
long)
k);
75 return ((
int)
h !=0) && (
h <= (r->ch>>1));
91 if (((
long)a == 0) || ((
long)
b == 0))
103 if (((
long)a == 0) || ((
long)
b == 0))
115 long ii=
i % (long)r->ch;
116 if (ii < 0L) ii += (long)r->ch;
118 number c = (number)ii;
131 if ((
long)n > (((
long)r->ch) >>1))
return ((
long)n -((
long)r->ch));
132 else return ((
long)n);
146 return ((r->npPminus1M == (
long)a) &&(1L!=(
long)a));
159 if ((
long)a==0)
return (number)0L;
162 #ifndef HAVE_GENERIC_MULT
163 int s = r->npLogTable[(long)a] - r->npLogTable[(
long)
b];
164 #ifdef HAVE_GENERIC_ADD
169 s += ((long)
s >> 63) & r->npPminus1M;
171 s += ((long)
s >> 31) & r->npPminus1M;
174 d = (number)(
long)r->npExpTable[
s];
203 if ((
long)c==0L)
return c;
222 return ((
long)a) > ((long)
b);
239 if ((
long)a>(((
long)r->ch) >>1))
StringAppend(
"-%d",(
int)(((
long)r->ch)-((
long)a)));
265 static inline const char*
npEati(
const char *
s,
int *
i,
const coeffs r)
267 return nEati((
char *)
s,
i,(
int)r->ch);
270 const char *
npRead (
const char *
s, number *a,
const coeffs r)
282 *a = (number)(
long)z;
290 *a =
nvDiv((number)(
long)z,(number)(
long)n,r);
293 *a =
npDiv((number)(
long)z,(number)(
long)n,r);
307 if (r->npInvTable!=
NULL)
309 omFreeSize( (
void *)r->npInvTable, r->ch*
sizeof(
unsigned short) );
313 #ifndef HAVE_GENERIC_MULT
314 if (r->npExpTable!=
NULL)
316 omFreeSize( (
void *)r->npExpTable, r->ch*
sizeof(
unsigned short) );
317 omFreeSize( (
void *)r->npLogTable, r->ch*
sizeof(
unsigned short) );
318 r->npExpTable=
NULL; r->npLogTable=
NULL;
326 return (n==
n_Zp) && (r->ch==(int)(
long)parameter);
350 snprintf(npCoeffName_buf,14,
"ZZ/%d",
cf->ch);
351 return npCoeffName_buf;
361 fprintf(d->
f_write,
"%d ",(
int)(
long)n);
369 return (number)(long)dd;
380 const int c = (int) (
long)
p;
391 r->npPminus1M = c - 1;
453 r->has_simple_Alloc=
TRUE;
454 r->has_simple_Inverse=
TRUE;
462 r->npInvTable=(
unsigned short*)
omAlloc0( r->ch*
sizeof(
unsigned short) );
464 #ifndef HAVE_GENERIC_MULT
465 r->npExpTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
466 r->npLogTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
467 r->npExpTable[0] = 1;
468 r->npLogTable[0] = 0;
474 r->npLogTable[1] = 0;
480 r->npExpTable[
i] =(int)(((
long)
w * (long)r->npExpTable[
i-1]) % r->ch);
481 r->npLogTable[r->npExpTable[
i]] =
i;
482 if ( r->npExpTable[
i] == 1 )
491 r->npExpTable[1] = 1;
492 r->npLogTable[1] = 0;
501 r->cfExactDiv =
nvDiv;
517 if (((
long)a<0L) || ((
long)a>(
long)r->ch))
519 Print(
"wrong mod p number %ld at %s,%d\n",(
long)a,
f,
l);
532 while (
i < 0)
i+=dst_r->ch;
549 size = (*f)[0]._mp_size;
563 e=(*f)[0]._mp_exp-
size;
575 al = dest->_mp_size =
size;
577 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
580 nn = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*bl);
582 for (
i=bl-2;
i>=0;
i--) nn[
i] = 0;
585 ndest->_mp_alloc = ndest->_mp_size = bl;
587 in=mpz_fdiv_ui(ndest,dst_r->ch);
592 al = dest->_mp_size =
size+e;
594 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
596 for (
i=0;
i<e;
i++) dd[
i] = 0;
601 dest->_mp_alloc = al;
602 iz=mpz_fdiv_ui(dest,dst_r->ch);
605 iz=(long)
npDiv((number)iz,(number)in,dst_r);
616 mpz_ptr erg = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
619 mpz_mod_ui(erg, (mpz_ptr) from, dst->ch);
620 number r = (number) mpz_get_si(erg);
642 long i = (long) (((
unsigned long) from) % dst->ch);
651 return (number) (
f.intval());
725 else if ((
long)
b==0L)
746 void nvPower (number a,
int i, number *
result,
const coeffs r)
768 Print(
"ZZ/%d",r->ch);
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
(mpz_ptr), see rmodulon,h
number nvMult(number a, number b, const coeffs r)
void npWrite(number a, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
static number nvMultM(number a, number b, const coeffs r)
nMapFunc npSetMap(const coeffs src, const coeffs dst)
#define npEqualM(A, B, r)
static number npMultM(number a, number b, const coeffs r)
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
static char * npCoeffString(const coeffs cf)
BOOLEAN npIsOne(number a, const coeffs r)
const char * npRead(const char *s, number *a, const coeffs r)
static number npReadFd(const ssiInfo *d, const coeffs)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
number nvInvers(number c, const coeffs r)
virtual class for internal CanonicalForm's
static number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
number npInit(long i, const coeffs r)
void npCoeffWrite(const coeffs r, BOOLEAN details)
number npInvers(number c, const coeffs r)
static number npMapZ(number from, const coeffs src, const coeffs dst)
BOOLEAN npInitChar(coeffs r, void *p)
number nvDiv(number a, number b, const coeffs r)
static char * npCoeffName(const coeffs cf)
static void npWriteFd(number n, const ssiInfo *d, const coeffs)
BOOLEAN npEqual(number a, number b, const coeffs r)
static number npAddM(number a, number b, const coeffs r)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static number npSubM(number a, number b, const coeffs r)
const char *const nDivBy0
#define omFreeSize(addr, size)
static number npNegM(number a, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
number npMult(number a, number b, const coeffs r)
static const char * npEati(const char *s, int *i, const coeffs r)
number nlModP(number q, const coeffs, const coeffs Zp)
static long npInvMod(long a, const coeffs R)
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
static void npInpAddM(number &a, number b, const coeffs r)
void npInpMult(number &a, number b, const coeffs r)
BOOLEAN npGreaterZero(number k, const coeffs r)
number npDiv(number a, number b, const coeffs r)
BOOLEAN npIsMOne(number a, const coeffs r)
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
long npInt(number &n, const coeffs r)
static number npMapP(number from, const coeffs src, const coeffs dst_r)
static number npMapGMP(number from, const coeffs, const coeffs dst)
void npKillChar(coeffs r)
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
static number nvInversM(number c, const coeffs r)
void WerrorS(const char *s)
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
static number npRandom(siRandProc p, number, number, const coeffs cf)
void npPower(number a, int i, number *result, const coeffs r)
const CanonicalForm int s
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
number npNeg(number c, const coeffs r)
BOOLEAN npIsZero(number a, const coeffs r)
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
void nvInpMult(number &a, number b, const coeffs r)
static number npInversM(number c, const coeffs r)
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
BOOLEAN npGreater(number a, number b, const coeffs r)
(), see rinteger.h, new impl.