 |
My Project
debian-1:4.1.2-p1+ds-2
|
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "misc/sirandom.h"
#include "misc/prime.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/longrat.h"
#include "coeffs/ffields.h"
#include <cmath>
#include <errno.h>
Go to the source code of this file.
|
BOOLEAN | nfDBTest (number a, const char *f, const int l, const coeffs r) |
|
static BOOLEAN | nfIsZero (number a, const coeffs r) |
|
static BOOLEAN | nfIsMOne (number a, const coeffs r) |
|
static BOOLEAN | nfGreaterZero (number k, const coeffs r) |
|
static number | nfMult (number a, number b, const coeffs r) |
|
static number | nfInit (long i, const coeffs r) |
|
static number | nfParameter (int i, const coeffs) |
|
static int | nfParDeg (number n, const coeffs r) |
|
static long | nfInt (number &n, const coeffs r) |
|
static number | nfAdd (number a, number b, const coeffs R) |
|
static number | nfNeg (number c, const coeffs r) |
|
static number | nfSub (number a, number b, const coeffs r) |
|
static BOOLEAN | nfIsOne (number a, const coeffs r) |
|
static number | nfDiv (number a, number b, const coeffs r) |
|
static number | nfInvers (number c, const coeffs r) |
|
static BOOLEAN | nfGreater (number a, number b, const coeffs r) |
|
static BOOLEAN | nfEqual (number a, number b, const coeffs r) |
|
static void | nfWriteLong (number a, const coeffs r) |
|
static void | nfWriteShort (number a, const coeffs r) |
|
static void | nfPower (number a, int i, number *result, const coeffs r) |
|
static const char * | nfEati (const char *s, int *i, const coeffs r) |
|
static const char * | nfRead (const char *s, number *a, const coeffs r) |
|
int | gf_tab_numdigits62 (int q) |
|
int | convertback62 (char *p, int n) |
|
void | nfShowMipo (const coeffs r) |
| Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d, BOOLEAN typed, int dim) (from Singular/subexpr.cc) for printing minpoly. More...
|
|
static void | nfReadMipo (char *s) |
|
static void | nfReadTable (const int c, const coeffs r) |
|
static number | nfMapP (number c, const coeffs, const coeffs dst) |
|
static number | nfMapGG (number c, const coeffs src, const coeffs) |
|
static number | nfMapGGrev (number c, const coeffs src, const coeffs) |
|
static nMapFunc | nfSetMap (const coeffs src, const coeffs dst) |
|
static BOOLEAN | nfCoeffIsEqual (const coeffs, n_coeffType, void *) |
|
static void | nfKillChar (coeffs r) |
|
static char * | nfCoeffString (const coeffs r) |
|
static char * | nfCoeffName (const coeffs r) |
|
static number | nfRandom (siRandProc p, number, number, const coeffs cf) |
|
static void | nfCoeffWrite (const coeffs r, BOOLEAN details) |
|
BOOLEAN | nfInitChar (coeffs r, void *parameter) |
|
◆ nfTest
◆ sixteenlog2
#define sixteenlog2 11.09035489 |
◆ convertback62()
int convertback62 |
( |
char * |
p, |
|
|
int |
n |
|
) |
| |
◆ gf_tab_numdigits62()
int gf_tab_numdigits62 |
( |
int |
q | ) |
|
◆ nfAdd()
static number nfAdd |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
R |
|
) |
| |
|
static |
Definition at line 257 of file ffields.cc.
265 if ((
long)
R->m_nfCharQ == (
long)a)
return b;
266 if ((
long)
R->m_nfCharQ == (
long)
b)
return a;
268 if ((
long)a >= (
long)
b)
271 zab = (long)a-(
long)
b;
276 zab = (long)
b-(
long)a;
281 if (
R->m_nfPlus1Table[zab]==
R->m_nfCharQ) r=(long)
R->m_nfCharQ;
284 r= zb+(
long)
R->m_nfPlus1Table[zab];
285 if(r>=(
long)
R->m_nfCharQ1) r-=(
long)
R->m_nfCharQ1;
◆ nfCoeffIsEqual()
Definition at line 823 of file ffields.cc.
827 int c = (int)
pow ((
double)
p->GFChar, (double)
p->GFDegree);
◆ nfCoeffName()
Definition at line 795 of file ffields.cc.
799 nfCoeffName_buf[31]=
'\0';
800 snprintf(nfCoeffName_buf,31,
"ZZ/%d[%s]",r->m_nfCharQ,
p);
801 return nfCoeffName_buf;
◆ nfCoeffString()
Definition at line 787 of file ffields.cc.
791 sprintf(
s,
"%d,%s",r->m_nfCharQ,
p);
◆ nfCoeffWrite()
◆ nfDBTest()
Definition at line 110 of file ffields.cc.
113 if (((
long)a<0L) || ((
long)a>(
long)r->m_nfCharQ))
115 Print(
"wrong %d in %s:%d\n",(
int)((
long)a),
f,
l);
121 if (r->m_nfPlus1Table[
i]>r->m_nfCharQ)
123 Print(
"wrong table %d=%d in %s:%d\n",
i,r->m_nfPlus1Table[
i],
f,
l);
127 }
while (i<r->m_nfCharQ);
◆ nfDiv()
static number nfDiv |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 334 of file ffields.cc.
339 if ((
long)
b==(
long)r->m_nfCharQ)
342 return (number)((long)r->m_nfCharQ);
347 if ((
long)a==(
long)r->m_nfCharQ)
348 return (number)((long)r->m_nfCharQ);
350 long s = (long)a - (
long)
b;
352 s += (long)r->m_nfCharQ1;
◆ nfEati()
◆ nfEqual()
Definition at line 393 of file ffields.cc.
399 return (
long)a == (long)
b;
◆ nfGreater()
Definition at line 381 of file ffields.cc.
387 return (
long)a != (long)
b;
◆ nfGreaterZero()
◆ nfInit()
Definition at line 190 of file ffields.cc.
195 if (
i==0)
return (number)(long)r->m_nfCharQ;
196 while (
i < 0)
i += r->m_nfCharP;
197 while (
i >= r->m_nfCharP)
i -= r->m_nfCharP;
198 if (
i==0)
return (number)(long)r->m_nfCharQ;
202 c=r->m_nfPlus1Table[c];
206 nfTest((number)(
long)c, r);
208 return (number)(long)c;
◆ nfInitChar()
Definition at line 833 of file ffields.cc.
849 r->cfExactDiv=
nfDiv;
899 const char *
name =
p->GFPar_name;
902 r->m_nfCharP =
p->GFChar;
905 r->iNumberOfParameters = 1;
908 char ** pParameterNames = (
char **)
omAlloc(
sizeof(
char *));
913 r->pParameterNames = (
const char**)pParameterNames;
915 r->m_nfPlus1Table=
NULL;
917 if (strlen(
name) > 1)
922 r->has_simple_Alloc=
TRUE;
923 r->has_simple_Inverse=
TRUE;
925 if(
p->GFChar > (2<<15))
928 WarnS(
"illegal characteristic");
933 const double check=
log ((
double) (
p->GFChar));
935 #define sixteenlog2 11.09035489
939 Warn(
"Sorry: illegal size: %u ^ %u",
p->GFChar,
p->GFDegree );
944 int c = (int)
pow ((
double)
p->GFChar, (double)
p->GFDegree);
948 if( r->m_nfPlus1Table ==
NULL )
954 assume (r -> m_nfCharQ > 0);
956 r->ch = r->m_nfCharP;
◆ nfInt()
Definition at line 239 of file ffields.cc.
242 unsigned short nn=(
unsigned short)(
long)n;
243 if (nn==r->m_nfCharQ)
return 0;
245 while ((c!=nn)&&(
i<r->m_nfCharP))
247 c=r->m_nfPlus1Table[c];
◆ nfInvers()
Definition at line 362 of file ffields.cc.
367 if ((
long)c==(
long)r->m_nfCharQ)
370 return (number)((long)r->m_nfCharQ);
373 nfTest(((number)((
long)r->m_nfCharQ1-(
long)c)), r);
375 return (number)((long)r->m_nfCharQ1-(
long)c);
◆ nfIsMOne()
Definition at line 147 of file ffields.cc.
152 if (0L == (
long)a)
return FALSE;
153 return (
long)r->m_nfM1 == (long)a;
◆ nfIsOne()
Definition at line 323 of file ffields.cc.
328 return 0L == (long)a;
◆ nfIsZero()
Definition at line 136 of file ffields.cc.
141 return (
long)r->m_nfCharQ == (long)a;
◆ nfKillChar()
static void nfKillChar |
( |
coeffs |
r | ) |
|
|
static |
◆ nfMapGG()
Definition at line 703 of file ffields.cc.
707 while (
i >src->m_nfCharQ1)
i-=src->m_nfCharQ1;
708 return (number)((long)
i);
◆ nfMapGGrev()
Definition at line 713 of file ffields.cc.
715 int ex=(int)((
long)c);
719 return (number)(long)src->m_nfCharQ;
◆ nfMapP()
◆ nfMult()
static number nfMult |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 170 of file ffields.cc.
176 if (((
long)a == (
long)r->m_nfCharQ) || ((
long)
b == (
long)r->m_nfCharQ))
177 return (number)(long)r->m_nfCharQ;
179 int i=(
int)((long)a+(
long)
b);
180 if (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
184 return (number)(long)
i;
◆ nfNeg()
Definition at line 296 of file ffields.cc.
302 if ((
long)r->m_nfCharQ == (
long)c)
return c;
303 long i=(long)c+(
long)r->m_nfM1;
304 if (
i>=(
long)r->m_nfCharQ1)
i-=(
long)r->m_nfCharQ1;
◆ nfParameter()
static number nfParameter |
( |
int |
i, |
|
|
const |
coeffs |
|
) |
| |
|
static |
◆ nfParDeg()
Definition at line 227 of file ffields.cc.
232 if((
long)r->m_nfCharQ == (
long)n)
return -1;
233 return (
int)((long)n);
◆ nfPower()
static void nfPower |
( |
number |
a, |
|
|
int |
i, |
|
|
number * |
result, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 472 of file ffields.cc.
488 if ((
long)a == (long)r->m_nfCharQ) rl=(long)r->m_nfCharQ;
489 else rl=((
long)a*(long)
i) % (long)r->m_nfCharQ1;
◆ nfRandom()
Definition at line 804 of file ffields.cc.
806 return (number)(long)(
p() %(
cf->m_nfCharQ+1));
◆ nfRead()
Definition at line 508 of file ffields.cc.
525 const int N = strlen(nf_Parameter);
526 if (strncmp(
s,nf_Parameter,
N)==0)
529 if ((*
s >=
'0') && (*
s <=
'9'))
532 while (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
◆ nfReadMipo()
static void nfReadMipo |
( |
char * |
s | ) |
|
|
static |
Definition at line 566 of file ffields.cc.
568 const char *
l=strchr(
s,
';')+1;
570 int i=strtol(
l,&n,10);
584 WerrorS(
"error in reading minpoly from gftables");
◆ nfReadTable()
Definition at line 591 of file ffields.cc.
594 if ((c==r->m_nfCharQ)||(c== -r->m_nfCharQ))
610 if (r->m_nfCharQ > 1)
612 omFreeSize( (
ADDRESS)r->m_nfPlus1Table,(r->m_nfCharQ+1)*
sizeof(
unsigned short) );
613 r->m_nfPlus1Table=
NULL;
617 if (c>1) r->m_nfCharQ = c;
618 else r->m_nfCharQ = -c;
620 sprintf(
buf,
"gftables/%d",r->m_nfCharQ);
626 if(!fgets(
buf,
sizeof(
buf),
fp))
return;
627 if(strcmp(
buf,
"@@ factory GF(q) table @@\n")!=0)
639 res = sscanf(
buf,
"%d %d",&r->m_nfCharP,&q);
641 while((
res < 0) and (errno == EINTR));
644 r->m_nfCharQ1=r->m_nfCharQ-1;
646 r->m_nfPlus1Table= (
unsigned short *)
omAlloc0( (r->m_nfCharQ+1)*
sizeof(
unsigned short) );
651 while ( i < r->m_nfCharQ )
657 while ( (i < r->m_nfCharQ) && (
k < 30) )
660 if(r->m_nfPlus1Table[
i]>r->m_nfCharQ)
662 Print(
"wrong entry %d: %d(%c%c%c)\n",
i,r->m_nfPlus1Table[
i],bufptr[0],bufptr[1],bufptr[2]);
665 if (r->m_nfPlus1Table[
i]==r->m_nfCharQ)
679 r->m_nfPlus1Table[0]=r->m_nfPlus1Table[r->m_nfCharQ1];
688 Werror(
"illegal GF-table %d",r->m_nfCharQ);
◆ nfSetMap()
Definition at line 725 of file ffields.cc.
735 if ((src->m_nfCharQ % q)==0)
740 while(qq!=q) { qq *= r->m_nfCharP; n1++; }
743 while(qq!=src->m_nfCharQ) { qq *= r->m_nfCharP; n2++; }
747 int save_ch=r->m_nfCharQ;
749 int nn=r->m_nfPlus1Table[0];
755 else if ((n1 % n2)==0)
◆ nfShowMipo()
◆ nfSub()
static number nfSub |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nfWriteLong()
Definition at line 405 of file ffields.cc.
417 unsigned short nn=(
unsigned short)(
long)a;
418 while ((c!=nn)&&(
i<r->m_nfCharQ))
420 c=r->m_nfPlus1Table[c];
◆ nfWriteShort()
Definition at line 439 of file ffields.cc.
451 unsigned short nn=(
unsigned short)(
long)a;
452 while ((c!=nn)&&(
i<r->m_nfCharQ))
454 c=r->m_nfPlus1Table[c];
◆ fftable
const unsigned short fftable[] |
◆ nfMapGG_factor
◆ nfMinPoly
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static nMapFunc nfSetMap(const coeffs src, const coeffs dst)
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
void StringAppendS(const char *st)
static char * nfCoeffString(const coeffs r)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
static void nfCoeffWrite(const coeffs r, BOOLEAN details)
Creation data needed for finite fields.
static BOOLEAN nfIsMOne(number a, const coeffs r)
static int nfParDeg(number n, const coeffs r)
const unsigned short fftable[]
static void nfPower(number a, int i, number *result, const coeffs r)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
static const char * nfEati(const char *s, int *i, const coeffs r)
const CanonicalForm CFMap CFMap & N
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
static number nfRandom(siRandProc p, number, number, const coeffs cf)
static number nfMapGGrev(number c, const coeffs src, const coeffs)
int gf_tab_numdigits62(int q)
static number nfInvers(number c, const coeffs r)
static void nfWriteLong(number a, const coeffs r)
int convertback62(char *p, int n)
static BOOLEAN nfIsZero(number a, const coeffs r)
static number nfDiv(number a, number b, const coeffs r)
static char * nfCoeffName(const coeffs r)
static const char * nfRead(const char *s, number *a, const coeffs r)
static BOOLEAN nfEqual(number a, number b, const coeffs r)
int status int void * buf
const char *const nDivBy0
void PrintS(const char *s)
#define omFreeSize(addr, size)
static number nfSub(number a, number b, const coeffs r)
static BOOLEAN nfGreater(number a, number b, const coeffs r)
static BOOLEAN nfIsOne(number a, const coeffs r)
number nlModP(number q, const coeffs, const coeffs Zp)
STATIC_VAR int nfMapGG_factor
void nfShowMipo(const coeffs r)
Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d,...
static number nfInit(long i, const coeffs r)
static void nfReadTable(const int c, const coeffs r)
static FORCE_INLINE const char ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
STATIC_VAR int nfMinPoly[16]
static number nfAdd(number a, number b, const coeffs R)
static BOOLEAN nfGreaterZero(number k, const coeffs r)
void StringSetS(const char *st)
gmp_float log(const gmp_float &a)
static number nfNeg(number c, const coeffs r)
void Werror(const char *fmt,...)
char name(const Variable &v)
Rational pow(const Rational &a, int e)
void WerrorS(const char *s)
BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
static long nfInt(number &n, const coeffs r)
const char * eati(const char *s, int *i)
static number nfMult(number a, number b, const coeffs r)
static number nfMapGG(number c, const coeffs src, const coeffs)
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
static number nfParameter(int i, const coeffs)
const CanonicalForm int s
static void nfKillChar(coeffs r)
static number nfMapP(number c, const coeffs, const coeffs dst)
static void nfReadMipo(char *s)
static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void *)
static void nfWriteShort(number a, const coeffs r)