Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,671 changes: 1,671 additions & 0 deletions check/features.frm

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ AS_IF([test -f "$srcdir/extern/zstd/zlibWrapper/zstd_zlibwrapper.h"], [],
# Check for flint
AC_ARG_WITH([flint],
[AS_HELP_STRING([--with-flint@<:@=DIR@:>@],
[use flint for polynomial arithmetic (installed in prefix DIR) @<:@default=check@:>@])],
[use flint for polynomial arithmetic and p-adics (installed in prefix DIR) @<:@default=check@:>@])],
[AS_IF([test "x$withval" != xyes && test "x$withval" != xno && test "x$withval" != xcheck],
[with_flint=yes
CPPFLAGS="$CPPFLAGS -I$withval/include"
Expand Down Expand Up @@ -423,7 +423,7 @@ AS_IF([test "x$with_flint" != xno],
[MATH_LIBS="$ac_cv_search_pow"])])])
AS_IF([$flag], [AC_CHECK_LIB([flint], [fmpz_mpoly_init], [LIBS="-lflint $MATH_LIBS $LIBS"], [flag=false], [$MATH_LIBS])])
AS_IF([$flag],
[AC_DEFINE(WITHFLINT, [], [Define to use flint for polynomial arithmetic.])
[AC_DEFINE(WITHFLINT, [], [Define to use flint for polynomial arithmetic and p-adics.])
with_flint=yes],
[AS_IF([test "x$with_flint" = xyes],
[AC_MSG_FAILURE([test for flint failed. Give --without-flint if you want to compile without flint])])
Expand Down
3 changes: 2 additions & 1 deletion sources/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ if WITHFLINT
SRCBASE += \
flintinterface.cc \
flintinterface.h \
flintwrap.cc
flintwrap.cc \
padic.c
endif

if WITHFLOAT
Expand Down
8 changes: 8 additions & 0 deletions sources/argument.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ int execarg(PHEAD WORD *term, WORD level)
if ( m[1] == 2 ) {
#ifdef WITHFLOAT
if ( *t != FLOATFUN || TestFloat(t) == 0 )
#endif
#ifdef WITHFLINT
if ( *t != PADICFUN || TestPadic(t) == 0 )
#endif
{
m += 2;
Expand All @@ -181,6 +184,11 @@ int execarg(PHEAD WORD *term, WORD level)
else {
m += 2;
}
#endif
#ifdef WITHFLINT
else {
m += 2;
}
#endif
}
else {
Expand Down
73 changes: 73 additions & 0 deletions sources/compcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ static KEYWORD formatoptions[] = {
,{"mathematica", (TFUN)0, MATHEMATICAMODE, 0}
,{"normal", (TFUN)0, NORMALFORMAT, 1}
,{"nospaces", (TFUN)0, NOSPACEFORMAT, 3}
#ifdef WITHFLINT
,{"padicprint", (TFUN)0, 0, 6}
#endif
,{"pfortran", (TFUN)0, PFORTRANMODE, 0}
,{"quadfortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
,{"quadruplefortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
Expand Down Expand Up @@ -410,6 +413,39 @@ WrongOption: MesPrint("&Illegal option in Format FloatPrecision: %s",s);
error = 1;
}
}
#endif
#ifdef WITHFLINT
else if ( key->flags == 6 ) {
/*
Syntax: Format PadicPrint [on];
Format PadicPrint off;
*/
while ( FG.cTable[*s] == 0 ) s++;
while ( *s == ' ' || *s == '\t' || *s == ',' ) s++;
if ( *s == 0 ) {
AO.PadicPrint = 1;
}
else if ( tolower(*s) == 'o' && tolower(s[1]) == 'n' ) {
ss = s;
s += 2;
while ( *s == ' ' || *s == '\t' || *s == ',' ) s++;
if ( *s ) { s = ss; goto WrongPadicOption; }
AO.PadicPrint = 1;
}
else if ( tolower(*s) == 'o' && tolower(s[1]) == 'f'
&& tolower(s[2]) == 'f' ) {
ss = s;
s += 3;
while ( *s == ' ' || *s == '\t' || *s == ',' ) s++;
if ( *s ) { s = ss; goto WrongPadicOption; }
AO.PadicPrint = 0;
}
else {
WrongPadicOption:
MesPrint("&Illegal option in Format PadicPrint: %s",s);
error = 1;
}
}
#endif
}
else if ( ( *s == 'c' || *s == 'C' ) && ( FG.cTable[s[1]] == 1 ) ) {
Expand Down Expand Up @@ -2069,6 +2105,19 @@ doset: if ( Sets[number].type != CFUNCTION ) goto nofun;
error = 1;
}
}
#endif
#ifdef WITHFLINT
{
WORD *r1, *r2;
r1 = SetElements + Sets[number].first;
r2 = SetElements + Sets[number].last;
while ( r1 < r2 ) {
if ( *r1++ == PADICFUN ) {
MesPrint("&Illegal use of argument environment and padic_.");
error = 1;
}
}
}
#endif
*w++ = CSET; *w++ = number;
}
Expand All @@ -2078,6 +2127,12 @@ doset: if ( Sets[number].type != CFUNCTION ) goto nofun;
MesPrint("&Illegal use of argument environment and float_.");
error = 1;
}
#endif
#ifdef WITHFLINT
if ( (number + FUNCTION) == PADICFUN ) {
MesPrint("&Illegal use of argument environment and padic_.");
error = 1;
}
#endif
*w++ = CFUNCTION; *w++ = number + FUNCTION;
}
Expand Down Expand Up @@ -3604,6 +3659,12 @@ int CoModulus(UBYTE *inp)
MesPrint("&Simultaneous use of floating point and modulus arithmetic makes no sense.");
Retval = 1;
}
#endif
#ifdef WITHFLINT
if ( AC.activePadic ) {
MesPrint("&Simultaneous use of p-adic and modulus arithmetic makes no sense.");
Retval = 1;
}
#endif
AC.modmode = 0;
if ( *inp == '-' ) {
Expand Down Expand Up @@ -5403,6 +5464,12 @@ int CoPolyFun(UBYTE *s)
MesPrint("&Simultaneous use of PolyFun and float_ is not allowed.");
error = 1;
}
#endif
#ifdef WITHFLINT
if ( AC.activePadic ) {
MesPrint("&Simultaneous use of PolyFun and padic_ is not allowed.");
error = 1;
}
#endif
return(error);
}
Expand Down Expand Up @@ -5435,6 +5502,12 @@ int CoPolyRatFun(UBYTE *s)
MesPrint("&Simultaneous use of PolyFun and float_ is not allowed.");
error = 1;
}
#endif
#ifdef WITHFLINT
if ( AC.activePadic ) {
MesPrint("&Simultaneous use of PolyFun and padic_ is not allowed.");
error = 1;
}
#endif
if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
|| ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
Expand Down
9 changes: 9 additions & 0 deletions sources/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ static KEYWORD com2commands[] = {
,{"factorize", (TFUN)CoFactorize, TOOUTPUT, PARTEST}
,{"fill", (TFUN)CoFill, DECLARATION, PARTEST}
,{"fillexpression", (TFUN)CoFillExpression, DECLARATION, PARTEST}
#ifdef WITHFLINT
,{"frompadic", (TFUN)CoFromPadic, STATEMENT, PARTEST}
#endif
,{"frompolynomial", (TFUN)CoFromPolynomial, STATEMENT, PARTEST}
,{"funpowers", (TFUN)CoFunPowers, DECLARATION, PARTEST}
,{"hide", (TFUN)CoHide, SPECIFICATION,PARTEST}
Expand Down Expand Up @@ -197,6 +200,9 @@ static KEYWORD com2commands[] = {
,{"on", (TFUN)CoOn, DECLARATION, PARTEST}
,{"once", (TFUN)CoOnce, STATEMENT, PARTEST}
,{"only", (TFUN)CoOnly, STATEMENT, PARTEST}
#ifdef WITHFLINT
,{"padictorat", (TFUN)CoPadicToRat, STATEMENT, PARTEST}
#endif
,{"particle", (TFUN)CoParticle, DECLARATION, PARTEST}
,{"polyfun", (TFUN)CoPolyFun, DECLARATION, PARTEST}
,{"polyratfun", (TFUN)CoPolyRatFun, DECLARATION, PARTEST}
Expand Down Expand Up @@ -236,6 +242,9 @@ static KEYWORD com2commands[] = {
,{"threadbucketsize",(TFUN)CoThreadBucket, DECLARATION, PARTEST}
#ifdef WITHFLOAT
,{"tofloat", (TFUN)CoToFloat, STATEMENT, PARTEST}
#endif
#ifdef WITHFLINT
,{"topadic", (TFUN)CoToPadic, STATEMENT, PARTEST}
#endif
,{"topolynomial", (TFUN)CoToPolynomial, STATEMENT, PARTEST}
#ifdef WITHFLOAT
Expand Down
30 changes: 29 additions & 1 deletion sources/declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ TP=T+1;while(TP<TT){if(*TP==AR.PolyFun){TP[2]|=(DIRTYFLAG|MUSTCLEANPRF);}TP+=TP[

#endif


/*
MesPrint("P-level popped to %d with %d",AP.PreAssignLevel,(WORD)(AC.iPointer - AC.iBuffer));

Expand Down Expand Up @@ -1637,6 +1636,8 @@ extern void poly_free_poly_vars(PHEAD const char *);
#ifdef WITHFLINT
extern void flint_final_cleanup_thread(void);
extern void flint_final_cleanup_master(void);
extern WORD flint_fmpz_get_form(void *, WORD *);
extern void flint_fmpz_set_form(void *, UWORD *, WORD);
extern WORD* flint_div(PHEAD WORD *, WORD *, const WORD);
extern int flint_factorize_argument(PHEAD WORD *, WORD *);
extern WORD* flint_factorize_dollar(PHEAD WORD *);
Expand Down Expand Up @@ -1773,6 +1774,33 @@ int CoStrictRounding(UBYTE *);
int StrictRounding(PHEAD WORD *, WORD, WORD, WORD);
#endif

#ifdef WITHFLINT
int TestPadic(WORD *);
int TestPadicLimbTerm(const WORD *);
int ExpandPadicArgument(WORD *, const WORD *);
int ConvertPadicLimbs32(int32_t *, LONG, const int32_t *, int, int);

int DoStartPadic(UBYTE *);
int DoEndPadic(UBYTE *);
int StartPadicSystem(UBYTE *, LONG);
void ClearPadicSystem(void);
int CoToPadic(UBYTE *);
int CoPadicToRat(UBYTE *);
int CoFromPadic(UBYTE *);
int ToPadic(PHEAD WORD *,WORD);
int PadicToRat(PHEAD WORD *,WORD);
int FromPadic(PHEAD WORD *,WORD,WORD);
int PrintPadic(WORD *fun);
int AddWithPadic(PHEAD WORD **,WORD **);
int MergeWithPadic(PHEAD WORD **,WORD **);
int MulPadics(PHEAD WORD *, WORD *, WORD *);
int DivPadics(PHEAD WORD *, WORD *, WORD *);
int InvPadic(PHEAD WORD *, WORD *);
int MulRatToPadic(PHEAD WORD *, WORD *, UWORD *, WORD);
int NormalizePadicUnit(PHEAD WORD *, WORD *);
void CheckPadicPrime(WORD *);
#endif

/*
#] Declarations :
*/
Expand Down
3 changes: 3 additions & 0 deletions sources/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,9 @@ int PutBracket(PHEAD WORD *termin)
if ( AR.PolyFun && AT.PolyAct ) tStop = termin + AT.PolyAct;
#ifdef WITHFLOAT
else if ( AT.FloatPos ) tStop = termin + AT.FloatPos;
#endif
#ifdef WITHFLINT
else if ( AT.PadicPos ) tStop = termin + AT.PadicPos;
#endif
else tStop = tStopa - i;
t++;
Expand Down
16 changes: 16 additions & 0 deletions sources/flintwrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ void flint_final_cleanup_master(void) {
}
/*
#] flint_final_cleanup_master :
#[ flint_fmpz_get_form :
*/
WORD flint_fmpz_get_form(void *z, WORD *a)
{
return flint::fmpz_get_form((fmpz *)z, a);
}
/*
#] flint_fmpz_get_form :
#[ flint_fmpz_set_form :
*/
void flint_fmpz_set_form(void *z, UWORD *a, WORD na)
{
flint::fmpz_set_form((fmpz *)z, a, na);
}
/*
#] flint_fmpz_set_form :
#[ flint_div :
*/
WORD* flint_div(PHEAD WORD *a, WORD *b, const WORD must_fit_term) {
Expand Down
13 changes: 11 additions & 2 deletions sources/ftypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ typedef int (*TFUN1)(UBYTE *,int);
#define MINVECTOR 10
#define SETEXP 11
#define DOLLAREXPR2 12
#ifdef WITHFLINT
#define PADICLIMBS 13
#define PADICLIMBHEAD 3 /* type, positive object length, signed limb count */
#endif
#define HAAKJE0 9
#define FUNCTION 20

Expand Down Expand Up @@ -469,7 +473,8 @@ typedef int (*TFUN1)(UBYTE *,int);
#define EXPFUNCTION 124
#define HPLFUNCTION 125
#define MPLFUNCTION 126
#define MAXBUILTINFUNCTION 126
#define PADICFUN 127
#define MAXBUILTINFUNCTION 127

#define FIRSTUSERFUNCTION 150

Expand Down Expand Up @@ -597,6 +602,11 @@ typedef int (*TFUN1)(UBYTE *,int);
#define TYPESTRICTROUNDING 91
#define TYPECHOP 92
#endif
#ifdef WITHFLINT
#define TYPETOPADIC 93
#define TYPEPADICTORAT 94
#define TYPEFROMPADIC 95
#endif

/*
The codes for the 'operations' that are part of TYPEOPERATION.
Expand Down Expand Up @@ -1140,4 +1150,3 @@ typedef int (*TFUN1)(UBYTE *,int);
#define CYCLR 8388608
#define FLOOP 16777216
#define NOTFLOOP 33554432

4 changes: 4 additions & 0 deletions sources/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@ int MatchFunction(PHEAD WORD *pattern, WORD *interm, WORD *wilds)
// functions and tensors are handled specially.
if ( *interm == FLOATFUN ) return(0);
#endif
#ifdef WITHFLINT
// Pattern matching against padic_ functions is currently disabled.
if ( *interm == PADICFUN ) return(0);
#endif
/*
Test first for a straight match
*/
Expand Down
1 change: 1 addition & 0 deletions sources/inivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ static struct fixedfun {
,{"eexp_" ,0 ,0 ,0 ,0} /* EXPFUNCTION */
,{"hpl_" ,0 ,0 ,0 ,0} /* HPLFUNCTION */
,{"mpl_" ,0 ,0 ,0 ,0} /* MPLFUNCTION */
,{"padic_" ,0 ,0 ,0 ,0} /* PADICFUN */
};

FIXEDSET fixedsets[] = {
Expand Down
Loading
Loading