 |
My Project
UNKNOWN_GIT_VERSION
|
Go to the documentation of this file.
11 #include "factory/factory.h"
42 const char *
npRead (
const char *
s, number *a,
const coeffs r);
52 #pragma GCC diagnostic ignored "-Wlong-long"
58 #define ULONG64 (unsigned long long)(unsigned long)
60 #define ULONG64 (unsigned long)
75 int h = (int)((
long)
k);
76 return ((
int)
h !=0) && (
h <= (r->ch>>1));
92 if (((
long)a == 0) || ((
long)
b == 0))
104 if (((
long)a == 0) || ((
long)
b == 0))
116 long ii=
i % (long)r->ch;
117 if (ii < 0L) ii += (long)r->ch;
119 number c = (number)ii;
132 if ((
long)n > (((
long)r->ch) >>1))
return ((
long)n -((
long)r->ch));
133 else return ((
long)n);
147 return ((r->npPminus1M == (
long)a) &&(1L!=(
long)a));
160 if ((
long)a==0)
return (number)0L;
163 #ifndef HAVE_GENERIC_MULT
164 int s = r->npLogTable[(long)a] - r->npLogTable[(
long)
b];
165 #ifdef HAVE_GENERIC_ADD
170 s += ((long)
s >> 63) & r->npPminus1M;
172 s += ((long)
s >> 31) & r->npPminus1M;
175 d = (number)(
long)r->npExpTable[
s];
204 if ((
long)c==0L)
return c;
223 return ((
long)a) > ((long)
b);
240 if ((
long)a>(((
long)r->ch) >>1))
StringAppend(
"-%d",(
int)(((
long)r->ch)-((
long)a)));
268 return nEati((
char *)
s,
i,(
int)r->ch);
283 *a = (number)(
long)z;
291 *a =
nvDiv((number)(
long)z,(number)(
long)n,r);
294 *a =
npDiv((number)(
long)z,(number)(
long)n,r);
308 if (r->npInvTable!=
NULL)
310 omFreeSize( (
void *)r->npInvTable, r->ch*
sizeof(
unsigned short) );
314 #ifndef HAVE_GENERIC_MULT
315 if (r->npExpTable!=
NULL)
317 omFreeSize( (
void *)r->npExpTable, r->ch*
sizeof(
unsigned short) );
318 omFreeSize( (
void *)r->npLogTable, r->ch*
sizeof(
unsigned short) );
319 r->npExpTable=
NULL; r->npLogTable=
NULL;
327 return (n==
n_Zp) && (r->ch==(int)(
long)parameter);
350 static char npCoeffName_buf[15];
351 snprintf(npCoeffName_buf,14,
"ZZ/%d",
cf->ch);
352 return npCoeffName_buf;
362 fprintf(d->
f_write,
"%d ",(
int)(
long)n);
370 return (number)(long)dd;
381 const int c = (int) (
long)
p;
392 r->npPminus1M = c - 1;
454 r->has_simple_Alloc=
TRUE;
455 r->has_simple_Inverse=
TRUE;
463 r->npInvTable=(
unsigned short*)
omAlloc0( r->ch*
sizeof(
unsigned short) );
465 #ifndef HAVE_GENERIC_MULT
466 r->npExpTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
467 r->npLogTable=(
unsigned short *)
omAlloc0( r->ch*
sizeof(
unsigned short) );
468 r->npExpTable[0] = 1;
469 r->npLogTable[0] = 0;
475 r->npLogTable[1] = 0;
481 r->npExpTable[
i] =(int)(((
long)
w * (long)r->npExpTable[
i-1]) % r->ch);
482 r->npLogTable[r->npExpTable[
i]] =
i;
483 if ( r->npExpTable[
i] == 1 )
492 r->npExpTable[1] = 1;
493 r->npLogTable[1] = 0;
502 r->cfExactDiv =
nvDiv;
518 if (((
long)a<0L) || ((
long)a>(
long)r->ch))
520 Print(
"wrong mod p number %ld at %s,%d\n",(
long)a,
f,
l);
533 while (
i < 0)
i+=dst_r->ch;
550 size = (*f)[0]._mp_size;
564 e=(*f)[0]._mp_exp-
size;
576 al = dest->_mp_size =
size;
578 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
581 nn = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*bl);
583 for (
i=bl-2;
i>=0;
i--) nn[
i] = 0;
586 ndest->_mp_alloc = ndest->_mp_size = bl;
588 in=mpz_fdiv_ui(ndest,dst_r->ch);
593 al = dest->_mp_size =
size+e;
595 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
597 for (
i=0;
i<e;
i++) dd[
i] = 0;
602 dest->_mp_alloc = al;
603 iz=mpz_fdiv_ui(dest,dst_r->ch);
606 iz=(long)
npDiv((number)iz,(number)in,dst_r);
617 mpz_ptr erg = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
620 mpz_mod_ui(erg, (mpz_ptr) from, dst->ch);
621 number r = (number) mpz_get_si(erg);
643 long i = (long) (((
unsigned long) from) % dst->ch);
652 return (number) (
f.intval());
726 else if ((
long)
b==0L)
747 void nvPower (number a,
int i, number *
result,
const coeffs r)
769 Print(
"ZZ/%d",r->ch);
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_gmp
(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
@ n_rep_int
(int), see modulop.h
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)
@ n_rep_gmp_float
(gmp_float), see
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)
@ n_rep_gap_gmp
(), see rinteger.h, new impl.