Loading...
Searching...
No Matches
iparith.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT: table driven kernel interface, used by interpreter
*/
long all_farey=0L;
long farey_cnt=0L;
#include "kernel/mod2.h"
#include "factory/factory.h"
#include "coeffs/bigintmat.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "misc/sirandom.h"
#include "misc/prime.h"
#include "polys/matpol.h"
#include "polys/monomials/maps.h"
#include "polys/sparsmat.h"
#include "polys/weight.h"
#include "polys/ext_fields/transext.h"
#include "polys/clapsing.h"
#include "polys/flintconv.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/combinatorics/hilb.h"
#include "kernel/linear_algebra/interpolation.h"
#include "kernel/linear_algebra/linearAlgebra.h"
#include "kernel/linear_algebra/MinorInterface.h"
#include "kernel/GBEngine/kChinese.h"
#include "kernel/spectrum/GMPrat.h"
#include "kernel/groebner_walk/walkProc.h"
#include "kernel/oswrapper/timer.h"
#include "kernel/fglm/fglm.h"
#include "kernel/GBEngine/kstdfac.h"
#include "kernel/GBEngine/syz.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/units.h"
#include "kernel/GBEngine/tgb.h"
#include "kernel/preimage.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "Singular/mod_lib.h"
#include "Singular/fevoices.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "Singular/sdb.h"
#include "Singular/subexpr.h"
#include "Singular/lists.h"
#include "Singular/maps_ip.h"
#include "Singular/feOpt.h"
#include "Singular/ipconv.h"
#include "Singular/ipprint.h"
#include "Singular/attrib.h"
#include "Singular/links/silink.h"
#include "Singular/misc_ip.h"
#include "Singular/linearAlgebra_ip.h"
#include "Singular/number2.h"
#include "Singular/htable.h"
#include "Singular/fglm.h"
#include "Singular/blackbox.h"
#include "Singular/newstruct.h"
#include "Singular/ipshell.h"
//#include "kernel/mpr_inout.h"
#include "reporter/si_signals.h"
#include <ctype.h>
// defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR
#ifdef HAVE_PLURAL
#include "kernel/GBEngine/ratgring.h"
#include "kernel/GBEngine/nc.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#define NC_MASK (3+64)
#else /* HAVE_PLURAL */
#define NC_MASK 0
#endif /* HAVE_PLURAL */
#define RING_MASK 4
#define ZERODIVISOR_MASK 8
#define ALLOW_PLURAL 1
#define NO_NC 0
#define COMM_PLURAL 2
#define ALLOW_RING 4
#define NO_RING 0
#define NO_ZERODIVISOR 8
#define ALLOW_ZERODIVISOR 0
#define ALLOW_LP 64
#define NO_LRING 128
#define ALLOW_NC ALLOW_LP|ALLOW_PLURAL
#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
// bit 4 for warning, if used at toplevel
#define WARN_RING 16
// bit 5: do no try automatic conversions
#define NO_CONVERSION 32
static BOOLEAN check_valid(const int p, const int op);
#define bit31 SIZEOF_LONG*8-1
/*=============== types =====================*/
struct sValCmdTab
{
short cmd;
short start;
};
typedef sValCmdTab jjValCmdTab[];
struct _scmdnames
{
char *name;
short alias;
short tokval;
short toktype;
};
typedef struct _scmdnames cmdnames;
struct sValCmd1
{
proc1 p;
short cmd;
short res;
short arg;
short valid_for;
};
typedef BOOLEAN (*proc2)(leftv,leftv,leftv);
struct sValCmd2
{
proc2 p;
short cmd;
short res;
short arg1;
short arg2;
short valid_for;
};
typedef BOOLEAN (*proc3)(leftv,leftv,leftv,leftv);
struct sValCmd3
{
proc3 p;
short cmd;
short res;
short arg1;
short arg2;
short arg3;
short valid_for;
};
struct sValCmdM
{
proc1 p;
short cmd;
short res;
short number_of_args; /* -1: any, -2: any >0, .. */
short valid_for;
};
typedef struct
{
cmdnames *sCmds; /**< array of existing commands */
struct sValCmd1 *psValCmd1;
struct sValCmd2 *psValCmd2;
struct sValCmd3 *psValCmd3;
struct sValCmdM *psValCmdM;
unsigned nCmdUsed; /**< number of commands used */
unsigned nCmdAllocated; /**< number of commands-slots allocated */
unsigned nLastIdentifier; /**< valid identifiers are slot 1..nLastIdentifier */
} SArithBase;
/*---------------------------------------------------------------------*
* File scope Variables (Variables share by several functions in
* the same file )
*
*---------------------------------------------------------------------*/
STATIC_VAR SArithBase sArithBase; /**< Base entry for arithmetic */
/*---------------------------------------------------------------------*
* Extern Functions declarations
*
*---------------------------------------------------------------------*/
static int _gentable_sort_cmds(const void *a, const void *b);
extern int iiArithRemoveCmd(char *szName);
extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
short nToktype, short nPos=-1);
/*============= proc =======================*/
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
static Subexpr jjMakeSub(leftv e);
/*============= vars ======================*/
EXTERN_VAR int cmdtok;
EXTERN_VAR BOOLEAN expected_parms;
#define ii_div_by_0 "div. by 0"
VAR int iiOp; /* the current operation*/
/*=================== simple helpers =================*/
static int iin_Int(number &n,coeffs cf)
{
long l=n_Int(n,cf);
int i=(int)l;
if ((long)i==l) return l;
return 0;
}
int iiTokType(int op)
{
for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
{
if (sArithBase.sCmds[i].tokval==op)
return sArithBase.sCmds[i].toktype;
}
return 0;
}
/*=================== operations with 2 args.: static proc =================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
{
bigintmat* aa= (bigintmat *)u->Data();
long bb = (long)(v->Data());
if (errorreported) return TRUE;
bigintmat *cc=NULL;
switch (iiOp)
{
case '+': cc=bimAdd(aa,bb); break;
case '-': cc=bimSub(aa,bb); break;
case '*': cc=bimMult(aa,bb); break;
}
res->data=(char *)cc;
return cc==NULL;
}
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
{
return jjOP_BIM_I(res, v, u);
}
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
{
bigintmat* aa= (bigintmat *)u->Data();
number bb = (number)(v->Data());
if (errorreported) return TRUE;
bigintmat *cc=NULL;
switch (iiOp)
{
case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
}
res->data=(char *)cc;
return cc==NULL;
}
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
{
return jjOP_BIM_BI(res, v, u);
}
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
{
intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
int bb = (int)(long)(v->Data());
if (errorreported) return TRUE;
switch (iiOp)
{
case '+': (*aa) += bb; break;
case '-': (*aa) -= bb; break;
case '*': (*aa) *= bb; break;
case '/':
case INTDIV_CMD: (*aa) /= bb; break;
case '%': (*aa) %= bb; break;
}
res->data=(char *)aa;
return FALSE;
}
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
{
return jjOP_IV_I(res,v,u);
}
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
{
intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
int bb = (int)(long)(v->Data());
int i=si_min(aa->rows(),aa->cols());
switch (iiOp)
{
case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
break;
case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
break;
}
res->data=(char *)aa;
return FALSE;
}
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
{
return jjOP_IM_I(res,v,u);
}
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
{
int l=(int)(long)v->Data();
if (l>=0)
{
int d=(int)(long)u->Data();
intvec *vv=new intvec(l);
int i;
for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
res->data=(char *)vv;
}
return (l<0);
}
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
{
res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
return FALSE;
}
static void jjEQUAL_REST(leftv res,leftv u,leftv v);
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
{
intvec* a = (intvec * )(u->Data());
intvec* b = (intvec * )(v->Data());
int r=a->compare(b);
switch (iiOp)
{
case '<':
res->data = (char *) (r<0);
break;
case '>':
res->data = (char *) (r>0);
break;
case LE:
res->data = (char *) (r<=0);
break;
case GE:
res->data = (char *) (r>=0);
break;
case EQUAL_EQUAL:
case NOTEQUAL: /* negation handled by jjEQUAL_REST */
res->data = (char *) (r==0);
break;
}
jjEQUAL_REST(res,u,v);
if(r==-2) { WerrorS("size incompatible"); return TRUE; }
return FALSE;
}
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
{
bigintmat* a = (bigintmat * )(u->Data());
bigintmat* b = (bigintmat * )(v->Data());
int r=a->compare(b);
switch (iiOp)
{
#if 0
case '<':
res->data = (char *) (r<0);
break;
case '>':
res->data = (char *) (r>0);
break;
case LE:
res->data = (char *) (r<=0);
break;
case GE:
res->data = (char *) (r>=0);
break;
#endif
case EQUAL_EQUAL:
case NOTEQUAL: /* negation handled by jjEQUAL_REST */
res->data = (char *) (r==0);
break;
}
jjEQUAL_REST(res,u,v);
if(r==-2) { WerrorS("size incompatible"); return TRUE; }
return FALSE;
}
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
{
intvec* a = (intvec * )(u->Data());
int b = (int)(long)(v->Data());
int r=a->compare(b);
switch (iiOp)
{
case '<':
res->data = (char *) (r<0);
break;
case '>':
res->data = (char *) (r>0);
break;
case LE:
res->data = (char *) (r<=0);
break;
case GE:
res->data = (char *) (r>=0);
break;
case EQUAL_EQUAL:
case NOTEQUAL: /* negation handled by jjEQUAL_REST */
res->data = (char *) (r==0);
break;
}
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjCOMPARE_MA(leftv res, leftv u, leftv v)
{
//Print("in: >>%s<<\n",my_yylinebuf);
matrix a=(matrix)u->Data();
matrix b=(matrix)v->Data();
int r=mp_Compare(a,b,currRing);
switch (iiOp)
{
case '<':
res->data = (char *) (long)(r < 0);
break;
case '>':
res->data = (char *) (long)(r > 0);
break;
case LE:
res->data = (char *) (long)(r <= 0);
break;
case GE:
res->data = (char *) (long)(r >= 0);
break;
case EQUAL_EQUAL:
case NOTEQUAL: /* negation handled by jjEQUAL_REST */
res->data = (char *)(long) (r == 0);
break;
}
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
poly q=(poly)v->Data();
int r=p_Compare(p,q,currRing);
switch (iiOp)
{
case '<':
res->data = (char *) (r < 0);
break;
case '>':
res->data = (char *) (r > 0);
break;
case LE:
res->data = (char *) (r <= 0);
break;
case GE:
res->data = (char *) (r >= 0);
break;
//case EQUAL_EQUAL:
//case NOTEQUAL: /* negation handled by jjEQUAL_REST */
// res->data = (char *) (r == 0);
// break;
}
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
{
char* a = (char * )(u->Data());
char* b = (char * )(v->Data());
int result = strcmp(a,b);
switch (iiOp)
{
case '<':
res->data = (char *) (result < 0);
break;
case '>':
res->data = (char *) (result > 0);
break;
case LE:
res->data = (char *) (result <= 0);
break;
case GE:
res->data = (char *) (result >= 0);
break;
case EQUAL_EQUAL:
case NOTEQUAL: /* negation handled by jjEQUAL_REST */
res->data = (char *) (result == 0);
break;
}
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
{
if (u->Next()!=NULL)
{
u=u->next;
res->next = (leftv)omAllocBin(sleftv_bin);
return iiExprArith2(res->next,u,iiOp,v);
}
else if (v->Next()!=NULL)
{
v=v->next;
res->next = (leftv)omAllocBin(sleftv_bin);
return iiExprArith2(res->next,u,iiOp,v);
}
return FALSE;
}
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
{
long b=(long)u->Data();
long e=(long)v->Data();
long rc = 1;
BOOLEAN overflow=FALSE;
if (e >= 0)
{
if (b==0)
{
rc=(e==0);
}
else if ((e==0)||(b==1))
{
rc= 1;
}
else if (b== -1)
{
if (e&1) rc= -1;
else rc= 1;
}
else
{
long oldrc;
while ((e--)!=0)
{
oldrc=rc;
rc *= b;
if (!overflow)
{
if(rc/b!=oldrc) overflow=TRUE;
}
}
if (overflow)
WarnS("int overflow(^), result may be wrong");
}
res->data = (char *)rc;
if (u!=NULL) return jjOP_REST(res,u,v);
return FALSE;
}
else
{
WerrorS("exponent must be non-negative");
return TRUE;
}
}
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
{
int e=(int)(long)v->Data();
number n=(number)u->Data();
if (e>=0)
{
n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
}
else
{
WerrorS("exponent must be non-negative");
return TRUE;
}
if (u!=NULL) return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
{
int e=(int)(long)v->Data();
number n=(number)u->Data();
int d=0;
if (e<0)
{
n=nInvers(n);
e=-e;
d=1;
}
number r;
nPower(n,e,(number*)&r);
res->data=(char*)r;
if (d) nDelete(&n);
if (u!=NULL) return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
{
int v_i=(int)(long)v->Data();
if (v_i<0)
{
WerrorS("exponent must be non-negative");
return TRUE;
}
poly u_p=(poly)u->CopyD(POLY_CMD);
if ((u_p!=NULL)
&& (!rIsLPRing(currRing))
&& ((v_i!=0) &&
((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
{
Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
pTotaldegree(u_p),v_i,currRing->bitmask/2);
pDelete(&u_p);
return TRUE;
}
res->data = (char *)pPower(u_p,v_i);
if (u!=NULL) return jjOP_REST(res,u,v);
return errorreported; /* pPower may set errorreported via Werror */
}
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
{
res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
if (u!=NULL) return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
{
u=u->next;
v=v->next;
if (u==NULL)
{
if (v==NULL) return FALSE; /* u==NULL, v==NULL */
if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
{
do
{
if (res->next==NULL)
res->next = (leftv)omAlloc0Bin(sleftv_bin);
leftv tmp_v=v->next;
v->next=NULL;
BOOLEAN b=iiExprArith1(res->next,v,'-');
v->next=tmp_v;
if (b)
return TRUE;
v=tmp_v;
res=res->next;
} while (v!=NULL);
return FALSE;
}
loop /* u==NULL, v<>NULL, iiOp=='+' */
{
res->next = (leftv)omAlloc0Bin(sleftv_bin);
res=res->next;
res->data = v->CopyD();
res->rtyp = v->Typ();
v=v->next;
if (v==NULL) return FALSE;
}
}
if (v!=NULL) /* u<>NULL, v<>NULL */
{
do
{
res->next = (leftv)omAlloc0Bin(sleftv_bin);
leftv tmp_u=u->next; u->next=NULL;
leftv tmp_v=v->next; v->next=NULL;
BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
u->next=tmp_u;
v->next=tmp_v;
if (b)
return TRUE;
u=tmp_u;
v=tmp_v;
res=res->next;
} while ((u!=NULL) && (v!=NULL));
return FALSE;
}
loop /* u<>NULL, v==NULL */
{
res->next = (leftv)omAlloc0Bin(sleftv_bin);
res=res->next;
res->data = u->CopyD();
res->rtyp = u->Typ();
u=u->next;
if (u==NULL) return FALSE;
}
}
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
{
switch(u->Typ())
{
case 0:
{
int name_err=0;
if(isupper(u->name[0]))
{
const char *c=u->name+1;
while((*c!='\0')&&(islower(*c)||(isdigit(*c))||(*c=='_'))) c++;
if (*c!='\0')
name_err=1;
else
{
Print("%s of type 'ANY'. Trying load.\n", u->name);
if(iiTryLoadLib(u, u->name))
{
Werror("'%s' no such package", u->name);
return TRUE;
}
syMake(u,u->name,NULL);
}
}
else name_err=1;
if(name_err)
{ Werror("'%s' is an invalid package name",u->name);return TRUE;}
// and now, after the loading: use next case !!! no break !!!
}
case PACKAGE_CMD:
{
package pa=(package)u->Data();
if (u->rtyp==IDHDL) pa=IDPACKAGE((idhdl)u->data);
if((!pa->loaded)
&& (pa->language > LANG_TOP))
{
Werror("'%s' not loaded", u->name);
return TRUE;
}
if(v->rtyp == IDHDL)
{
v->name = omStrDup(v->name);
}
else if (v->rtyp!=0)
{
WerrorS("reserved name with ::");
return TRUE;
}
v->req_packhdl=pa;
syMake(v, v->name, pa);
memcpy(res, v, sizeof(sleftv));
v->Init();
}
break;
case DEF_CMD:
break;
default:
WerrorS("<package>::<id> expected");
return TRUE;
}
return FALSE;
}
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
{
unsigned long a=(unsigned long)u->Data();
unsigned long b=(unsigned long)v->Data();
unsigned long c=a+b;
res->data = (char *)((long)c);
if (((Sy_bitL(bit31)&a)==(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
{
WarnS("int overflow(+), result may be wrong");
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
{
res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
{
res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
{
res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_B(leftv res, leftv u, leftv v)
{
//res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
sBucket_pt b=sBucketCreate(currRing);
poly p=(poly)u->CopyD(POLY_CMD);
int l=pLength(p);
sBucket_Add_p(b,p,l);
p= (poly)v->CopyD(POLY_CMD);
l=pLength(p);
sBucket_Add_p(b,p,l);
res->data=(void*)b;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
{
sBucket_pt b=(sBucket_pt)u->CopyD(BUCKET_CMD);
poly p= (poly)v->CopyD(POLY_CMD);
int l=pLength(p);
sBucket_Add_p(b,p,l);
res->data=(void*)b;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
{
res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
if (res->data==NULL)
{
WerrorS("intmat size not compatible");
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
{
res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
if (res->data==NULL)
{
WerrorS("bigintmat/cmatrix not compatible");
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
{
matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
res->data = (char *)(mp_Add(A , B, currRing));
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d)",
MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
{
ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
res->data = (char *)(sm_Add(A , B, currRing));
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d)",
(int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
{
matrix m=(matrix)u->Data();
matrix p= mp_InitP(m->nrows,m->ncols,(poly)(v->CopyD(POLY_CMD)),currRing);
if (iiOp=='+')
res->data = (char *)mp_Add(m , p,currRing);
else
res->data = (char *)mp_Sub(m , p,currRing);
idDelete((ideal *)&p);
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
{
return jjPLUS_MA_P(res,v,u);
}
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
{
char* a = (char * )(u->Data());
char* b = (char * )(v->Data());
char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
strcpy(r,a);
strcat(r,b);
res->data=r;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
{
res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
{
void *ap=u->Data(); void *bp=v->Data();
long aa=(long)ap;
long bb=(long)bp;
long cc=aa-bb;
unsigned long a=(unsigned long)ap;
unsigned long b=(unsigned long)bp;
unsigned long c=a-b;
if (((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
{
WarnS("int overflow(-), result may be wrong");
}
res->data = (char *)cc;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
{
res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
{
res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
{
res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_B_P(leftv res, leftv u, leftv v)
{
sBucket_pt b=(sBucket_pt)u->CopyD(BUCKET_CMD);
poly p= (poly)v->CopyD(POLY_CMD);
int l=pLength(p);
p=p_Neg(p,currRing);
sBucket_Add_p(b,p,l);
res->data=(void*)b;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_B(leftv res, leftv u, leftv v)
{
sBucket_pt b=sBucketCreate(currRing);
poly p=(poly)u->CopyD(POLY_CMD);
int l=pLength(p);
sBucket_Add_p(b,p,l);
p= (poly)v->CopyD(POLY_CMD);
p=p_Neg(p,currRing);
l=pLength(p);
sBucket_Add_p(b,p,l);
res->data=(void*)b;
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
{
res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
if (res->data==NULL)
{
WerrorS("intmat size not compatible");
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
{
res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
if (res->data==NULL)
{
WerrorS("bigintmat/cmatrix not compatible");
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
}
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
{
matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
res->data = (char *)(mp_Sub(A , B, currRing));
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d)",
MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
return FALSE;
}
static BOOLEAN jjMINUS_SM(leftv res, leftv u, leftv v)
{
ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
res->data = (char *)(sm_Sub(A , B, currRing));
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d)",
(int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
return TRUE;
}
return jjPLUSMINUS_Gen(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
{
long a=(long)u->Data();
long b=(long)v->Data();
long c=(long)((unsigned long)a * (unsigned long)b);
// unsigned long has no overflow
if ((a!=0)&&(c/a!=b))
WarnS("int overflow(*), result may be wrong");
res->data = (char *)c;
if ((u->Next()!=NULL) || (v->Next()!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
{
res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
{
res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
number n=(number)res->data;
nNormalize(n);
res->data=(char *)n;
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
{
poly a;
poly b;
if (v->next==NULL)
{
if (u->next==NULL)
{
a=(poly)u->Data(); // works also for VECTOR_CMD
b=(poly)v->Data(); // works also for VECTOR_CMD
if (!rIsLPRing(currRing)
&& (a!=NULL) && (b!=NULL)
&& ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
{
Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
}
res->data = (char *)(pp_Mult_qq( a, b, currRing));
return FALSE;
}
// u->next exists: copy v
a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
b=pCopy((poly)v->Data());
if (!rIsLPRing(currRing)
&& (a!=NULL) && (b!=NULL)
&& (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
{
Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
}
res->data = (char *)(pMult( a, b));
return jjOP_REST(res,u,v);
}
// v->next exists: copy u
a=pCopy((poly)u->Data());
b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
if ((a!=NULL) && (b!=NULL)
&& ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
{
pDelete(&a);
pDelete(&b);
WerrorS("OVERFLOW");
return TRUE;
}
res->data = (char *)(pMult( a, b));
return jjOP_REST(res,u,v);
}
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
{
res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
{
res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
if (res->data==NULL)
{
WerrorS("intmat size not compatible");
return TRUE;
}
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
{
res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
if (res->data==NULL)
{
WerrorS("bigintmat/cmatrix not compatible");
return TRUE;
}
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
{
nMapFunc nMap=n_SetMap(coeffs_BIGINT,currRing->cf);
if (nMap==NULL) return TRUE;
number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
poly p=pNSet(n);
ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
res->data = (char *)I;
return FALSE;
}
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
{
return jjTIMES_MA_BI1(res,v,u);
}
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
{
poly p=(poly)v->CopyD(POLY_CMD);
int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
if (r>0) I->rank=r;
res->data = (char *)I;
return FALSE;
}
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
{
poly p=(poly)u->CopyD(POLY_CMD);
int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
ideal I= (ideal)pMultMp(p,(matrix)v->CopyD(MATRIX_CMD),currRing);
if (r>0) I->rank=r;
res->data = (char *)I;
return FALSE;
}
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
{
number n=(number)v->CopyD(NUMBER_CMD);
poly p=pNSet(n);
res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
return FALSE;
}
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
{
return jjTIMES_MA_N1(res,v,u);
}
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
{
res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(long)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
{
return jjTIMES_MA_I1(res,v,u);
}
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
{
matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
res->data = (char *)mp_Mult(A,B,currRing);
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d) in *",
MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
return TRUE;
}
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
{
ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
res->data = (char *)sm_Mult(A,B,currRing);
if (res->data==NULL)
{
Werror("matrix size not compatible(%dx%d, %dx%d) in *",
(int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
return TRUE;
}
if ((v->next!=NULL) || (u->next!=NULL))
return jjOP_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
{
number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
n_Delete(&h,coeffs_BIGINT);
return FALSE;
}
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
return FALSE;
}
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
{
res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
|| nEqual((number)u->Data(),(number)v->Data()));
return FALSE;
}
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
{
number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
n_Delete(&h,coeffs_BIGINT);
return FALSE;
}
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
return FALSE;
}
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
return FALSE;
}
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
{
return jjGE_BI(res,v,u);
}
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
return FALSE;
}
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
{
return jjGE_N(res,v,u);
}
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
{
return jjGT_BI(res,v,u);
}
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
return FALSE;
}
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
{
return jjGT_N(res,v,u);
}
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
{
if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
long a= (long)u->Data();
long b= (long)v->Data();
if (b==0)
{
WerrorS(ii_div_by_0);
return TRUE;
}
long c=a%b;
long r=0;
switch (iiOp)
{
case '%':
r=c; break;
case '/':
case INTDIV_CMD:
r=((a-c) /b); break;
}
res->data=(void *)r;
return FALSE;
}
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
{
number q=(number)v->Data();
if (n_IsZero(q,coeffs_BIGINT))
{
WerrorS(ii_div_by_0);
return TRUE;
}
q = n_Div((number)u->Data(),q,coeffs_BIGINT);
n_Normalize(q,coeffs_BIGINT);
res->data = (char *)q;
return FALSE;
}
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
{
number q=(number)v->Data();
if (nIsZero(q))
{
WerrorS(ii_div_by_0);
return TRUE;
}
q = nDiv((number)u->Data(),q);
nNormalize(q);
res->data = (char *)q;
return FALSE;
}
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
{
poly q=(poly)v->Data();
poly p=(poly)(u->Data());
if (q!=NULL)
{
res->data=(void*)(pp_Divide(p /*(poly)(u->Data())*/ ,
q /*(poly)(v->Data())*/ ,currRing));
if (res->data!=NULL) pNormalize((poly)res->data);
return errorreported; /*there may be errors in p_Divide: div. ny 0, etc.*/
}
else
{
WerrorS("div. by 0");
return TRUE;
}
}
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
{
poly q=(poly)v->Data();
if (q==NULL)
{
WerrorS(ii_div_by_0);
return TRUE;
}
matrix m=(matrix)(u->Data());
int r=m->rows();
int c=m->cols();
matrix mm=mpNew(r,c);
unsigned i,j;
for(i=r;i>0;i--)
{
for(j=c;j>0;j--)
{
if (pNext(q)!=NULL)
{
MATELEM(mm,i,j) = singclap_pdivide( MATELEM(m,i,j) ,
q /*(poly)(v->Data())*/, currRing );
}
else
MATELEM(mm,i,j) = pp_DivideM(MATELEM(m,i,j),q,currRing);
}
}
res->data=(char *)mm;
return FALSE;
}
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
{
res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)sm_Equal((ideal)u->Data(),(ideal)v->Data(),currRing));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_R(leftv res, leftv u, leftv v)
{
res->data = (char *)(long)(u->Data()==v->Data());
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
poly q=(poly)v->Data();
res->data = (char *) ((long)pEqualPolys(p,q));
jjEQUAL_REST(res,u,v);
return FALSE;
}
static void jjEQUAL_REST(leftv res,leftv u,leftv v)
{
if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
{
int save_iiOp=iiOp;
if (iiOp==NOTEQUAL)
iiExprArith2(res,u->next,EQUAL_EQUAL,v->next);
else
iiExprArith2(res,u->next,iiOp,v->next);
iiOp=save_iiOp;
}
if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
}
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)u->Data() && (long)v->Data());
return FALSE;
}
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
{
res->data = (char *)((long)u->Data() || (long)v->Data());
return FALSE;
}
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
{
res->rtyp=u->rtyp; u->rtyp=0;
res->data=u->data; u->data=NULL;
res->name=u->name; u->name=NULL;
res->e=u->e; u->e=NULL;
if (res->e==NULL) res->e=jjMakeSub(v);
else
{
Subexpr sh=res->e;
while (sh->next != NULL) sh=sh->next;
sh->next=jjMakeSub(v);
}
if (u->next!=NULL)
{
leftv rn=(leftv)omAlloc0Bin(sleftv_bin);
BOOLEAN bo=iiExprArith2(rn,u->next,iiOp,v);
res->next=rn;
return bo;
}
return FALSE;
}
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
{
if ((u->rtyp!=IDHDL)||(u->e!=NULL))
{
WerrorS("indexed object must have a name");
return TRUE;
}
intvec * iv=(intvec *)v->Data();
leftv p=NULL;
int i;
sleftv t;
t.Init();
t.rtyp=INT_CMD;
for (i=0;i<iv->length(); i++)
{
t.data=(char *)((long)(*iv)[i]);
if (p==NULL)
{
p=res;
}
else
{
p->next=(leftv)omAlloc0Bin(sleftv_bin);
p=p->next;
}
p->rtyp=IDHDL;
p->data=u->data;
p->name=u->name;
p->flag=u->flag;
p->e=jjMakeSub(&t);
}
u->rtyp=0;
u->data=NULL;
u->name=NULL;
return FALSE;
}
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
long i=(long)v->Data();
long j=0;
while (p!=NULL)
{
j++;
if (j==i)
{
res->data=(char *)pHead(p);
return FALSE;
}
pIter(p);
}
return FALSE;
}
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
{
sBucket_pt b=(sBucket_pt)u->CopyD();
sBucketCanonicalize(b);
int l; poly p,pp;
sBucketDestroyAdd(b, &pp, &l);
long i=(long)v->Data();
long j=0;
p=pp;
while (p!=NULL)
{
j++;
if (j==i)
{
res->data=(char *)pHead(p);
p_Delete(&pp,currRing);
return FALSE;
}
pIter(p);
}
p_Delete(&pp,currRing);
return FALSE;
}
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
poly r=NULL;
intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
int i;
int sum=0;
for(i=iv->length()-1;i>=0;i--)
sum+=(*iv)[i];
int j=0;
while ((p!=NULL) && (sum>0))
{
j++;
for(i=iv->length()-1;i>=0;i--)
{
if (j==(*iv)[i])
{
r=pAdd(r,pHead(p));
sum-=j;
(*iv)[i]=0;
break;
}
}
pIter(p);
}
delete iv;
res->data=(char *)r;
return FALSE;
}
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
int i=(int)(long)v->Data();
res->data=(char *)p_Vec2Poly(p,i,currRing);
return FALSE;
}
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
{
poly p=(poly)u->CopyD(VECTOR_CMD);
if (p!=NULL)
{
poly r=pOne();
poly hp=r;
intvec *iv=(intvec *)v->Data();
int i;
loop
{
for(i=0;i<iv->length();i++)
{
if (((int)pGetComp(p))==(*iv)[i])
{
poly h;
pSplit(p,&h);
pNext(hp)=p;
p=h;
pIter(hp);
break;
}
}
if (p==NULL) break;
if (i==iv->length())
{
pLmDelete(&p);
if (p==NULL) break;
}
}
pLmDelete(&r);
res->data=(char *)r;
}
return FALSE;
}
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v);
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
{
if(u->name==NULL) return TRUE;
long slen = strlen(u->name) + 14;
char *nn = (char*) omAlloc(slen);
snprintf(nn,slen,"%s(%d)",u->name,(int)(long)v->Data());
char *n=omStrDup(nn);
omFreeSize((ADDRESS)nn,slen);
syMake(res,n);
if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
return FALSE;
}
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
{
if(u->name==NULL) return TRUE;
intvec * iv=(intvec *)v->Data();
leftv p=NULL;
int i;
long slen = strlen(u->name) + 14;
char *n = (char*) omAlloc(slen);
for (i=0;i<iv->length(); i++)
{
if (p==NULL)
{
p=res;
}
else
{
p->next=(leftv)omAlloc0Bin(sleftv_bin);
p=p->next;
}
snprintf(n,slen,"%s(%d)",u->name,(*iv)[i]);
syMake(p,omStrDup(n));
}
omFreeSize(n, slen);
if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
return FALSE;
}
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
{
leftv tmp=(leftv)omAlloc0Bin(sleftv_bin);
BOOLEAN b;
if (v->Typ()==INTVEC_CMD)
b=jjKLAMMER_IV(tmp,u,v);
else
b=jjKLAMMER(tmp,u,v);
if (b)
{
omFreeBin(tmp,sleftv_bin);
return TRUE;
}
leftv h=res;
while (h->next!=NULL) h=h->next;
h->next=tmp;
return FALSE;
}
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
{
void *d;
Subexpr e;
int typ;
BOOLEAN t=FALSE;
idhdl tmp_proc=NULL;
if ((u->rtyp!=IDHDL)||(u->e!=NULL))
{
tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
tmp_proc->id="_auto";
tmp_proc->typ=PROC_CMD;
tmp_proc->data.pinf=(procinfo *)u->Data();
tmp_proc->ref=1;
d=u->data; u->data=(void *)tmp_proc;
e=u->e; u->e=NULL;
t=TRUE;
typ=u->rtyp; u->rtyp=IDHDL;
}
BOOLEAN sl;
if (u->req_packhdl==currPack)
sl = iiMake_proc((idhdl)u->data,NULL,v);
else
sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
if (t)
{
u->rtyp=typ;
u->data=d;
u->e=e;
omFreeSize(tmp_proc,sizeof(idrec));
}
if (sl) return TRUE;
memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
iiRETURNEXPR.Init();
return FALSE;
}
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
{
//Print("try to map %s with %s\n",$3.Name(),$1.Name());
if ((v->e==NULL)&&(v->name!=NULL)&&(v->next==NULL))
{
map m=(map)u->Data();
leftv sl=iiMap(m,v->name);
if (sl!=NULL)
{
memcpy(res,sl,sizeof(sleftv));
omFreeBin((ADDRESS)sl, sleftv_bin);
return FALSE;
}
}
else
{
Werror("%s(<name>) expected",u->Name());
}
return TRUE; /*sl==NULL or Werror*/
}
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
{
u->next=(leftv)omAlloc(sizeof(sleftv));
memcpy(u->next,v,sizeof(sleftv));
v->Init();
BOOLEAN bo=iiExprArithM(res,u,'[');
u->next=NULL;
return bo;
}
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
{
intvec *c=(intvec*)u->Data();
intvec* p=(intvec*)v->Data();
int rl=p->length();
number *x=(number *)omAlloc(rl*sizeof(number));
number *q=(number *)omAlloc(rl*sizeof(number));
int i;
for(i=rl-1;i>=0;i--)
{
q[i]=n_Init((*p)[i], coeffs_BIGINT);
x[i]=n_Init((*c)[i], coeffs_BIGINT);
}
CFArray iv(rl);
number n=n_ChineseRemainderSym(x,q,rl,FALSE,iv,coeffs_BIGINT);
for(i=rl-1;i>=0;i--)
{
n_Delete(&(q[i]),coeffs_BIGINT);
n_Delete(&(x[i]),coeffs_BIGINT);
}
omFree(x); omFree(q);
res->data=(char *)n;
return FALSE;
}
#if 0
static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v)
{
lists c=(lists)u->CopyD(); // list of poly
intvec* p=(intvec*)v->Data();
int rl=p->length();
poly r=NULL,h, result=NULL;
number *x=(number *)omAlloc(rl*sizeof(number));
number *q=(number *)omAlloc(rl*sizeof(number));
int i;
for(i=rl-1;i>=0;i--)
{
q[i]=nlInit((*p)[i]);
}
loop
{
for(i=rl-1;i>=0;i--)
{
if (c->m[i].Typ()!=POLY_CMD)
{
Werror("poly expected at pos %d",i+1);
for(i=rl-1;i>=0;i--)
{
nlDelete(&(q[i]),currRing);
}
omFree(x); omFree(q); // delete c
return TRUE;
}
h=((poly)c->m[i].Data());
if (r==NULL) r=h;
else if (pLmCmp(r,h)==-1) r=h;
}
if (r==NULL) break;
for(i=rl-1;i>=0;i--)
{
h=((poly)c->m[i].Data());
if (pLmCmp(r,h)==0)
{
x[i]=pGetCoeff(h);
h=pLmFreeAndNext(h);
c->m[i].data=(char*)h;
}
else
x[i]=nlInit(0);
}
number n=n_ChineseRemainder(x,q,rl,currRing->cf);
for(i=rl-1;i>=0;i--)
{
nlDelete(&(x[i]),currRing);
}
h=pHead(r);
pSetCoeff(h,n);
result=pAdd(result,h);
}
for(i=rl-1;i>=0;i--)
{
nlDelete(&(q[i]),currRing);
}
omFree(x); omFree(q);
res->data=(char *)result;
return FALSE;
}
#endif
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
{
poly p=(poly)u->CopyD();
long s=(long)v->Data();
if (s+p_MinComp(p,currRing)<=0)
{ p_Delete(&p,currRing);return TRUE;}
p_Shift(&p,s,currRing);
res->data=p;
return FALSE;
}
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
{
ideal M=(ideal)u->CopyD();
int s=(int)(long)v->Data();
for(int i=IDELEMS(M)-1; i>=0;i--)
{
if (s+p_MinComp(M->m[i],currRing)<=0)
{ id_Delete(&M,currRing);return TRUE;}
}
id_Shift(M,s,currRing);
res->data=M;
return FALSE;
}
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v);
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
{
poly p=(poly)v->Data();
if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
return FALSE;
}
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
{
poly p=(poly)v->Data();
if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
res->data=(char *)mp_CoeffProcId((ideal)u->Data(),p /*(poly)v->Data()*/,currRing);
return FALSE;
}
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
{
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
return FALSE;
}
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
{
poly p = pInit();
int i;
for (i=1; i<=currRing->N; i++)
{
pSetExp(p, i, 1);
}
pSetm(p);
res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
(ideal)(v->Data()), p);
pLmFree(&p);
return FALSE;
}
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
{
res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
return FALSE;
}
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
{
int *iv=iv2array((intvec *)v->Data(),currRing);
ideal I=(ideal)u->Data();
int d=-1;
int i;
for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
res->data = (char *)((long)d);
return FALSE;
}
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
{
poly p=(poly)u->Data();
if (p!=NULL)
{
int *iv=iv2array((intvec *)v->Data(),currRing);
const long d = p_DegW(p,iv,currRing);
omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
res->data = (char *)(d);
}
else
res->data=(char *)(long)(-1);
return FALSE;
}
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
{
int pos=(int)(long)v->Data();
intvec *iv=(intvec*)u->Data();
res->data=(void*)iv->delete_pos(pos-1);
return res->data==NULL;
}
static BOOLEAN jjDelete_ID(leftv res, leftv u, leftv v)
{
int pos=(int)(long)v->Data();
ideal I=(ideal)u->Data();
res->data=(void*)id_Delete_Pos(I,pos-1,currRing);
return res->data==NULL;
}
static BOOLEAN jjDelete_ID_IV(leftv res, leftv u, leftv v)
{
intvec *iv=(intvec*)v->Data();
ideal I=(ideal)u->Data();
ideal tmp1=NULL;
ideal tmp2;
for(int i=iv->length()-1;i>=0;i--)
{
int pos= (*iv)[i];
tmp2=id_Delete_Pos(I,pos-1,currRing);
if (tmp1==NULL) /* first entry */
{ tmp1=I; }
else
{ id_Delete(&I,currRing); }
I=tmp2;
if (I==NULL) break;
}
res->data=(void*)I;
return res->data==NULL;
}
static BOOLEAN jjDET2(leftv res, leftv u, leftv v)
{
matrix m=(matrix)u->Data();
DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
res ->data = mp_Det(m,currRing,d);
return FALSE;
}
static BOOLEAN jjDET2_S(leftv res, leftv u, leftv v)
{
DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
ideal m=(ideal)u->Data();
res ->data = sm_Det(m,currRing,d);
return FALSE;
}
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
{
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
res->data=(char *)pDiff((poly)(u->Data()),i);
return FALSE;
}
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
{
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
res->data=(char *)idDiff((matrix)(u->Data()),i);
return FALSE;
}
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
{
res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
return FALSE;
}
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
{
assumeStdFlag(v);
if (rHasMixedOrdering(currRing))
{
Warn("dim(%s,...) may be wrong because the mixed monomial ordering",v->Name());
}
if(currRing->qideal==NULL)
res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),(ideal)w->Data()));
else
{
ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),q));
idDelete(&q);
}
return FALSE;
}
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
{
ideal vi=(ideal)v->Data();
int vl= IDELEMS(vi);
ideal ui=(ideal)u->Data();
unsigned ul= IDELEMS(ui);
ideal R; matrix U;
ideal m = idLift(vi,ui,&R, FALSE,hasFlag(v,FLAG_STD),TRUE,&U);
if (m==NULL) return TRUE;
// now make sure that all matrices have the correct size:
matrix T = id_Module2formatedMatrix(m,vl,ul,currRing);
assume (MATCOLS(U) == (int)ul);
lists L=(lists)omAllocBin(slists_bin);
L->Init(3);
L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
res->data=(char *)L;
return FALSE;
}
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
{
res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
//setFlag(res,FLAG_STD);
return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
}
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
{
poly p=pOne();
intvec *iv=(intvec*)v->Data();
for(int i=iv->length()-1; i>=0; i--)
{
pSetExp(p,(*iv)[i],1);
}
pSetm(p);
res->data=(char *)idElimination((ideal)u->Data(),p);
pLmDelete(&p);
//setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
{
//Print("exportto %s -> %s\n",v->Name(),u->Name() );
return iiExport(v,0,IDPACKAGE((idhdl)u->data));
}
static BOOLEAN jjERROR(leftv, leftv u)
{
WerrorS((char *)u->Data());
EXTERN_VAR int inerror;
inerror=3;
return TRUE;
}
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
{
number uu=(number)u->Data();number vv=(number)v->Data();
lists L=(lists)omAllocBin(slists_bin);
number a,b;
number p0=n_ExtGcd(uu,vv,&a,&b,coeffs_BIGINT);
L->Init(3);
L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
res->rtyp=LIST_CMD;
res->data=(char *)L;
return FALSE;
}
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
{
int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
int p0=ABS(uu),p1=ABS(vv);
int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
while ( p1!=0 )
{
q=p0 / p1;
r=p0 % p1;
p0 = p1; p1 = r;
r = g0 - g1 * q;
g0 = g1; g1 = r;
r = f0 - f1 * q;
f0 = f1; f1 = r;
}
int a = f0;
int b = g0;
if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
lists L=(lists)omAllocBin(slists_bin);
L->Init(3);
L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
res->data=(char *)L;
return FALSE;
}
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
{
poly r,pa,pb;
BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
if (ret) return TRUE;
lists L=(lists)omAllocBin(slists_bin);
L->Init(3);
res->data=(char *)L;
L->m[0].data=(void *)r;
L->m[0].rtyp=POLY_CMD;
L->m[1].data=(void *)pa;
L->m[1].rtyp=POLY_CMD;
L->m[2].data=(void *)pb;
L->m[2].rtyp=POLY_CMD;
return FALSE;
}
EXTERN_VAR int singclap_factorize_retry;
static BOOLEAN jjFAC_P2(leftv res, leftv u,leftv dummy)
{
intvec *v=NULL;
int sw=(int)(long)dummy->Data();
int fac_sw=sw;
if ((sw<0)||(sw>2)) fac_sw=1;
singclap_factorize_retry=0;
ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
if (f==NULL)
return TRUE;
switch(sw)
{
case 0:
case 2:
{
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=(void *)f;
l->m[1].rtyp=INTVEC_CMD;
l->m[1].data=(void *)v;
res->data=(void *)l;
res->rtyp=LIST_CMD;
return FALSE;
}
case 1:
res->data=(void *)f;
return FALSE;
case 3:
{
poly p=f->m[0];
int i=IDELEMS(f);
f->m[0]=NULL;
while(i>1)
{
i--;
p=pMult(p,f->m[i]);
f->m[i]=NULL;
}
res->data=(void *)p;
res->rtyp=POLY_CMD;
}
return FALSE;
}
WerrorS("invalid switch");
return TRUE;
}
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
{
ideal_list p,h;
h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
p=h;
int l=0;
while (p!=NULL) { p=p->next;l++; }
lists L=(lists)omAllocBin(slists_bin);
L->Init(l);
l=0;
while(h!=NULL)
{
L->m[l].data=(char *)h->d;
L->m[l].rtyp=IDEAL_CMD;
p=h->next;
omFreeSize(h,sizeof(*h));
h=p;
l++;
}
res->data=(void *)L;
return FALSE;
}
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
{
if (rField_is_Q(currRing))
{
number uu=(number)u->Data();
number vv=(number)v->Data();
res->data=(char *)n_Farey(uu,vv,currRing->cf);
return FALSE;
}
else return TRUE;
}
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
{
ideal uu=(ideal)u->Data();
number vv=(number)v->Data();
//timespec buf1,buf2;
//clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf1);
#ifdef HAVE_VSPACE
int cpus = (long) feOptValue(FE_OPT_CPUS);
if ((cpus>1) && (rField_is_Q(currRing)))
res->data=(void*)id_Farey_0(uu,vv,currRing);
else
#endif
res->data=(void*)id_Farey(uu,vv,currRing);
//clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
//const unsigned long SEC = 1000L*1000L*1000L;
//all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
// buf2.tv_nsec-buf1.tv_nsec);
//farey_cnt++;
return FALSE;
}
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
{
ring r=(ring)u->Data();
idhdl w;
int op=iiOp;
nMapFunc nMap;
if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
{
int *perm=NULL;
int *par_perm=NULL;
int par_perm_size=0;
BOOLEAN bo;
nMap=n_SetMap(r->cf,currRing->cf);
if (nMap==NULL)
{
// Allow imap/fetch to be make an exception only for:
if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
|| (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
{
par_perm_size=rPar(r);
}
else
{
goto err_fetch;
}
}
if (
(iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing))
#ifdef HAVE_SHIFTBBA
|| rIsLPRing(currRing)
#endif
)
{
perm=(int *)omAlloc0((r->N+1)*sizeof(int));
if (par_perm_size!=0)
par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
op=IMAP_CMD;
if (iiOp==IMAP_CMD)
{
int r_par=0;
char ** r_par_names=NULL;
if (r->cf->extRing!=NULL)
{
r_par=r->cf->extRing->N;
r_par_names=r->cf->extRing->names;
}
int c_par=0;
char ** c_par_names=NULL;
if (currRing->cf->extRing!=NULL)
{
c_par=currRing->cf->extRing->N;
c_par_names=currRing->cf->extRing->names;
}
if (!rIsLPRing(r))
{
maFindPerm(r->names, r->N, r_par_names, r_par,
currRing->names,currRing->N,c_par_names, c_par,
perm,par_perm, currRing->cf->type);
}
#ifdef HAVE_SHIFTBBA
else
{
maFindPermLP(r->names, r->N, r_par_names, r_par,
currRing->names,currRing->N,c_par_names, c_par,
perm,par_perm, currRing->cf->type,r->isLPring);
}
#endif
}
else
{
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
maFetchPermLP(r, currRing, perm);
}
else
#endif
{
unsigned i;
if (par_perm_size!=0)
for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
}
}
}
if ((iiOp==FETCH_CMD) && (BVERBOSE(V_IMAP)))
{
unsigned i;
for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
{
Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
}
for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
{
Print("// par nr %d: %s -> %s\n",
i,rParameter(r)[i],rParameter(currRing)[i]);
}
}
if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
sleftv tmpW;
tmpW.Init();
tmpW.rtyp=IDTYP(w);
tmpW.data=IDDATA(w);
if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
perm,par_perm,par_perm_size,nMap)))
{
Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
}
if (perm!=NULL)
omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
if (par_perm!=NULL)
omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
return bo;
}
else
{
Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
}
return TRUE;
err_fetch:
char *s1=nCoeffString(r->cf);
char *s2=nCoeffString(currRing->cf);
Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
omFree(s2); omFree(s1);
return TRUE;
}
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
{
/*4
* look for the substring what in the string where
* return the position of the first char of what in where
* or 0
*/
char *where=(char *)u->Data();
char *what=(char *)v->Data();
char *found = strstr(where,what);
if (found != NULL)
{
res->data=(char *)((found-where)+1);
}
/*else res->data=NULL;*/
return FALSE;
}
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
{
assumeStdFlag(u);
ideal id = (ideal)u->Data();
int max_length = (int)(long)v->Data();
if (max_length < 0)
{
WerrorS("length for fres must not be negative");
return TRUE;
}
if (max_length == 0)
{
max_length = currRing->N+4;
if (currRing->qideal != NULL)
{
max_length = currRing->N+1;
Warn("full resolution in a qring may be infinite, "
"setting max length to %d", max_length);
}
}
char *method = (char *)w->Data();
/* For the moment, only "complete" (default), "frame", or "extended frame"
* are allowed. Another useful option would be "linear strand".
*/
if (strcmp(method, "complete") != 0
&& strcmp(method, "frame") != 0
&& strcmp(method, "extended frame") != 0
&& strcmp(method, "single module") != 0)
{
WerrorS("wrong optional argument for fres");
return TRUE;
}
syStrategy r = syFrank(id, max_length, method);
assume(r->fullres != NULL);
syFix(r);
res->data = (void *)r;
return FALSE;
}
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
{
leftv w = (leftv)omAlloc0Bin(sleftv_bin);
w->rtyp = STRING_CMD;
w->data = (char *)"complete"; // default
BOOLEAN RES = jjFRES3(res, u, v, w);
omFreeBin(w,sleftv_bin);
return RES;
}
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
{
res->data=(char *)fractalWalkProc(u,v);
setFlag( res, FLAG_STD );
return FALSE;
}
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
{
int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
int p0=ABS(uu),p1=ABS(vv);
int r;
while ( p1!=0 )
{
r=p0 % p1;
p0 = p1; p1 = r;
}
res->data=(char *)(long)p0;
return FALSE;
}
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
{
number n1 = (number) u->Data();
number n2 = (number) v->Data();
res->data = n_Gcd(n1,n2,coeffs_BIGINT);
return FALSE;
}
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
{
number a=(number) u->Data();
number b=(number) v->Data();
if (nIsZero(a))
{
if (nIsZero(b)) res->data=(char *)nInit(1);
else res->data=(char *)nCopy(b);
}
else
{
if (nIsZero(b)) res->data=(char *)nCopy(a);
//else res->data=(char *)n_Gcd(a, b, currRing->cf);
else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
}
return FALSE;
}
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
{
res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
(poly)(v->CopyD(POLY_CMD)),currRing);
return FALSE;
}
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
{
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of Hilbert series etc. is being\n");
PrintS("// performed for generic fibre, that is, over Q\n");
}
assumeStdFlag(u);
intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
#if 1
switch((int)(long)v->Data())
{
case 1:
res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
return FALSE;
case 2:
res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
return FALSE;
}
#else
intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
if (errorreported) return TRUE;
switch((int)(long)v->Data())
{
case 1:
res->data=(void *)iv;
return FALSE;
case 2:
res->data=(void *)hSecondSeries(iv);
delete iv;
return FALSE;
}
delete iv;
#endif
WerrorS(feNotImplemented);
return TRUE;
}
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
{
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
poly p=pOne(); pSetExp(p,i,1); pSetm(p);
int d=pWTotaldegree(p);
pLmDelete(p);
if (d==1)
res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
else
WerrorS("variable must have weight 1");
return (d!=1);
}
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
{
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
pFDegProc deg;
if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
deg=p_Totaldegree;
else
deg=currRing->pFDeg;
poly p=pOne(); pSetExp(p,i,1); pSetm(p);
int d=deg(p,currRing);
pLmDelete(p);
if (d==1)
res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
else
WerrorS("variable must have weight 1");
return (d!=1);
}
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
{
intvec *w=new intvec(rVar(currRing));
intvec *vw=(intvec*)u->Data();
ideal v_id=(ideal)v->Data();
pFDegProc save_FDeg=currRing->pFDeg;
pLDegProc save_LDeg=currRing->pLDeg;
BOOLEAN save_pLexOrder=currRing->pLexOrder;
currRing->pLexOrder=FALSE;
kHomW=vw;
kModW=w;
pSetDegProcs(currRing,kHomModDeg);
res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
currRing->pLexOrder=save_pLexOrder;
kHomW=NULL;
kModW=NULL;
pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
if (w!=NULL) delete w;
return FALSE;
}
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
{
intvec *vw=(intvec*)u->Data();
ideal v_id=(ideal)v->Data();
res->data=(void *)(long)id_HomIdealW(v_id,currRing->qideal,vw,currRing);
return FALSE;
}
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
{
assumeStdFlag(u);
res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
currRing->qideal);
return FALSE;
}
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
{
res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjINTERPOLATION (leftv res, leftv l, leftv v)
{
const lists L = (lists)l->Data();
const int n = L->nr; assume (n >= 0);
std::vector<ideal> V(n + 1);
for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
res->data=interpolation(V, (intvec*)v->Data());
setFlag(res,FLAG_STD);
return errorreported;
}
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
{
extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
return jjStdJanetBasis(res,u,(int)(long)v->Data());
}
static BOOLEAN jjJanetBasis(leftv res, leftv v)
{
extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
return jjStdJanetBasis(res,v,0);
}
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
{
res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
return FALSE;
}
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
{
res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
{
assumeStdFlag(u);
intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
res->data = (char *)scKBase((int)(long)v->Data(),
(ideal)(u->Data()),currRing->qideal, w_u);
if (w_u!=NULL)
{
atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
}
return FALSE;
}
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w);
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
{
return jjPREIMAGE(res,u,v,NULL);
}
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
{
return mpKoszul(res, u,v,NULL);
}
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
{
sleftv h;
h.Init();
h.rtyp=INT_CMD;
h.data=(void *)(long)IDELEMS((ideal)v->Data());
return mpKoszul(res, u, &h, v);
}
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
{
int ul= IDELEMS((ideal)u->Data());
int vl= IDELEMS((ideal)v->Data());
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < ul)
{
Werror("At least %d ncgen variables are needed for this computation.", ul);
return TRUE;
}
}
#endif
ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
hasFlag(u,FLAG_STD));
if ((m==NULL)||(errorreported)) return TRUE;
res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
return FALSE;
}
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
{
if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
idhdl h=(idhdl)v->data;
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
{
Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
return TRUE;
}
}
#endif
// CopyD for IDEAL_CMD and MODUL_CMD are identical:
res->data = (char *)idLiftStd((ideal)u->Data(),
&(h->data.umatrix),testHomog);
setFlag(res,FLAG_STD); v->flag=0;
return FALSE;
}
static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
{
return jjLOAD((char*)v->Data(),TRUE);
}
static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
{
char * s=(char *)u->Data();
if(strcmp(s, "with")==0)
return jjLOAD((char*)v->Data(), TRUE);
if (strcmp(s,"try")==0)
return jjLOAD_TRY((char*)v->Data());
WerrorS("invalid second argument");
WerrorS("load(\"libname\" [,option]);");
return TRUE;
}
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
{
intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w_u!=NULL)
{
//PrintS("modulo: wu:");w_u->show(INTVEC_CMD);PrintLn();
w_u=ivCopy(w_u);
hom=isHomog;
}
//else PrintS("modulo: wu:none\n");
intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
if (w_v!=NULL)
{
//PrintS("modulo: wv:");w_v->show(INTVEC_CMD);PrintLn();
w_v=ivCopy(w_v);
hom=isHomog;
}
//else PrintS("modulo: wv:none\n");
if ((w_u!=NULL) && (w_v==NULL))
w_v=ivCopy(w_u);
if ((w_v!=NULL) && (w_u==NULL))
w_u=ivCopy(w_v);
ideal u_id=(ideal)u->Data();
ideal v_id=(ideal)v->Data();
if (w_u!=NULL)
{
if ((*w_u).compare((w_v))!=0)
{
WarnS("incompatible weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
else
{
if ((!idTestHomModule(u_id,currRing->qideal,w_v))
|| (!idTestHomModule(v_id,currRing->qideal,w_v)))
{
WarnS("wrong weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
}
}
res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
if (w_u!=NULL)
{
atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
}
delete w_v;
//if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
{
number q=(number)v->Data();
if (n_IsZero(q,coeffs_BIGINT))
{
WerrorS(ii_div_by_0);
return TRUE;
}
res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
return FALSE;
}
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
{
number q=(number)v->Data();
if (nIsZero(q))
{
WerrorS(ii_div_by_0);
return TRUE;
}
res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
return FALSE;
}
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
{
poly q=(poly)v->Data();
if (q==NULL)
{
WerrorS(ii_div_by_0);
return TRUE;
}
poly p=(poly)(u->Data());
if (p==NULL)
{
res->data=NULL;
return FALSE;
}
res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
q /*(poly)(v->Data())*/ ,currRing));
return FALSE;
}
static BOOLEAN jjMONITOR2(leftv res, leftv u,leftv v);
static BOOLEAN jjMONITOR1(leftv res, leftv v)
{
return jjMONITOR2(res,v,NULL);
}
static BOOLEAN jjMONITOR2(leftv, leftv u,leftv v)
{
#if 0
char *opt=(char *)v->Data();
int mode=0;
while(*opt!='\0')
{
if (*opt=='i') mode |= SI_PROT_I;
else if (*opt=='o') mode |= SI_PROT_O;
opt++;
}
monitor((char *)(u->Data()),mode);
#else
si_link l=(si_link)u->Data();
if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
if(strcmp(l->m->type,"ASCII")!=0)
{
Werror("ASCII link required, not `%s`",l->m->type);
slClose(l);
return TRUE;
}
SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
if ( l->name[0]!='\0') // "" is the stop condition
{
const char *opt;
int mode=0;
if (v==NULL) opt=(const char*)"i";
else opt=(const char *)v->Data();
while(*opt!='\0')
{
if (*opt=='i') mode |= SI_PROT_I;
else if (*opt=='o') mode |= SI_PROT_O;
opt++;
}
monitor((FILE *)l->data,mode);
}
else
monitor(NULL,0);
return FALSE;
#endif
}
static BOOLEAN jjMONOM(leftv res, leftv v)
{
intvec *iv=(intvec *)v->Data();
poly p=pOne();
int e;
BOOLEAN err=FALSE;
for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
{
e=(*iv)[i-1];
if (e>=0) pSetExp(p,i,e);
else err=TRUE;
}
if (iv->length()==(currRing->N+1))
{
res->rtyp=VECTOR_CMD;
e=(*iv)[currRing->N];
if (e>=0) pSetComp(p,e);
else err=TRUE;
}
pSetm(p);
res->data=(char*)p;
if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
return err;
}
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
{
// u: the name of the new type
// v: the elements
const char *s=(const char *)u->Data();
newstruct_desc d=NULL;
if (strlen(s)>=2)
{
d=newstructFromString((const char *)v->Data());
if (d!=NULL) newstruct_setup(s,d);
}
else WerrorS("name of newstruct must be longer than 1 character");
return d==NULL;
}
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
{
idhdl h=(idhdl)u->data;
int i=(int)(long)v->Data();
int p=0;
if ((0<i)
&& (rParameter(IDRING(h))!=NULL)
&& (i<=(p=rPar(IDRING(h)))))
res->data=omStrDup(rParameter(IDRING(h))[i-1]);
else
{
Werror("par number %d out of range 1..%d",i,p);
return TRUE;
}
return FALSE;
}
#ifdef HAVE_PLURAL
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
{
if( currRing->qideal != NULL )
{
WerrorS("basering must NOT be a qring!");
return TRUE;
}
if (iiOp==NCALGEBRA_CMD)
{
return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
}
else
{
ring r=rCopy(currRing);
BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
res->data=r;
return result;
}
}
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
{
if( currRing->qideal != NULL )
{
WerrorS("basering must NOT be a qring!");
return TRUE;
}
if (iiOp==NCALGEBRA_CMD)
{
return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
}
else
{
ring r=rCopy(currRing);
BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
res->data=r;
return result;
}
}
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
{
if( currRing->qideal != NULL )
{
WerrorS("basering must NOT be a qring!");
return TRUE;
}
if (iiOp==NCALGEBRA_CMD)
{
return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
}
else
{
ring r=rCopy(currRing);
BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
res->data=r;
return result;
}
}
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
{
if( currRing->qideal != NULL )
{
WerrorS("basering must NOT be a qring!");
return TRUE;
}
if (iiOp==NCALGEBRA_CMD)
{
return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
}
else
{
ring r=rCopy(currRing);
BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
res->data=r;
return result;
}
}
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
{
res->data=NULL;
if (rIsPluralRing(currRing) || rIsLPRing(currRing))
{
const poly q = (poly)b->Data();
if( q != NULL )
{
if( (poly)a->Data() != NULL )
{
if (rIsPluralRing(currRing))
{
poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
}
else if (rIsLPRing(currRing))
{
const poly p = (poly)a->Data();
res->data = pAdd(ppMult_qq(p,q), pNeg(ppMult_qq(q,p)));
}
}
}
}
return FALSE;
}
static BOOLEAN jjBRACKET_REC(leftv res, leftv a, leftv b, leftv c)
{
res->data=NULL;
if (rIsLPRing(currRing) || rIsPluralRing(currRing))
{
const poly q = (poly)b->Data();
if(q != NULL)
{
if((poly)a->Data() != NULL)
{
const poly p = (poly)a->Data();
int k=(int)(long)c->Data();
if (k > 0)
{
poly qq = pCopy(q);
for (int i = 0; i < k; i++)
{
poly qq_ref = qq;
if (rIsLPRing(currRing))
{
qq = pAdd(ppMult_qq(p,qq), pNeg(ppMult_qq(qq,p)));
}
else if (rIsPluralRing(currRing))
{
qq = nc_p_Bracket_qq(pCopy(p), qq, currRing);
}
pDelete(&qq_ref);
if (qq == NULL) break;
}
res->data = qq;
}
else
{
Werror("invalid number of iterations");
}
}
}
}
return FALSE;
}
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
{
/* number, poly, vector, ideal, module, matrix */
ring r = (ring)a->Data();
if (r == currRing)
{
res->data = b->Data();
res->rtyp = b->rtyp;
return FALSE;
}
if (!rIsLikeOpposite(currRing, r))
{
Werror("%s is not an opposite ring to current ring",a->Fullname());
return TRUE;
}
idhdl w;
if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
{
int argtype = IDTYP(w);
switch (argtype)
{
case NUMBER_CMD:
{
/* since basefields are equal, we can apply nCopy */
res->data = nCopy((number)IDDATA(w));
res->rtyp = argtype;
break;
}
case POLY_CMD:
case VECTOR_CMD:
{
poly q = (poly)IDDATA(w);
res->data = pOppose(r,q,currRing);
res->rtyp = argtype;
break;
}
case IDEAL_CMD:
case MODUL_CMD:
{
ideal Q = (ideal)IDDATA(w);
res->data = idOppose(r,Q,currRing);
res->rtyp = argtype;
break;
}
case MATRIX_CMD:
{
ring save = currRing;
rChangeCurrRing(r);
matrix m = (matrix)IDDATA(w);
ideal Q = id_Matrix2Module(mp_Copy(m, currRing),currRing);
rChangeCurrRing(save);
ideal S = idOppose(r,Q,currRing);
id_Delete(&Q, r);
res->data = id_Module2Matrix(S,currRing);
res->rtyp = argtype;
break;
}
default:
{
WerrorS("unsupported type in oppose");
return TRUE;
}
}
}
else
{
Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
return TRUE;
}
return FALSE;
}
#endif /* HAVE_PLURAL */
static BOOLEAN jjPRUNE_MAP(leftv res, leftv v, leftv ma)
{
if (ma->Typ()!=SMATRIX_CMD)
{
WerrorS("expected prune_map(`module`,`smatrix`)`");
return TRUE;
}
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
ideal v_id=(ideal)v->Data();
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
// and continue at the non-homog case below
}
else
{
w=ivCopy(w);
intvec **ww=&w;
ideal mat;
int *g=(int*)omAlloc(v_id->rank*sizeof(int));
res->data = (char *)idMinEmbedding_with_map_v(v_id,ww,mat,g);
atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
idhdl h=(idhdl)ma->data;
idDelete(&IDIDEAL(h));
IDIDEAL(h)=mat;
for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]);
PrintLn();
omFreeSize(g,v_id->rank*sizeof(int));
return FALSE;
}
}
ideal mat;
int *g=(int*)omAlloc(v_id->rank*sizeof(int));
res->data = (char *)idMinEmbedding_with_map_v(v_id,NULL,mat,g);
for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]);
PrintLn();
omFreeSize(g,v_id->rank*sizeof(int));
idhdl h=(idhdl)ma->data;
idDelete(&IDIDEAL(h));
IDIDEAL(h)=mat;
return FALSE;
}
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
{
res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
//if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
{
int i=(int)(long)u->Data();
int j=(int)(long)v->Data();
if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
return FALSE;
}
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
{
matrix m =(matrix)u->Data();
int isRowEchelon = (int)(long)v->Data();
if (isRowEchelon != 1) isRowEchelon = 0;
int rank = luRank(m, isRowEchelon);
res->data =(char *)(long)rank;
return FALSE;
}
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
{
si_link l=(si_link)u->Data();
leftv r=slRead(l,v);
if (r==NULL)
{
const char *s;
if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
else s=sNoName_fe;
Werror("cannot read from `%s`",s);
return TRUE;
}
memcpy(res,r,sizeof(sleftv));
omFreeBin((ADDRESS)r, sleftv_bin);
return FALSE;
}
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
{
ideal vi=(ideal)v->Data();
if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
assumeStdFlag(v);
res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
return FALSE;
}
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
{
ideal ui=(ideal)u->Data();
ideal vi=(ideal)v->Data();
if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
assumeStdFlag(v);
res->data = (char *)kNF(vi,currRing->qideal,ui);
return FALSE;
}
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
{
// handles hres,kres,lres,mres,nres,sres
int maxl=(int)(long)v->Data();
if (maxl<0)
{
WerrorS("length for res must not be negative");
return TRUE;
}
BOOLEAN complete=(maxl==0) && (currRing->qideal==NULL);
syStrategy r;
intvec *weights=NULL;
int wmaxl=maxl;
ideal u_id=(ideal)u->Data();
maxl--;
if (maxl==-1)
{
if ((iiOp!=MRES_CMD) && (iiOp!=RES_CMD)&&(iiOp!=SRES_CMD))
maxl = currRing->N;
if (currRing->qideal!=NULL)
{
maxl = currRing->N-1+2*(iiOp==MRES_CMD);
Warn(
"full resolution in a qring may be infinite, setting max length to %d",
maxl+1);
}
}
weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
if (weights!=NULL)
{
if (!idTestHomModule(u_id,currRing->qideal,weights))
{
WarnS("wrong weights given:");weights->show();PrintLn();
weights=NULL;
}
}
intvec *ww=NULL;
int add_row_shift=0;
if (weights!=NULL)
{
ww=ivCopy(weights);
add_row_shift = ww->min_in();
(*ww) -= add_row_shift;
}
unsigned save_opt=si_opt_1;
si_opt_1 |= Sy_bit(OPT_REDTAIL_SYZ);
if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
{
r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
}
else if (iiOp==SRES_CMD)
// r=sySchreyerResolvente(u_id,maxl+1,&l);
r=sySchreyer(u_id,maxl+1);
else if (iiOp == LRES_CMD)
{
int dummy;
if((currRing->qideal!=NULL)||
(!idHomIdeal (u_id,NULL)))
{
WerrorS("`lres` not implemented for inhomogeneous input or qring");
return TRUE;
}
if(currRing->N == 1)
WarnS("the current implementation of `lres` may not work in the case of a single variable");
r=syLaScala3(u_id,&dummy);
}
else if (iiOp == KRES_CMD)
{
int dummy;
if((currRing->qideal!=NULL)||
(!idHomIdeal (u_id,NULL)))
{
WerrorS
("`kres` not implemented for inhomogeneous input or qring");
return TRUE;
}
r=syKosz(u_id,&dummy);
}
else
{ // HRES
int dummy;
if((currRing->qideal!=NULL)||
(!idHomIdeal (u_id,NULL)))
{
WerrorS
("`hres` not implemented for inhomogeneous input or qring");
return TRUE;
}
ideal u_id_copy=idCopy(u_id);
idSkipZeroes(u_id_copy);
r=syHilb(u_id_copy,&dummy);
idDelete(&u_id_copy);
}
if (r==NULL) return TRUE;
if (wmaxl>0)
{
if (r->list_length>wmaxl)
{
for(int i=wmaxl-1;i<=r->list_length;i++)
{
if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
}
}
r->list_length=wmaxl;
}
res->data=(void *)r;
if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
if ((r->weights!=NULL) && (r->weights[0]!=NULL))
{
ww=ivCopy(r->weights[0]);
if (weights!=NULL) (*ww) += add_row_shift;
atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
}
else
{
if (weights!=NULL)
{
atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
}
}
// test the La Scala case' output
assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
assume( (r->syRing != NULL) == (r->resPairs != NULL) );
if(iiOp != HRES_CMD)
assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
else
assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
if(complete) syFix(r);
si_opt_1=save_opt;
return FALSE;
}
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
{
number n1; int i;
if ((u->Typ() == BIGINT_CMD) ||
((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
{
n1 = (number)u->CopyD();
}
else if (u->Typ() == INT_CMD)
{
i = (int)(long)u->Data();
n1 = n_Init(i, coeffs_BIGINT);
}
else
{
return TRUE;
}
i = (int)(long)v->Data();
lists l = primeFactorisation(n1, i);
n_Delete(&n1, coeffs_BIGINT);
res->data = (char*)l;
return FALSE;
}
static BOOLEAN jjRMINUS(leftv res, leftv u, leftv v)
{
ring r=rMinusVar((ring)u->Data(),(char*)v->Data());
res->data = (char *)r;
return r==NULL;
}
static BOOLEAN jjRPLUS(leftv res, leftv u, leftv v)
{
int left;
if (u->Typ()==RING_CMD) left=0;
else
{
leftv h=u;u=v;v=h;
left=1;
}
ring r=rPlusVar((ring)u->Data(),(char*)v->Data(),left);
res->data = (char *)r;
return r==NULL;
}
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
{
ring r;
int i=rSum((ring)u->Data(),(ring)v->Data(),r);
res->data = (char *)r;
return (i==-1);
}
#define SIMPL_NORMALIZE 64
#define SIMPL_LMDIV 32
#define SIMPL_LMEQ 16
#define SIMPL_MULT 8
#define SIMPL_EQU 4
#define SIMPL_NULL 2
#define SIMPL_NORM 1
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
{
int sw = (int)(long)v->Data();
// CopyD for IDEAL_CMD and MODUL_CMD are identical:
ideal id = (ideal)u->CopyD(IDEAL_CMD);
if (sw & SIMPL_LMDIV)
{
id_DelDiv(id,currRing);
}
if (sw & SIMPL_LMEQ)
{
id_DelLmEquals(id,currRing);
}
if (sw & SIMPL_MULT)
{
id_DelMultiples(id,currRing);
}
else if(sw & SIMPL_EQU)
{
id_DelEquals(id,currRing);
}
if (sw & SIMPL_NULL)
{
idSkipZeroes(id);
}
if (sw & SIMPL_NORM)
{
id_Norm(id,currRing);
}
if (sw & SIMPL_NORMALIZE)
{
id_Normalize(id,currRing);
}
res->data = (char * )id;
return FALSE;
}
EXTERN_VAR int singclap_factorize_retry;
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
{
intvec *v=NULL;
int sw=(int)(long)dummy->Data();
int fac_sw=sw;
if (sw<0) fac_sw=1;
singclap_factorize_retry=0;
ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
if (f==NULL)
return TRUE;
switch(sw)
{
case 0:
case 2:
{
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=(void *)f;
l->m[1].rtyp=INTVEC_CMD;
l->m[1].data=(void *)v;
res->data=(void *)l;
res->rtyp=LIST_CMD;
return FALSE;
}
case 1:
res->data=(void *)f;
return FALSE;
case 3:
{
poly p=f->m[0];
int i=IDELEMS(f);
f->m[0]=NULL;
while(i>1)
{
i--;
p=pMult(p,f->m[i]);
f->m[i]=NULL;
}
res->data=(void *)p;
res->rtyp=POLY_CMD;
}
return FALSE;
}
WerrorS("invalid switch");
return FALSE;
}
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
{
res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
return FALSE;
}
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
{
res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
//return (res->data== (void*)(long)-2);
return FALSE;
}
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
{
int sw = (int)(long)v->Data();
// CopyD for POLY_CMD and VECTOR_CMD are identical:
poly p = (poly)u->CopyD(POLY_CMD);
if (sw & SIMPL_NORM)
{
pNorm(p);
}
if (sw & SIMPL_NORMALIZE)
{
p_Normalize(p,currRing);
}
res->data = (char * )p;
return FALSE;
}
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
{
ideal result;
intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
ideal u_id=(ideal)(u->Data());
if (w!=NULL)
{
if (!idTestHomModule(u_id,currRing->qideal,w))
{
WarnS("wrong weights:");w->show();PrintLn();
w=NULL;
}
else
{
w=ivCopy(w);
hom=isHomog;
}
}
bigintmat *vv=(bigintmat*)v->Data();
result=kStd2(u_id,currRing->qideal,hom,&w,vv);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
{
ideal result;
assumeStdFlag(u);
ideal i1=(ideal)(u->Data());
int ii1=idElem(i1); /* size of i1 */
ideal i0;
int r=v->Typ();
BITSET save1;
SI_SAVE_OPT1(save1);
intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
{
poly p=(poly)v->Data();
i0=idInit(1,i1->rank);
i0->m[0]=p;
i1=idSimpleAdd(i1,i0); //
i0->m[0]=NULL;
idDelete(&i0);
if (w!=NULL)
{
if (!idTestHomModule(i1,currRing->qideal,w))
{
// no warnung: this is legal, if i in std(i,p)
// is homogeneous, but p not
w=NULL;
}
else
{
w=ivCopy(w);
hom=isHomog;
}
}
si_opt_1|=Sy_bit(OPT_SB_1);
/* ii1 appears to be the position of the first element of il that
does not belong to the old SB ideal */
result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
}
else /*IDEAL/MODULE*/
{
i0=(ideal)v->CopyD();
i1=idSimpleAdd(i1,i0); //
memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
idDelete(&i0);
if (w!=NULL)
{
if (!idTestHomModule(i1,currRing->qideal,w))
{
// no warnung: this is legal, if i in std(i,p)
// is homogeneous, but p not
w=NULL;
hom=isNotHomog;
}
else
{
w=ivCopy(w);
hom=isHomog;
}
}
si_opt_1|=Sy_bit(OPT_SB_1);
/* ii1 appears to be the position of the first element of i1 that
does not belong to the old SB ideal */
result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
}
SI_RESTORE_OPT1(save1);
idDelete(&i1);
if (errorreported) return TRUE;
idSkipZeroes(result);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjSYZ_2(leftv res, leftv u, leftv v)
{
// see jjSYZYGY
intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
intvec *w=NULL;
tHomog hom=testHomog;
ideal I=(ideal)u->Data();
GbVariant alg=syGetAlgorithm((char*)v->Data(),currRing,I);
if (ww!=NULL)
{
if (idTestHomModule(I,currRing->qideal,ww))
{
w=ivCopy(ww);
int add_row_shift=w->min_in();
(*w)-=add_row_shift;
hom=isHomog;
}
else
{
//WarnS("wrong weights");
delete ww; ww=NULL;
hom=testHomog;
}
}
else
{
if (u->Typ()==IDEAL_CMD)
if (idHomIdeal(I,currRing->qideal))
hom=isHomog;
}
ideal S=idSyzygies(I,hom,&w,TRUE,FALSE,NULL,alg);
if (w!=NULL) delete w;
res->data = (char *)S;
if (hom==isHomog)
{
int vl=S->rank;
intvec *vv=new intvec(vl);
if ((u->Typ()==IDEAL_CMD)||(ww==NULL))
{
for(int i=0;i<vl;i++)
{
if (I->m[i]!=NULL)
(*vv)[i]=p_Deg(I->m[i],currRing);
}
}
else
{
p_SetModDeg(ww, currRing);
for(int i=0;i<vl;i++)
{
if (I->m[i]!=NULL)
(*vv)[i]=currRing->pFDeg(I->m[i],currRing);
}
p_SetModDeg(NULL, currRing);
}
if (idTestHomModule(S,currRing->qideal,vv))
atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
else
delete vv;
}
if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
#ifdef HTABLE
static BOOLEAN jjTABLE_GET(leftv res, leftv u, leftv v)
{
stablerec* t=(stablerec*)u->Data();
leftv r=t_findTabelVal(t,(char*)v->Data());
if (r!=NULL) res->Copy(r);
return (r==NULL);
}
#endif
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
{
ideal A=(ideal)u->Data();
ideal B=(ideal)v->Data();
res->data = (char *)sm_Tensor(A,B,currRing);
return FALSE;
}
static BOOLEAN jjTENSOR_Ma(leftv res, leftv u, leftv v)
{
sleftv tmp_u,tmp_v,tmp_res;
int index=iiTestConvert(MATRIX_CMD,SMATRIX_CMD,dConvertTypes);
iiConvert(MATRIX_CMD,SMATRIX_CMD,index,u,&tmp_u,dConvertTypes);
iiConvert(MATRIX_CMD,SMATRIX_CMD,index,v,&tmp_v,dConvertTypes);
tmp_res.Init();
tmp_res.rtyp=SMATRIX_CMD;
BOOLEAN bo=jjTENSOR(&tmp_res,&tmp_u,&tmp_v);
if (!bo)
{
index=iiTestConvert(SMATRIX_CMD,MATRIX_CMD,dConvertTypes);
iiConvert(SMATRIX_CMD,MATRIX_CMD,index,&tmp_res,res,dConvertTypes);
}
tmp_u.CleanUp();
tmp_v.CleanUp();
tmp_res.CleanUp();
return bo;
}
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
{
idhdl h=(idhdl)u->data;
int i=(int)(long)v->Data();
if ((0<i) && (i<=IDRING(h)->N))
res->data=omStrDup(IDRING(h)->names[i-1]);
else
{
Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
{
// input: u: a list with links of type
// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
// v: timeout for select in milliseconds
// or 0 for polling
// returns: ERROR (via Werror): timeout negative
// -1: the read state of all links is eof
// 0: timeout (or polling): none ready
// i>0: (at least) L[i] is ready
lists L = (lists)u->Data();
int t = (int)(long)v->Data();
if(t < 0)
{
t= -1;
}
int i = slStatusSsiL(L, t);
if(i == -2) /* error */
{
return TRUE;
}
res->data = (void*)(long)i;
return FALSE;
}
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
{
// input: u: a list with links of type
// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
// v: timeout for select in milliseconds
// or 0 for polling
// or -1 for infinite
// returns: ERROR (via Werror): timeout negative
// -1: the read state of all links is eof or error
// 0: timeout (or polling): none ready
// 1: all links are ready
// (caution: at least one is ready, but some maybe dead)
lists L = (lists)u->Data();
BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
int timeout = (int)(long)v->Data();
if(timeout < 0)
{
timeout=-1;
}
int t = getRTimer()/TIMER_RESOLUTION; // in seconds
int i;
int ret = -1;
for(unsigned nfinished = 0; nfinished <= ((unsigned)L->nr); nfinished++)
{
i = slStatusSsiL(L, timeout, ignore);
if(i > 0) /* L[i] is ready */
{
ret = 1;
ignore[i-1]=TRUE;
timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
}
else /* terminate the for loop */
{
omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
if(i == -2) /* error */
{
return TRUE;
}
if(i == 0) /* timeout */
{
ret = 0;
}
break;
}
}
res->data = (void*)(long)ret;
return FALSE;
}
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
{
res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjWRONG(leftv, leftv)
{
return TRUE;
}
static BOOLEAN jjWRONG2(leftv, leftv, leftv)
{
return TRUE;
}
static BOOLEAN jjWRONG3(leftv, leftv, leftv, leftv)
{
return TRUE;
}
/*=================== operations with 1 arg.: static proc =================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN jjDUMMY(leftv res, leftv u)
{
// res->data = (char *)u->CopyD();
// also copy attributes:
res->Copy(u);
return FALSE;
}
static BOOLEAN jjNULL(leftv, leftv)
{
return FALSE;
}
//static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
//{
// res->data = (char *)((int)(long)u->Data()+1);
// return FALSE;
//}
//static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
//{
// res->data = (char *)((int)(long)u->Data()-1);
// return FALSE;
//}
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
{
if (IDTYP((idhdl)u->data)==INT_CMD)
{
int i=IDINT((idhdl)u->data);
if (iiOp==PLUSPLUS) i++;
else i--;
IDDATA((idhdl)u->data)=(char *)(long)i;
return FALSE;
}
return TRUE;
}
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
{
number n=(number)u->CopyD(BIGINT_CMD);
n=n_InpNeg(n,coeffs_BIGINT);
res->data = (char *)n;
return FALSE;
}
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
{
res->data = (char *)(-(long)u->Data());
return FALSE;
}
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
{
number n=(number)u->CopyD(NUMBER_CMD);
n=nInpNeg(n);
res->data = (char *)n;
return FALSE;
}
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
{
res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
return FALSE;
}
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
{
poly m1=pISet(-1);
res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
return FALSE;
}
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
{
intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
(*iv)*=(-1);
res->data = (char *)iv;
return FALSE;
}
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
{
bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD);
(*bim)*=(-1);
res->data = (char *)bim;
return FALSE;
}
// dummy for python_module.so and similiar
static BOOLEAN jjSetRing(leftv, leftv u)
{
if (u->rtyp==IDHDL) rSetHdl((idhdl)u->data);
else
{
ring r=(ring)u->Data();
idhdl h=rFindHdl(r,NULL);
if (h==NULL)
{
char name_buffer[100];
STATIC_VAR int ending=1000000;
ending++;
snprintf(name_buffer,100, "PYTHON_RING_VAR%d",ending);
h=enterid(name_buffer,0,RING_CMD,&IDROOT);
IDRING(h)=rIncRefCnt(r);
}
rSetHdl(h);
}
return FALSE;
}
static BOOLEAN jjPROC1(leftv res, leftv u)
{
return jjPROC(res,u,NULL);
}
static BOOLEAN jjBAREISS(leftv res, leftv v)
{
//matrix m=(matrix)v->Data();
//lists l=mpBareiss(m,FALSE);
intvec *iv;
ideal m;
sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=MODUL_CMD;
l->m[1].rtyp=INTVEC_CMD;
l->m[0].data=(void *)m;
l->m[1].data=(void *)iv;
res->data = (char *)l;
return FALSE;
}
//static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
//{
// intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
// ivTriangMat(m);
// res->data = (char *)m;
// return FALSE;
//}
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
{
bigintmat *b=(bigintmat*)v->CopyD(BIGINTMAT_CMD);
b->hnf();
res->data=(char*)b;
return FALSE;
}
static BOOLEAN jjBI2N(leftv res, leftv u)
{
BOOLEAN bo=FALSE;
number n=(number)u->CopyD();
nMapFunc nMap=n_SetMap(coeffs_BIGINT,currRing->cf);
if (nMap!=NULL)
res->data=nMap(n,coeffs_BIGINT,currRing->cf);
else
{
Werror("cannot convert bigint to cring %s", nCoeffName(currRing->cf));
bo=TRUE;
}
n_Delete(&n,coeffs_BIGINT);
return bo;
}
static BOOLEAN jjBI2IM(leftv res, leftv u)
{
bigintmat *b=(bigintmat*)u->Data();
res->data=(void *)bim2iv(b);
return FALSE;
}
static BOOLEAN jjBI2P(leftv res, leftv u)
{
sleftv tmp;
BOOLEAN bo=jjBI2N(&tmp,u);
if (!bo)
{
number n=(number) tmp.data;
if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
else
{
res->data=(void *)pNSet(n);
}
}
return bo;
}
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
{
return iiExprArithM(res,u,iiOp);
}
static BOOLEAN jjCHAR(leftv res, leftv v)
{
res->data = (char *)(long)rChar((ring)v->Data());
return FALSE;
}
static BOOLEAN jjCOEFFS1(leftv res, leftv v)
{
ring r=(ring)v->Data();
r->cf->ref++;
res->data = (char *)r->cf;
return FALSE;
}
static BOOLEAN jjCOLS(leftv res, leftv v)
{
res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
return FALSE;
}
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
{
res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
return FALSE;
}
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
{
res->data = (char *)(long)((intvec*)(v->Data()))->cols();
return FALSE;
}
static BOOLEAN jjCONTENT(leftv res, leftv v)
{
// CopyD for POLY_CMD and VECTOR_CMD are identical:
poly p=(poly)v->CopyD(POLY_CMD);
if (p!=NULL) p_Cleardenom(p, currRing);
res->data = (char *)p;
return FALSE;
}
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
{
res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
return FALSE;
}
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
{
bigintmat* aa= (bigintmat *)v->Data();
res->data = (char *)(long)(aa->rows()*aa->cols());
return FALSE;
}
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
{
res->data = (char *)(long)nSize((number)v->Data());
return FALSE;
}
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
{
lists l=(lists)v->Data();
res->data = (char *)(long)(lSize(l)+1);
return FALSE;
}
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
{
matrix m=(matrix)v->Data();
res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
return FALSE;
}
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
{
res->data = (char *)(long)((intvec*)(v->Data()))->length();
return FALSE;
}
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
{
ring r=(ring)v->Data();
int elems=-1;
if (rField_is_Zp(r)) elems=r->cf->ch;
else if (rField_is_GF(r)) elems=r->cf->m_nfCharQ;
else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
{
extern int ipower ( int b, int n ); /* factory/cf_util */
elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
}
res->data = (char *)(long)elems;
return FALSE;
}
static BOOLEAN jjDEG(leftv res, leftv v)
{
int dummy;
poly p=(poly)v->Data();
if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
else res->data=(char *)-1;
return FALSE;
}
static BOOLEAN jjDEG_M(leftv res, leftv u)
{
ideal I=(ideal)u->Data();
int d=-1;
int dummy;
int i;
for(i=IDELEMS(I)-1;i>=0;i--)
if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
res->data = (char *)(long)d;
return FALSE;
}
static BOOLEAN jjDEGREE(leftv res, leftv v)
{
SPrintStart();
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of degree is being performed for\n");
PrintS("// generic fibre, that is, over Q\n");
}
assumeStdFlag(v);
intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
scDegree((ideal)v->Data(),module_w,currRing->qideal);
char *s=SPrintEnd();
int l=strlen(s)-1;
s[l]='\0';
res->data=(void*)s;
return FALSE;
}
static BOOLEAN jjDEFINED(leftv res, leftv v)
{
if ((v->rtyp==IDHDL)
&& ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
{
res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
}
else if (v->rtyp!=0) res->data=(void *)(-1);
return FALSE;
}
/// Return the denominator of the input number
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
{
number n = reinterpret_cast<number>(v->CopyD());
res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
n_Delete(&n,currRing->cf);
return FALSE;
}
/// Return the numerator of the input number
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
{
number n = reinterpret_cast<number>(v->CopyD());
res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
n_Delete(&n,currRing->cf);
return FALSE;
}
static BOOLEAN jjDET(leftv res, leftv v)
{
matrix m=(matrix)v->Data();
res ->data = mp_Det(m,currRing);
return FALSE;
}
static BOOLEAN jjDET_BI(leftv res, leftv v)
{
bigintmat * m=(bigintmat*)v->Data();
int i,j;
i=m->rows();j=m->cols();
if(i==j)
res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
else
{
Werror("det of %d x %d bigintmat",i,j);
return TRUE;
}
return FALSE;
}
#ifdef SINGULAR_4_2
static BOOLEAN jjDET_N2(leftv res, leftv v)
{
bigintmat * m=(bigintmat*)v->Data();
number2 r=(number2)omAlloc0(sizeof(*r));
int i,j;
i=m->rows();j=m->cols();
if(i==j)
{
r->n=m->det();
r->cf=m->basecoeffs();
}
else
{
omFreeSize(r,sizeof(*r));
Werror("det of %d x %d cmatrix",i,j);
return TRUE;
}
res->data=(void*)r;
return FALSE;
}
#endif
static BOOLEAN jjDET_I(leftv res, leftv v)
{
intvec * m=(intvec*)v->Data();
int i,j;
i=m->rows();j=m->cols();
if(i==j)
res->data = (char *)(long)singclap_det_i(m,currRing);
else
{
Werror("det of %d x %d intmat",i,j);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjDET_S(leftv res, leftv v)
{
ideal I=(ideal)v->Data();
res->data=(char*)sm_Det(I,currRing);
return FALSE;
}
static BOOLEAN jjDIM(leftv res, leftv v)
{
assumeStdFlag(v);
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (rField_is_Ring(currRing))
{
WerrorS("`dim` is not implemented for letterplace rings over rings");
return TRUE;
}
if (currRing->qideal != NULL)
{
WerrorS("qring not supported by `dim` for letterplace rings at the moment");
return TRUE;
}
int gkDim = lp_gkDim((ideal)(v->Data()));
res->data = (char *)(long)gkDim;
return (gkDim == -2);
}
#endif
if (rHasMixedOrdering(currRing))
{
Warn("dim(%s) may be wrong because the mixed monomial ordering",v->Name());
}
res->data = (char *)(long)scDimIntRing((ideal)(v->Data()),currRing->qideal);
return FALSE;
}
static BOOLEAN jjDUMP(leftv, leftv v)
{
si_link l = (si_link)v->Data();
if (slDump(l))
{
const char *s;
if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
else s=sNoName_fe;
Werror("cannot dump to `%s`",s);
return TRUE;
}
else
return FALSE;
}
static BOOLEAN jjE(leftv res, leftv v)
{
res->data = (char *)pOne();
int co=(int)(long)v->Data();
if (co>0)
{
pSetComp((poly)res->data,co);
pSetm((poly)res->data);
}
else WerrorS("argument of gen must be positive");
return (co<=0);
}
static BOOLEAN jjEXECUTE(leftv, leftv v)
{
char * d = (char *)v->Data();
char * s = (char *)omAlloc(strlen(d) + 13);
strcpy( s, (char *)d);
strcat( s, "\n;RETURN();\n");
newBuffer(s,BT_execute);
return yyparse();
}
static BOOLEAN jjFACSTD(leftv res, leftv v)
{
lists L=(lists)omAllocBin(slists_bin);
if (currRing->cf->convSingNFactoryN!=ndConvSingNFactoryN) /* conversion to factory*/
{
ideal_list p,h;
h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
if (h==NULL)
{
L->Init(1);
L->m[0].data=(char *)idInit(1);
L->m[0].rtyp=IDEAL_CMD;
}
else
{
p=h;
int l=0;
while (p!=NULL) { p=p->next;l++; }
L->Init(l);
l=0;
while(h!=NULL)
{
L->m[l].data=(char *)h->d;
L->m[l].rtyp=IDEAL_CMD;
p=h->next;
omFreeSize(h,sizeof(*h));
h=p;
l++;
}
}
}
else
{
WarnS("no factorization implemented");
L->Init(1);
iiExprArith1(&(L->m[0]),v,STD_CMD);
}
res->data=(void *)L;
return FALSE;
}
static BOOLEAN jjFAC_P(leftv res, leftv u)
{
intvec *v=NULL;
singclap_factorize_retry=0;
ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
if (f==NULL) return TRUE;
ivTest(v);
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=(void *)f;
l->m[1].rtyp=INTVEC_CMD;
l->m[1].data=(void *)v;
res->data=(void *)l;
return FALSE;
}
static BOOLEAN jjGETDUMP(leftv, leftv v)
{
si_link l = (si_link)v->Data();
if (slGetDump(l))
{
const char *s;
if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
else s=sNoName_fe;
Werror("cannot get dump from `%s`",s);
return TRUE;
}
else
return FALSE;
}
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
{
assumeStdFlag(v);
ideal I=(ideal)v->Data();
res->data=(void *)iiHighCorner(I,0);
return FALSE;
}
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
{
assumeStdFlag(v);
intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
BOOLEAN delete_w=FALSE;
ideal I=(ideal)v->Data();
int i;
poly p=NULL,po=NULL;
int rk=id_RankFreeModule(I,currRing);
if (w==NULL)
{
w = new intvec(rk);
delete_w=TRUE;
}
for(i=rk;i>0;i--)
{
p=iiHighCorner(I,i);
if (p==NULL)
{
WerrorS("module must be zero-dimensional");
if (delete_w) delete w;
return TRUE;
}
if (po==NULL)
{
po=p;
}
else
{
// now po!=NULL, p!=NULL
int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
if (d==0)
d=pLmCmp(po,p);
if (d > 0)
{
pDelete(&p);
}
else // (d < 0)
{
pDelete(&po); po=p;
}
}
}
if (delete_w) delete w;
res->data=(void *)po;
return FALSE;
}
static BOOLEAN jjHILBERT(leftv, leftv v)
{
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of Hilbert series etc. is being\n");
PrintS("// performed for generic fibre, that is, over Q\n");
}
assumeStdFlag(v);
intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
//scHilbertPoly((ideal)v->Data(),currRing->qideal);
hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
return FALSE;
}
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
{
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of Hilbert series etc. is being\n");
PrintS("// performed for generic fibre, that is, over Q\n");
}
res->data=(void *)hSecondSeries((intvec *)v->Data());
return FALSE;
}
static BOOLEAN jjHOMOG1(leftv res, leftv v)
{
intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
ideal v_id=(ideal)v->Data();
if (w==NULL)
{
res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
if (res->data!=NULL)
{
if (v->rtyp==IDHDL)
{
char *s_isHomog=omStrDup("isHomog");
if (v->e==NULL)
atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
else
atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
}
else if (w!=NULL) delete w;
} // if res->data==NULL then w==NULL
}
else
{
res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
if((res->data==NULL) && (v->rtyp==IDHDL))
{
if (v->e==NULL)
atKill((idhdl)(v->data),"isHomog");
else
atKill((idhdl)(v->LData()),"isHomog");
}
}
return FALSE;
}
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
{
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
int deg = (int)(long)v->Data();
if (deg > currRing->N/currRing->isLPring)
{
WerrorS("degree bound of Letterplace ring is to small");
return TRUE;
}
}
#endif
res->data = (char *)idMaxIdeal((int)(long)v->Data());
setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
{
matrix mat=(matrix)v->CopyD(MATRIX_CMD);
IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
MATROWS(mat)=1;
mat->rank=1;
res->data=(char *)mat;
return FALSE;
}
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
{
map m=(map)v->CopyD(MAP_CMD);
omFreeBinAddr((ADDRESS)m->preimage);
m->preimage=NULL;
ideal I=(ideal)m;
I->rank=1;
res->data=(char *)I;
return FALSE;
}
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
{
if (currRing!=NULL)
{
ring q=(ring)v->Data();
if (rSamePolyRep(currRing, q))
{
if (q->qideal==NULL)
res->data=(char *)idInit(1,1);
else
res->data=(char *)idCopy(q->qideal);
return FALSE;
}
}
WerrorS("can only get ideal from identical qring");
return TRUE;
}
static BOOLEAN jjIm2Iv(leftv res, leftv v)
{
intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
iv->makeVector();
res->data = iv;
return FALSE;
}
static BOOLEAN jjIMPART(leftv res, leftv v)
{
res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
return FALSE;
}
static BOOLEAN jjINDEPSET(leftv res, leftv v)
{
assumeStdFlag(v);
res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
return FALSE;
}
static BOOLEAN jjINTERRED(leftv res, leftv v)
{
ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
if (TEST_OPT_PROT) { PrintLn(); mflush(); }
res->data = result;
return FALSE;
}
static BOOLEAN jjBIV2IV(leftv res, leftv v)
{
bigintmat* aa= (bigintmat *)v->Data();
int l=aa->cols();
intvec *iv=new intvec(l);
for(int i=0;i<l;i++) (*iv)[i]=iin_Int(BIMATELEM((*aa),1,i+1),coeffs_BIGINT);
res->data = (void*)iv;
return FALSE;
}
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
{
res->data = (char *)(long)pVar((poly)v->Data());
return FALSE;
}
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
{
res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
currRing->N)+1);
return FALSE;
}
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
{
res->data = (char *)0;
return FALSE;
}
static BOOLEAN jjJACOB_P(leftv res, leftv v)
{
ideal i=idInit(currRing->N,1);
int k;
poly p=(poly)(v->Data());
for (k=currRing->N;k>0;k--)
{
i->m[k-1]=pDiff(p,k);
}
res->data = (char *)i;
return FALSE;
}
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
{
if (!nCoeff_is_transExt(currRing->cf))
{
WerrorS("differentiation not defined in the coefficient ring");
return TRUE;
}
number n = (number) u->Data();
number k = (number) v->Data();
res->data = ntDiff(n,k,currRing->cf);
return FALSE;
}
/*2
* compute Jacobi matrix of a module/matrix
* Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
* where Mt := transpose(M)
* Note that this is consistent with the current conventions for jacob in Singular,
* whereas M2 computes its transposed.
*/
static BOOLEAN jjJACOB_M(leftv res, leftv a)
{
ideal id = (ideal)a->Data();
id = id_Transp(id,currRing);
int W = IDELEMS(id);
ideal result = idInit(W * currRing->N, id->rank);
poly *p = result->m;
for( int v = 1; v <= currRing->N; v++ )
{
poly* q = id->m;
for( int i = 0; i < W; i++, p++, q++ )
*p = pDiff( *q, v );
}
idDelete(&id);
res->data = (char *)result;
return FALSE;
}
static BOOLEAN jjKERNEL_M(leftv res, leftv v)
{
#ifdef HAVE_FLINT
res->data = (char *)singflint_kernel((matrix)(v->Data()),currRing);
return res->data==NULL;
#else
return TRUE;
#endif
}
static BOOLEAN jjKERNEL_SM(leftv res, leftv v)
{
#ifdef HAVE_FLINT
res->data = (char *)singflint_kernel((ideal)(v->Data()),currRing);
return res->data==NULL;
#else
return TRUE;
#endif
}
static BOOLEAN jjKBASE(leftv res, leftv v)
{
assumeStdFlag(v);
res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
return FALSE;
}
static BOOLEAN jjL2R(leftv res, leftv v)
{
res->data=(char *)syConvList((lists)v->Data());
if (res->data != NULL)
return FALSE;
else
return TRUE;
}
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
{
poly p=(poly)v->Data();
if (p==NULL)
{
res->data=(char *)nInit(0);
}
else
{
nNormalize(pGetCoeff(p));
res->data=(char *)nCopy(pGetCoeff(p));
}
return FALSE;
}
static BOOLEAN jjLEADEXP(leftv res, leftv v)
{
poly p=(poly)v->Data();
int s=currRing->N;
if (v->Typ()==VECTOR_CMD) s++;
intvec *iv=new intvec(s);
if (p!=NULL)
{
for(int i = currRing->N;i;i--)
{
(*iv)[i-1]=pGetExp(p,i);
}
if (s!=currRing->N)
(*iv)[currRing->N]=pGetComp(p);
}
res->data=(char *)iv;
return FALSE;
}
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
{
poly p=(poly)v->Data();
if (p == NULL)
{
res->data = (char*) NULL;
}
else
{
poly lm = pLmInit(p);
pSetCoeff0(lm, nInit(1));
res->data = (char*) lm;
}
return FALSE;
}
static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
{
return jjLOAD((char*)v->Data(),FALSE);
}
static BOOLEAN jjLISTRING(leftv res, leftv v)
{
lists l=(lists)v->Data();
long mm=(long)atGet(v,"maxExp",INT_CMD);
int isLetterplace=(int)(long)atGet(v,"isLetterplaceRing",INT_CMD);
ring r=rCompose(l,TRUE,mm,isLetterplace);
res->data=(char *)r;
return (r==NULL);
}
static BOOLEAN jjPFAC1(leftv res, leftv v)
{
/* call method jjPFAC2 with second argument = 0 (meaning that no
valid bound for the prime factors has been given) */
sleftv tmp;
tmp.Init();
tmp.rtyp = INT_CMD;
return jjPFAC2(res, v, &tmp);
}
static BOOLEAN jjLagSolve(leftv res, leftv v)
{
sleftv a2,a3;
a2.Init();
a3.Init();
a2.rtyp=INT_CMD; a2.data=(void*)10;
a3.rtyp=INT_CMD; a3.data=(void*)1;
return nuLagSolve(res,v,&a2,&a3);
}
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
{
/* computes the LU-decomposition of a matrix M;
i.e., M = P * L * U, where
- P is a row permutation matrix,
- L is in lower triangular form,
- U is in upper row echelon form
Then, we also have P * M = L * U.
A list [P, L, U] is returned. */
matrix mat = (matrix)v->Data();
if (!idIsConstant((ideal)mat))
{
WerrorS("matrix must be constant");
return TRUE;
}
matrix pMat;
matrix lMat;
matrix uMat;
luDecomp(mat, pMat, lMat, uMat);
lists ll = (lists)omAllocBin(slists_bin);
ll->Init(3);
ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
res->data=(char*)ll;
return FALSE;
}
static BOOLEAN jjMEMORY(leftv res, leftv v)
{
// clean out "_":
sLastPrinted.CleanUp();
// collect all info:
omUpdateInfo();
switch(((int)(long)v->Data()))
{
case 0:
res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
break;
case 1:
res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
break;
case 2:
res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
break;
default:
omPrintStats(stdout);
omPrintInfo(stdout);
omPrintBinStats(stdout);
res->data = (char *)0;
res->rtyp = NONE;
}
return FALSE;
}
//static BOOLEAN jjMONITOR1(leftv res, leftv v)
//{
// return jjMONITOR2(res,v,NULL);
//}
static BOOLEAN jjMSTD(leftv res, leftv v)
{
int t=v->Typ();
ideal r,m;
r=kMin_std2((ideal)v->Data(),currRing->qideal,testHomog,NULL,m,NULL);
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=t;
l->m[0].data=(char *)r;
setFlag(&(l->m[0]),FLAG_STD);
l->m[1].rtyp=t;
l->m[1].data=(char *)m;
res->data=(char *)l;
return FALSE;
}
static BOOLEAN jjMULT(leftv res, leftv v)
{
assumeStdFlag(v);
res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
return FALSE;
}
static BOOLEAN jjMINRES_R(leftv res, leftv v)
{
intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
syStrategy tmp=syCopy((syStrategy)v->Data());
tmp = syMinimize(tmp); // enrich itself!
res->data=(char *)tmp;
if (weights!=NULL)
atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjN2BI(leftv res, leftv v)
{
number n,i; i=(number)v->Data();
nMapFunc nMap=n_SetMap(currRing->cf,coeffs_BIGINT);
if (nMap!=NULL)
n=nMap(i,currRing->cf,coeffs_BIGINT);
else goto err;
res->data=(void *)n;
return FALSE;
err:
WerrorS("cannot convert to bigint"); return TRUE;
}
static BOOLEAN jjNAMEOF(leftv res, leftv v)
{
if ((v->rtyp==IDHDL)||(v->rtyp==ALIAS_CMD))
res->data=omStrDup(v->name);
else if (v->name==NULL)
res->data=omStrDup("");
else
{
res->data = (char *)v->name;
v->name=NULL;
}
return FALSE;
}
static BOOLEAN jjNAMES(leftv res, leftv v)
{
res->data=ipNameList(((ring)v->Data())->idroot);
return FALSE;
}
static BOOLEAN jjNAMES_I(leftv res, leftv v)
{
res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
return FALSE;
}
static BOOLEAN jjNOT(leftv res, leftv v)
{
res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
return FALSE;
}
static BOOLEAN jjNVARS(leftv res, leftv v)
{
res->data = (char *)(long)(((ring)(v->Data()))->N);
return FALSE;
}
static BOOLEAN jjOpenClose(leftv, leftv v)
{
si_link l=(si_link)v->Data();
if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
else { slPrepClose(l); return slClose(l);}
}
static BOOLEAN jjORD(leftv res, leftv v)
{
poly p=(poly)v->Data();
res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
return FALSE;
}
static BOOLEAN jjPAR1(leftv res, leftv v)
{
int i=(int)(long)v->Data();
int p=0;
p=rPar(currRing);
if ((0<i) && (i<=p))
{
res->data=(char *)n_Param(i,currRing);
}
else
{
Werror("par number %d out of range 1..%d",i,p);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjPARDEG(leftv res, leftv v)
{
number nn=(number)v->Data();
res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
return FALSE;
}
static BOOLEAN jjPARSTR1(leftv res, leftv v)
{
if (currRing==NULL)
{
WerrorS("no ring active (1)");
return TRUE;
}
int i=(int)(long)v->Data();
int p=0;
if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
res->data=omStrDup(rParameter(currRing)[i-1]);
else
{
Werror("par number %d out of range 1..%d",i,p);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjP2BI(leftv res, leftv v)
{
poly p=(poly)v->Data();
if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
{
WerrorS("poly must be constant");
return TRUE;
}
number i=pGetCoeff(p);
number n;
nMapFunc nMap=n_SetMap(currRing->cf,coeffs_BIGINT);
if (nMap!=NULL)
n=nMap(i,currRing->cf,coeffs_BIGINT);
else goto err;
res->data=(void *)n;
return FALSE;
err:
WerrorS("cannot convert to bigint"); return TRUE;
}
static BOOLEAN jjP2I(leftv res, leftv v)
{
poly p=(poly)v->Data();
if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
{
WerrorS("poly must be constant");
return TRUE;
}
res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
return FALSE;
}
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
{
map mapping=(map)v->Data();
syMake(res,omStrDup(mapping->preimage));
return FALSE;
}
static BOOLEAN jjPRIME(leftv res, leftv v)
{
int i = IsPrime((int)(long)(v->Data()));
res->data = (char *)(long)(i > 1 ? i : 2);
return FALSE;
}
static BOOLEAN jjPRUNE(leftv res, leftv v)
{
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
ideal v_id=(ideal)v->Data();
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
// and continue at the non-homog case below
}
else
{
w=ivCopy(w);
intvec **ww=&w;
res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
return FALSE;
}
}
res->data = (char *)idMinEmbedding(v_id);
return FALSE;
}
static BOOLEAN jjP2N(leftv res, leftv v)
{
number n;
poly p;
if (((p=(poly)v->Data())!=NULL)
&& (pIsConstant(p)))
{
n=nCopy(pGetCoeff(p));
}
else
{
n=nInit(0);
}
res->data = (char *)n;
return FALSE;
}
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
{
char *s= (char *)v->Data();
// try system keywords
for(unsigned i=0; i<sArithBase.nCmdUsed; i++)
{
//Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
if (strcmp(s, sArithBase.sCmds[i].name) == 0)
{
res->data = (char *)1;
return FALSE;
}
}
// try blackbox names
int id;
blackboxIsCmd(s,id);
if (id>0)
{
res->data = (char *)1;
}
return FALSE;
}
static BOOLEAN jjRANK1(leftv res, leftv v)
{
matrix m =(matrix)v->Data();
int rank = luRank(m, 0);
res->data =(char *)(long)rank;
return FALSE;
}
static BOOLEAN jjREAD(leftv res, leftv v)
{
return jjREAD2(res,v,NULL);
}
static BOOLEAN jjREGULARITY(leftv res, leftv v)
{
res->data = (char *)(long)iiRegularity((lists)v->Data());
return FALSE;
}
static BOOLEAN jjREPART(leftv res, leftv v)
{
res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
return FALSE;
}
static BOOLEAN jjRINGLIST(leftv res, leftv v)
{
ring r=(ring)v->Data();
if (r!=NULL)
{
res->data = (char *)rDecompose((ring)v->Data());
if (res->data!=NULL)
{
long mm=r->wanted_maxExp;
if (mm!=0) atSet(res,omStrDup("maxExp"),(void*)mm,INT_CMD);
return FALSE;
}
}
return TRUE;
}
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
{
coeffs r=(coeffs)v->Data();
if (r!=NULL)
return rDecompose_CF(res,r);
return TRUE;
}
static BOOLEAN jjRING_LIST(leftv res, leftv v)
{
ring r=(ring)v->Data();
if (r!=NULL)
res->data = (char *)rDecompose_list_cf((ring)v->Data());
return (r==NULL)||(res->data==NULL);
}
static BOOLEAN jjROWS(leftv res, leftv v)
{
ideal i = (ideal)v->Data();
res->data = (char *)i->rank;
return FALSE;
}
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
{
res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
return FALSE;
}
static BOOLEAN jjROWS_IV(leftv res, leftv v)
{
res->data = (char *)(long)((intvec*)(v->Data()))->rows();
return FALSE;
}
static BOOLEAN jjRPAR(leftv res, leftv v)
{
res->data = (char *)(long)rPar(((ring)v->Data()));
return FALSE;
}
static BOOLEAN jjS2I(leftv res, leftv v)
{
res->data = (char *)(long)atoi((char*)v->Data());
return FALSE;
}
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
{
const bool bIsSCA = rIsSCA(currRing);
if ((currRing->qideal!=NULL) && !bIsSCA)
{
WerrorS("qring not supported by slimgb at the moment");
return TRUE;
}
if (rHasLocalOrMixedOrdering(currRing))
{
WerrorS("ordering must be global for slimgb");
return TRUE;
}
if (rField_is_numeric(currRing))
WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
// tHomog hom=testHomog;
ideal u_id=(ideal)u->Data();
if (w!=NULL)
{
if (!idTestHomModule(u_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
}
else
{
w=ivCopy(w);
// hom=isHomog;
}
}
assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
res->data=(char *)t_rep_gb(currRing,
u_id,u_id->rank);
//res->data=(char *)t_rep_gb(currRing, u_id);
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSBA(leftv res, leftv v)
{
ideal result;
ideal v_id=(ideal)v->Data();
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
}
else
{
hom=isHomog;
w=ivCopy(w);
}
}
result=kSba(v_id,currRing->qideal,hom,&w,1,0,NULL);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
{
ideal result;
ideal v_id=(ideal)v->Data();
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
}
else
{
hom=isHomog;
w=ivCopy(w);
}
}
result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0,NULL);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
{
ideal result;
ideal v_id=(ideal)v->Data();
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
}
else
{
hom=isHomog;
w=ivCopy(w);
}
}
result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data(),NULL);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSTD(leftv res, leftv v)
{
if (rField_is_numeric(currRing))
WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
ideal result;
ideal v_id=(ideal)v->Data();
intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w!=NULL)
{
if (!idTestHomModule(v_id,currRing->qideal,w))
{
WarnS("wrong weights");
w=NULL;
}
else
{
hom=isHomog;
w=ivCopy(w);
}
}
result=kStd2(v_id,currRing->qideal,hom,&w,(bigintmat*)NULL);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjSort_Id(leftv res, leftv v)
{
res->data = (char *)idSort((ideal)v->Data());
return FALSE;
}
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
{
singclap_factorize_retry=0;
intvec *v=NULL;
ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
if (f==NULL) return TRUE;
ivTest(v);
lists l=(lists)omAllocBin(slists_bin);
l->Init(2);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=(void *)f;
l->m[1].rtyp=INTVEC_CMD;
l->m[1].data=(void *)v;
res->data=(void *)l;
return FALSE;
}
#if 0
static BOOLEAN jjSYZYGY(leftv res, leftv v)
{
intvec *w=NULL;
res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
if (w!=NULL) delete w;
if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
#else
// activate, if idSyz handle module weights correctly !
static BOOLEAN jjSYZYGY(leftv res, leftv v)
{
ideal v_id=(ideal)v->Data();
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < IDELEMS(v_id))
{
Werror("At least %d ncgen variables are needed for this computation.", IDELEMS(v_id));
return TRUE;
}
}
#endif
intvec *ww=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
intvec *w=NULL;
tHomog hom=testHomog;
if (ww!=NULL)
{
if (idTestHomModule(v_id,currRing->qideal,ww))
{
w=ivCopy(ww);
int add_row_shift=w->min_in();
(*w)-=add_row_shift;
hom=isHomog;
}
else
{
//WarnS("wrong weights");
delete ww; ww=NULL;
hom=testHomog;
}
}
else
{
if (v->Typ()==IDEAL_CMD)
if (idHomIdeal(v_id,currRing->qideal))
hom=isHomog;
}
ideal S=idSyzygies(v_id,hom,&w);
res->data = (char *)S;
if (hom==isHomog)
{
int vl=S->rank;
intvec *vv=new intvec(vl);
if ((v->Typ()==IDEAL_CMD)||(ww==NULL))
{
for(int i=0;i<vl;i++)
{
if (v_id->m[i]!=NULL)
(*vv)[i]=p_Deg(v_id->m[i],currRing);
}
}
else
{
p_SetModDeg(ww, currRing);
for(int i=0;i<vl;i++)
{
if (v_id->m[i]!=NULL)
(*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
}
p_SetModDeg(NULL, currRing);
}
if (idTestHomModule(S,currRing->qideal,vv))
atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
else
delete vv;
}
if (w!=NULL) delete w;
return FALSE;
}
#endif
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
{
res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
return FALSE;
}
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
{
res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
return FALSE;
}
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
{
res->data = (char *)ivTranp((intvec*)(v->Data()));
return FALSE;
}
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
{
#ifdef HAVE_PLURAL
ring r = (ring)a->Data();
//if (rIsPluralRing(r))
if (r->OrdSgn==1)
{
res->data = rOpposite(r);
}
else
{
WarnS("opposite only for global orderings");
res->data = rCopy(r);
}
return FALSE;
#else
return TRUE;
#endif
}
static BOOLEAN jjENVELOPE(leftv res, leftv a)
{
#ifdef HAVE_PLURAL
ring r = (ring)a->Data();
if (rIsPluralRing(r))
{
ring s = rEnvelope(r);
res->data = s;
}
else res->data = rCopy(r);
return FALSE;
#else
return TRUE;
#endif
}
static BOOLEAN jjTWOSTD(leftv res, leftv a)
{
#ifdef HAVE_PLURAL
ideal result;
ideal v_id=(ideal)a->Data();
if (rIsPluralRing(currRing))
result=(ideal)twostd(v_id);
else /*commutative or shiftalgebra*/
{
return jjSTD(res,a);
}
res->data = (char *)result;
setFlag(res,FLAG_STD);
setFlag(res,FLAG_TWOSTD);
return FALSE;
#else
return TRUE;
#endif
}
static BOOLEAN jjRIGHTSTD(leftv res, leftv v)
{
#if defined(HAVE_SHIFTBBA) || defined(HAVE_PLURAL)// do not place above jjSTD in this file because we need to reference it
if (rIsLPRing(currRing))
{
if (rField_is_numeric(currRing))
WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
ideal result;
ideal v_id=(ideal)v->Data();
/* intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD); */
/* tHomog hom=testHomog; */
/* if (w!=NULL) */
/* { */
/* if (!idTestHomModule(v_id,currRing->qideal,w)) */
/* { */
/* WarnS("wrong weights"); */
/* w=NULL; */
/* } */
/* else */
/* { */
/* hom=isHomog; */
/* w=ivCopy(w); */
/* } */
/* } */
/* result=kStd2(v_id,currRing->qideal,hom,&w); */
result = rightgb(v_id, currRing->qideal);
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
/* if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD); */
return FALSE;
}
else if (rIsPluralRing(currRing))
{
ideal I=(ideal)v->Data();
ring A = currRing;
ring Aopp = rOpposite(A);
currRing = Aopp;
ideal Iopp = idOppose(A, I, Aopp);
ideal Jopp = kStd2(Iopp,currRing->qideal,testHomog,NULL,(bigintmat*)NULL);
if (errorreported) return TRUE;
currRing = A;
ideal J = idOppose(Aopp, Jopp, A);
id_Delete(&Iopp, Aopp);
id_Delete(&Jopp, Aopp);
rDelete(Aopp);
idSkipZeroes(J);
res->data = (char *)J;
if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
return FALSE;
}
else
{
return jjSTD(res, v);
}
#else
return TRUE;
#endif
}
static BOOLEAN jjTYPEOF(leftv res, leftv v)
{
int t=(int)(long)v->data;
switch (t)
{
case CRING_CMD:
case INT_CMD:
case POLY_CMD:
case VECTOR_CMD:
case STRING_CMD:
case INTVEC_CMD:
case IDEAL_CMD:
case MATRIX_CMD:
case MODUL_CMD:
case MAP_CMD:
case PROC_CMD:
case RING_CMD:
case SMATRIX_CMD:
//case QRING_CMD:
case INTMAT_CMD:
case BIGINTMAT_CMD:
case BIGINTVEC_CMD:
case NUMBER_CMD:
#ifdef SINGULAR_4_2
case CNUMBER_CMD:
#endif
case BIGINT_CMD:
case BUCKET_CMD:
case LIST_CMD:
case PACKAGE_CMD:
case LINK_CMD:
case RESOLUTION_CMD:
#ifdef HTABLE
case HTABLE_CMD:
#endif
res->data=omStrDup(Tok2Cmdname(t)); break;
case DEF_CMD:
case NONE: res->data=omStrDup("none"); break;
default:
{
if (t>MAX_TOK)
res->data=omStrDup(getBlackboxName(t));
else
res->data=omStrDup("?unknown type?");
break;
}
}
return FALSE;
}
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
{
res->data=(char *)(long)pIsUnivariate((poly)v->Data());
return FALSE;
}
static BOOLEAN jjVAR1(leftv res, leftv v)
{
int i=(int)(long)v->Data();
if ((0<i) && (i<=currRing->N))
{
poly p=pOne();
pSetExp(p,i,1);
pSetm(p);
res->data=(char *)p;
}
else
{
Werror("var number %d out of range 1..%d",i,currRing->N);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjVARSTR1(leftv res, leftv v)
{
if (currRing==NULL)
{
WerrorS("no ring active (2)");
return TRUE;
}
int i=(int)(long)v->Data();
if ((0<i) && (i<=currRing->N))
res->data=omStrDup(currRing->names[i-1]);
else
{
Werror("var number %d out of range 1..%d",i,currRing->N);
return TRUE;
}
return FALSE;
}
static BOOLEAN jjVDIM(leftv res, leftv v)
{
assumeStdFlag(v);
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (rField_is_Ring(currRing))
{
WerrorS("`vdim` is not implemented for letterplace rings over rings");
return TRUE;
}
if (currRing->qideal != NULL)
{
WerrorS("qring not supported by `vdim` for letterplace rings at the moment");
return TRUE;
}
int kDim = lp_kDim((ideal)(v->Data()));
res->data = (char *)(long)kDim;
return (kDim == -2);
}
#endif
long l=scMult0Int((ideal)v->Data(),currRing->qideal);
if (l<-1L)
WerrorS("int overflow in vdim");
res->data = (char *)l;
return FALSE;
}
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
{
// input: u: a list with links of type
// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
// returns: -1: the read state of all links is eof or error
// i>0: (at least) u[i] is ready
lists L = (lists)u->Data();
int i = slStatusSsiL(L, -1);
if(i == -2) /* error */
{
return TRUE;
}
res->data = (void*)(long)i;
return FALSE;
}
BOOLEAN jjWAITALL1(leftv res, leftv u)
{
// input: u: a list with links of type
// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
// returns: -1: the read state of all links is eof or error
// 1: all links are ready
// (caution: at least one is ready, but some maybe dead)
lists L = (lists)u->Data();
int i;
int j = -1;
BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
for(int nfinished = 0; nfinished <= L->nr; nfinished++)
{
i = slStatusSsiL(L, -1, ignore);
if(i == -2) /* error */
{
omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
return TRUE;
}
if((i == -1)||(j==0))
{
j=-1;
break;
}
if (i>0)
{
j=1;
ignore[i-1]=TRUE;
}
}
omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
res->data = (void*)(long)j;
return FALSE;
}
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
{
char libnamebuf[1024];
lib_types LT = type_of_LIB(s, libnamebuf);
#ifdef HAVE_DYNAMIC_LOADING
extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
#endif /* HAVE_DYNAMIC_LOADING */
switch(LT)
{
default:
case LT_NONE:
Werror("%s: unknown type", s);
break;
case LT_NOTFOUND:
Werror("cannot open %s", s);
break;
case LT_SINGULAR:
{
char *plib = iiConvName(s);
idhdl pl = IDROOT->get_level(plib,0);
if (pl==NULL)
{
pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
IDPACKAGE(pl)->language = LANG_SINGULAR;
IDPACKAGE(pl)->libname=omStrDup(s);
}
else if (IDTYP(pl)!=PACKAGE_CMD)
{
Werror("can not create package `%s`",plib);
omFreeBinAddr(plib);
return TRUE;
}
else /* package */
{
package pa=IDPACKAGE(pl);
if ((pa->language==LANG_C)
|| (pa->language==LANG_MIX))
{
Werror("can not create package `%s` - binaries exists",plib);
omFreeBinAddr(plib);
return TRUE;
}
}
omFreeBinAddr(plib);
package savepack=currPack;
currPack=IDPACKAGE(pl);
IDPACKAGE(pl)->loaded=TRUE;
char libnamebuf[1024];
FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
currPack=savepack;
IDPACKAGE(pl)->loaded=(!bo);
return bo;
}
case LT_BUILTIN:
SModulFunc_t iiGetBuiltinModInit(const char*);
return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
case LT_MACH_O:
case LT_ELF:
case LT_HPUX:
#ifdef HAVE_DYNAMIC_LOADING
return load_modules(s, libnamebuf, autoexport);
#else /* HAVE_DYNAMIC_LOADING */
WerrorS("Dynamic modules are not supported by this version of Singular");
break;
#endif /* HAVE_DYNAMIC_LOADING */
}
return TRUE;
}
STATIC_VAR int WerrorS_dummy_cnt=0;
static void WerrorS_dummy(const char *)
{
WerrorS_dummy_cnt++;
}
BOOLEAN jjLOAD_TRY(const char *s)
{
if (!iiGetLibStatus(s))
{
void (*WerrorS_save)(const char *s) = WerrorS_callback;
WerrorS_callback=WerrorS_dummy;
WerrorS_dummy_cnt=0;
BOOLEAN bo=jjLOAD(s,TRUE);
if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
Print("loading of >%s< failed\n",s);
WerrorS_callback=WerrorS_save;
errorreported=0;
}
return FALSE;
}
static BOOLEAN jjstrlen(leftv res, leftv v)
{
res->data = (char *)strlen((char *)v->Data());
return FALSE;
}
static BOOLEAN jjpLength(leftv res, leftv v)
{
res->data = (char *)(long)pLength((poly)v->Data());
return FALSE;
}
static BOOLEAN jjidElem(leftv res, leftv v)
{
res->data = (char *)(long)idElem((ideal)v->Data());
return FALSE;
}
static BOOLEAN jjidFreeModule(leftv res, leftv v)
{
res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
return FALSE;
}
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
{
res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
return FALSE;
}
static BOOLEAN jjrCharStr(leftv res, leftv v)
{
res->data = rCharStr((ring)v->Data());
return FALSE;
}
static BOOLEAN jjpHead(leftv res, leftv v)
{
res->data = (char *)pHead((poly)v->Data());
return FALSE;
}
static BOOLEAN jjidHead(leftv res, leftv v)
{
res->data = (char *)id_Head((ideal)v->Data(),currRing);
setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjidMinBase(leftv res, leftv v)
{
res->data = (char *)idMinBase((ideal)v->Data());
return FALSE;
}
#if 0 // unused
static BOOLEAN jjsyMinBase(leftv res, leftv v)
{
res->data = (char *)syMinBase((ideal)v->Data());
return FALSE;
}
#endif
static BOOLEAN jjpMaxComp(leftv res, leftv v)
{
res->data = (char *)pMaxComp((poly)v->Data());
return FALSE;
}
static BOOLEAN jjmpTrace(leftv res, leftv v)
{
res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjmpTransp(leftv res, leftv v)
{
res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjrOrdStr(leftv res, leftv v)
{
res->data = rOrdStr((ring)v->Data());
return FALSE;
}
static BOOLEAN jjrVarStr(leftv res, leftv v)
{
res->data = rVarStr((ring)v->Data());
return FALSE;
}
static BOOLEAN jjrParStr(leftv res, leftv v)
{
res->data = rParStr((ring)v->Data());
return FALSE;
}
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
{
res->data=(char *)(long)sySize((syStrategy)v->Data());
return FALSE;
}
static BOOLEAN jjDIM_R(leftv res, leftv v)
{
res->data = (char *)(long)syDim((syStrategy)v->Data());
return FALSE;
}
static BOOLEAN jjidTransp(leftv res, leftv v)
{
res->data = (char *)id_Transp((ideal)v->Data(),currRing);
return FALSE;
}
static BOOLEAN jjnInt(leftv res, leftv u)
{
number n=(number)u->CopyD(); // n_Int may call n_Normalize
res->data=(char *)(long)iin_Int(n,currRing->cf);
n_Delete(&n,currRing->cf);
return FALSE;
}
static BOOLEAN jjnlInt(leftv res, leftv u)
{
number n=(number)u->Data();
res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
return FALSE;
}
/*=================== operations with 3 args.: static proc =================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v,leftv w)
{
char *s= (char *)u->Data();
int r = (int)(long)v->Data();
int c = (int)(long)w->Data();
int l = strlen(s);
if ( (r<1) || (r>l) || (c<0) )
{
Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
return TRUE;
}
res->data = (char *)omAlloc((long)(c+1));
snprintf((char *)res->data,c+1,"%-*.*s",c,c,s+r-1);
return FALSE;
}
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v,leftv w)
{
intvec *iv = (intvec *)u->Data();
int r = (int)(long)v->Data();
int c = (int)(long)w->Data();
if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
{
Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
r,c,u->Fullname(),iv->rows(),iv->cols());
return TRUE;
}
res->data=u->data; u->data=NULL;
res->rtyp=u->rtyp; u->rtyp=0;
res->name=u->name; u->name=NULL;
Subexpr e=jjMakeSub(v);
e->next=jjMakeSub(w);
if (u->e==NULL) res->e=e;
else
{
Subexpr h=u->e;
while (h->next!=NULL) h=h->next;
h->next=e;
res->e=u->e;
u->e=NULL;
}
return FALSE;
}
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
{
bigintmat *bim = (bigintmat *)u->Data();
int r = (int)(long)v->Data();
int c = (int)(long)w->Data();
if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
{
Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
r,c,u->Fullname(),bim->rows(),bim->cols());
return TRUE;
}
res->data=u->data; u->data=NULL;
res->rtyp=u->rtyp; u->rtyp=0;
res->name=u->name; u->name=NULL;
Subexpr e=jjMakeSub(v);
e->next=jjMakeSub(w);
if (u->e==NULL)
res->e=e;
else
{
Subexpr h=u->e;
while (h->next!=NULL) h=h->next;
h->next=e;
res->e=u->e;
u->e=NULL;
}
return FALSE;
}
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v,leftv w)
{
matrix m= (matrix)u->Data();
int r = (int)(long)v->Data();
int c = (int)(long)w->Data();
//Print("gen. elem %d, %d\n",r,c);
if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
{
Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
MATROWS(m),MATCOLS(m));
return TRUE;
}
res->data=u->data; u->data=NULL;
res->rtyp=u->rtyp; u->rtyp=0;
res->name=u->name; u->name=NULL;
Subexpr e=jjMakeSub(v);
e->next=jjMakeSub(w);
if (u->e==NULL)
res->e=e;
else
{
Subexpr h=u->e;
while (h->next!=NULL) h=h->next;
h->next=e;
res->e=u->e;
u->e=NULL;
}
return FALSE;
}
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v,leftv w)
{
ideal m= (ideal)u->Data();
int r = (int)(long)v->Data();
int c = (int)(long)w->Data();
//Print("gen. elem %d, %d\n",r,c);
if ((r<1)||(r>m->rank)||(c<1)||(c>IDELEMS(m)))
{
Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
(int)m->rank,IDELEMS(m));
return TRUE;
}
res->data=u->data; u->data=NULL;
res->rtyp=u->rtyp; u->rtyp=0;
res->name=u->name; u->name=NULL;
Subexpr e=jjMakeSub(v);
e->next=jjMakeSub(w);
if (u->e==NULL)
res->e=e;
else
{
Subexpr h=u->e;
while (h->next!=NULL) h=h->next;
h->next=e;
res->e=u->e;
u->e=NULL;
}
return FALSE;
}
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v,leftv w)
{
if ((u->rtyp!=IDHDL)||(u->e!=NULL))
{
WerrorS("cannot build expression lists from unnamed objects");
return TRUE;
}
leftv p=NULL;
intvec *iv=(intvec *)w->Data();
int l;
BOOLEAN nok;
sleftv ut;
memcpy(&ut,u,sizeof(ut));
sleftv t;
t.Init();
t.rtyp=INT_CMD;
for (l=0;l< iv->length(); l++)
{
t.data=(char *)(long)((*iv)[l]);
if (p==NULL)
{
p=res;
}
else
{
p->next=(leftv)omAlloc0Bin(sleftv_bin);
p=p->next;
}
memcpy(u,&ut,sizeof(ut));
if (u->Typ() == MATRIX_CMD)
nok=jjBRACK_Ma(p,u,v,&t);
else if (u->Typ() == BIGINTMAT_CMD)
nok=jjBRACK_Bim(p,u,v,&t);
else /* INTMAT_CMD */
nok=jjBRACK_Im(p,u,v,&t);
if (nok)
{
while (res->next!=NULL)
{
p=res->next->next;
omFreeBin((ADDRESS)res->next, sleftv_bin);
// res->e aufraeumen !!!!
res->next=p;
}
return TRUE;
}
}
return FALSE;
}
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v,leftv w)
{
if ((u->rtyp!=IDHDL)||(u->e!=NULL))
{
WerrorS("cannot build expression lists from unnamed objects");
return TRUE;
}
leftv p=NULL;
intvec *iv=(intvec *)v->Data();
int l;
BOOLEAN nok;
sleftv ut;
memcpy(&ut,u,sizeof(ut));
sleftv t;
t.Init();
t.rtyp=INT_CMD;
for (l=0;l< iv->length(); l++)
{
t.data=(char *)(long)((*iv)[l]);
if (p==NULL)
{
p=res;
}
else
{
p->next=(leftv)omAlloc0Bin(sleftv_bin);
p=p->next;
}
memcpy(u,&ut,sizeof(ut));
if (u->Typ() == MATRIX_CMD)
nok=jjBRACK_Ma(p,u,&t,w);
else if (u->Typ() == BIGINTMAT_CMD)
nok=jjBRACK_Bim(p,u,&t,w);
else /* INTMAT_CMD */
nok=jjBRACK_Im(p,u,&t,w);
if (nok)
{
while (res->next!=NULL)
{
p=res->next->next;
omFreeBin((ADDRESS)res->next, sleftv_bin);
// res->e aufraeumen !!
res->next=p;
}
return TRUE;
}
}
return FALSE;
}
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v,leftv w)
{
if ((u->rtyp!=IDHDL)||(u->e!=NULL))
{
WerrorS("cannot build expression lists from unnamed objects");
return TRUE;
}
leftv p=NULL;
intvec *vv=(intvec *)v->Data();
intvec *wv=(intvec *)w->Data();
int vl;
int wl;
BOOLEAN nok;
sleftv t1,t2,ut;
memcpy(&ut,u,sizeof(ut));
t1.Init();
t1.rtyp=INT_CMD;
t2.Init();
t2.rtyp=INT_CMD;
for (vl=0;vl< vv->length(); vl++)
{
t1.data=(char *)(long)((*vv)[vl]);
for (wl=0;wl< wv->length(); wl++)
{
t2.data=(char *)(long)((*wv)[wl]);
if (p==NULL)
{
p=res;
}
else
{
p->next=(leftv)omAlloc0Bin(sleftv_bin);
p=p->next;
}
memcpy(u,&ut,sizeof(ut));
if (u->Typ() == MATRIX_CMD)
nok=jjBRACK_Ma(p,u,&t1,&t2);
else if (u->Typ() == BIGINTMAT_CMD)
nok=jjBRACK_Bim(p,u,&t1,&t2);
else /* INTMAT_CMD */
nok=jjBRACK_Im(p,u,&t1,&t2);
if (nok)
{
res->CleanUp();
return TRUE;
}
}
}
return FALSE;
}
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
{
v->next=(leftv)omAllocBin(sleftv_bin);
memcpy(v->next,w,sizeof(sleftv));
w->Init();
return jjPROC(res,u,v);
}
static BOOLEAN jjRING_2(leftv res, leftv u, leftv v, leftv w)
{
u->next=(leftv)omAlloc(sizeof(sleftv));
memcpy(u->next,v,sizeof(sleftv));
v->Init();
u->next->next=(leftv)omAlloc(sizeof(sleftv));
memcpy(u->next->next,w,sizeof(sleftv));
w->Init();
BOOLEAN bo=iiExprArithM(res,u,'[');
u->next=NULL;
return bo;
}
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
{
intvec *iv;
ideal m;
lists l=(lists)omAllocBin(slists_bin);
int k=(int)(long)w->Data();
if (k>=0)
{
sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
l->Init(2);
l->m[0].rtyp=MODUL_CMD;
l->m[1].rtyp=INTVEC_CMD;
l->m[0].data=(void *)m;
l->m[1].data=(void *)iv;
}
else
{
m=sm_CallSolv((ideal)u->Data(), currRing);
l->Init(1);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=(void *)m;
}
res->data = (char *)l;
return FALSE;
}
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
{
if ((w->rtyp!=IDHDL)||(w->e!=NULL))
{
WerrorS("3rd argument must be a name of a matrix");
return TRUE;
}
ideal i=(ideal)u->Data();
int rank=(int)i->rank;
BOOLEAN r=jjCOEFFS_Id(res,u,v);
if (r) return TRUE;
mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
return FALSE;
}
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
{
res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
(ideal)(v->Data()),(poly)(w->Data()));
return FALSE;
}
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
{
if ((w->rtyp!=IDHDL)||(w->e!=NULL))
{
WerrorS("3rd argument must be a name of a matrix");
return TRUE;
}
// CopyD for POLY_CMD and VECTOR_CMD are identical:
poly p=(poly)u->CopyD(POLY_CMD);
ideal i=idInit(1,1);
i->m[0]=p;
sleftv t;
t.Init();
t.data=(char *)i;
t.rtyp=IDEAL_CMD;
int rank=1;
if (u->Typ()==VECTOR_CMD)
{
i->rank=rank=pMaxComp(p);
t.rtyp=MODUL_CMD;
}
BOOLEAN r=jjCOEFFS_Id(res,&t,v);
t.CleanUp();
if (r) return TRUE;
mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
return FALSE;
}
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
{
ideal I=(ideal)u->Data();
GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
res->data=(char *)idElimination(I,(poly)v->Data(),NULL,alg);
//setFlag(res,FLAG_STD);
return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
}
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
{
bigintmat *ww=(bigintmat*)w->Data();
res->data=(char *)idElimination2((ideal)u->Data(),(poly)v->Data(),
ww);
//setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
{
/*4
* look for the substring what in the string where
* starting at position n
* return the position of the first char of what in where
* or 0
*/
int n=(int)(long)w->Data();
char *where=(char *)u->Data();
char *what=(char *)v->Data();
char *found;
if ((1>n)||(n>(int)strlen(where)))
{
Werror("start position %d out of range",n);
return TRUE;
}
found = strchr(where+n-1,*what);
if (*(what+1)!='\0')
{
while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
{
found=strchr(found+1,*what);
}
}
if (found != NULL)
{
res->data=(char *)((found-where)+1);
}
return FALSE;
}
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
{
if ((int)(long)w->Data()==0)
res->data=(char *)walkProc(u,v);
else
res->data=(char *)fractalWalkProc(u,v);
setFlag( res, FLAG_STD );
return FALSE;
}
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
{
intvec *wdegree=(intvec*)w->Data();
if (wdegree->length()!=currRing->N)
{
Werror("weight vector must have size %d, not %d",
currRing->N,wdegree->length());
return TRUE;
}
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of Hilbert series etc. is being\n");
PrintS("// performed for generic fibre, that is, over Q\n");
}
assumeStdFlag(u);
intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
if (errorreported) return TRUE;
switch((int)(long)v->Data())
{
case 1:
res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
return FALSE;
case 2:
res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
return FALSE;
}
WerrorS(feNotImplemented);
return TRUE;
}
static BOOLEAN jjHILBERT3Qt(leftv, leftv u, leftv v, leftv w)
{
if (rField_is_Z(currRing))
{
PrintS("// NOTE: computation of Hilbert series etc. is being\n");
PrintS("// performed for generic fibre, that is, over Q\n");
}
assumeStdFlag(u);
ring Qt =(ring)v->Data();
char *name=(char*)w->Data();
poly h;
if (u->Typ()==IDEAL_CMD)
h=hFirstSeries0p((ideal)u->Data(),currRing->qideal,NULL,currRing,Qt);
else
{
intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
h=hFirstSeries0m((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,Qt);
}
idhdl hh=enterid(name,myynest,POLY_CMD,&(Qt->idroot),FALSE,FALSE);
IDPOLY(hh)=h;
return FALSE;
}
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv /*w*/)
{
PrintS("TODO\n");
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
poly p=pOne(); pSetExp(p,i,1); pSetm(p);
int d=pWTotaldegree(p);
pLmDelete(p);
if (d==1)
res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
else
WerrorS("variable must have weight 1");
return (d!=1);
}
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v,leftv /*w*/)
{
PrintS("TODO\n");
int i=pVar((poly)v->Data());
if (i==0)
{
WerrorS("ringvar expected");
return TRUE;
}
poly p=pOne(); pSetExp(p,i,1); pSetm(p);
int d=pWTotaldegree(p);
pLmDelete(p);
if (d==1)
res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
else
WerrorS("variable must have weight 1");
return (d!=1);
}
static BOOLEAN jjHOMOG_W_M(leftv res, leftv v1, leftv v2, leftv v3)
{
intvec *w=(intvec *)v3->Data();
intvec *vw=(intvec*)v2->Data();
ideal v_id=(ideal)v1->Data();
res->data=(void *)(long)id_HomModuleW(v_id,currRing->qideal,vw,w,currRing);
return FALSE;
}
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v,leftv w)
{
intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
intvec* arg = (intvec*) u->Data();
int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
for (i=0; i<n; i++)
{
(*im)[i] = (*arg)[i];
}
res->data = (char *)im;
return FALSE;
}
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
{
ideal I1=(ideal)u->Data();
ideal I2=(ideal)v->Data();
ideal I3=(ideal)w->Data();
resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
r[0]=I1;
r[1]=I2;
r[2]=I3;
res->data=(char *)idMultSect(r,3);
omFreeSize((ADDRESS)r,3*sizeof(ideal));
return FALSE;
}
static BOOLEAN jjINTERSEC3S(leftv res, leftv u, leftv v, leftv w)
{
ideal I=(ideal)u->Data();
GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
res->data=(char *)idSect(I,(ideal)v->Data(),alg);
if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
{
int *iw=iv2array((intvec *)w->Data(),currRing);
res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(int) );
return FALSE;
}
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
{
if (!pIsUnit((poly)v->Data()))
{
WerrorS("2nd argument must be a unit");
return TRUE;
}
res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
return FALSE;
}
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
{
res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
(intvec *)w->Data(),currRing);
return FALSE;
}
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
{
if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
{
WerrorS("2nd argument must be a diagonal matrix of units");
return TRUE;
}
res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
(matrix)v->CopyD());
return FALSE;
}
static BOOLEAN jjMINOR_M(leftv res, leftv v)
{
/* Here's the use pattern for the minor command:
minor ( matrix_expression m, int_expression minorSize,
optional ideal_expression IasSB, optional int_expression k,
optional string_expression algorithm,
optional int_expression cachedMinors,
optional int_expression cachedMonomials )
This method here assumes that there are at least two arguments.
- If IasSB is present, it must be a std basis. All minors will be
reduced w.r.t. IasSB.
- If k is absent, all non-zero minors will be computed.
If k is present and k > 0, the first k non-zero minors will be
computed.
If k is present and k < 0, the first |k| minors (some of which
may be zero) will be computed.
If k is present and k = 0, an error is reported.
- If algorithm is absent, all the following arguments must be absent too.
In this case, a heuristic picks the best-suited algorithm (among
Bareiss, Laplace, and Laplace with caching).
If algorithm is present, it must be one of "Bareiss", "bareiss",
"Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
"cache" two more arguments may be given, determining how many entries
the cache may have at most, and how many cached monomials there are at
most. (Cached monomials are counted over all cached polynomials.)
If these two additional arguments are not provided, 200 and 100000
will be used as defaults.
*/
matrix m;
leftv u=v->next;
v->next=NULL;
int v_typ=v->Typ();
if (v_typ==MATRIX_CMD)
{
m = (matrix)v->Data();
}
else
{
if (v_typ==0)
{
Werror("`%s` is undefined",v->Fullname());
return TRUE;
}
// try to convert to MATRIX:
int ii=iiTestConvert(v_typ,MATRIX_CMD);
BOOLEAN bo;
sleftv tmp;
if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
else bo=TRUE;
if (bo)
{
Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
return TRUE;
}
m=(matrix)tmp.data;
}
const int mk = (int)(long)u->Data();
bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
bool noCacheMinors = true; bool noCacheMonomials = true;
ideal IasSB; int k=0; char* algorithm; int cacheMinors; int cacheMonomials;
/* here come the different cases of correct argument sets */
if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
{
IasSB = (ideal)u->next->Data();
noIdeal = false;
if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
{
k = (int)(long)u->next->next->Data();
noK = false;
if ((u->next->next->next != NULL) &&
(u->next->next->next->Typ() == STRING_CMD))
{
algorithm = (char*)u->next->next->next->Data();
noAlgorithm = false;
if ((u->next->next->next->next != NULL) &&
(u->next->next->next->next->Typ() == INT_CMD))
{
cacheMinors = (int)(long)u->next->next->next->next->Data();
noCacheMinors = false;
if ((u->next->next->next->next->next != NULL) &&
(u->next->next->next->next->next->Typ() == INT_CMD))
{
cacheMonomials =
(int)(long)u->next->next->next->next->next->Data();
noCacheMonomials = false;
}
}
}
}
}
else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
{
k = (int)(long)u->next->Data();
noK = false;
if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
{
algorithm = (char*)u->next->next->Data();
noAlgorithm = false;
if ((u->next->next->next != NULL) &&
(u->next->next->next->Typ() == INT_CMD))
{
cacheMinors = (int)(long)u->next->next->next->Data();
noCacheMinors = false;
if ((u->next->next->next->next != NULL) &&
(u->next->next->next->next->Typ() == INT_CMD))
{
cacheMonomials = (int)(long)u->next->next->next->next->Data();
noCacheMonomials = false;
}
}
}
}
else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
{
algorithm = (char*)u->next->Data();
noAlgorithm = false;
if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
{
cacheMinors = (int)(long)u->next->next->Data();
noCacheMinors = false;
if ((u->next->next->next != NULL) &&
(u->next->next->next->Typ() == INT_CMD))
{
cacheMonomials = (int)(long)u->next->next->next->Data();
noCacheMonomials = false;
}
}
}
/* upper case conversion for the algorithm if present */
if (!noAlgorithm)
{
if (strcmp(algorithm, "bareiss") == 0)
algorithm = (char*)"Bareiss";
if (strcmp(algorithm, "laplace") == 0)
algorithm = (char*)"Laplace";
if (strcmp(algorithm, "cache") == 0)
algorithm = (char*)"Cache";
}
v->next=u;
/* here come some tests */
if (!noIdeal)
{
assumeStdFlag(u->next);
}
if ((!noK) && (k == 0))
{
WerrorS("Provided number of minors to be computed is zero.");
return TRUE;
}
if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
&& (strcmp(algorithm, "Laplace") != 0)
&& (strcmp(algorithm, "Cache") != 0))
{
WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
return TRUE;
}
if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
&& (!rField_is_Domain(currRing)))
{
Werror("Bareiss algorithm not defined over coefficient rings %s",
"with zero divisors.");
return TRUE;
}
if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
{
ideal I=idInit(1,1);
if (mk<1) I->m[0]=p_One(currRing);
//Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
// m->rows(), m->cols());
res->data=(void*)I;
return FALSE;
}
if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
&& (noCacheMinors || noCacheMonomials))
{
cacheMinors = 200;
cacheMonomials = 100000;
}
/* here come the actual procedure calls */
if (noAlgorithm)
res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
(noIdeal ? 0 : IasSB), false);
else if (strcmp(algorithm, "Cache") == 0)
res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
(noIdeal ? 0 : IasSB), 3, cacheMinors,
cacheMonomials, false);
else
res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
(noIdeal ? 0 : IasSB), false);
if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
return FALSE;
}
static BOOLEAN jjMRES_MAP(leftv res, leftv u, leftv v, leftv ma)
{
if ((ma->rtyp!=IDHDL)||(ma->e!=NULL))
{
WerrorS("3rd argument must have a name");
return TRUE;
}
int maxl=(int)(long)v->Data();
if (maxl<0)
{
WerrorS("length for res must not be negative");
return TRUE;
}
syStrategy r;
intvec *weights=NULL;
int wmaxl=maxl;
ideal u_id=(ideal)u->Data();
maxl--;
if (/*(*/ maxl==-1 /*)*/)
{
maxl = currRing->N-1+2;
if (currRing->qideal!=NULL)
{
Warn(
"full resolution in a qring may be infinite, setting max length to %d",
maxl+1);
}
}
weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
if (weights!=NULL)
{
if (!idTestHomModule(u_id,currRing->qideal,weights))
{
WarnS("wrong weights given:");weights->show();PrintLn();
weights=NULL;
}
}
intvec *ww=NULL;
int add_row_shift=0;
if (weights!=NULL)
{
ww=ivCopy(weights);
add_row_shift = ww->min_in();
(*ww) -= add_row_shift;
}
unsigned save_opt=si_opt_1;
si_opt_1 |= Sy_bit(OPT_REDTAIL_SYZ);
u_id=(ideal)u->CopyD();
ideal mat;
r=syMres_with_map(u_id,maxl,ww,mat);
idhdl h=(idhdl)ma->data;
idDelete(&IDIDEAL(h));
IDIDEAL(h)=mat;
if (r->list_length>wmaxl)
{
for(int i=wmaxl-1;i>=r->list_length;i--)
{
if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
}
}
r->list_length=wmaxl;
res->data=(void *)r;
if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
if ((r->weights!=NULL) && (r->weights[0]!=NULL))
{
ww=ivCopy(r->weights[0]);
if (weights!=NULL) (*ww) += add_row_shift;
atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
}
else
{
if (weights!=NULL)
{
atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
}
}
assume( (r->syRing != NULL) == (r->resPairs != NULL) );
assume( (r->minres != NULL) || (r->fullres != NULL) );
si_opt_1=save_opt;
return FALSE;
}
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
{
// u: the name of the new type
// v: the parent type
// w: the elements
newstruct_desc d=newstructChildFromString((const char *)v->Data(),
(const char *)w->Data());
if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
return (d==NULL);
}
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
{
// handles preimage(r,phi,i) and kernel(r,phi)
idhdl h;
ring rr;
map mapping;
BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
{
WerrorS("2nd/3rd arguments must have names");
return TRUE;
}
rr=(ring)u->Data();
const char *ring_name=u->Name();
if ((h=rr->idroot->get(v->name,myynest))!=NULL)
{
if (h->typ==MAP_CMD)
{
mapping=IDMAP(h);
idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
if ((preim_ring==NULL)
|| (IDRING(preim_ring)!=currRing))
{
Werror("preimage ring `%s` is not the basering",mapping->preimage);
return TRUE;
}
}
else if (h->typ==IDEAL_CMD)
{
mapping=IDMAP(h);
}
else
{
Werror("`%s` is no map nor ideal",IDID(h));
return TRUE;
}
}
else
{
Werror("`%s` is not defined in `%s`",v->name,ring_name);
return TRUE;
}
ideal image;
if (kernel_cmd) image=idInit(1,1);
else
{
if ((h=rr->idroot->get(w->name,myynest))!=NULL)
{
if (h->typ==IDEAL_CMD)
{
image=IDIDEAL(h);
}
else
{
Werror("`%s` is no ideal",IDID(h));
return TRUE;
}
}
else
{
Werror("`%s` is not defined in `%s`",w->name,ring_name);
return TRUE;
}
}
if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
|| ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
{
WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
}
res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
if (kernel_cmd) idDelete(&image);
return (res->data==NULL/* is of type ideal, should not be NULL*/);
}
#ifdef HTABLE
static BOOLEAN jjTABLE_ADD(leftv res, leftv u, leftv v, leftv w)
{
stablerec* lt=(stablerec*)u->Data();
char *key=(char*)v->CopyD();
t_addTable(lt,key,w);
return FALSE;
}
#endif
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
{
int di, k;
int i=(int)(long)u->Data();
int r=(int)(long)v->Data();
int c=(int)(long)w->Data();
if ((r<=0) || (c<=0)) return TRUE;
intvec *iv = new intvec(r, c, 0);
if (iv->rows()==0)
{
delete iv;
return TRUE;
}
if (i!=0)
{
if (i<0) i = -i;
di = 2 * i + 1;
for (k=0; k<iv->length(); k++)
{
(*iv)[k] = ((siRand() % di) - i);
}
}
res->data = (char *)iv;
return FALSE;
}
#ifdef SINGULAR_4_2
static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
// <coeff>, par1, par2 -> number2
{
coeffs cf=(coeffs)u->Data();
if ((cf==NULL) ||(cf->cfRandom==NULL))
{
Werror("no random function defined for coeff %d",cf->type);
return TRUE;
}
else
{
number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
number2 nn=(number2)omAlloc(sizeof(*nn));
nn->cf=cf;
nn->n=n;
res->data=nn;
return FALSE;
}
return TRUE;
}
#endif
static BOOLEAN jjSUBST_Test(leftv v,leftv w,
int &ringvar, poly &monomexpr)
{
monomexpr=(poly)w->Data();
poly p=(poly)v->Data();
#if 0
if (pLength(monomexpr)>1)
{
Werror("`%s` substitutes a ringvar only by a term",
Tok2Cmdname(SUBST_CMD));
return TRUE;
}
#endif
if ((ringvar=pVar(p))==0)
{
if ((p!=NULL) && (currRing->cf->extRing!=NULL))
{
number n = pGetCoeff(p);
ringvar= -n_IsParam(n, currRing);
}
if(ringvar==0)
{
WerrorS("ringvar/par expected");
return TRUE;
}
}
return FALSE;
}
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v,leftv w)
{
// generic conversion from polyBucket to poly:
// force this to be the first try everytime
poly p; int l;
sBucket_pt bu=(sBucket_pt)w->CopyD();
sBucketDestroyAdd(bu,&p,&l);
sleftv tmpw;
tmpw.Init();
tmpw.rtyp=POLY_CMD;
tmpw.data=p;
return iiExprArith3(res, iiOp, u, v, &tmpw);
}
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v,leftv w)
{
int ringvar;
poly monomexpr;
BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
if (nok) return TRUE;
poly p=(poly)u->Data();
if (ringvar>0)
{
int mm=p_MaxExpPerVar(p,ringvar,currRing);
if (!rIsLPRing(currRing) &&
(monomexpr!=NULL) && (p!=NULL) && (mm!=0) &&
((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)mm/2)))
{
Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), mm);
//return TRUE;
}
if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
else
res->data= pSubstPoly(p,ringvar,monomexpr);
}
else
{
if (rIsLPRing(currRing))
{
WerrorS("Substituting parameters not implemented for Letterplace rings.");
return TRUE;
}
res->data=pSubstPar(p,-ringvar,monomexpr);
}
return FALSE;
}
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v,leftv w)
{
int ringvar;
poly monomexpr;
BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
if (nok) return TRUE;
ideal id=(ideal)u->Data();
if (ringvar>0)
{
BOOLEAN overflow=FALSE;
if (!rIsLPRing(currRing) && (monomexpr!=NULL))
{
long deg_monexp=pTotaldegree(monomexpr);
for(int i=IDELEMS(id)-1;i>=0;i--)
{
poly p=id->m[i];
int mm=p_MaxExpPerVar(p,ringvar,currRing);
if ((p!=NULL) && (mm!=0) &&
((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)mm/2)))
{
overflow=TRUE;
break;
}
}
}
if (overflow)
Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
{
if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
else id=id_Copy(id,currRing);
res->data = id_Subst(id, ringvar, monomexpr, currRing);
}
else
res->data = idSubstPoly(id,ringvar,monomexpr);
}
else
{
if (rIsLPRing(currRing))
{
WerrorS("Substituting parameters not implemented for Letterplace rings.");
return TRUE;
}
res->data = idSubstPar(id,-ringvar,monomexpr);
}
return FALSE;
}
// we do not want to have jjSUBST_Id_X inlined:
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w,
int input_type);
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v,leftv w)
{
return jjSUBST_Id_X(res,u,v,w,INT_CMD);
}
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v,leftv w)
{
return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
}
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
{
sleftv tmp;
tmp.Init();
// do not check the result, conversion from int/number to poly works always
iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
tmp.CleanUp();
return b;
}
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v,leftv w)
{
int mi=(int)(long)v->Data();
int ni=(int)(long)w->Data();
if ((mi<1)||(ni<1))
{
Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
return TRUE;
}
matrix m=mpNew(mi,ni);
ideal I=(ideal)u->CopyD(IDEAL_CMD);
int i=si_min(IDELEMS(I),mi*ni);
//for(i=i-1;i>=0;i--)
//{
// m->m[i]=I->m[i];
// I->m[i]=NULL;
//}
memcpy(m->m,I->m,i*sizeof(poly));
memset(I->m,0,i*sizeof(poly));
id_Delete(&I,currRing);
res->data = (char *)m;
return FALSE;
}
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v,leftv w)
{
int mi=(int)(long)v->Data();
int ni=(int)(long)w->Data();
if ((mi<0)||(ni<1))
{
Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
return TRUE;
}
res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
mi,ni,currRing);
return FALSE;
}
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v,leftv w)
{
int mi=(int)(long)v->Data();
int ni=(int)(long)w->Data();
if ((mi<1)||(ni<1))
{
Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
return TRUE;
}
matrix m=mpNew(mi,ni);
matrix I=(matrix)u->CopyD(MATRIX_CMD);
int r=si_min(MATROWS(I),mi);
int c=si_min(MATCOLS(I),ni);
int i,j;
for(i=r;i>0;i--)
{
for(j=c;j>0;j--)
{
MATELEM(m,i,j)=MATELEM(I,i,j);
MATELEM(I,i,j)=NULL;
}
}
id_Delete((ideal *)&I,currRing);
res->data = (char *)m;
return FALSE;
}
static BOOLEAN jjMODULO3(leftv res, leftv u, leftv v, leftv w)
{
if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w_u!=NULL)
{
w_u=ivCopy(w_u);
hom=isHomog;
}
intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
if (w_v!=NULL)
{
w_v=ivCopy(w_v);
hom=isHomog;
}
if ((w_u!=NULL) && (w_v==NULL))
w_v=ivCopy(w_u);
if ((w_v!=NULL) && (w_u==NULL))
w_u=ivCopy(w_v);
ideal u_id=(ideal)u->Data();
ideal v_id=(ideal)v->Data();
if (w_u!=NULL)
{
if ((*w_u).compare((w_v))!=0)
{
WarnS("incompatible weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
else
{
if ((!idTestHomModule(u_id,currRing->qideal,w_v))
|| (!idTestHomModule(v_id,currRing->qideal,w_v)))
{
WarnS("wrong weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
}
}
idhdl h=(idhdl)w->data;
res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix));
if (w_u!=NULL)
{
atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
}
delete w_v;
//if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
{
if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w_u!=NULL)
{
w_u=ivCopy(w_u);
hom=isHomog;
}
intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
if (w_v!=NULL)
{
w_v=ivCopy(w_v);
hom=isHomog;
}
if ((w_u!=NULL) && (w_v==NULL))
w_v=ivCopy(w_u);
if ((w_v!=NULL) && (w_u==NULL))
w_u=ivCopy(w_v);
ideal u_id=(ideal)u->Data();
GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,u_id);
ideal v_id=(ideal)v->Data();
if (w_u!=NULL)
{
if ((*w_u).compare((w_v))!=0)
{
WarnS("incompatible weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
else
{
if ((!idTestHomModule(u_id,currRing->qideal,w_v))
|| (!idTestHomModule(v_id,currRing->qideal,w_v)))
{
WarnS("wrong weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
}
}
res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, NULL,alg);
if (w_u!=NULL)
{
atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
}
delete w_v;
//if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v,leftv w)
{
int mi=(int)(long)v->Data();
int ni=(int)(long)w->Data();
if ((mi<0)||(ni<1))
{
Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
return TRUE;
}
res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
mi,ni,currRing);
return FALSE;
}
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
{
if (w->rtyp!=IDHDL) return TRUE;
int ul= IDELEMS((ideal)u->Data());
int vl= IDELEMS((ideal)v->Data());
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < ul)
{
Werror("At least %d ncgen variables are needed for this computation.", ul);
return TRUE;
}
}
#endif
ideal m
= idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
if (m==NULL) return TRUE;
res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
return FALSE;
}
static BOOLEAN jjLIFTSTD_SYZ(leftv res, leftv u, leftv v, leftv w)
{
if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
idhdl hv=(idhdl)v->data;
idhdl hw=(idhdl)w->data;
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
{
Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
return TRUE;
}
}
#endif
// CopyD for IDEAL_CMD and MODUL_CMD are identical:
res->data = (char *)idLiftStd((ideal)u->Data(),
&(hv->data.umatrix),testHomog,
&(hw->data.uideal));
setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
return FALSE;
}
static BOOLEAN jjLIFTSTD_ALG(leftv res, leftv u, leftv v, leftv w)
{
if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
idhdl hv=(idhdl)v->data;
GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,(ideal)u->Data());
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
{
Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
return TRUE;
}
}
#endif
// CopyD for IDEAL_CMD and MODUL_CMD are identical:
res->data = (char *)idLiftStd((ideal)u->Data(),
&(hv->data.umatrix),testHomog,
NULL,alg);
setFlag(res,FLAG_STD); v->flag=0;
return FALSE;
}
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
{
assumeStdFlag(v);
if (!idIsZeroDim((ideal)v->Data()))
{
Werror("`%s` must be 0-dimensional",v->Name());
return TRUE;
}
res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
(poly)w->CopyD());
return FALSE;
}
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
{
assumeStdFlag(v);
if (!idIsZeroDim((ideal)v->Data()))
{
Werror("`%s` must be 0-dimensional",v->Name());
return TRUE;
}
res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
(matrix)w->CopyD());
return FALSE;
}
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
{
assumeStdFlag(v);
res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
0,(int)(long)w->Data());
return FALSE;
}
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
{
assumeStdFlag(v);
res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
0,(int)(long)w->Data());
return FALSE;
}
#ifdef OLD_RES
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
{
int maxl=(int)v->Data();
ideal u_id=(ideal)u->Data();
int l=0;
resolvente r;
intvec **weights=NULL;
int wmaxl=maxl;
maxl--;
unsigned save_opt=si_opt_1;
si_opt_1 |= Sy_bit(OPT_REDTAIL_SYZ);
if ((maxl==-1) && (iiOp!=MRES_CMD))
maxl = currRing->N-1;
if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
{
intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
if (iv!=NULL)
{
l=1;
if (!idTestHomModule(u_id,currRing->qideal,iv))
{
WarnS("wrong weights");
iv=NULL;
}
else
{
weights = (intvec**)omAlloc0Bin(char_ptr_bin);
weights[0] = ivCopy(iv);
}
}
r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
}
else
r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
if (r==NULL) return TRUE;
int t3=u->Typ();
iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
si_opt_1=save_opt;
return FALSE;
}
#endif
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
{
res->data=(void *)rInit(u,v,w);
return (res->data==NULL);
}
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
{
int yes;
jjSTATUS2(res, u, v);
yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
omFreeBinAddr((ADDRESS) res->data);
res->data = (void *)(long)yes;
return FALSE;
}
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
{
intvec *vw=(intvec *)w->Data(); // weights of vars
if (vw->length()!=currRing->N)
{
Werror("%d weights for %d variables",vw->length(),currRing->N);
return TRUE;
}
ideal result;
intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
ideal u_id=(ideal)(u->Data());
if (ww!=NULL)
{
if (!idTestHomModule(u_id,currRing->qideal,ww))
{
WarnS("wrong weights");
ww=NULL;
}
else
{
ww=ivCopy(ww);
hom=isHomog;
}
}
bigintmat *vv=(bigintmat*)v->Data();
result=kStd2(u_id,
currRing->qideal,
hom,
&ww, // module weights
vv, // hilbert series
0,0, // syzComp, newIdeal
vw); // weights of vars
if (errorreported) return TRUE;
idSkipZeroes(result);
res->data = (char *)result;
setFlag(res,FLAG_STD);
if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
return FALSE;
}
/*=================== operations with many arg.: static proc =================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN jjBREAK0(leftv, leftv)
{
#ifdef HAVE_SDB
sdb_show_bp();
#endif
return FALSE;
}
static BOOLEAN jjBREAK1(leftv, leftv v)
{
#ifdef HAVE_SDB
if(v->Typ()==PROC_CMD)
{
int lineno=0;
if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
{
lineno=(int)(long)v->next->Data();
}
return sdb_set_breakpoint(v->Name(),lineno);
}
return TRUE;
#else
return FALSE;
#endif
}
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
{
return iiExprArith1(res,v,iiOp);
}
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
{
leftv v=u->next;
u->next=NULL;
BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
u->next=v;
return b;
}
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
{
leftv v = u->next;
leftv w = v->next;
u->next = NULL;
v->next = NULL;
BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
u->next = v;
v->next = w;
return b;
}
static BOOLEAN jjCOEF_M(leftv, leftv v)
{
const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
if (iiCheckTypes(v,t,1))
{
idhdl c=(idhdl)v->next->next->data;
if (v->next->next->next->rtyp!=IDHDL) return TRUE;
idhdl m=(idhdl)v->next->next->next->data;
idDelete((ideal *)&(c->data.uideal));
idDelete((ideal *)&(m->data.uideal));
mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
(matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
return FALSE;
}
return TRUE;
}
static BOOLEAN jjDIVISION4(leftv res, leftv v)
{ // may have 3 or 4 arguments
leftv v1=v;
leftv v2=v1->next;
leftv v3=v2->next;
leftv v4=v3->next;
assumeStdFlag(v2);
int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
if((i1==0)||(i2==0)
||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
{
WarnS("<module>,<module>,<int>[,<intvec>] expected!");
return TRUE;
}
sleftv w1,w2;
iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
ideal P=(ideal)w1.Data();
ideal Q=(ideal)w2.Data();
int n=(int)(long)v3->Data();
int *w=NULL;
if(v4!=NULL)
{
w = iv2array((intvec *)v4->Data(),currRing);
int * w0 = w + 1;
int i = currRing->N;
while( (i > 0) && ((*w0) > 0) )
{
w0++;
i--;
}
if(i>0)
WarnS("not all weights are positive!");
}
matrix T;
ideal R;
idLiftW(P,Q,n,T,R,w);
w1.CleanUp();
w2.CleanUp();
if(w!=NULL)
omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(int) );
lists L=(lists) omAllocBin(slists_bin);
L->Init(2);
L->m[1].rtyp=v1->Typ();
if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
{
if(v1->Typ()==POLY_CMD)
p_Shift(&R->m[0],-1,currRing);
L->m[1].data=(void *)R->m[0];
R->m[0]=NULL;
idDelete(&R);
}
else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
L->m[1].data=(void *)id_Module2Matrix(R,currRing);
else
{
L->m[1].rtyp=MODUL_CMD;
L->m[1].data=(void *)R;
}
L->m[0].rtyp=MATRIX_CMD;
L->m[0].data=(char *)T;
res->data=L;
return FALSE;
}
//BOOLEAN jjDISPATCH(leftv res, leftv v)
//{
// WerrorS("`dispatch`: not implemented");
// return TRUE;
//}
//static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
//{
// int l=u->listLength();
// if (l<2) return TRUE;
// BOOLEAN b;
// leftv v=u->next;
// leftv zz=v;
// leftv z=zz;
// u->next=NULL;
// do
// {
// leftv z=z->next;
// b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
// if (b) break;
// } while (z!=NULL);
// u->next=zz;
// return b;
//}
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
{
leftv h=v;
int s=exprlist_length(h);
ideal id=idInit(s,1);
int rank=1;
int i=0;
poly p;
int dest_type=POLY_CMD;
if (iiOp==MODUL_CMD) dest_type=VECTOR_CMD;
while (h!=NULL)
{
// use standard type conversions to poly/vector
int ri;
int ht=h->Typ();
if (ht==dest_type)
{
p=(poly)h->CopyD();
if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
}
else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
{
sleftv tmp;
leftv hnext=h->next;
h->next=NULL;
iiConvert(ht,dest_type,ri,h,&tmp,dConvertTypes);
h->next=hnext;
p=(poly)tmp.data;
if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
}
else
{
idDelete(&id);
return TRUE;
}
id->m[i]=p;
i++;
h=h->next;
}
id->rank=rank;
res->data=(char *)id;
return FALSE;
}
static BOOLEAN jjFETCH_M(leftv res, leftv u)
{
ring r=(ring)u->Data();
leftv v=u->next;
leftv perm_var_l=v->next;
leftv perm_par_l=v->next->next;
if ((perm_var_l->Typ()!=INTVEC_CMD)
||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
||(u->Typ()!=RING_CMD))
{
WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
return TRUE;
}
intvec *perm_var_v=(intvec*)perm_var_l->Data();
intvec *perm_par_v=NULL;
if (perm_par_l!=NULL)
perm_par_v=(intvec*)perm_par_l->Data();
idhdl w;
nMapFunc nMap;
if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
{
int *perm=NULL;
int *par_perm=NULL;
int par_perm_size=0;
BOOLEAN bo;
if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
{
// Allow imap/fetch to be make an exception only for:
if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
|| (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
{
par_perm_size=rPar(r);
}
else
{
goto err_fetch;
}
}
else
par_perm_size=rPar(r);
perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
if (par_perm_size!=0)
par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
int i;
if (perm_par_l==NULL)
{
if (par_perm_size!=0)
for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
}
else
{
if (par_perm_size==0) WarnS("source ring has no parameters");
else
{
for(i=rPar(r)-1;i>=0;i--)
{
if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
if ((par_perm[i]<-rPar(currRing))
|| (par_perm[i]>rVar(currRing)))
{
Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
par_perm[i]=0;
}
}
}
}
for(i=rVar(r)-1;i>=0;i--)
{
if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
if ((perm[i]<-rPar(currRing))
|| (perm[i]>rVar(currRing)))
{
Warn("invalid entry for var %d: %d\n",i,perm[i]);
perm[i]=0;
}
}
if (BVERBOSE(V_IMAP))
{
for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
{
if (perm[i]>0)
Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
else if (perm[i]<0)
Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
}
for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
{
if (par_perm[i-1]<0)
Print("// par nr %d: %s -> par %s\n",
i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
else if (par_perm[i-1]>0)
Print("// par nr %d: %s -> var %s\n",
i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
}
}
if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
sleftv tmpW;
tmpW.Init();
tmpW.rtyp=IDTYP(w);
tmpW.data=IDDATA(w);
if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
perm,par_perm,par_perm_size,nMap)))
{
Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
}
if (perm!=NULL)
omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
if (par_perm!=NULL)
omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
return bo;
}
else
{
Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
}
return TRUE;
err_fetch:
char *s1=nCoeffString(r->cf);
char *s2=nCoeffString(currRing->cf);
Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
omFreeBinAddr(s2);omFreeBinAddr(s1);
return TRUE;
}
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
{
leftv h=v;
int l=v->listLength();
resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
int t=0;
// try to convert to IDEAL_CMD
while (h!=NULL)
{
if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
{
t=IDEAL_CMD;
}
else break;
h=h->next;
}
// if failure, try MODUL_CMD
if (t==0)
{
h=v;
while (h!=NULL)
{
if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
{
t=MODUL_CMD;
}
else break;
h=h->next;
}
}
// check for success in converting
if (t==0)
{
WerrorS("cannot convert to ideal or module");
return TRUE;
}
// call idMultSect
h=v;
int i=0;
sleftv tmp;
while (h!=NULL)
{
if (h->Typ()==t)
{
r[i]=(ideal)h->Data(); /*no copy*/
h=h->next;
}
else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
{
omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
omFreeSize((ADDRESS)r,l*sizeof(ideal));
Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
return TRUE;
}
else
{
r[i]=(ideal)tmp.Data(); /*now it's a copy*/
copied[i]=TRUE;
h=tmp.next;
}
i++;
}
res->rtyp=t;
res->data=(char *)idMultSect(r,i);
while(i>0)
{
i--;
if (copied[i]) idDelete(&(r[i]));
}
omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
omFreeSize((ADDRESS)r,l*sizeof(ideal));
return FALSE;
}
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
{
/* computation of the inverse of a quadratic matrix A
using the L-U-decomposition of A;
There are two valid parametrisations:
1) exactly one argument which is just the matrix A,
2) exactly three arguments P, L, U which already
realise the L-U-decomposition of A, that is,
P * A = L * U, and P, L, and U satisfy the
properties decribed in method 'jjLU_DECOMP';
see there;
If A is invertible, the list [1, A^(-1)] is returned,
otherwise the list [0] is returned. Thus, the user may
inspect the first entry of the returned list to see
whether A is invertible. */
matrix iMat; int invertible;
const short t1[]={1,MATRIX_CMD};
const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
if (iiCheckTypes(v,t1))
{
matrix aMat = (matrix)v->Data();
int rr = aMat->rows();
int cc = aMat->cols();
if (rr != cc)
{
Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
return TRUE;
}
if (!idIsConstant((ideal)aMat))
{
WerrorS("matrix must be constant");
return TRUE;
}
invertible = luInverse(aMat, iMat);
}
else if (iiCheckTypes(v,t2))
{
matrix pMat = (matrix)v->Data();
matrix lMat = (matrix)v->next->Data();
matrix uMat = (matrix)v->next->next->Data();
int rr = uMat->rows();
int cc = uMat->cols();
if (rr != cc)
{
Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
rr, cc);
return TRUE;
}
if (!idIsConstant((ideal)pMat)
|| (!idIsConstant((ideal)lMat))
|| (!idIsConstant((ideal)uMat))
)
{
WerrorS("matricesx must be constant");
return TRUE;
}
invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
}
else
{
Werror("expected either one or three matrices");
return TRUE;
}
/* build the return structure; a list with either one or two entries */
lists ll = (lists)omAllocBin(slists_bin);
if (invertible)
{
ll->Init(2);
ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
}
else
{
ll->Init(1);
ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
}
res->data=(char*)ll;
return FALSE;
}
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
{
/* for solving a linear equation system A * x = b, via the
given LU-decomposition of the matrix A;
There is one valid parametrisation:
1) exactly four arguments P, L, U, b;
P, L, and U realise the L-U-decomposition of A, that is,
P * A = L * U, and P, L, and U satisfy the
properties decribed in method 'jjLU_DECOMP';
see there;
b is the right-hand side vector of the equation system;
The method will return a list of either 1 entry or three entries:
1) [0] if there is no solution to the system;
2) [1, x, H] if there is at least one solution;
x is any solution of the given linear system,
H is the matrix with column vectors spanning the homogeneous
solution space.
The method produces an error if matrix and vector sizes do not fit. */
const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
if (!iiCheckTypes(v,t))
{
WerrorS("expected exactly three matrices and one vector as input");
return TRUE;
}
matrix pMat = (matrix)v->Data();
matrix lMat = (matrix)v->next->Data();
matrix uMat = (matrix)v->next->next->Data();
matrix bVec = (matrix)v->next->next->next->Data();
matrix xVec; int solvable; matrix homogSolSpace;
if (pMat->rows() != pMat->cols())
{
Werror("first matrix (%d x %d) is not quadratic",
pMat->rows(), pMat->cols());
return TRUE;
}
if (lMat->rows() != lMat->cols())
{
Werror("second matrix (%d x %d) is not quadratic",
lMat->rows(), lMat->cols());
return TRUE;
}
if (lMat->rows() != uMat->rows())
{
Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
return TRUE;
}
if (uMat->rows() != bVec->rows())
{
Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
uMat->rows(), uMat->cols(), bVec->rows());
return TRUE;
}
if (!idIsConstant((ideal)pMat)
||(!idIsConstant((ideal)lMat))
||(!idIsConstant((ideal)uMat))
)
{
WerrorS("matrices must be constant");
return TRUE;
}
solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
/* build the return structure; a list with either one or three entries */
lists ll = (lists)omAllocBin(slists_bin);
if (solvable)
{
ll->Init(3);
ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
}
else
{
ll->Init(1);
ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
}
res->data=(char*)ll;
return FALSE;
}
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
{
leftv h=v;
int i=exprlist_length(h);
intvec *iv=new intvec(i);
i=0;
while (h!=NULL)
{
if(h->Typ()==INT_CMD)
{
(*iv)[i]=(int)(long)h->Data();
}
else if (h->Typ()==INTVEC_CMD)
{
intvec *ivv=(intvec*)h->Data();
for(int j=0;j<ivv->length();j++,i++)
{
(*iv)[i]=(*ivv)[j];
}
i--;
}
else
{
delete iv;
return TRUE;
}
i++;
h=h->next;
}
res->data=(char *)iv;
return FALSE;
}
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
{
leftv h=v;
int l=0;
while (h!=NULL)
{
if(h->Typ()==INT_CMD) l++;
else if (h->Typ()==BIGINT_CMD) l++;
else if (h->Typ()==INTVEC_CMD)
{
intvec *ivv=(intvec*)h->Data();
l+=ivv->rows();
}
else if (h->Typ()==BIGINTVEC_CMD)
{
bigintmat *ivv=(bigintmat *)h->Data();
l+=ivv->rows();
}
else return TRUE;
h=h->next;
}
bigintmat *bim=new bigintmat(1,l,coeffs_BIGINT);
h=v;
int i=0;
while (h!=NULL)
{
if(h->Typ()==INT_CMD)
{
number tp = n_Init((long)(h->Data()), coeffs_BIGINT);
bim->set(i++, tp);
n_Delete(&tp, coeffs_BIGINT);
}
else if (h->Typ()==INTVEC_CMD)
{
intvec *ivv=(intvec*)h->Data();
for(int j=0;j<ivv->length();j++)
{
number tp = n_Init((long)(*ivv)[j], coeffs_BIGINT);
bim->set(i++, tp);
n_Delete(&tp, coeffs_BIGINT);
}
}
else if(h->Typ()==BIGINT_CMD)
{
number tp = (number)h->Data();
bim->set(i++, tp);
}
else if(h->Typ()==BIGINTVEC_CMD)
{
bigintmat *b=(bigintmat*)h->Data();
for(int j=0;j<b->cols();j++)
{
number tp=BIMATELEM((*b),1,j);
bim->set(i++, tp);
}
}
h=h->next;
}
res->data=(char *)bim;
return FALSE;
}
static BOOLEAN jjJET4(leftv res, leftv u)
{
const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
leftv u1=u;
leftv u2=u1->next;
leftv u3=u2->next;
leftv u4=u3->next;
if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
{
if(!pIsUnit((poly)u2->Data()))
{
WerrorS("2nd argument must be a unit");
return TRUE;
}
res->rtyp=u1->Typ();
res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
pCopy((poly)u2->Data()),(intvec*)u4->Data());
return FALSE;
}
else
if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
{
if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
{
WerrorS("2nd argument must be a diagonal matrix of units");
return TRUE;
}
res->rtyp=u1->Typ();
res->data=(char*)idSeries(
(int)(long)u3->Data(),
idCopy((ideal)u1->Data()),
mp_Copy((matrix)u2->Data(), currRing),
(intvec*)u4->Data()
);
return FALSE;
}
else
{
Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
Tok2Cmdname(iiOp));
return TRUE;
}
}
#if 0
static BOOLEAN jjBRACKET_PL(leftv res, leftv u)
{
int ut=u->Typ();
leftv v=u->next; u->next=NULL;
leftv w=v->next; v->next=NULL;
if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
{
BOOLEAN bo=TRUE;
if (w==NULL)
{
bo=iiExprArith2(res,u,'[',v);
}
else if (w->next==NULL)
{
bo=iiExprArith3(res,'[',u,v,w);
}
v->next=w;
u->next=v;
return bo;
}
v->next=w;
u->next=v;
#ifdef SINGULAR_4_1
// construct new rings:
while (u!=NULL)
{
Print("name: %s,\n",u->Name());
u=u->next;
}
#else
res->Init();
res->rtyp=NONE;
return TRUE;
#endif
}
#endif
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
{
if ((yyInRingConstruction)
&& ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
{
memcpy(res,u,sizeof(sleftv));
u->Init();
return FALSE;
}
leftv v=u->next;
BOOLEAN b;
if(v==NULL) // p()
b=iiExprArith1(res,u,iiOp);
else if ((v->next==NULL) // p(1)
|| (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
{
u->next=NULL;
b=iiExprArith2(res,u,iiOp,v);
u->next=v;
}
else // p(1,2), p undefined
{
if (v->Typ()!=INT_CMD)
{
Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
return TRUE;
}
int l=u->listLength();
size_t len=strlen(u->name) + 12*l;
char * nn = (char *)omAlloc(len);
snprintf(nn,len,"%s(%d",u->name,(int)(long)v->Data());
char *s=nn;
do
{
while (*s!='\0') s++;
v=v->next;
if (v->Typ()!=INT_CMD)
{
Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
omFree((ADDRESS)nn);
return TRUE;
}
snprintf(s,len-(nn-s),",%d",(int)(long)v->Data());
} while (v->next!=NULL);
while (*s!='\0') s++;
nn=strcat(nn,")");
char *n=omStrDup(nn);
omFree((ADDRESS)nn);
syMake(res,n);
b=FALSE;
}
return b;
}
static BOOLEAN jjLIFT_4(leftv res, leftv U)
{
const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
leftv u=U;
leftv v=u->next;
leftv w=v->next;
leftv u4=w->next;
if (w->rtyp!=IDHDL) return TRUE;
if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
{
// see jjLIFT3
ideal I=(ideal)u->Data();
int ul= IDELEMS(I /*(ideal)u->Data()*/);
int vl= IDELEMS((ideal)v->Data());
GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
ideal m
= idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
if (m==NULL) return TRUE;
res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
return FALSE;
}
else
{
Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
"or (`module`,`module`,`matrix`,`string`) expected",
Tok2Cmdname(iiOp));
return TRUE;
}
}
static BOOLEAN jjLIFTSTD_M(leftv res, leftv U)
{
// we have 4 or 5 arguments
leftv u=U;
leftv v=u->next;
leftv u3=v->next;
leftv u4=u3->next;
leftv u5=u4->next; // might be NULL
ideal *syz=NULL;
GbVariant alg=GbDefault;
ideal h11=NULL;
if(u5==NULL)
{
// test all three possibilities for 4 arguments
const short t1[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
const short t2[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
const short t3[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,IDEAL_CMD};
const short t4[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,MODUL_CMD};
const short t5[]={4,IDEAL_CMD,MATRIX_CMD,STRING_CMD,IDEAL_CMD};
const short t6[]={4,MODUL_CMD,MATRIX_CMD,STRING_CMD,MODUL_CMD};
if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
{
if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
idhdl hw=(idhdl)u3->data;
syz=&(hw->data.uideal);
alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
}
else if(iiCheckTypes(U,t3)||iiCheckTypes(U,t4))
{
if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
idhdl hw=(idhdl)u3->data;
syz=&(hw->data.uideal);
h11=(ideal)u4->Data();
}
else if(iiCheckTypes(U,t5)||iiCheckTypes(U,t6))
{
alg=syGetAlgorithm((char*)u3->Data(),currRing,(ideal)u->Data());
h11=(ideal)u4->Data();
}
else
{
Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
return TRUE;
}
}
else
{
// we have 5 arguments
const short t1[]={5,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,IDEAL_CMD};
const short t2[]={5,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,MODUL_CMD};
if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
{
idhdl hw=(idhdl)u3->data;
syz=&(hw->data.uideal);
alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
h11=(ideal)u5->Data();
}
else
{
Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
return TRUE;
}
}
#ifdef HAVE_SHIFTBBA
if (rIsLPRing(currRing))
{
if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
{
Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
return TRUE;
}
}
#endif
if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
idhdl hv=(idhdl)v->data;
// CopyD for IDEAL_CMD and MODUL_CMD are identical:
res->rtyp = u->Typ();
res->data = (char *)idLiftStd((ideal)u->Data(),
&(hv->data.umatrix),testHomog,
syz,alg,h11);
setFlag(res,FLAG_STD); v->flag=0;
if(syz!=NULL)
u3->flag=0;
return FALSE;
}
BOOLEAN jjLIST_PL(leftv res, leftv v)
{
int sl=0;
if (v!=NULL) sl = v->listLength();
lists L;
if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
{
int add_row_shift = 0;
intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
if (weights!=NULL) add_row_shift=weights->min_in();
L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
}
else
{
L=(lists)omAllocBin(slists_bin);
leftv h=NULL;
int i;
int rt;
L->Init(sl);
for (i=0;i<sl;i++)
{
if (h!=NULL)
{ /* e.g. not in the first step:
* h is the pointer to the old sleftv,
* v is the pointer to the next sleftv
* (in this moment) */
h->next=v;
}
h=v;
v=v->next;
h->next=NULL;
rt=h->Typ();
if (rt==0)
{
L->Clean();
Werror("`%s` is undefined",h->Fullname());
return TRUE;
}
if (rt==RING_CMD)
{
L->m[i].rtyp=rt;
L->m[i].data=rIncRefCnt(((ring)h->Data()));
}
else
L->m[i].Copy(h);
}
}
res->data=(char *)L;
return FALSE;
}
static BOOLEAN jjMODULO4(leftv res, leftv u)
{
leftv v=u->next;
leftv w=v->next;
leftv u4=w->next;
GbVariant alg;
ideal u_id,v_id;
// we have 4 arguments
const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
if(iiCheckTypes(u,t1)||iiCheckTypes(u,t2)||(w->rtyp!=IDHDL))
{
u_id=(ideal)u->Data();
v_id=(ideal)v->Data();
alg=syGetAlgorithm((char*)u4->Data(),currRing,u_id);
}
else
{
Werror("%s(`ideal/module`,`ideal/module`[,`matrix`][,`string`]) expected",Tok2Cmdname(iiOp));
return TRUE;
}
intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
if (w_u!=NULL)
{
w_u=ivCopy(w_u);
hom=isHomog;
}
intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
if (w_v!=NULL)
{
w_v=ivCopy(w_v);
hom=isHomog;
}
if ((w_u!=NULL) && (w_v==NULL))
w_v=ivCopy(w_u);
if ((w_v!=NULL) && (w_u==NULL))
w_u=ivCopy(w_v);
if (w_u!=NULL)
{
if ((*w_u).compare((w_v))!=0)
{
WarnS("incompatible weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
else
{
if ((!idTestHomModule(u_id,currRing->qideal,w_v))
|| (!idTestHomModule(v_id,currRing->qideal,w_v)))
{
WarnS("wrong weights");
delete w_u; w_u=NULL;
hom=testHomog;
}
}
}
idhdl h=(idhdl)w->data;
res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix),alg);
if (w_u!=NULL)
{
atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
}
delete w_v;
//if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
return FALSE;
}
static BOOLEAN jjNAMES0(leftv res, leftv)
{
res->data=(void *)ipNameList(IDROOT);
return FALSE;
}
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
{
if(v==NULL)
{
res->data=(char *)showOption();
return FALSE;
}
res->rtyp=NONE;
return setOption(res,v);
}
static BOOLEAN jjREDUCE4(leftv res, leftv u)
{
leftv u1=u;
leftv u2=u1->next;
leftv u3=u2->next;
leftv u4=u3->next;
int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
{
int save_d=Kstd1_deg;
Kstd1_deg=(int)(long)u3->Data();
kModW=(intvec *)u4->Data();
BITSET save2;
SI_SAVE_OPT2(save2);
si_opt_2|=Sy_bit(V_DEG_STOP);
u2->next=NULL;
BOOLEAN r=jjCALL2ARG(res,u);
kModW=NULL;
Kstd1_deg=save_d;
SI_RESTORE_OPT2(save2);
u->next->next=u3;
return r;
}
else
if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
(u4->Typ()==INT_CMD))
{
assumeStdFlag(u3);
if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
{
WerrorS("2nd argument must be a diagonal matrix of units");
return TRUE;
}
res->data=(char*)redNF(
idCopy((ideal)u3->Data()),
idCopy((ideal)u1->Data()),
mp_Copy((matrix)u2->Data(), currRing),
(int)(long)u4->Data()
);
return FALSE;
}
else
if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
(u4->Typ()==INT_CMD))
{
poly u1p;
if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
else u1p=(poly)u1->Data();
poly u2p;
if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
else u2p=(poly)u2->Data();
assumeStdFlag(u3);
if(!pIsUnit(u2p))
{
WerrorS("2nd argument must be a unit");
return TRUE;
}
res->rtyp=POLY_CMD;
res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
pCopy(u2p),(int)(long)u4->Data());
return FALSE;
}
else
{
Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
return TRUE;
}
}
static BOOLEAN jjREDUCE5(leftv res, leftv u)
{
leftv u1=u;
leftv u2=u1->next;
leftv u3=u2->next;
leftv u4=u3->next;
leftv u5=u4->next;
if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
(u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
{
assumeStdFlag(u3);
if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
{
WerrorS("2nd argument must be a diagonal matrix of units");
return TRUE;
}
res->data=(char*)redNF(
idCopy((ideal)u3->Data()),
idCopy((ideal)u1->Data()),
mp_Copy((matrix)u2->Data(),currRing),
(int)(long)u4->Data(),
(intvec*)u5->Data()
);
return FALSE;
}
else
if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
(u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
{
assumeStdFlag(u3);
if(!pIsUnit((poly)u2->Data()))
{
WerrorS("2nd argument must be a unit");
return TRUE;
}
res->rtyp=POLY_CMD;
res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
pCopy((poly)u2->Data()),
(int)(long)u4->Data(),(intvec*)u5->Data());
return FALSE;
}
else
{
Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
Tok2Cmdname(iiOp));
return TRUE;
}
}
static BOOLEAN jjRESERVED0(leftv, leftv)
{
unsigned i=1;
unsigned nCount = (sArithBase.nCmdUsed-1)/3;
if((3*nCount)<sArithBase.nCmdUsed) nCount++;
//Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
// sArithBase.nCmdAllocated);
for(i=0; i<nCount; i++)
{
Print("%-20s",sArithBase.sCmds[i+1].name);
if(i+1+nCount<sArithBase.nCmdUsed)
Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
if(i+1+2*nCount<sArithBase.nCmdUsed)
Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
//if ((i%3)==1) PrintLn();
PrintLn();
}
PrintLn();
printBlackboxTypes();
return FALSE;
}
static BOOLEAN jjRESERVEDLIST0(leftv res, leftv)
{
int l = 0;
int k = 0;
lists L = (lists)omAllocBin(slists_bin);
struct blackbox_list *bb_list = NULL;
unsigned nCount = (sArithBase.nCmdUsed-1) / 3;
if ((3*nCount) < sArithBase.nCmdUsed)
{
nCount++;
}
bb_list = getBlackboxTypes();
// count the number of entries;
for (unsigned i=0; i<nCount; i++)
{
l++;
if (i + 1 + nCount < sArithBase.nCmdUsed)
{
l++;
}
if(i+1+2*nCount<sArithBase.nCmdUsed)
{
l++;
}
}
for (int i = 0; i < bb_list->count; i++)
{
if (bb_list->list[i] != NULL)
{
l++;
}
}
// initiate list
L->Init(l);
k = 0;
for (unsigned i=0; i<nCount; i++)
{
L->m[k].rtyp = STRING_CMD;
L->m[k].data = omStrDup(sArithBase.sCmds[i+1].name);
k++;
// Print("%-20s", sArithBase.sCmds[i+1].name);
if (i + 1 + nCount < sArithBase.nCmdUsed)
{
L->m[k].rtyp = STRING_CMD;
L->m[k].data = omStrDup(sArithBase.sCmds[i+1+nCount].name);
k++;
// Print("%-20s", sArithBase.sCmds[i+1 + nCount].name);
}
if(i+1+2*nCount<sArithBase.nCmdUsed)
{
L->m[k].rtyp = STRING_CMD;
L->m[k].data = omStrDup(sArithBase.sCmds[i+1+2*nCount].name);
k++;
// Print("%-20s", sArithBase.sCmds[i+1+2*nCount].name);
}
// PrintLn();
}
// assign blackbox types
for (int i = 0; i < bb_list->count; i++)
{
if (bb_list->list[i] != NULL)
{
L->m[k].rtyp = STRING_CMD;
// already used strdup in getBlackBoxTypes
L->m[k].data = bb_list->list[i];
k++;
}
}
// free the struct (not the list entries itself, which were allocated
// by strdup)
omfree(bb_list->list);
omfree(bb_list);
// pass the resultant list to the res datastructure
res->data=(void *)L;
return FALSE;
}
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
{
if (v == NULL)
{
res->data = omStrDup("");
return FALSE;
}
int n = v->listLength();
if (n == 1)
{
res->data = v->String();
return FALSE;
}
char** slist = (char**) omAlloc(n*sizeof(char*));
int i, j;
for (i=0, j=0; i<n; i++, v = v ->next)
{
slist[i] = v->String();
assume(slist[i] != NULL);
j+=strlen(slist[i]);
}
char* s = (char*) omAlloc((j+1)*sizeof(char));
*s='\0';
for (i=0;i<n;i++)
{
strcat(s, slist[i]);
omFree(slist[i]);
}
omFreeSize(slist, n*sizeof(char*));
res->data = s;
return FALSE;
}
static BOOLEAN jjTEST(leftv, leftv v)
{
do
{
if (v->Typ()!=INT_CMD)
return TRUE;
test_cmd((int)(long)v->Data());
v=v->next;
}
while (v!=NULL);
return FALSE;
}
#if defined(__alpha) && !defined(linux)
extern "C"
{
void usleep(unsigned long usec);
};
#endif
static BOOLEAN jjFactModD_M(leftv res, leftv v)
{
/* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
valid argument lists:
- (poly h, int d),
- (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
- (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
in list of ring vars,
- (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
optional: all 4 optional args
(The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
by singclap_factorize and h(0, y)
has exactly two distinct monic factors [possibly with exponent > 1].)
result:
- list with the two factors f and g such that
h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
poly h = NULL;
int d = 1;
poly f0 = NULL;
poly g0 = NULL;
int xIndex = 1; /* default index if none provided */
int yIndex = 2; /* default index if none provided */
leftv u = v; int factorsGiven = 0;
if ((u == NULL) || (u->Typ() != POLY_CMD))
{
WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
return TRUE;
}
else h = (poly)u->Data();
u = u->next;
if ((u == NULL) || (u->Typ() != INT_CMD))
{
WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
return TRUE;
}
else d = (int)(long)u->Data();
u = u->next;
if ((u != NULL) && (u->Typ() == POLY_CMD))
{
if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
{
WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
return TRUE;
}
else
{
f0 = (poly)u->Data();
g0 = (poly)u->next->Data();
factorsGiven = 1;
u = u->next->next;
}
}
if ((u != NULL) && (u->Typ() == INT_CMD))
{
if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
{
WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
return TRUE;
}
else
{
xIndex = (int)(long)u->Data();
yIndex = (int)(long)u->next->Data();
u = u->next->next;
}
}
if (u != NULL)
{
WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
return TRUE;
}
/* checks for provided arguments */
if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
{
WerrorS("expected non-constant polynomial argument(s)");
return TRUE;
}
int n = rVar(currRing);
if ((xIndex < 1) || (n < xIndex))
{
Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
return TRUE;
}
if ((yIndex < 1) || (n < yIndex))
{
Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
return TRUE;
}
if (xIndex == yIndex)
{
WerrorS("expected distinct indices for variables x and y");
return TRUE;
}
/* computation of f0 and g0 if missing */
if (factorsGiven == 0)
{
poly h0 = pSubst(pCopy(h), xIndex, NULL);
intvec* v = NULL;
ideal i = singclap_factorize(h0, &v, 0,currRing);
ivTest(v);
if (i == NULL) return TRUE;
idTest(i);
if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
{
WerrorS("expected h(0,y) to have exactly two distinct monic factors");
return TRUE;
}
f0 = pPower(pCopy(i->m[1]), (*v)[1]);
g0 = pPower(pCopy(i->m[2]), (*v)[2]);
idDelete(&i);
}
poly f; poly g;
henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
lists L = (lists)omAllocBin(slists_bin);
L->Init(2);
L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
res->rtyp = LIST_CMD;
res->data = (char*)L;
return FALSE;
}
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
{
if ((v->Typ() != LINK_CMD) ||
(v->next->Typ() != STRING_CMD) ||
(v->next->next->Typ() != STRING_CMD) ||
(v->next->next->next->Typ() != INT_CMD))
return TRUE;
jjSTATUS3(res, v, v->next, v->next->next);
#if defined(HAVE_USLEEP)
if (((long) res->data) == 0L)
{
int i_s = (int)(long) v->next->next->next->Data();
if (i_s > 0)
{
usleep((int)(long) v->next->next->next->Data());
jjSTATUS3(res, v, v->next, v->next->next);
}
}
#elif defined(HAVE_SLEEP)
if (((int) res->data) == 0)
{
int i_s = (int) v->next->next->next->Data();
if (i_s > 0)
{
si_sleep((is - 1)/1000000 + 1);
jjSTATUS3(res, v, v->next, v->next->next);
}
}
#endif
return FALSE;
}
static BOOLEAN jjSUBST_M(leftv res, leftv u)
{
leftv v = u->next; // number of args > 0
if (v==NULL) return TRUE;
leftv w = v->next;
if (w==NULL) return TRUE;
leftv rest = w->next;
u->next = NULL;
v->next = NULL;
w->next = NULL;
BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
if ((rest!=NULL) && (!b))
{
leftv tmp_next=res->next;
res->next=rest;
sleftv tmp_res;
tmp_res.Init();
b = iiExprArithM(&tmp_res,res,iiOp);
memcpy(res,&tmp_res,sizeof(tmp_res));
res->next=tmp_next;
}
u->next = v;
v->next = w;
// rest was w->next, but is already cleaned
return b;
}
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
{
if ((INPUT->Typ() != MATRIX_CMD) ||
(INPUT->next->Typ() != NUMBER_CMD) ||
(INPUT->next->next->Typ() != NUMBER_CMD) ||
(INPUT->next->next->next->Typ() != NUMBER_CMD))
{
WerrorS("expected (matrix, number, number, number) as arguments");
return TRUE;
}
leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
res->data = (char *)qrDoubleShift((matrix)(u->Data()),
(number)(v->Data()),
(number)(w->Data()),
(number)(x->Data()));
return FALSE;
}
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
{ ideal result;
leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
leftv v = u->next; /* one additional polynomial or ideal */
leftv h = v->next; /* Hilbert vector */
leftv w = h->next; /* weight vector */
assumeStdFlag(u);
ideal i1=(ideal)(u->Data());
ideal i0;
if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
|| (h->Typ()!=BIGINTVEC_CMD)
|| (w->Typ()!=INTVEC_CMD))
{
WerrorS("expected `std(`ideal/module`,`poly/vector`,`bigintvec`,`intvec`)");
return TRUE;
}
intvec *vw=(intvec *)w->Data(); // weights of vars
/* merging std_hilb_w and std_1 */
if (vw->length()!=currRing->N)
{
Werror("%d weights for %d variables",vw->length(),currRing->N);
return TRUE;
}
int r=v->Typ();
BOOLEAN cleanup_i0=FALSE;
if ((r==POLY_CMD) ||(r==VECTOR_CMD))
{
i0=idInit(1,i1->rank);
i0->m[0]=(poly)v->Data();
cleanup_i0=TRUE;
}
else if (r==IDEAL_CMD)/* IDEAL */
{
i0=(ideal)v->Data();
}
else
{
WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
return TRUE;
}
int ii0=idElem(i0);
i1 = idSimpleAdd(i1,i0);
if (cleanup_i0)
{
memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
idDelete(&i0);
}
intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
tHomog hom=testHomog;
/* u_id from jjSTD_W is now i1 as in jjSTD_1 */
if (ww!=NULL)
{
if (!idTestHomModule(i1,currRing->qideal,ww))
{
WarnS("wrong weights");
ww=NULL;
}
else
{
ww=ivCopy(ww);
hom=isHomog;
}
}
BITSET save1;
SI_SAVE_OPT1(save1);
si_opt_1|=Sy_bit(OPT_SB_1);
result=kStd2(i1,
currRing->qideal,
hom,
&ww, // module weights
(bigintmat *)h->Data(), // hilbert series
0, // syzComp, whatever it is...
IDELEMS(i1)-ii0, // new ideal
vw); // weights of vars
SI_RESTORE_OPT1(save1);
if (errorreported) return TRUE;
idDelete(&i1);
idSkipZeroes(result);
res->data = (char *)result;
if (!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
return FALSE;
}
static BOOLEAN jjRING_PL(leftv res, leftv a)
{
//Print("construct ring\n");
if (a->Typ()!=CRING_CMD)
{
WerrorS("expected `cring` [ `id` ... ]");
return TRUE;
}
assume(a->next!=NULL);
leftv names=a->next;
int N=names->listLength();
char **n=(char**)omAlloc0(N*sizeof(char*));
for(int i=0; i<N;i++,names=names->next)
{
n[i]=(char *)names->Name();
}
coeffs cf=(coeffs)a->CopyD();
res->data=rDefault(cf,N,n, ringorder_dp);
omFreeSize(n,N*sizeof(char*));
return FALSE;
}
static Subexpr jjMakeSub(leftv e)
{
assume( e->Typ()==INT_CMD );
Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
r->start =(int)(long)e->Data();
return r;
}
static BOOLEAN jjRESTART(leftv, leftv u)
{
int c=(int)(long)u->Data();
switch(c)
{
case 0:{
PrintS("delete all variables\n");
killlocals(0);
WerrorS("restarting...");
break;
};
default: WerrorS("not implemented");
}
return FALSE;
}
#define D(A) (A)
#define NULL_VAL NULL
#define IPARITH
#include "table.h"
#include "iparith.inc"
/*=================== operations with 2 args. ============================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN iiExprArith2TabIntern(leftv res, leftv a, int op, leftv b,
BOOLEAN proccall,
const struct sValCmd2* dA2,
int at, int bt,
const struct sConvertTypes *dConvertTypes)
{
BOOLEAN call_failed=FALSE;
if (!errorreported)
{
int i=0;
iiOp=op;
while (dA2[i].cmd==op)
{
if ((at==dA2[i].arg1)
&& (bt==dA2[i].arg2))
{
res->rtyp=dA2[i].res;
if (currRing!=NULL)
{
if (check_valid(dA2[i].valid_for,op)) break;
}
else
{
if (RingDependend(dA2[i].res))
{
WerrorS("no ring active (3)");
break;
}
}
if (traceit&TRACE_CALL)
Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
if ((call_failed=dA2[i].p(res,a,b)))
{
break;// leave loop, goto error handling
}
a->CleanUp();
b->CleanUp();
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return FALSE;
}
i++;
}
// implicite type conversion ----------------------------------------------
if (dA2[i].cmd!=op)
{
int ai,bi;
leftv an = (leftv)omAlloc0Bin(sleftv_bin);
leftv bn = (leftv)omAlloc0Bin(sleftv_bin);
BOOLEAN failed=FALSE;
i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
//Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
while (dA2[i].cmd==op)
{
//Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
if ((dA2[i].valid_for & NO_CONVERSION)==0)
{
if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
{
if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
{
res->rtyp=dA2[i].res;
if (currRing!=NULL)
{
if (check_valid(dA2[i].valid_for,op)) break;
}
else
{
if (RingDependend(dA2[i].res))
{
WerrorS("no ring active (4)");
break;
}
}
if (traceit&TRACE_CALL)
Print("call %s(%s,%s)\n",iiTwoOps(op),
Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
|| (iiConvert(bt,dA2[i].arg2,bi,b,bn))
|| (call_failed=dA2[i].p(res,an,bn)));
// everything done, clean up temp. variables
if (failed)
{
// leave loop, goto error handling
break;
}
else
{
// everything ok, clean up and return
an->CleanUp();
bn->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
omFreeBin((ADDRESS)bn, sleftv_bin);
return FALSE;
}
}
}
}
i++;
}
an->CleanUp();
bn->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
omFreeBin((ADDRESS)bn, sleftv_bin);
}
// error handling ---------------------------------------------------
const char *s=NULL;
if (!errorreported)
{
if ((at==0) && (a->Fullname()!=sNoName_fe))
{
s=a->Fullname();
}
else if ((bt==0) && (b->Fullname()!=sNoName_fe))
{
s=b->Fullname();
}
if (s!=NULL)
Werror("`%s` is not defined",s);
else
{
i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
s = iiTwoOps(op);
if (proccall)
{
Werror("%s(`%s`,`%s`) failed"
,s,Tok2Cmdname(at),Tok2Cmdname(bt));
}
else
{
Werror("`%s` %s `%s` failed"
,Tok2Cmdname(at),s,Tok2Cmdname(bt));
}
if ((!call_failed) && BVERBOSE(V_SHOW_USE))
{
while (dA2[i].cmd==op)
{
if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
&& (dA2[i].res!=0)
&& (dA2[i].p!=jjWRONG2))
{
if (proccall)
Werror("expected %s(`%s`,`%s`)"
,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
else
Werror("expected `%s` %s `%s`"
,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
}
i++;
}
}
}
}
a->CleanUp();
b->CleanUp();
res->rtyp = UNKNOWN;
}
return TRUE;
}
BOOLEAN iiExprArith2Tab(leftv res, leftv a, int op,
const struct sValCmd2* dA2,
int at,
const struct sConvertTypes *dConvertTypes)
{
res->Init();
leftv b=a->next;
a->next=NULL;
int bt=b->Typ();
BOOLEAN bo=iiExprArith2TabIntern(res,a,op,b,TRUE,dA2,at,bt,dConvertTypes);
a->next=b;
a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
return bo;
}
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
{
res->Init();
if (!errorreported)
{
#ifdef SIQ
if (siq>0)
{
//Print("siq:%d\n",siq);
command d=(command)omAlloc0Bin(sip_command_bin);
memcpy(&d->arg1,a,sizeof(sleftv));
a->Init();
memcpy(&d->arg2,b,sizeof(sleftv));
b->Init();
d->argc=2;
d->op=op;
res->data=(char *)d;
res->rtyp=COMMAND;
return FALSE;
}
#endif
int at=a->Typ();
int bt=b->Typ();
// handling bb-objects ----------------------------------------------------
if (at>MAX_TOK)
{
blackbox *bb=getBlackboxStuff(at);
if (bb!=NULL)
{
if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
// if not defined, try generic (attrib, ..)
}
else
return TRUE;
}
else if ((bt>MAX_TOK)&&(op!='('))
{
blackbox *bb=getBlackboxStuff(bt);
if (bb!=NULL)
{
if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
// if not defined, try generic (attrib, ..)
}
else
return TRUE;
}
int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
}
a->CleanUp();
b->CleanUp();
return TRUE;
}
/*==================== operations with 1 arg. ===============================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
{
res->Init();
BOOLEAN call_failed=FALSE;
if (!errorreported)
{
BOOLEAN failed=FALSE;
iiOp=op;
int i = 0;
while (dA1[i].cmd==op)
{
if (at==dA1[i].arg)
{
if (currRing!=NULL)
{
if (check_valid(dA1[i].valid_for,op)) break;
}
else
{
if (RingDependend(dA1[i].res))
{
WerrorS("no ring active (5)");
break;
}
}
if (traceit&TRACE_CALL)
Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
res->rtyp=dA1[i].res;
if ((call_failed=dA1[i].p(res,a)))
{
break;// leave loop, goto error handling
}
if (a->Next()!=NULL)
{
res->next=(leftv)omAllocBin(sleftv_bin);
failed=iiExprArith1(res->next,a->next,op);
}
a->CleanUp();
return failed;
}
i++;
}
// implicite type conversion --------------------------------------------
if (dA1[i].cmd!=op)
{
leftv an = (leftv)omAlloc0Bin(sleftv_bin);
i=0;
//Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
while (dA1[i].cmd==op)
{
int ai;
//Print("test %s\n",Tok2Cmdname(dA1[i].arg));
if ((dA1[i].valid_for & NO_CONVERSION)==0)
{
if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
{
if (currRing!=NULL)
{
if (check_valid(dA1[i].valid_for,op)) break;
}
else
{
if (RingDependend(dA1[i].res))
{
WerrorS("no ring active (6)");
break;
}
}
if (traceit&TRACE_CALL)
Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
res->rtyp=dA1[i].res;
failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
|| (call_failed=dA1[i].p(res,an)));
// everything done, clean up temp. variables
if (failed)
{
// leave loop, goto error handling
break;
}
else
{
if (an->Next() != NULL)
{
res->next = (leftv)omAllocBin(sleftv_bin);
failed=iiExprArith1(res->next,an->next,op);
}
// everything ok, clean up and return
an->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
return failed;
}
}
}
i++;
}
an->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
}
// error handling
if (!errorreported)
{
if ((at==0) && (a->Fullname()!=sNoName_fe))
{
Werror("`%s` is not defined",a->Fullname());
}
else
{
i=0;
const char *s = iiTwoOps(op);
Werror("%s(`%s`) failed"
,s,Tok2Cmdname(at));
if ((!call_failed) && BVERBOSE(V_SHOW_USE))
{
while (dA1[i].cmd==op)
{
if ((dA1[i].res!=0)
&& (dA1[i].p!=jjWRONG))
Werror("expected %s(`%s`)"
,s,Tok2Cmdname(dA1[i].arg));
i++;
}
}
}
}
res->rtyp = UNKNOWN;
}
a->CleanUp();
return TRUE;
}
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
{
if (!errorreported)
{
res->Init();
#ifdef SIQ
if (siq>0)
{
//Print("siq:%d\n",siq);
command d=(command)omAlloc0Bin(sip_command_bin);
memcpy(&d->arg1,a,sizeof(sleftv));
a->Init();
d->op=op;
d->argc=1;
res->data=(char *)d;
res->rtyp=COMMAND;
return FALSE;
}
#endif
int at=a->Typ();
// handling bb-objects ----------------------------------------------------
if(op>MAX_TOK) // explicit type conversion to bb
{
blackbox *bb=getBlackboxStuff(op);
if (bb!=NULL)
{
res->rtyp=op;
res->data=bb->blackbox_Init(bb);
return bb->blackbox_Assign(res,a);
}
else
return TRUE;
}
else if (at>MAX_TOK) // argument is of bb-type
{
blackbox *bb=getBlackboxStuff(at);
if (bb!=NULL)
{
if(!bb->blackbox_Op1(op,res,a)) return FALSE;
// if not defined, try generic routines (attrib, defined,..)
}
else
return TRUE;
}
if (errorreported) return TRUE;
int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
}
a->CleanUp();
return TRUE;
}
/*=================== operations with 3 args. ============================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
static BOOLEAN iiExprArith3TabIntern(leftv res, int op, leftv a, leftv b, leftv c,
const struct sValCmd3* dA3, int at, int bt, int ct,
const struct sConvertTypes *dConvertTypes)
{
BOOLEAN call_failed=FALSE;
assume(dA3[0].cmd==op);
if (!errorreported)
{
int i=0;
iiOp=op;
while (dA3[i].cmd==op)
{
if ((at==dA3[i].arg1)
&& (bt==dA3[i].arg2)
&& (ct==dA3[i].arg3))
{
res->rtyp=dA3[i].res;
if (currRing!=NULL)
{
if (check_valid(dA3[i].valid_for,op)) break;
}
if (traceit&TRACE_CALL)
Print("call %s(%s,%s,%s)\n",
iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
if ((call_failed=dA3[i].p(res,a,b,c)))
{
break;// leave loop, goto error handling
}
a->CleanUp();
b->CleanUp();
c->CleanUp();
return FALSE;
}
i++;
}
// implicite type conversion ----------------------------------------------
if (dA3[i].cmd!=op)
{
int ai,bi,ci;
leftv an = (leftv)omAlloc0Bin(sleftv_bin);
leftv bn = (leftv)omAlloc0Bin(sleftv_bin);
leftv cn = (leftv)omAlloc0Bin(sleftv_bin);
BOOLEAN failed=FALSE;
i=0;
//while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
while (dA3[i].cmd==op)
{
if ((dA3[i].valid_for & NO_CONVERSION)==0)
{
if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
{
if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
{
if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
{
res->rtyp=dA3[i].res;
if (currRing!=NULL)
{
if (check_valid(dA3[i].valid_for,op)) break;
}
if (traceit&TRACE_CALL)
Print("call %s(%s,%s,%s)\n",
iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
|| (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
|| (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
|| (call_failed=dA3[i].p(res,an,bn,cn)));
// everything done, clean up temp. variables
if (failed)
{
// leave loop, goto error handling
break;
}
else
{
// everything ok, clean up and return
an->CleanUp();
bn->CleanUp();
cn->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
omFreeBin((ADDRESS)bn, sleftv_bin);
omFreeBin((ADDRESS)cn, sleftv_bin);
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return FALSE;
}
}
}
}
}
i++;
}
an->CleanUp();
bn->CleanUp();
cn->CleanUp();
omFreeBin((ADDRESS)an, sleftv_bin);
omFreeBin((ADDRESS)bn, sleftv_bin);
omFreeBin((ADDRESS)cn, sleftv_bin);
}
// error handling ---------------------------------------------------
if (!errorreported)
{
const char *s=NULL;
if ((at==0) && (a->Fullname()!=sNoName_fe))
{
s=a->Fullname();
}
else if ((bt==0) && (b->Fullname()!=sNoName_fe))
{
s=b->Fullname();
}
else if ((ct==0) && (c->Fullname()!=sNoName_fe))
{
s=c->Fullname();
}
if (s!=NULL)
Werror("`%s` is not defined",s);
else
{
i=0;
//while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
const char *s = iiTwoOps(op);
Werror("%s(`%s`,`%s`,`%s`) failed"
,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
if ((!call_failed) && BVERBOSE(V_SHOW_USE))
{
while (dA3[i].cmd==op)
{
if(((at==dA3[i].arg1)
||(bt==dA3[i].arg2)
||(ct==dA3[i].arg3))
&& (dA3[i].res!=0))
{
Werror("expected %s(`%s`,`%s`,`%s`)"
,s,Tok2Cmdname(dA3[i].arg1)
,Tok2Cmdname(dA3[i].arg2)
,Tok2Cmdname(dA3[i].arg3));
}
i++;
}
}
}
}
res->rtyp = UNKNOWN;
}
a->CleanUp();
b->CleanUp();
c->CleanUp();
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return TRUE;
}
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
{
res->Init();
if (!errorreported)
{
#ifdef SIQ
if (siq>0)
{
//Print("siq:%d\n",siq);
command d=(command)omAlloc0Bin(sip_command_bin);
memcpy(&d->arg1,a,sizeof(sleftv));
a->Init();
memcpy(&d->arg2,b,sizeof(sleftv));
b->Init();
memcpy(&d->arg3,c,sizeof(sleftv));
c->Init();
d->op=op;
d->argc=3;
res->data=(char *)d;
res->rtyp=COMMAND;
return FALSE;
}
#endif
int at=a->Typ();
// handling bb-objects ----------------------------------------------
if (at>MAX_TOK)
{
blackbox *bb=getBlackboxStuff(at);
if (bb!=NULL)
{
if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
// otherwise, try defaul (attrib,..)
}
else
return TRUE;
if (errorreported) return TRUE;
}
int bt=b->Typ();
int ct=c->Typ();
iiOp=op;
int i=0;
while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
}
a->CleanUp();
b->CleanUp();
c->CleanUp();
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return TRUE;
}
BOOLEAN iiExprArith3Tab(leftv res, leftv a, int op,
const struct sValCmd3* dA3,
int at,
const struct sConvertTypes *dConvertTypes)
{
res->Init();
leftv b=a->next;
a->next=NULL;
int bt=b->Typ();
leftv c=b->next;
b->next=NULL;
int ct=c->Typ();
BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
b->next=c;
a->next=b;
a->CleanUp(); // to cleanup the chain, content already done
return bo;
}
/*==================== operations with many arg. ===============================*/
/* must be ordered: first operations for chars (infix ops),
* then alphabetically */
#if 0 // unused
static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
{
// cnt = 0: all
// cnt = 1: only first one
leftv next;
BOOLEAN failed = TRUE;
if(v==NULL) return failed;
res->rtyp = LIST_CMD;
if(cnt) v->next = NULL;
next = v->next; // saving next-pointer
failed = jjLIST_PL(res, v);
v->next = next; // writeback next-pointer
return failed;
}
#endif
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
{
res->Init();
if (!errorreported)
{
#ifdef SIQ
if (siq>0)
{
//Print("siq:%d\n",siq);
command d=(command)omAlloc0Bin(sip_command_bin);
d->op=op;
res->data=(char *)d;
if (a!=NULL)
{
d->argc=a->listLength();
// else : d->argc=0;
memcpy(&d->arg1,a,sizeof(sleftv));
switch(d->argc)
{
case 3:
memcpy(&d->arg3,a->next->next,sizeof(sleftv));
a->next->next->Init(); /* no break */
case 2:
memcpy(&d->arg2,a->next,sizeof(sleftv));
a->next->Init();
a->next->next=d->arg2.next;
d->arg2.next=NULL; /* no break */
case 1:
a->Init();
a->next=d->arg1.next;
d->arg1.next=NULL;
}
if (d->argc>3) a->next=NULL;
a->name=NULL;
a->rtyp=0;
a->data=NULL;
a->e=NULL;
a->attribute=NULL;
a->CleanUp();
}
res->rtyp=COMMAND;
return FALSE;
}
#endif
if ((a!=NULL) && (a->Typ()>MAX_TOK))
{
blackbox *bb=getBlackboxStuff(a->Typ());
if (bb!=NULL)
{
if(!bb->blackbox_OpM(op,res,a)) return FALSE;
// otherwise, try default
}
else
return TRUE;
if (errorreported) return TRUE;
}
int args=0;
if (a!=NULL) args=a->listLength();
iiOp=op;
int i=0;
while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
while (dArithM[i].cmd==op)
{
if ((args==dArithM[i].number_of_args)
|| (dArithM[i].number_of_args==-1)
|| ((dArithM[i].number_of_args==-2)&&(args>0)))
{
res->rtyp=dArithM[i].res;
if (currRing!=NULL)
{
if (check_valid(dArithM[i].valid_for,op)) break;
}
if (traceit&TRACE_CALL)
Print("call %s(... (%d args))\n", iiTwoOps(op),args);
if (dArithM[i].p(res,a))
{
break;// leave loop, goto error handling
}
if (a!=NULL) a->CleanUp();
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return FALSE;
}
i++;
}
// error handling
if (!errorreported)
{
if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
{
Werror("`%s` is not defined",a->Fullname());
}
else
{
const char *s = iiTwoOps(op);
Werror("%s(...) failed",s);
}
}
res->rtyp = UNKNOWN;
}
if (a!=NULL) a->CleanUp();
//Print("op: %d,result typ:%d\n",op,res->rtyp);
return TRUE;
}
/*=================== general utilities ============================*/
int IsCmd(const char *n, int & tok)
{
int i;
int an=1;
int en=sArithBase.nLastIdentifier;
loop
//for(an=0; an<sArithBase.nCmdUsed; )
{
if(an>=en-1)
{
if (strcmp(n, sArithBase.sCmds[an].name) == 0)
{
i=an;
break;
}
else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
{
i=en;
break;
}
else
{
// -- blackbox extensions:
// return 0;
return blackboxIsCmd(n,tok);
}
}
i=(an+en)/2;
if (*n < *(sArithBase.sCmds[i].name))
{
en=i-1;
}
else if (*n > *(sArithBase.sCmds[i].name))
{
an=i+1;
}
else
{
int v=strcmp(n,sArithBase.sCmds[i].name);
if(v<0)
{
en=i-1;
}
else if(v>0)
{
an=i+1;
}
else /*v==0*/
{
break;
}
}
}
lastreserved=sArithBase.sCmds[i].name;
tok=sArithBase.sCmds[i].tokval;
if(sArithBase.sCmds[i].alias==2)
{
Warn("outdated identifier `%s` used - please change your code",
sArithBase.sCmds[i].name);
sArithBase.sCmds[i].alias=1;
}
#if 0
if (currRingHdl==NULL)
{
#ifdef SIQ
if (siq<=0)
{
#endif
if ((tok>=BEGIN_RING) && (tok<=END_RING))
{
WerrorS("no ring active");
return 0;
}
#ifdef SIQ
}
#endif
}
#endif
if (!expected_parms)
{
switch (tok)
{
case IDEAL_CMD:
case INT_CMD:
case INTVEC_CMD:
case MAP_CMD:
case MATRIX_CMD:
case MODUL_CMD:
case POLY_CMD:
case PROC_CMD:
case RING_CMD:
case STRING_CMD:
cmdtok = tok;
break;
}
}
return sArithBase.sCmds[i].toktype;
}
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
{
// user defined types are not in the pre-computed table:
if (op>MAX_TOK) return 0;
int a=0;
int e=len;
int p=len/2;
do
{
if (op==dArithTab[p].cmd) return dArithTab[p].start;
if (op<dArithTab[p].cmd) e=p-1;
else a = p+1;
p=a+(e-a)/2;
}
while ( a <= e);
// catch missing a cmd:
// may be missing as a op for blackbox, if the first operand is "undef" instead of bb
// Print("op %d (%c) unknown",op,op);
return 0;
}
typedef char si_char_2[2];
STATIC_VAR si_char_2 Tok2Cmdname_buf=" ";
const char * Tok2Cmdname(int tok)
{
if (tok <= 0)
{
return sArithBase.sCmds[0].name;
}
if (tok==ANY_TYPE) return "any_type";
if (tok==COMMAND) return "command";
if (tok==NONE) return "nothing";
if (tok < 128)
{
Tok2Cmdname_buf[0]=(char)tok;
return Tok2Cmdname_buf;
}
//if (tok==IFBREAK) return "if_break";
//if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
//if (tok==ORDER_VECTOR) return "ordering";
//if (tok==REF_VAR) return "ref";
//if (tok==OBJECT) return "object";
//if (tok==PRINT_EXPR) return "print_expr";
if (tok==IDHDL) return "identifier";
if (tok>MAX_TOK) return getBlackboxName(tok);
unsigned i;
for(i=0; i<sArithBase.nCmdUsed; i++)
//while (sArithBase.sCmds[i].tokval!=0)
{
if ((sArithBase.sCmds[i].tokval == tok)&&
(sArithBase.sCmds[i].alias==0))
{
return sArithBase.sCmds[i].name;
}
}
// try gain for alias/old names:
for(i=0; i<sArithBase.nCmdUsed; i++)
{
if (sArithBase.sCmds[i].tokval == tok)
{
return sArithBase.sCmds[i].name;
}
}
return sArithBase.sCmds[0].name;
}
/*---------------------------------------------------------------------*/
/**
* @brief compares to entry of cmdsname-list
@param[in] a
@param[in] b
@return <ReturnValue>
**/
/*---------------------------------------------------------------------*/
static int _gentable_sort_cmds( const void *a, const void *b )
{
cmdnames *pCmdL = (cmdnames*)a;
cmdnames *pCmdR = (cmdnames*)b;
if(a==NULL || b==NULL) return 0;
/* empty entries goes to the end of the list for later reuse */
if(pCmdL->name==NULL) return 1;
if(pCmdR->name==NULL) return -1;
/* $INVALID$ must come first */
if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
/* tokval=-1 are reserved names at the end */
if (pCmdL->tokval==-1)
{
if (pCmdR->tokval==-1)
return strcmp(pCmdL->name, pCmdR->name);
/* pCmdL->tokval==-1, pCmdL goes at the end */
return 1;
}
/* pCmdR->tokval==-1, pCmdR goes at the end */
if(pCmdR->tokval==-1) return -1;
return strcmp(pCmdL->name, pCmdR->name);
}
/*---------------------------------------------------------------------*/
/**
* @brief initialisation of arithmetic structured data
@retval 0 on success
**/
/*---------------------------------------------------------------------*/
int iiInitArithmetic()
{
//printf("iiInitArithmetic()\n");
memset(&sArithBase, 0, sizeof(sArithBase));
iiInitCmdName();
/* fix last-identifier */
#if 0
/* we expect that gentable allready did every thing */
for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--) {
if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
}
#endif
//Print("L=%d\n", sArithBase.nLastIdentifier);
//iiArithAddCmd(szName, nAlias, nTokval, nToktype);
//iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
//iiArithAddCmd("Top", 0,-1,0);
//for(i=0; i<sArithBase.nCmdUsed; i++) {
// printf("CMD[%03d] %s, %d, %d, %d\n", i,
// sArithBase.sCmds[i].name,
// sArithBase.sCmds[i].alias,
// sArithBase.sCmds[i].tokval,
// sArithBase.sCmds[i].toktype);
//}
//iiArithRemoveCmd("Top");
//iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
//iiArithRemoveCmd("mygcd");
//iiArithAddCmd("kkk", 1, 1234, CMD_1);
return 0;
}
int iiArithFindCmd(const char *szName)
{
int an=0;
int i = 0,v = 0;
int en=sArithBase.nLastIdentifier;
loop
//for(an=0; an<sArithBase.nCmdUsed; )
{
if(an>=en-1)
{
if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
{
//Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
return an;
}
else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
{
//Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
return en;
}
else
{
//Print("RET- 1\n");
return -1;
}
}
i=(an+en)/2;
if (*szName < *(sArithBase.sCmds[i].name))
{
en=i-1;
}
else if (*szName > *(sArithBase.sCmds[i].name))
{
an=i+1;
}
else
{
v=strcmp(szName,sArithBase.sCmds[i].name);
if(v<0)
{
en=i-1;
}
else if(v>0)
{
an=i+1;
}
else /*v==0*/
{
//Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
return i;
}
}
}
//if(i>=0 && i<sArithBase.nCmdUsed)
// return i;
//PrintS("RET-2\n");
return -2;
}
char *iiArithGetCmd( int nPos )
{
if(nPos<0) return NULL;
if(nPos<(int)sArithBase.nCmdUsed)
return sArithBase.sCmds[nPos].name;
return NULL;
}
int iiArithRemoveCmd(const char *szName)
{
int nIndex;
if(szName==NULL) return -1;
nIndex = iiArithFindCmd(szName);
if(nIndex<0 || nIndex>=(int)sArithBase.nCmdUsed)
{
Print("'%s' not found (%d)\n", szName, nIndex);
return -1;
}
omFreeBinAddr(sArithBase.sCmds[nIndex].name);
sArithBase.sCmds[nIndex].name=NULL;
qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
(&_gentable_sort_cmds));
sArithBase.nCmdUsed--;
/* fix last-identifier */
for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
{
if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
}
//Print("L=%d\n", sArithBase.nLastIdentifier);
return 0;
}
int iiArithAddCmd(
const char *szName,
short nAlias,
short nTokval,
short nToktype,
short nPos
)
{
//printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
// nTokval, nToktype, nPos);
if(nPos>=0)
{
// no checks: we rely on a correct generated code in iparith.inc
assume((unsigned)nPos < sArithBase.nCmdAllocated);
assume(szName!=NULL);
sArithBase.sCmds[nPos].name = omStrDup(szName);
sArithBase.sCmds[nPos].alias = nAlias;
sArithBase.sCmds[nPos].tokval = nTokval;
sArithBase.sCmds[nPos].toktype = nToktype;
sArithBase.nCmdUsed++;
//if(nTokval>0) sArithBase.nLastIdentifier++;
}
else
{
if(szName==NULL) return -1;
int nIndex = iiArithFindCmd(szName);
if(nIndex>=0)
{
Print("'%s' already exists at %d\n", szName, nIndex);
return -1;
}
if(sArithBase.nCmdUsed>=sArithBase.nCmdAllocated)
{
/* needs to create new slots */
unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
if(sArithBase.sCmds==NULL) return -1;
sArithBase.nCmdAllocated++;
}
/* still free slots available */
sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
sArithBase.nCmdUsed++;
qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
(&_gentable_sort_cmds));
for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
{
if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
}
//Print("L=%d\n", sArithBase.nLastIdentifier);
}
return 0;
}
static BOOLEAN check_valid(const int p, const int op)
{
if (rIsPluralRing(currRing))
{
if ((p & NC_MASK)==NO_NC)
{
WerrorS("not implemented for non-commutative rings");
return TRUE;
}
else if ((p & NC_MASK)==COMM_PLURAL)
{
Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
return FALSE;
}
/* else, ALLOW_PLURAL */
}
else if (rIsLPRing(currRing))
{
if ((p & ALLOW_LP)==0)
{
Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
return TRUE;
}
}
if (rField_is_Ring(currRing))
{
if ((p & RING_MASK)==0 /*NO_RING*/)
{
WerrorS("not implemented for rings with rings as coeffients");
return TRUE;
}
if (((p & NO_LRING)==NO_LRING) && rHasLocalOrMixedOrdering(currRing))
{
WerrorS("not implemented for rings with rings as coeffients and non-global orderings");
return TRUE;
}
/* else ALLOW_RING */
else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
&&(!rField_is_Domain(currRing)))
{
WerrorS("domain required as coeffients");
return TRUE;
}
/* else ALLOW_ZERODIVISOR */
else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
{
WarnS("considering the image in Q[...]");
}
}
return FALSE;
}
// --------------------------------------------------------------------
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
{
if ((currRing!=NULL)
&& rField_is_Ring(currRing)
&& (!rField_is_Z(currRing)))
{
WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
return TRUE;
}
coeffs cf;
lists c=(lists)u->CopyD(); // list of ideal or bigint/int
int rl=c->nr+1;
int return_type=c->m[0].Typ();
if ((return_type!=IDEAL_CMD)
&& (return_type!=MODUL_CMD)
&& (return_type!=SMATRIX_CMD)
&& (return_type!=MATRIX_CMD)
&& (return_type!=POLY_CMD))
{
if((return_type==BIGINT_CMD)
||(return_type==INT_CMD))
return_type=BIGINT_CMD;
else if (return_type==LIST_CMD)
{
// create a tmp list of the correct size
lists res_l=(lists)omAllocBin(slists_bin);
res_l->Init(rl /*c->nr+1*/);
BOOLEAN bo=FALSE;
int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,CHINREM_CMD);
for (unsigned i=0;i<=(unsigned)c->nr;i++)
{
sleftv tmp;
tmp.Copy(v);
bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
}
c->Clean();
res->data=res_l;
res->rtyp=LIST_CMD;
return bo;
}
else
{
c->Clean();
WerrorS("poly/ideal/module/matrix/list expected");
return TRUE;
}
}
if (return_type==BIGINT_CMD)
cf=coeffs_BIGINT;
else
{
cf=currRing->cf;
if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
cf=cf->extRing->cf;
}
lists pl=NULL;
intvec *p=NULL;
if (v->Typ()==LIST_CMD)
{
pl=(lists)v->Data();
if (pl->nr!=rl-1)
{
Werror("wromg number of primes (%d:%d) for chinrem",pl->nr+1,rl);
return TRUE;
}
}
else
{
p=(intvec*)v->Data();
if (p->length()!=rl)
{
Werror("wromg number of primes (%d:%d) for chinrem",p->length(),rl);
return TRUE;
}
}
ideal result;
ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
number *xx=NULL;
nMapFunc nMap=n_SetMap(coeffs_BIGINT,cf);
int i;
if (return_type!=BIGINT_CMD)
{
for(i=rl-1;i>=0;i--)
{
if (c->m[i].Typ()!=return_type)
{
Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
omFree(x); // delete c
return TRUE;
}
if (return_type==POLY_CMD)
{
x[i]=idInit(1,1);
x[i]->m[0]=(poly)c->m[i].CopyD();
}
else
{
x[i]=(ideal)c->m[i].CopyD();
}
//c->m[i].Init();
}
}
else
{
if (nMap==NULL)
{
Werror("not implemented: map bigint -> %s", nCoeffName(cf));
return TRUE;
}
xx=(number *)omAlloc(rl*sizeof(number));
for(i=rl-1;i>=0;i--)
{
if (c->m[i].Typ()==INT_CMD)
{
xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
}
else if (c->m[i].Typ()==BIGINT_CMD)
{
xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
}
else
{
Werror("bigint expected at pos %d",i+1);
omFree(x); // delete c
omFree(xx); // delete c
return TRUE;
}
}
}
number *q=(number *)omAlloc(rl*sizeof(number));
if (p!=NULL)
{
for(i=rl-1;i>=0;i--)
{
q[i]=n_Init((*p)[i], cf);
}
}
else
{
for(i=rl-1;i>=0;i--)
{
if (pl->m[i].Typ()==INT_CMD)
{
q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
}
else if (pl->m[i].Typ()==BIGINT_CMD)
{
q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
}
else
{
Werror("bigint expected at pos %d",i+1);
for(i++;i<rl;i++)
{
n_Delete(&(q[i]),cf);
}
omFree(x); // delete c
omFree(q); // delete pl
if (xx!=NULL) omFree(xx); // delete c
return TRUE;
}
}
}
if (return_type==BIGINT_CMD)
{
CFArray i_v(rl);
number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
res->data=(char *)n;
}
else
{
/* called in modular.lib::chinrem_recursive: too many proc.
#ifdef HAVE_VSPACE
int cpus = (long) feOptValue(FE_OPT_CPUS);
if ((cpus>1) && (rField_is_Q(currRing)))
result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
else
#endif
*/
result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
c->Clean();
if ((return_type==POLY_CMD) &&(result!=NULL))
{
res->data=(char *)result->m[0];
result->m[0]=NULL;
idDelete(&result);
}
else
res->data=(char *)result;
}
for(i=rl-1;i>=0;i--)
{
n_Delete(&(q[i]),cf);
}
omFree(q);
res->rtyp=return_type;
return result==NULL;
}
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
{
lists c=(lists)u->CopyD();
lists res_l=(lists)omAllocBin(slists_bin);
res_l->Init(c->nr+1);
BOOLEAN bo=FALSE;
int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,FAREY_CMD);
for (unsigned i=0;i<=(unsigned)c->nr;i++)
{
sleftv tmp;
tmp.Copy(v);
bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],FAREY_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
if (bo) { Werror("farey failed for list entry %d",i+1); break;}
}
c->Clean();
res->data=res_l;
return bo;
}
// --------------------------------------------------------------------
static int jjCOMPARE_ALL(const void * aa, const void * bb)
{
leftv a=(leftv)aa;
int at=a->Typ();
leftv b=(leftv)bb;
int bt=b->Typ();
if (at < bt) return -1;
if (at > bt) return 1;
int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
sleftv tmp;
tmp.Init();
iiOp='<';
BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
if (bo)
{
Werror(" no `<` for %s",Tok2Cmdname(at));
unsigned long ad=(unsigned long)a->Data();
unsigned long bd=(unsigned long)b->Data();
if (ad<bd) return -1;
else if (ad==bd) return 0;
else return 1;
}
else if (tmp.data==NULL) /* not < */
{
iiOp=EQUAL_EQUAL;
tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
bo=iiExprArith2TabIntern(&tmp,a,EQUAL_EQUAL,b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
if (bo)
{
Werror(" no `==` for %s",Tok2Cmdname(at));
unsigned long ad=(unsigned long)a->Data();
unsigned long bd=(unsigned long)b->Data();
if (ad<bd) return -1;
else if (ad==bd) return 0;
else return 1;
}
else if (tmp.data==NULL) /* not <,== */ return 1;
else return 0;
}
else return -1;
}
BOOLEAN jjSORTLIST(leftv, leftv arg)
{
lists l=(lists)arg->Data();
if (l->nr>0)
{
qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
}
return FALSE;
}
BOOLEAN jjUNIQLIST(leftv, leftv arg)
{
lists l=(lists)arg->Data();
if (l->nr>0)
{
qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
int i, j, len;
len=l->nr;
i=0;
while(i<len)
{
if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
{
l->m[i].CleanUp();
for(j=i; j<len;j++) l->m[j]=l->m[j+1];
l->m[len].Init();
l->m[len].rtyp=DEF_CMD;
len--;
}
else
i++;
}
//Print("new len:%d\n",len);
}
return FALSE;
}
GMPrat.h
getMinorIdealCache
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
Definition MinorInterface.cc:457
getMinorIdeal
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
Definition MinorInterface.cc:238
getMinorIdealHeuristic
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
Definition MinorInterface.cc:495
MinorInterface.h
fglm.h
atSet
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
attrib.h
atKill
#define atKill(H, A)
Definition attrib.h:49
ABS
static int ABS(int v)
Definition auxiliary.h:113
BITSET
#define BITSET
Definition auxiliary.h:85
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
bim2iv
intvec * bim2iv(bigintmat *b)
Definition bigintmat.cc:339
bimMult
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:253
bimSub
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:216
bimAdd
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
Definition bigintmat.cc:180
bigintmat.h
BIMATELEM
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
getBlackboxTypes
struct blackbox_list * getBlackboxTypes()
return array of all define types.
Definition blackbox.cc:245
getBlackboxName
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition blackbox.cc:213
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
blackboxIsCmd
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
printBlackboxTypes
void printBlackboxTypes()
list all defined type (for debugging)
Definition blackbox.cc:236
blackbox.h
blackbox_list::list
void ** list
Definition blackbox.h:86
blackbox_list::count
int count
Definition blackbox.h:85
blackbox_list
struct for containing list of blackbox names and the number of them.
Definition blackbox.h:84
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
CFArray
Array< CanonicalForm > CFArray
Definition canonicalform.h:397
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
x
Variable x
Definition cfModGcd.cc:4090
p
int p
Definition cfModGcd.cc:4086
g
g
Definition cfModGcd.cc:4098
fp
CanonicalForm fp
Definition cfModGcd.cc:4110
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
b
CanonicalForm b
Definition cfModGcd.cc:4111
map
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition cf_map_ext.cc:505
ipower
int ipower(int b, int m)
int ipower ( int b, int m )
Definition cf_util.cc:27
f
FILE * f
Definition checklibs.c:9
singclap_pmod
poly singclap_pmod(poly f, poly g, const ring r)
Definition clapsing.cc:732
singclap_factorize
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:983
singclap_factorize_retry
VAR int singclap_factorize_retry
Definition clapsing.cc:981
singclap_pdivide
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:649
singclap_extgcd
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition clapsing.cc:505
singclap_det_bi
number singclap_det_bi(bigintmat *m, const coeffs cf)
Definition clapsing.cc:1852
singclap_det_i
int singclap_det_i(intvec *m, const ring)
Definition clapsing.cc:1834
singclap_sqrfree
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:1377
clapsing.h
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
bigintmat::cols
int cols() const
Definition bigintmat.h:144
bigintmat::rows
int rows() const
Definition bigintmat.h:145
bigintmat::set
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition bigintmat.cc:93
bigintmat::compare
int compare(const bigintmat *op) const
Definition bigintmat.cc:360
idrec
Definition idrec.h:35
idrec::data
utypes data
Definition idrec.h:40
idrec::typ
int typ
Definition idrec.h:43
idrec::ref
short ref
Definition idrec.h:46
idrec::id
const char * id
Definition idrec.h:39
intvec
Definition intvec.h:24
intvec::makeVector
void makeVector()
Definition intvec.h:103
intvec::delete_pos
intvec * delete_pos(int p)
Definition intvec.cc:842
intvec::show
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
intvec::min_in
int min_in()
Definition intvec.h:122
intvec::length
int length() const
Definition intvec.h:95
intvec::compare
int compare(const intvec *o) const
Definition intvec.cc:206
intvec::cols
int cols() const
Definition intvec.h:96
intvec::rows
int rows() const
Definition intvec.h:97
ip_smatrix::rank
long rank
Definition matpol.h:19
ip_smatrix::cols
int & cols()
Definition matpol.h:24
ip_smatrix::rows
int & rows()
Definition matpol.h:23
sleftv
Class used for (list of) interpreter objects.
Definition subexpr.h:83
sleftv::CopyD
void * CopyD(int t)
Definition subexpr.cc:714
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::name
const char * name
Definition subexpr.h:87
sleftv::req_packhdl
package req_packhdl
Definition subexpr.h:106
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::Data
void * Data()
Definition subexpr.cc:1192
sleftv::Init
void Init()
Definition subexpr.h:107
sleftv::next
leftv next
Definition subexpr.h:86
sleftv::Name
const char * Name()
Definition subexpr.h:120
sleftv::listLength
int listLength()
Definition subexpr.cc:51
sleftv::Copy
void Copy(leftv e)
Definition subexpr.cc:689
sleftv::data
void * data
Definition subexpr.h:88
sleftv::Next
leftv Next()
Definition subexpr.h:136
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
sleftv::flag
BITSET flag
Definition subexpr.h:90
sleftv::Fullname
const char * Fullname()
Definition subexpr.h:125
sleftv::e
Subexpr e
Definition subexpr.h:105
sleftv::attribute
attr attribute
Definition subexpr.h:89
slists::m
sleftv * m
Definition lists.h:46
slists::Clean
void Clean(ring r=currRing)
Definition lists.h:26
slists::Init
INLINE_THIS void Init(int l=0)
slists::nr
int nr
Definition lists.h:44
coeffs.h
Coefficient rings, fields and other domains suitable for Singular polynomials.
n_ParDeg
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition coeffs.h:765
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
n_Param
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:778
n_Int
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:550
n_Add
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:653
n_GetDenom
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition coeffs.h:606
nCoeff_is_Extension
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:841
n_Random
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition coeffs.h:965
n_algExt
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
n_Gcd
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667
nCoeffString
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:958
n_GreaterZero
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:500
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
n_InpNeg
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:560
n_Power
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:635
n_Farey
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition coeffs.h:762
n_Div
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:618
n_RePart
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:785
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
n_Size
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:573
n_Sub
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:658
n_ChineseRemainderSym
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition coeffs.h:759
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:962
n_ExtGcd
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:674
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
n_IntMod
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:631
n_Equal
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:466
n_GetNumerator
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:611
n_SubringGcd
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:669
n_ImPart
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:788
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:581
nCoeff_is_transExt
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:913
pa
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
pb
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3796
Print
#define Print
Definition emacs.cc:80
Warn
#define Warn
Definition emacs.cc:77
WarnS
#define WarnS
Definition emacs.cc:78
result
return result
Definition facAbsBiFact.cc:76
s
const CanonicalForm int s
Definition facAbsFact.cc:51
res
CanonicalForm res
Definition facAbsFact.cc:60
w
const CanonicalForm & w
Definition facAbsFact.cc:51
B
b *CanonicalForm B
Definition facBivar.cc:52
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
found
bool found
Definition facFactorize.cc:55
tmp1
CFList tmp1
Definition facFqBivar.cc:75
tmp2
CFList tmp2
Definition facFqBivar.cc:75
j
int j
Definition facHensel.cc:110
factory.h
factory.h' is the user interface to Factory.
name
char name(const Variable &v)
Definition factory.h:189
WerrorS_callback
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
feFopen
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
errorreported
VAR short errorreported
Definition feFopen.cc:23
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
feOpt.h
feOptValue
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
my_yylinebuf
VAR char my_yylinebuf[80]
Definition febase.cc:44
myynest
VAR int myynest
Definition febase.cc:41
monitor
void monitor(void *F, int mode)
Definition febase.cc:68
if
if(!FE_OPT_NO_SHELL_FLAG)
Definition fehelp.cc:1000
newBuffer
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
sNoName_fe
const char sNoName_fe[]
Definition fevoices.cc:57
fevoices.h
BT_execute
@ BT_execute
Definition fevoices.h:23
flintconv.h
This file is work in progress and currently not part of the official Singular.
singflint_kernel
matrix singflint_kernel(matrix m, const ring R)
COMM_PLURAL
#define COMM_PLURAL
Definition gentable.cc:31
_gentable_sort_cmds
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition gentable.cc:191
jjWRONG3
#define jjWRONG3
Definition gentable.cc:126
NO_ZERODIVISOR
#define NO_ZERODIVISOR
Definition gentable.cc:42
NO_LRING
#define NO_LRING
Definition gentable.cc:54
NO_CONVERSION
#define NO_CONVERSION
Definition gentable.cc:51
iiTestConvert
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:298
iiTwoOps
const char * iiTwoOps(int t)
Definition gentable.cc:258
ALLOW_LP
#define ALLOW_LP
Definition gentable.cc:33
RING_MASK
#define RING_MASK
Definition gentable.cc:20
WARN_RING
#define WARN_RING
Definition gentable.cc:49
NC_MASK
#define NC_MASK
Definition gentable.cc:34
jjWRONG2
#define jjWRONG2
Definition gentable.cc:125
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
jjWRONG
#define jjWRONG
Definition gentable.cc:124
RingDependend
static int RingDependend(int t)
Definition gentable.cc:23
NO_NC
#define NO_NC
Definition gentable.cc:29
ZERODIVISOR_MASK
#define ZERODIVISOR_MASK
Definition gentable.cc:21
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7
EXTERN_VAR
#define EXTERN_VAR
Definition globaldefs.h:6
VAR
#define VAR
Definition globaldefs.h:5
PLUSPLUS
@ PLUSPLUS
Definition grammar.cc:274
END_RING
@ END_RING
Definition grammar.cc:311
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
BUCKET_CMD
@ BUCKET_CMD
Definition grammar.cc:284
BIGINTMAT_CMD
@ BIGINTMAT_CMD
Definition grammar.cc:278
IMAP_CMD
@ IMAP_CMD
Definition grammar.cc:299
GE
@ GE
Definition grammar.cc:269
EQUAL_EQUAL
@ EQUAL_EQUAL
Definition grammar.cc:268
MAP_CMD
@ MAP_CMD
Definition grammar.cc:286
PROC_CMD
@ PROC_CMD
Definition grammar.cc:281
LE
@ LE
Definition grammar.cc:270
BEGIN_RING
@ BEGIN_RING
Definition grammar.cc:283
INTMAT_CMD
@ INTMAT_CMD
Definition grammar.cc:280
MODUL_CMD
@ MODUL_CMD
Definition grammar.cc:288
SMATRIX_CMD
@ SMATRIX_CMD
Definition grammar.cc:292
VECTOR_CMD
@ VECTOR_CMD
Definition grammar.cc:293
RESOLUTION_CMD
@ RESOLUTION_CMD
Definition grammar.cc:291
NOTEQUAL
@ NOTEQUAL
Definition grammar.cc:273
BIGINTVEC_CMD
@ BIGINTVEC_CMD
Definition grammar.cc:279
NUMBER_CMD
@ NUMBER_CMD
Definition grammar.cc:289
POLY_CMD
@ POLY_CMD
Definition grammar.cc:290
RING_CMD
@ RING_CMD
Definition grammar.cc:282
FETCH_CMD
@ FETCH_CMD
Definition grammar.cc:296
cmdtok
int cmdtok
Definition grammar.cc:174
expected_parms
BOOLEAN expected_parms
Definition grammar.cc:173
yyparse
int yyparse(void)
Definition grammar.cc:2149
yyInRingConstruction
BOOLEAN yyInRingConstruction
Definition grammar.cc:172
scKBase
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition hdegree.cc:1414
scDimIntRing
int scDimIntRing(ideal vid, ideal Q)
scDimInt for ring-coefficients
Definition hdegree.cc:136
scMult0Int
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
scIndIntvec
intvec * scIndIntvec(ideal S, ideal Q)
Definition hdegree.cc:284
lp_kDim
int lp_kDim(const ideal _G)
Definition hdegree.cc:2081
lp_gkDim
int lp_gkDim(const ideal _G)
Definition hdegree.cc:1827
scMultInt
int scMultInt(ideal S, ideal Q)
Definition hdegree.cc:901
hFirstSeries0m
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1427
hFirstSeries0p
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1384
hSecondSeries
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:71
hFirstSeries
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:1514
hFirstSeries0b
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2019
hSecondSeries0b
bigintmat * hSecondSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2041
scDegree
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition hilb.cc:2057
hLookSeries
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:220
hilb.h
t_findTabelVal
leftv t_findTabelVal(stablerec *t, const char *s)
find the data to key s
Definition htable.cc:85
t_addTable
void t_addTable(stablerec *t, char *s, leftv v)
add a new entry (key s, data v) to table t, eats s, copies v
Definition htable.cc:93
htable.h
stablerec
Definition htable.h:23
syGetAlgorithm
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition ideals.cc:3698
idCoeffOfKBase
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition ideals.cc:2668
idLiftW
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, int *w)
Definition ideals.cc:1347
idSyzygies
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:836
idDiff
matrix idDiff(matrix i, int k)
Definition ideals.cc:2189
idTestHomModule
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2120
idLiftStd
ideal idLiftStd(ideal h1, matrix *T, tHomog hi, ideal *S, GbVariant alg, ideal h11)
Definition ideals.cc:982
idQuot
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1539
idSeries
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition ideals.cc:2172
idMinEmbedding_with_map_v
ideal idMinEmbedding_with_map_v(ideal arg, intvec **w, ideal &trans, int *g)
Definition ideals.cc:2874
idElimination2
ideal idElimination2(ideal h1, poly delVar, bigintmat *hilb, GbVariant alg)
Definition ideals.cc:1640
idDiffOp
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition ideals.cc:2202
idElimination
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition ideals.cc:1884
idSect
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:315
idMultSect
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition ideals.cc:472
idLift
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1111
idModulo
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2463
idMinBase
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
id_Farey
ideal id_Farey(ideal x, number N, const ring r)
Definition ideals.cc:3103
idMinEmbedding
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2853
ideals.h
GbVariant
GbVariant
Definition ideals.h:119
GbDefault
@ GbDefault
Definition ideals.h:120
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
idSimpleAdd
#define idSimpleAdd(A, B)
Definition ideals.h:42
idIsConstant
#define idIsConstant(I)
Definition ideals.h:40
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition simpleideals.cc:542
idIsZeroDim
static BOOLEAN idIsZeroDim(ideal i)
Definition ideals.h:180
idHomModule
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
idTest
#define idTest(id)
Definition ideals.h:47
idHomIdeal
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
idMult
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition ideals.h:84
idCopy
ideal idCopy(ideal A)
Definition ideals.h:60
idAdd
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition ideals.h:68
idMaxIdeal
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition ideals.h:33
resolvente
ideal * resolvente
Definition ideals.h:18
idSort
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:188
interpolation
ideal interpolation(const std::vector< ideal > &L, intvec *v)
Definition interpolation.cc:1484
interpolation.h
inerror
EXTERN_VAR int inerror
Definition interpreter_support.cc:21
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
ivSub
intvec * ivSub(intvec *a, intvec *b)
Definition intvec.cc:297
ivTrace
int ivTrace(intvec *o)
Definition intvec.cc:339
ivAdd
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
ivMult
intvec * ivMult(intvec *a, intvec *b)
Definition intvec.cc:349
ivTranp
intvec * ivTranp(intvec *o)
Definition intvec.cc:327
intvec.h
ivCopy
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
ivTest
#define ivTest(v)
Definition intvec.h:172
IMATELEM
#define IMATELEM(M, I, J)
Definition intvec.h:86
jjUMINUS_MA
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition iparith.cc:3834
jjOP_BIM_I
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:244
jjRANK1
static BOOLEAN jjRANK1(leftv res, leftv v)
Definition iparith.cc:4964
jjINDEX_V_IV
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1524
jjIMPART
static BOOLEAN jjIMPART(leftv res, leftv v)
Definition iparith.cc:4461
jjIm2Iv
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition iparith.cc:4454
_scmdnames::name
const char * name
Definition gentable.cc:58
SIMPL_EQU
#define SIMPL_EQU
Definition iparith.cc:3354
jjQUOT
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition iparith.cc:3105
jjUMINUS_IV
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition iparith.cc:3840
jjOPPOSITE
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition iparith.cc:5310
_gentable_sort_cmds
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition iparith.cc:9951
jjWAITALL1
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition iparith.cc:5556
jjRESTART
static BOOLEAN jjRESTART(leftv, leftv u)
Definition iparith.cc:8977
jjidHead
static BOOLEAN jjidHead(leftv res, leftv v)
Definition iparith.cc:5718
jjHILBERT
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition iparith.cc:4345
jjTIMES_MA_P1
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
Definition iparith.cc:1100
jjLEADMONOM
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
Definition iparith.cc:4620
jjOP_IV_I
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:280
jjstrlen
static BOOLEAN jjstrlen(leftv res, leftv v)
Definition iparith.cc:5683
jjBRACK_Bim
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5840
jjEXTGCD_P
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2048
jjDET_BI
static BOOLEAN jjDET_BI(leftv res, leftv v)
Definition iparith.cc:4102
jjWAIT1ST1
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition iparith.cc:5541
jjLOAD
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition iparith.cc:5591
jjMATRIX_Mo
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6973
jjP2I
static BOOLEAN jjP2I(leftv res, leftv v)
Definition iparith.cc:4878
jjIS_RINGVAR_P
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition iparith.cc:4488
jjDOTDOT
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
Definition iparith.cc:333
jjFWALK3
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6215
jjREPART
static BOOLEAN jjREPART(leftv res, leftv v)
Definition iparith.cc:4980
jjTIMES_MA_BI2
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
Definition iparith.cc:1096
jjMAP
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition iparith.cc:1653
jjGT_BI
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1184
jjN2BI
static BOOLEAN jjN2BI(leftv res, leftv v)
Definition iparith.cc:4761
jjRESERVEDLIST0
static BOOLEAN jjRESERVEDLIST0(leftv res, leftv)
Definition iparith.cc:8524
sValCmdTab::start
short start
Definition iparith.cc:127
jjCHAR
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition iparith.cc:3949
jjOP_I_IM
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
Definition iparith.cc:316
jjBRACK_Ma_IV_I
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5976
jjROWS_IV
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition iparith.cc:5025
jjLIFTSTD
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition iparith.cc:2609
jjNULL
static BOOLEAN jjNULL(leftv, leftv)
Definition iparith.cc:3784
jjNEWSTRUCT2
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition iparith.cc:2807
jjBIV2IV
static BOOLEAN jjBIV2IV(leftv res, leftv v)
Definition iparith.cc:4479
jjMONITOR2
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2742
jjDIM
static BOOLEAN jjDIM(leftv res, leftv v)
Definition iparith.cc:4158
jjCOUNT_BIM
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
Definition iparith.cc:3989
jjBRACKET
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition iparith.cc:2918
jjCOLS_IV
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition iparith.cc:3971
jjNAMES_I
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition iparith.cc:4791
jjMULT
static BOOLEAN jjMULT(leftv res, leftv v)
Definition iparith.cc:4741
jjHOMOG1_WI
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
Definition iparith.cc:2507
jjPARDEG
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition iparith.cc:4834
jjDENOMINATOR
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
Return the denominator of the input number.
Definition iparith.cc:4079
jjRANDOM
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition iparith.cc:3112
jjIDEAL_Ma
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition iparith.cc:4418
jjDIVISION
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition iparith.cc:1954
jjOP_I_IV
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:297
jjmpTransp
static BOOLEAN jjmpTransp(leftv res, leftv v)
Definition iparith.cc:5746
jjOPTION_PL
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition iparith.cc:8373
jjEQUAL_BI
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1323
jjDET_S
static BOOLEAN jjDET_S(leftv res, leftv v)
Definition iparith.cc:4152
jjL2R
static BOOLEAN jjL2R(leftv res, leftv v)
Definition iparith.cc:4580
jjREDUCE5
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition iparith.cc:8454
jjrCharStr
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition iparith.cc:5708
jjSUBST_Id_I
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6932
jjMINUS_B_P
static BOOLEAN jjMINUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:909
jjHILBERT_IV
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
Definition iparith.cc:4358
iiArithFindCmd
int iiArithFindCmd(const char *szName)
Definition iparith.cc:10023
jjIDEAL_R
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition iparith.cc:4437
jjINDEPSET
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition iparith.cc:4466
jjTYPEOF
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition iparith.cc:5426
jjLU_SOLVE
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition iparith.cc:7819
jjFACSTD
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition iparith.cc:4221
jjMEMORY
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition iparith.cc:4696
jjidTransp
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition iparith.cc:5776
jjLIFT
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition iparith.cc:2589
jjUMINUS_BIM
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition iparith.cc:3847
jjSUBST_Bu
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6836
jjTIMES_MA_N2
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
Definition iparith.cc:1125
jjDIM_R
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition iparith.cc:5771
jjSORTLIST
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition iparith.cc:10488
jjDUMP
static BOOLEAN jjDUMP(leftv, leftv v)
Definition iparith.cc:4186
jjpMaxComp
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition iparith.cc:5736
jjCOEFFS1
static BOOLEAN jjCOEFFS1(leftv res, leftv v)
Definition iparith.cc:3954
jjREDUCE3_ID
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7225
jjELIMIN_HILB
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6175
jjCOMPARE_ALL
static int jjCOMPARE_ALL(const void *aa, const void *bb)
Definition iparith.cc:10447
jjNAMEOF
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition iparith.cc:4773
jjPlural_mat_poly
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2878
jjTIMES_SM
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1152
jjMOD_BI
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2697
jjUNIQLIST
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition iparith.cc:10497
jjTIMES_MA_I2
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition iparith.cc:1134
jjSTATUS2L
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition iparith.cc:3446
proc3
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition iparith.cc:161
jjGT_I
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1191
jjPRIME
static BOOLEAN jjPRIME(leftv res, leftv v)
Definition iparith.cc:4896
jjPFAC2
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition iparith.cc:3298
jjidVec2Ideal
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition iparith.cc:5703
jjJACOB_P
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition iparith.cc:4504
jjSQR_FREE
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition iparith.cc:5197
jjSTD_HILB_W
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7288
jjEQUAL_I
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1329
jjTIMES_MA_P2
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition iparith.cc:1109
jjMODULO3
static BOOLEAN jjMODULO3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7012
jjSBA_1
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition iparith.cc:5109
SIMPL_NORM
#define SIMPL_NORM
Definition iparith.cc:3356
jjCOEFFS3_P
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6140
jjCALL1MANY
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition iparith.cc:3945
jjPLUS_MA
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:824
_scmdnames::tokval
short tokval
Definition gentable.cc:60
jjMINUS_V
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:904
jjINTERRED
static BOOLEAN jjINTERRED(leftv res, leftv v)
Definition iparith.cc:4472
jjJACOB_M
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition iparith.cc:4535
jjJET_ID_IV
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6372
jjTIMES_ID
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1055
jjBAREISS
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition iparith.cc:3879
jjREAD
static BOOLEAN jjREAD(leftv res, leftv v)
Definition iparith.cc:4971
jjLT_N
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1223
jjMINUS_MA
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:952
jjFactModD_M
static BOOLEAN jjFactModD_M(leftv res, leftv v)
Definition iparith.cc:8657
jjMATRIX_Id
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6950
jjEXTGCD_I
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2020
jjIS_RINGVAR_S
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
Definition iparith.cc:4493
jjDelete_ID
static BOOLEAN jjDelete_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1869
jjLE_N
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1210
jjSUBST_P
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6849
jjROWS_BIM
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition iparith.cc:5020
jjCOMPARE_S
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition iparith.cc:479
SIMPL_LMEQ
#define SIMPL_LMEQ
Definition iparith.cc:3352
iiInitArithmetic
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9988
jjOR_I
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1385
jjTIMES_MA_I1
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition iparith.cc:1129
jjLIFTSTD_SYZ
static BOOLEAN jjLIFTSTD_SYZ(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7149
jjBAREISS3
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6095
jjRESERVED0
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition iparith.cc:8502
jjTIMES_MA_N1
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
Definition iparith.cc:1118
jjLIFT_4
static BOOLEAN jjLIFT_4(leftv res, leftv U)
Definition iparith.cc:8129
jjSLIM_GB
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition iparith.cc:5040
jjMSTD
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition iparith.cc:4726
bit31
#define bit31
Definition iparith.cc:121
sValCmdTab::cmd
short cmd
Definition iparith.cc:126
jjBREAK1
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition iparith.cc:7339
jjJET_ID_M
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6378
jjMINUS_BIM
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:942
jjnInt
static BOOLEAN jjnInt(leftv res, leftv u)
Definition iparith.cc:5781
jjSQR_FREE2
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:3394
jjCOEFFS3_Id
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6120
jjREGULARITY
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition iparith.cc:4975
jjHOMOG_W_M
static BOOLEAN jjHOMOG_W_M(leftv res, leftv v1, leftv v2, leftv v3)
Definition iparith.cc:6312
jjMINUS_N
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:899
jjBREAK0
static BOOLEAN jjBREAK0(leftv, leftv)
Definition iparith.cc:7332
jjTRACE_IV
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition iparith.cc:5295
iiExprArith2
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9176
jjMONOM
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition iparith.cc:2783
jjSort_Id
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition iparith.cc:5192
jjCOEF_M
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition iparith.cc:7380
jjidMinBase
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition iparith.cc:5724
jjDEG_IV
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1848
jjRING_2
static BOOLEAN jjRING_2(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6083
jjMINUS_IV
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:932
jjPREIMAGE_R
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
Definition iparith.cc:4890
jjHOMOG_P
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2448
jjBRACK_Im
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5813
jjMATRIX_Ma
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6986
jjidMaxIdeal
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition iparith.cc:4401
jjMINOR_M
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition iparith.cc:6389
jjCOUNT_BI
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition iparith.cc:3984
jjPROC3
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6076
jjKERNEL_M
static BOOLEAN jjKERNEL_M(leftv res, leftv v)
Definition iparith.cc:4556
jjCOLS_BIM
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition iparith.cc:3966
jjREDUCE3_CP
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7194
SArithBase::psValCmd3
struct sValCmd3 * psValCmd3
Definition iparith.cc:186
jjBRACK_Ma_I_IV
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5926
jjLE_BI
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1201
jjPLUS_B_P
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:795
jjPlural_mat_mat
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2898
jjIDEAL_Map
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition iparith.cc:4427
jjPARSTR2
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2821
proc2
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition iparith.cc:150
jjKoszul
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition iparith.cc:2577
jjTIMES_N
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition iparith.cc:998
jjINTERSECT_PL
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
Definition iparith.cc:7664
jjTIMES_MA
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:1138
jjTIMES_IV
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1062
jjPLUS_I
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:755
jjINTERSEC3S
static BOOLEAN jjINTERSEC3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6347
jjRES3
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7233
jjBIGINTVEC_PL
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7932
jjJET_P_IV
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6355
jjREDUCE_ID
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3153
jjCOEF
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition iparith.cc:1793
iiExprArith3Tab
BOOLEAN iiExprArith3Tab(leftv res, leftv a, int op, const struct sValCmd3 *dA3, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a, a->next and a->next->next return TRUE on failure
Definition iparith.cc:9627
jjOP_REST
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:506
jjEXECUTE
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition iparith.cc:4212
jjDEG_M_IV
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1837
jjSTATUS3
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7279
jjLEADEXP
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition iparith.cc:4602
jjDEG_M
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition iparith.cc:4039
jjPLUS_IV
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:804
jjDIFF_COEF
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
Definition iparith.cc:4516
iiArithRemoveCmd
int iiArithRemoveCmd(char *szName)
jjGE_N
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1178
jjEQUAL_SM
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1341
jjINTERPOLATION
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition iparith.cc:2527
jjSIMPL_ID
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3357
jjRING3
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7274
jjREDUCE_P
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3145
jjDIV_Ma
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1294
jjFRES3
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:2312
jjMODULO
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition iparith.cc:2644
jjCOMPARE_IV
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:339
WerrorS_dummy_cnt
STATIC_VAR int WerrorS_dummy_cnt
Definition iparith.cc:5662
jjREAD2
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition iparith.cc:3129
jjREDUCE3_P
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7218
jjPAR1
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition iparith.cc:4818
jjnlInt
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition iparith.cc:5788
SArithBase::sCmds
cmdnames * sCmds
array of existing commands
Definition iparith.cc:183
jjFAREY_ID
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2145
jjPLUS_ID
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:873
jjGCD_N
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2387
jjELIMIN
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition iparith.cc:1974
jjPLUSPLUS
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition iparith.cc:3798
jjMakeSub
static Subexpr jjMakeSub(leftv e)
Definition iparith.cc:8970
jjCHINREM_BI
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1682
jjROWS
static BOOLEAN jjROWS(leftv res, leftv v)
Definition iparith.cc:5014
jjJET_ID
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2555
iiExprArith2TabIntern
static BOOLEAN iiExprArith2TabIntern(leftv res, leftv a, int op, leftv b, BOOLEAN proccall, const struct sValCmd2 *dA2, int at, int bt, const struct sConvertTypes *dConvertTypes)
Definition iparith.cc:9003
IsCmd
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9773
jjSBA
static BOOLEAN jjSBA(leftv res, leftv v)
Definition iparith.cc:5082
jjOP_IM_I
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:301
jjJanetBasis
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition iparith.cc:2545
jjKBASE
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition iparith.cc:4574
jjTENSOR
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
Definition iparith.cc:3644
jjmpTrace
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition iparith.cc:5741
jjRING_PL
static BOOLEAN jjRING_PL(leftv res, leftv a)
Definition iparith.cc:8948
jjREDUCE4
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition iparith.cc:8383
jjFWALK
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition iparith.cc:2361
jjTEST
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8638
jjDIFF_ID_ID
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1932
jjSYZ_2
static BOOLEAN jjSYZ_2(leftv res, leftv u, leftv v)
Definition iparith.cc:3572
jjPRUNE
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition iparith.cc:4902
jjDIVISION4
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition iparith.cc:7397
SArithBase::nLastIdentifier
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition iparith.cc:190
jjDEFINED
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition iparith.cc:4067
jjLagSolve
static BOOLEAN jjLagSolve(leftv res, leftv v)
Definition iparith.cc:4657
jjRING_1
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
Definition iparith.cc:1673
jjVDIM
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition iparith.cc:5514
jjHILBERT3Qt
static BOOLEAN jjHILBERT3Qt(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6254
jjOP_I_BIM
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:259
jjCOUNT_N
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition iparith.cc:3995
jjHILBERT2
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition iparith.cc:2410
jjFIND2
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition iparith.cc:2294
jjCOEF_Id
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1800
jjP2N
static BOOLEAN jjP2N(leftv res, leftv v)
Definition iparith.cc:4926
jjE
static BOOLEAN jjE(leftv res, leftv v)
Definition iparith.cc:4200
jjPOWER_ID
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:625
jjTIMES_MA_BI1
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition iparith.cc:1086
iiExprArith1
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9365
jjSTD_HILB_WP
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition iparith.cc:8864
jjLISTRING
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition iparith.cc:4639
jjCOEFFS2_KB
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition iparith.cc:1818
SIMPL_NULL
#define SIMPL_NULL
Definition iparith.cc:3355
jjLIFTSTD_M
static BOOLEAN jjLIFTSTD_M(leftv res, leftv U)
Definition iparith.cc:8160
jjELIMIN_ALG
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6167
jjVAR1
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition iparith.cc:5480
jjLEADCOEF
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition iparith.cc:4588
jjVARSTR2
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:3670
jjPLUS_N
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:772
jjSUBST_Id_X
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v, leftv w, int input_type)
Definition iparith.cc:6940
jjUMINUS_BI
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition iparith.cc:3810
iiArithAddCmd
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition iparith.cc:10118
jjpLength
static BOOLEAN jjpLength(leftv res, leftv v)
Definition iparith.cc:5688
jjJET_P_P
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6362
jjLT_I
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1218
jjIS_RINGVAR0
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition iparith.cc:4499
jjEXTGCD_BI
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2006
jjBI2P
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition iparith.cc:3930
jjTWOSTD
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition iparith.cc:5344
jjGCD_I
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2367
jjCONTRACT
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition iparith.cc:1832
_scmdnames::toktype
short toktype
Definition gentable.cc:61
jjFAC_P
static BOOLEAN jjFAC_P(leftv res, leftv u)
Definition iparith.cc:4261
jjREDUCE3_CID
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7206
jjFAREY_LI
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition iparith.cc:10428
jjTRANSP_BIM
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition iparith.cc:5300
jjCOUNT_RES
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition iparith.cc:5766
ii_div_by_0
#define ii_div_by_0
Definition iparith.cc:217
jjDelete_IV
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1862
jjGE_BI
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1166
jjrOrdStr
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition iparith.cc:5751
jjKERNEL
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition iparith.cc:2573
jjINTERSECT3
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6334
jjBRACK_Ma
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5868
jjValCmdTab
sValCmdTab jjValCmdTab[]
Definition iparith.cc:130
jjMOD_N
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2708
jjLOAD_E
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition iparith.cc:2633
jjNEWSTRUCT3
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6668
jjHOMOG_P_W
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6294
jjpHead
static BOOLEAN jjpHead(leftv res, leftv v)
Definition iparith.cc:5713
jjSUBST_Id
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6882
jjEQUAL_R
static BOOLEAN jjEQUAL_R(leftv res, leftv u, leftv v)
Definition iparith.cc:1347
jjCOUNT_L
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition iparith.cc:4000
SArithBase::psValCmdM
struct sValCmdM * psValCmdM
Definition iparith.cc:187
jjDET_I
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition iparith.cc:4138
jjCOUNT_RG
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition iparith.cc:4017
jjSMATRIX_Mo
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7114
jjINTERSECT
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition iparith.cc:2521
jjrVarStr
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition iparith.cc:5756
jjOP_BI_BIM
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:276
jjDIFF_P
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1910
check_valid
static BOOLEAN check_valid(const int p, const int op)
Definition iparith.cc:10177
jjSTRING_PL
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition iparith.cc:8604
jjMINUS_B
static BOOLEAN jjMINUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:919
jjRSUM
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
Definition iparith.cc:3343
jjINDEX_I
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1390
jjPOWER_BI
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:568
jjMONITOR1
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition iparith.cc:2738
jjKLAMMER_IV
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1572
jjFETCH
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition iparith.cc:2166
jjCALL3ARG
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition iparith.cc:7368
jjSTD_1
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition iparith.cc:3496
jjUMINUS_N
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition iparith.cc:3822
jjNUMERATOR
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
Return the numerator of the input number.
Definition iparith.cc:4088
jjORD
static BOOLEAN jjORD(leftv res, leftv v)
Definition iparith.cc:4812
jjTIMES_P
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1008
jjUMINUS_I
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
Definition iparith.cc:3817
jjPREIMAGE
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6678
jjBRACK_Ma_IV_IV
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6025
jjMRES_MAP
static BOOLEAN jjMRES_MAP(leftv res, leftv u, leftv v, leftv ma)
Definition iparith.cc:6585
jjPLUS_SM
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:836
jjLOAD_TRY
BOOLEAN jjLOAD_TRY(const char *s)
Definition iparith.cc:5667
jjLIFT3
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7127
jjENVELOPE
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition iparith.cc:5329
jjSetRing
static BOOLEAN jjSetRing(leftv, leftv u)
Definition iparith.cc:3855
iiOp
VAR int iiOp
Definition iparith.cc:219
jjMINUS_BI
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:894
jjTIMES_BI
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:991
jjFACSTD2
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition iparith.cc:2112
jjINTVEC_PL
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7900
sArithBase
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
Definition iparith.cc:198
jjEXPORTTO
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition iparith.cc:1994
jjPlural_num_poly
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2838
jjDIV_P
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1276
jjKBASE2
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition iparith.cc:2560
jjPOWER_I
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition iparith.cc:522
SIMPL_MULT
#define SIMPL_MULT
Definition iparith.cc:3353
jjRES
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition iparith.cc:3162
iin_Int
static int iin_Int(number &n, coeffs cf)
Definition iparith.cc:222
jjPLUS_P_MA
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:859
jjMINRES_R
static BOOLEAN jjMINRES_R(leftv res, leftv v)
Definition iparith.cc:4747
jjCOLS
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition iparith.cc:3961
jjPLUS_BIM
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:814
jjP2BI
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition iparith.cc:4858
WerrorS_dummy
static void WerrorS_dummy(const char *)
Definition iparith.cc:5663
jjGE_I
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1173
farey_cnt
long farey_cnt
Definition iparith.cc:9
jjTRANSP_IV
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
Definition iparith.cc:5305
jjGT_N
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1196
jjUNIVARIATE
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition iparith.cc:5475
jjMODULO4
static BOOLEAN jjMODULO4(leftv res, leftv u)
Definition iparith.cc:8301
jjHOMOG_ID_W
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6276
jjWEDGE
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition iparith.cc:3755
jjCOMPARE_P
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:452
jjFIND3
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6184
jjLU_INVERSE
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition iparith.cc:7738
jjMODULO3S
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7063
jjBAREISS_BIM
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
Definition iparith.cc:3902
jjPLUS_MA_P
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
Definition iparith.cc:848
jjSIMPL_P
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3452
jjPFAC1
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition iparith.cc:4648
jjQRDS
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition iparith.cc:8847
jjELIMIN_IV
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1980
jjCONTENT
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition iparith.cc:3976
jjDIFF_ID
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1921
jjSTD
static BOOLEAN jjSTD(leftv res, leftv v)
Definition iparith.cc:5163
jjTIMES_BIM
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:1074
jjTIMES_I
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition iparith.cc:978
jjDIV_N
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1263
jjINTMAT3
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6320
jjCOUNT_IV
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition iparith.cc:4012
jjFRES
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
Definition iparith.cc:2351
SArithBase::nCmdAllocated
unsigned nCmdAllocated
number of commands-slots allocated
Definition iparith.cc:189
jjDUMMY
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition iparith.cc:3777
jjS2I
static BOOLEAN jjS2I(leftv res, leftv v)
Definition iparith.cc:5035
jjKLAMMER
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
Definition iparith.cc:1560
iiExprArith2Tab
BOOLEAN iiExprArith2Tab(leftv res, leftv a, int op, const struct sValCmd2 *dA2, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a and a->next return TRUE on failure
Definition iparith.cc:9162
jjBI2N
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition iparith.cc:3909
_scmdnames::alias
short alias
Definition gentable.cc:59
jjRIGHTSTD
static BOOLEAN jjRIGHTSTD(leftv res, leftv v)
Definition iparith.cc:5363
iiExprArithM
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9666
jjCOMPARE_MA
static BOOLEAN jjCOMPARE_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:424
iiExprArith3
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition iparith.cc:9575
jjGETDUMP
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition iparith.cc:4277
jjidFreeModule
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition iparith.cc:5698
jjFAREY_BI
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2134
jjBRACKET_REC
static BOOLEAN jjBRACKET_REC(leftv res, leftv a, leftv b, leftv c)
Definition iparith.cc:2945
jjCOMPARE_IV_I
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:397
jjRANDOM_Im
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6761
jjRESERVEDNAME
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition iparith.cc:4942
SArithBase::psValCmd1
struct sValCmd1 * psValCmd1
Definition iparith.cc:184
jjDIVMOD_I
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1227
jjLE_I
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1205
jjTENSOR_Ma
static BOOLEAN jjTENSOR_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:3651
jjCOEFFS3_KB
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6134
iiExprArith3TabIntern
static BOOLEAN iiExprArith3TabIntern(leftv res, int op, leftv a, leftv b, leftv c, const struct sValCmd3 *dA3, int at, int bt, int ct, const struct sConvertTypes *dConvertTypes)
Definition iparith.cc:9422
jjRMINUS
static BOOLEAN jjRMINUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3324
jjPROC
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition iparith.cc:1617
jjPLUS_BI
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:767
jjHILBERT3
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6224
jjDET2
static BOOLEAN jjDET2(leftv res, leftv u, leftv v)
Definition iparith.cc:1896
jjSTD_HILB
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
Definition iparith.cc:3468
jjAND_I
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1380
jjINDEX_P_IV
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1488
jjRPAR
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition iparith.cc:5030
jjJanetBasis2
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition iparith.cc:2539
jjLOAD1
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition iparith.cc:4635
jjCOLON
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition iparith.cc:320
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition iparith.cc:9897
jjRPLUS
static BOOLEAN jjRPLUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3330
jjKERNEL_SM
static BOOLEAN jjKERNEL_SM(leftv res, leftv v)
Definition iparith.cc:4565
jjCOLCOL
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
Definition iparith.cc:693
all_farey
long all_farey
Definition iparith.cc:8
jjFAC_P2
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:2065
jjHOMOG_ID
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2465
jjrParStr
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition iparith.cc:5761
SArithBase::psValCmd2
struct sValCmd2 * psValCmd2
Definition iparith.cc:185
jjDEG
static BOOLEAN jjDEG(leftv res, leftv v)
Definition iparith.cc:4031
jjFETCH_M
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition iparith.cc:7539
jjINDEX_V
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1517
jjRINGLIST
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition iparith.cc:4985
jjidElem
static BOOLEAN jjidElem(leftv res, leftv v)
Definition iparith.cc:5693
jjDIM2
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
Definition iparith.cc:1937
jjOP_BIM_BI
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:263
jjGCD_BI
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2380
jjBI2IM
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition iparith.cc:3924
jjRANK2
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition iparith.cc:3120
jjDEGREE
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition iparith.cc:4050
jjLIFTSTD_ALG
static BOOLEAN jjLIFTSTD_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7172
jjINDEPSET2
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition iparith.cc:2514
jjWAITALL2
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition iparith.cc:3707
jjOpenClose
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition iparith.cc:4806
jjBRACK_S
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5797
jjUMINUS_P
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition iparith.cc:3829
jjMINUS_SM
static BOOLEAN jjMINUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:965
jjHIGHCORNER_M
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
Definition iparith.cc:4298
jjNAMES
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition iparith.cc:4786
jjINDEX_P
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1448
jjHIGHCORNER
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition iparith.cc:4291
jjEQUAL_Ma
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1335
jjNAMES0
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition iparith.cc:8368
SIMPL_NORMALIZE
#define SIMPL_NORMALIZE
Definition iparith.cc:3350
jjLOAD2
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition iparith.cc:2629
jjALIGN_M
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition iparith.cc:1779
jjWAIT1ST2
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
Definition iparith.cc:3683
jjDIV_BI
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1250
jjCOMPARE_BIM
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:367
jjEQUAL_N
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1353
jjDelete_ID_IV
static BOOLEAN jjDelete_ID_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1876
jjDET2_S
static BOOLEAN jjDET2_S(leftv res, leftv u, leftv v)
Definition iparith.cc:1903
jjCOEFFS_Id
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1807
Tok2Cmdname_buf
STATIC_VAR si_char_2 Tok2Cmdname_buf
Definition iparith.cc:9896
jjPROC1
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition iparith.cc:3875
jjNOT
static BOOLEAN jjNOT(leftv res, leftv v)
Definition iparith.cc:4796
jjPARSTR1
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition iparith.cc:4840
jjSUBST_Id_N
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6936
jjJET4
static BOOLEAN jjJET4(leftv res, leftv u)
Definition iparith.cc:7993
jjOPPOSE
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition iparith.cc:2986
jjMOD_P
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2719
iiExprArith1Tab
BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1 *dA1, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to an argument a return TRUE on failure
Definition iparith.cc:9235
jjPLUS_B
static BOOLEAN jjPLUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:782
jjGCD_P
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2404
jjHOMOG1
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition iparith.cc:4368
jjDET
static BOOLEAN jjDET(leftv res, leftv v)
Definition iparith.cc:4096
jjEQUAL_REST
static void jjEQUAL_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:1367
jjCOUNT_M
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
Definition iparith.cc:4006
jjPLUS_V
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:777
SIMPL_LMDIV
#define SIMPL_LMDIV
Definition iparith.cc:3351
iiTokType
int iiTokType(int op)
Definition iparith.cc:230
jjKoszul_Id
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:2581
jjKLAMMER_rest
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition iparith.cc:1599
jjCHINREM_ID
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:10229
jjPLUS_S
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition iparith.cc:863
jjHOMOG1_W
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition iparith.cc:2487
jjSBA_2
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition iparith.cc:5136
jjINDEX_IV
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1412
si_char_2
char si_char_2[2]
Definition iparith.cc:9895
SArithBase::nCmdUsed
unsigned nCmdUsed
number of commands used
Definition iparith.cc:188
jjRING_LIST
static BOOLEAN jjRING_LIST(leftv res, leftv v)
Definition iparith.cc:5007
jjBRACK_SM
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5897
jjSUBST_Test
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition iparith.cc:6808
jjMINUS_I
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:878
jjJET_P
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2550
jjVARSTR1
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition iparith.cc:5497
iiArithGetCmd
char * iiArithGetCmd(int nPos)
Definition iparith.cc:10083
jjSTATUS_M
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition iparith.cc:8789
jjCALL1ARG
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition iparith.cc:7356
jjPRUNE_MAP
static BOOLEAN jjPRUNE_MAP(leftv res, leftv v, leftv ma)
Definition iparith.cc:3059
jjLT_BI
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1214
jjPOWER_P
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition iparith.cc:602
jjLIST_PL
BOOLEAN jjLIST_PL(leftv res, leftv v)
Definition iparith.cc:8250
jjPLUSMINUS_Gen
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition iparith.cc:631
jjCALL2ARG
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7360
jjINDEX_PBu
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
Definition iparith.cc:1465
iiTabIndex
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
Definition iparith.cc:9872
jjSYZYGY
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition iparith.cc:5224
jjPOWER_N
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
Definition iparith.cc:584
jjKLAMMER_PL
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
Definition iparith.cc:8076
jjSUBST_M
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition iparith.cc:8820
jjEQUAL_P
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1359
jjLU_DECOMP
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
Definition iparith.cc:4666
jjPlural_num_mat
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2858
jjIDEAL_PL
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition iparith.cc:7496
jjNVARS
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition iparith.cc:4801
jjERROR
static BOOLEAN jjERROR(leftv, leftv u)
Definition iparith.cc:1999
jjSTATUS2
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition iparith.cc:3441
jjALIGN_V
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1769
jjRINGLIST_C
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
Definition iparith.cc:5000
SArithBase
Definition iparith.cc:182
_scmdnames
Definition gentable.cc:57
sValCmdTab
Definition iparith.cc:125
iiConvert
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:450
sConvertTypes
Definition gentable.cc:116
ipconv.h
dConvertTypes
const struct sConvertTypes dConvertTypes[]
Definition table.h:1321
sip_command_bin
VAR omBin sip_command_bin
Definition ipid.cc:45
ipNameListLev
lists ipNameListLev(idhdl root, int lev)
Definition ipid.cc:650
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:279
basePack
VAR package basePack
Definition ipid.cc:56
currRingHdl
VAR idhdl currRingHdl
Definition ipid.cc:57
currPack
VAR package currPack
Definition ipid.cc:55
ipNameList
lists ipNameList(idhdl root)
Definition ipid.cc:627
ipid.h
IDMAP
#define IDMAP(a)
Definition ipid.h:135
IDMATRIX
#define IDMATRIX(a)
Definition ipid.h:134
sleftv_bin
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
command
ip_command * command
Definition ipid.h:23
IDDATA
#define IDDATA(a)
Definition ipid.h:126
hasFlag
#define hasFlag(A, F)
Definition ipid.h:112
setFlag
#define setFlag(A, F)
Definition ipid.h:113
IDIDEAL
#define IDIDEAL(a)
Definition ipid.h:133
IDPOLY
#define IDPOLY(a)
Definition ipid.h:130
IDID
#define IDID(a)
Definition ipid.h:122
IDROOT
#define IDROOT
Definition ipid.h:19
IDINT
#define IDINT(a)
Definition ipid.h:125
FLAG_TWOSTD
#define FLAG_TWOSTD
Definition ipid.h:107
load_builtin
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition iplib.cc:1304
IDPACKAGE
#define IDPACKAGE(a)
Definition ipid.h:139
IDLEV
#define IDLEV(a)
Definition ipid.h:121
SModulFunc_t
int(* SModulFunc_t)(SModulFunctions *)
Definition ipid.h:81
IDRING
#define IDRING(a)
Definition ipid.h:127
IDTYP
#define IDTYP(a)
Definition ipid.h:119
FLAG_STD
#define FLAG_STD
Definition ipid.h:106
iiLoadLIB
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition iplib.cc:983
iiConvName
char * iiConvName(const char *libname)
Definition iplib.cc:1439
iiGetLibStatus
BOOLEAN iiGetLibStatus(const char *lib)
Definition iplib.cc:77
iiMake_proc
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:513
iiTryLoadLib
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition iplib.cc:832
load_modules
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition iplib.cc:1294
iiRETURNEXPR
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:483
iiGetBuiltinModInit
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition iplib.cc:816
ipprint.h
rDecompose
lists rDecompose(const ring r)
Definition ipshell.cc:2153
rDecompose_list_cf
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2114
iiCheckTypes
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition ipshell.cc:6576
rInit
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5628
iiMap
leftv iiMap(map theMap, const char *what)
Definition ipshell.cc:618
iiRegularity
int iiRegularity(lists L)
Definition ipshell.cc:1045
rDecompose_CF
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition ipshell.cc:1943
iiMakeResolv
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition ipshell.cc:854
killlocals
void killlocals(int v)
Definition ipshell.cc:387
exprlist_length
int exprlist_length(leftv v)
Definition ipshell.cc:551
mpKoszul
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition ipshell.cc:3086
iiHighCorner
poly iiHighCorner(ideal I, int ak)
the largest monomial in R/I
Definition ipshell.cc:1606
scIndIndset
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition ipshell.cc:1111
rFindHdl
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1701
syConvList
syStrategy syConvList(lists li)
Definition ipshell.cc:3250
test_cmd
void test_cmd(int i)
Definition ipshell.cc:513
rCompose
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition ipshell.cc:2782
lastreserved
const char * lastreserved
Definition ipshell.cc:83
syConvRes
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3178
rSetHdl
void rSetHdl(idhdl h)
Definition ipshell.cc:5129
iiExport
BOOLEAN iiExport(leftv v, int toLev)
Definition ipshell.cc:1510
ipshell.h
dArith1
const struct sValCmd1 dArith1[]
Definition table.h:38
sValCmd1::arg
short arg
Definition gentable.cc:80
sValCmd2::res
short res
Definition gentable.cc:70
proc3
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition ipshell.h:147
sValCmd3::p
int p
Definition gentable.cc:85
sValCmd2::arg1
short arg1
Definition gentable.cc:71
sValCmd1::p
int p
Definition gentable.cc:77
dArith2
const struct sValCmd2 dArith2[]
Definition table.h:325
sValCmdM::number_of_args
short number_of_args
Definition gentable.cc:98
sValCmdM::valid_for
short valid_for
Definition gentable.cc:99
proc2
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition ipshell.h:136
setOption
BOOLEAN setOption(leftv res, leftv v)
Definition misc_ip.cc:570
sValCmd3::cmd
short cmd
Definition gentable.cc:86
sValCmd2::cmd
short cmd
Definition gentable.cc:69
sValCmd3::valid_for
short valid_for
Definition gentable.cc:91
sValCmd1::cmd
short cmd
Definition gentable.cc:78
sValCmd2::valid_for
short valid_for
Definition gentable.cc:73
sValCmdM::res
short res
Definition gentable.cc:97
sValCmd3::res
short res
Definition gentable.cc:87
sValCmd3::arg1
short arg1
Definition gentable.cc:88
sValCmdM::p
int p
Definition gentable.cc:95
sValCmd3::arg2
short arg2
Definition gentable.cc:89
proc1
BOOLEAN(* proc1)(leftv, leftv)
Definition ipshell.h:124
dArithM
const struct sValCmdM dArithM[]
Definition table.h:937
sValCmd1::valid_for
short valid_for
Definition gentable.cc:81
sValCmd3::arg3
short arg3
Definition gentable.cc:90
sValCmd2::p
int p
Definition gentable.cc:68
sValCmd1::res
short res
Definition gentable.cc:79
sValCmd2::arg2
short arg2
Definition gentable.cc:72
dArith3
const struct sValCmd3 dArith3[]
Definition table.h:801
sValCmdM::cmd
short cmd
Definition gentable.cc:96
sValCmd1
Definition gentable.cc:76
sValCmd2
Definition gentable.cc:67
sValCmd3
Definition gentable.cc:84
sValCmdM
Definition gentable.cc:94
T
STATIC_VAR jList * T
Definition janet.cc:30
h
STATIC_VAR Poly * h
Definition janet.cc:971
next
ListNode * next
Definition janet.h:31
id_Farey_0
ideal id_Farey_0(ideal x, number N, const ring r)
Definition kChinese.cc:330
kChinese.h
nc.h
fglm.h
kHomModDeg
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
kMin_std2
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3069
kInterRed
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3802
kStd2
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
kSba
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw)
Definition kstd1.cc:2668
kHomW
VAR intvec * kHomW
Definition kstd1.cc:2409
kModW
VAR intvec * kModW
Definition kstd1.cc:2409
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3229
kstd1.h
Kstd1_deg
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
rightgb
ideal rightgb(ideal F, const ideal Q)
Definition kstd2.cc:4935
redNF
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2307
kStdfac
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition kstdfac.cc:800
kstdfac.h
showOption
char * showOption()
Definition misc_ip.cc:711
h0
VAR idhdl h0
Definition libparse.cc:1143
libnamebuf
VAR char libnamebuf[1024]
Definition libparse.cc:1098
nc.h
rIsSCA
static bool rIsSCA(const ring r)
Definition nc.h:190
idOppose
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
Definition old.gring.cc:3363
pOppose
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition old.gring.cc:3324
rIsLikeOpposite
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
Definition old.gring.cc:3297
nc_CallPlural
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition old.gring.cc:2692
nc_p_Bracket_qq
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition old.gring.cc:2251
luRank
int luRank(const matrix aMat, const bool isRowEchelon, const ring R)
Computes the rank of a given (m x n)-matrix.
Definition linearAlgebra.cc:230
luInverseFromLUDecomp
bool luInverseFromLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, matrix &iMat, const ring R)
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplicat...
Definition linearAlgebra.cc:352
henselFactors
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x,...
Definition linearAlgebra.cc:1228
luInverse
bool luInverse(const matrix aMat, matrix &iMat, const ring R)
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matr...
Definition linearAlgebra.cc:200
luDecomp
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
Definition linearAlgebra.cc:103
luSolveViaLUDecomp
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
Definition linearAlgebra.cc:377
linearAlgebra.h
qrDoubleShift
lists qrDoubleShift(const matrix A, const number tol1, const number tol2, const number tol3, const ring r=currRing)
Computes all eigenvalues of a given real quadratic matrix with multiplicites.
Definition linearAlgebra_ip.cc:41
linearAlgebra_ip.h
slists_bin
VAR omBin slists_bin
Definition lists.cc:23
lSize
int lSize(lists L)
Definition lists.cc:25
lists.h
jjANY2LIST
BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
nlDelete
LINLINE void nlDelete(number *a, const coeffs r)
Definition longrat.cc:2637
nlInit
LINLINE number nlInit(long i, const coeffs r)
Definition longrat.cc:2577
maFetchPermLP
void maFetchPermLP(const ring preimage_r, const ring dst_r, int *perm)
Definition maps.cc:298
maFindPerm
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition maps.cc:155
maFindPermLP
void maFindPermLP(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
Definition maps.cc:223
maps.h
pSubstPoly
poly pSubstPoly(poly p, int var, poly image)
Definition maps_ip.cc:403
idSubstPoly
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:425
maApplyFetch
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition maps_ip.cc:45
idSubstPar
ideal idSubstPar(ideal id, int n, poly e)
Definition maps_ip.cc:386
pSubstPar
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:266
maps_ip.h
mp_IsDiagUnit
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc:810
mp_Wedge
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition matpol.cc:1745
mp_Transp
matrix mp_Transp(matrix a, const ring R)
Definition matpol.cc:247
sm_Tensor
ideal sm_Tensor(ideal A, ideal B, const ring r)
Definition matpol.cc:1827
sm_Add
ideal sm_Add(ideal a, ideal b, const ring R)
Definition matpol.cc:1867
mp_CoeffProc
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition matpol.cc:392
pMultMp
matrix pMultMp(poly p, matrix a, const ring R)
Definition matpol.cc:158
mp_Monomials
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition matpol.cc:355
mp_GetAlgorithmDet
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition matpol.cc:2108
mp_CoeffProcId
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
Definition matpol.cc:469
sm_Det
poly sm_Det(ideal a, const ring r, DetVariant d)
Definition matpol.cc:2163
mp_MultI
matrix mp_MultI(matrix a, long f, const ring R)
c = f*a
Definition matpol.cc:128
sm_Sub
ideal sm_Sub(ideal a, ideal b, const ring R)
Definition matpol.cc:1877
sm_Mult
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition matpol.cc:1887
mp_Sub
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition matpol.cc:189
mp_Det
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition matpol.cc:2139
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
mp_Compare
int mp_Compare(matrix a, matrix b, const ring R)
Definition matpol.cc:637
sm_Equal
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition matpol.cc:1999
mp_Mult
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition matpol.cc:206
mp_Equal
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition matpol.cc:656
mp_Coeffs
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple's coeffs: var has to be the number of a variable
Definition matpol.cc:306
mp_Coef2
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
Definition matpol.cc:574
mp_MultP
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
Definition matpol.cc:141
mp_Copy
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
mp_Add
matrix mp_Add(matrix a, matrix b, const ring R)
Definition matpol.cc:172
mp_InitP
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition matpol.cc:106
mp_Trace
poly mp_Trace(matrix a, const ring R)
Definition matpol.cc:268
matpol.h
MATELEM
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
matrix
ip_smatrix * matrix
Definition matpol.h:43
MATROWS
#define MATROWS(i)
Definition matpol.h:26
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27
DetVariant
DetVariant
Definition matpol.h:35
primeFactorisation
lists primeFactorisation(const number n, const int pBound)
Factorises a given bigint number n into its prime factors less than or equal to a given bound,...
Definition misc_ip.cc:358
misc_ip.h
This file provides miscellaneous functionality.
mod2.h
TIMER_RESOLUTION
#define TIMER_RESOLUTION
Definition mod2.h:35
assume
#define assume(x)
Definition mod2.h:389
type_of_LIB
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition mod_lib.cc:27
mod_lib.h
lib_types
lib_types
Definition mod_raw.h:16
LT_MACH_O
@ LT_MACH_O
Definition mod_raw.h:16
LT_HPUX
@ LT_HPUX
Definition mod_raw.h:16
LT_SINGULAR
@ LT_SINGULAR
Definition mod_raw.h:16
LT_BUILTIN
@ LT_BUILTIN
Definition mod_raw.h:16
LT_ELF
@ LT_ELF
Definition mod_raw.h:16
LT_NONE
@ LT_NONE
Definition mod_raw.h:16
LT_NOTFOUND
@ LT_NOTFOUND
Definition mod_raw.h:16
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pSetCoeff0
#define pSetCoeff0(p, n)
Definition monomials.h:59
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
nuLagSolve
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
Definition ipshell.cc:4681
lists
slists * lists
Definition mpr_numeric.h:146
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
ap
Definition ap.h:40
twostd
ideal twostd(ideal I)
Compute two-sided GB:
Definition nc.cc:18
newstruct_setup
void newstruct_setup(const char *n, newstruct_desc d)
Definition newstruct.cc:699
newstructChildFromString
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition newstruct.cc:810
newstructFromString
newstruct_desc newstructFromString(const char *s)
Definition newstruct.cc:803
newstruct.h
number2.h
ndConvSingNFactoryN
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition numbers.cc:313
numbers.h
nDiv
#define nDiv(a, b)
Definition numbers.h:32
nDelete
#define nDelete(n)
Definition numbers.h:16
nInpNeg
#define nInpNeg(n)
Definition numbers.h:21
nIsZero
#define nIsZero(n)
Definition numbers.h:19
nEqual
#define nEqual(n1, n2)
Definition numbers.h:20
nSub
#define nSub(n1, n2)
Definition numbers.h:22
nCopy
#define nCopy(n)
Definition numbers.h:15
nGreater
#define nGreater(a, b)
Definition numbers.h:28
nAdd
#define nAdd(n1, n2)
Definition numbers.h:18
nSize
#define nSize(n)
Definition numbers.h:39
nInvers
#define nInvers(a)
Definition numbers.h:33
nIsOne
#define nIsOne(n)
Definition numbers.h:25
nNormalize
#define nNormalize(n)
Definition numbers.h:30
nInit
#define nInit(i)
Definition numbers.h:24
nMult
#define nMult(n1, n2)
Definition numbers.h:17
nPower
#define nPower(a, b, res)
Definition numbers.h:38
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omfree
#define omfree(addr)
Definition omAllocDecl.h:237
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206
omRealloc
#define omRealloc(addr, size)
Definition omAllocDecl.h:225
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
omFreeBinAddr
#define omFreeBinAddr(addr)
Definition omAllocDecl.h:258
NULL
#define NULL
Definition omList.c:12
om_Info
omInfo_t om_Info
Definition omStats.c:16
si_opt_2
VAR unsigned si_opt_2
Definition options.c:6
si_opt_1
VAR unsigned si_opt_1
Definition options.c:5
options.h
SI_SAVE_OPT2
#define SI_SAVE_OPT2(A)
Definition options.h:22
Sy_bitL
#define Sy_bitL(x)
Definition options.h:32
BVERBOSE
#define BVERBOSE(a)
Definition options.h:35
OPT_REDTAIL_SYZ
#define OPT_REDTAIL_SYZ
Definition options.h:88
OPT_SB_1
#define OPT_SB_1
Definition options.h:96
SI_SAVE_OPT1
#define SI_SAVE_OPT1(A)
Definition options.h:21
SI_RESTORE_OPT1
#define SI_RESTORE_OPT1(A)
Definition options.h:24
SI_RESTORE_OPT2
#define SI_RESTORE_OPT2(A)
Definition options.h:25
Sy_bit
#define Sy_bit(x)
Definition options.h:31
TEST_OPT_DEGBOUND
#define TEST_OPT_DEGBOUND
Definition options.h:115
TEST_OPT_RETURN_SB
#define TEST_OPT_RETURN_SB
Definition options.h:114
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
V_IMAP
#define V_IMAP
Definition options.h:53
V_DEG_STOP
#define V_DEG_STOP
Definition options.h:73
V_SHOW_USE
#define V_SHOW_USE
Definition options.h:52
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592
pRestoreDegProcs
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
p_Homogen
poly p_Homogen(poly p, int varnum, const ring r)
Definition p_polys.cc:3319
pp_DivideM
poly pp_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1637
p_Shift
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4860
p_Normalize
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
p_MaxExpPerVar
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5146
p_Compare
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5050
p_Series
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4652
p_DegW
long p_DegW(poly p, const int *w, const ring R)
Definition p_polys.cc:691
p_Cleardenom
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
p_Vec2Poly
poly p_Vec2Poly(poly v, int k, const ring r)
Definition p_polys.cc:3698
p_SetModDeg
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3798
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
pSetDegProcs
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3762
p_Deg
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_MinComp
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167
p_Totaldegree
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1528
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pp_Divide
poly pp_Divide(poly p, poly q, const ring r)
polynomial division a/b, ignoring the rest via singclap_pdivide resp. idLift does not destroy a,...
Definition polys.cc:178
singclap_gcd
poly singclap_gcd(poly f, poly g, const ring r)
polynomial gcd via singclap_gcd_r resp. idSyzygies destroys f and g
Definition polys.cc:409
polys.h
Compatibility layer for legacy polynomial operations (over currRing).
pAdd
#define pAdd(p, q)
Definition polys.h:204
pTotaldegree
static long pTotaldegree(poly p)
Definition polys.h:283
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
pHead
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
pSetm
#define pSetm(p)
Definition polys.h:272
pIsConstant
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
pSplit
#define pSplit(p, r)
Definition polys.h:266
pNeg
#define pNeg(p)
Definition polys.h:199
pGetComp
#define pGetComp(p)
Component.
Definition polys.h:38
pDiff
#define pDiff(a, b)
Definition polys.h:297
pSetCoeff
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
pNorm
void pNorm(poly p)
Definition polys.h:363
pNSet
#define pNSet(n)
Definition polys.h:314
pVar
#define pVar(m)
Definition polys.h:381
pJet
#define pJet(p, m)
Definition polys.h:368
pSub
#define pSub(a, b)
Definition polys.h:288
ppMult_qq
#define ppMult_qq(p, q)
Definition polys.h:209
ppJetW
#define ppJetW(p, m, iv)
Definition polys.h:369
pMaxComp
#define pMaxComp(p)
Definition polys.h:300
pLmInit
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
pIsUnit
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition polys.h:241
pPower
#define pPower(p, q)
Definition polys.h:205
pSetComp
#define pSetComp(p, v)
Definition polys.h:39
pLmDelete
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
pMult
#define pMult(p, q)
Definition polys.h:208
pLmFree
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
pSubst
#define pSubst(p, n, e)
Definition polys.h:366
pSeries
#define pSeries(n, p, u, w)
Definition polys.h:372
pGetExp
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
pNormalize
#define pNormalize(p)
Definition polys.h:318
pInit
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
pEqualPolys
#define pEqualPolys(p1, p2)
Definition polys.h:400
pSetExp
#define pSetExp(p, i, v)
Definition polys.h:43
pLmCmp
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
pCopy
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
pLmFreeAndNext
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition polys.h:75
pOne
#define pOne()
Definition polys.h:316
pIsUnivariate
#define pIsUnivariate(p)
Definition polys.h:250
pISet
#define pISet(i)
Definition polys.h:313
pWTotaldegree
#define pWTotaldegree(p)
Definition polys.h:284
maGetPreimage
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition preimage.cc:57
preimage.h
IsPrime
int IsPrime(int p)
Definition prime.cc:61
prime.h
ratgring.h
SPrintStart
void SPrintStart()
Definition reporter.cc:250
feNotImplemented
const char feNotImplemented[]
Definition reporter.cc:54
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
SPrintEnd
char * SPrintEnd()
Definition reporter.cc:277
PrintLn
void PrintLn()
Definition reporter.cc:314
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
traceit
EXTERN_VAR int traceit
Definition reporter.h:24
TRACE_CALL
#define TRACE_CALL
Definition reporter.h:44
SI_PROT_O
#define SI_PROT_O
Definition reporter.h:54
SI_PROT_I
#define SI_PROT_I
Definition reporter.h:53
mflush
#define mflush()
Definition reporter.h:58
rSum
int rSum(ring r1, ring r2, ring &sum)
Definition ring.cc:1408
r_IsRingVar
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
rChar
int rChar(ring r)
Definition ring.cc:719
rMinusVar
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:6024
rSamePolyRep
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition ring.cc:1805
rParStr
char * rParStr(ring r)
Definition ring.cc:654
rCharStr
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:652
rOpposite
ring rOpposite(ring src)
Definition ring.cc:5425
rOrdStr
char * rOrdStr(ring r)
Definition ring.cc:526
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rDefault
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
rVarStr
char * rVarStr(ring r)
Definition ring.cc:628
rPlusVar
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5942
rEnvelope
ring rEnvelope(ring R)
Definition ring.cc:5819
n_IsParam
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5921
rCopy
ring rCopy(ring r)
Definition ring.cc:1737
rField_is_Zp_a
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:535
rField_is_Z
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
rHasLocalOrMixedOrdering
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
pFDegProc
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
rIncRefCnt
static ring rIncRefCnt(ring r)
Definition ring.h:849
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
pLDegProc
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:38
rPar
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:605
rIsLPRing
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
ringorder_lp
@ ringorder_lp
Definition ring.h:78
ringorder_dp
@ ringorder_dp
Definition ring.h:79
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rParameter
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:631
rField_is_numeric
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:521
rField_is_GF
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
rHasMixedOrdering
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
idhdl
idrec * idhdl
Definition ring.h:22
sBucket_Add_p
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
sBucketCanonicalize
void sBucketCanonicalize(sBucket_pt bucket)
Definition sbuckets.cc:401
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
sBucketPeek
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
sBucket_pt
sBucket * sBucket_pt
Definition sbuckets.h:16
sBucketDestroyAdd
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68
sca.h
sdb_set_breakpoint
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition sdb.cc:64
sdb_show_bp
void sdb_show_bp()
Definition sdb.cc:57
sdb.h
si_signals.h
slPrepClose
BOOLEAN slPrepClose(si_link l)
Definition silink.cc:223
slRead
leftv slRead(si_link l, leftv a)
Definition silink.cc:261
slDump
BOOLEAN slDump(si_link l)
Definition silink.cc:344
slGetDump
BOOLEAN slGetDump(si_link l)
Definition silink.cc:374
slStatus
const char * slStatus(si_link l, const char *request)
Definition silink.cc:156
slClose
BOOLEAN slClose(si_link l)
Definition silink.cc:240
slOpen
BOOLEAN slOpen(si_link l, short flag, leftv h)
Definition silink.cc:194
silink.h
SI_LINK_WRITE
#define SI_LINK_WRITE
Definition silink.h:67
si_link
ip_link * si_link
Definition silink.h:20
SI_LINK_SET_CLOSE_P
#define SI_LINK_SET_CLOSE_P(l)
Definition silink.h:76
slStatusSsiL
int slStatusSsiL(lists L, int timeout, BOOLEAN *ignore=NULL)
Definition ssiLink.cc:2919
SI_LINK_OPEN
#define SI_LINK_OPEN
Definition silink.h:65
id_Vec2Ideal
ideal id_Vec2Ideal(poly vec, const ring R)
Definition simpleideals.cc:1528
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
id_Norm
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
Definition simpleideals.cc:282
id_HomModuleW
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
Definition simpleideals.cc:1105
id_Normalize
void id_Normalize(ideal I, const ring r)
normialize all polys in id
Definition simpleideals.cc:1983
id_Transp
ideal id_Transp(ideal a, const ring rRing)
transpose a module
Definition simpleideals.cc:2014
id_FreeModule
ideal id_FreeModule(int i, const ring r)
the free module of rank i
Definition simpleideals.cc:1235
id_Homogen
ideal id_Homogen(ideal h, int varnum, const ring r)
Definition simpleideals.cc:1503
id_Power
ideal id_Power(ideal given, int exp, const ring r)
Definition simpleideals.cc:1433
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition simpleideals.cc:1594
id_Head
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
Definition simpleideals.cc:1483
id_HomIdealW
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
Definition simpleideals.cc:1082
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition simpleideals.cc:992
id_DelDiv
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
Definition simpleideals.cc:463
id_DelMultiples
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
Definition simpleideals.cc:296
id_Module2formatedMatrix
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
Definition simpleideals.cc:1640
id_Matrix2Module
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
Definition simpleideals.cc:1560
id_ResizeModule
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
Definition simpleideals.cc:1672
id_Delete_Pos
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
Definition simpleideals.cc:2210
id_DelEquals
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
Definition simpleideals.cc:331
id_Jet
ideal id_Jet(const ideal i, int d, const ring R)
Definition simpleideals.cc:1847
id_DelLmEquals
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
Definition simpleideals.cc:354
id_JetW
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
Definition simpleideals.cc:1873
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201
id_Shift
void id_Shift(ideal M, int s, const ring r)
Definition simpleideals.cc:2196
id_ChineseRemainder
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
Definition simpleideals.cc:2147
id_Subst
ideal id_Subst(ideal id, int n, poly e, const ring r)
Definition simpleideals.cc:1709
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
idElem
static int idElem(const ideal F)
number of non-zero polys in F
Definition simpleideals.h:69
siRand
int siRand()
Definition sirandom.c:42
R
#define R
Definition sirandom.c:27
A
#define A
Definition sirandom.c:24
M
#define M
Definition sirandom.c:25
Q
#define Q
Definition sirandom.c:26
sirandom.h
sm_CallBareiss
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition sparsmat.cc:347
sm_CallSolv
ideal sm_CallSolv(ideal I, const ring R)
Definition sparsmat.cc:2316
sparsmat.h
stairc.h
leftv
sleftv * leftv
Definition structs.h:53
tHomog
tHomog
Definition structs.h:31
isHomog
@ isHomog
Definition structs.h:33
testHomog
@ testHomog
Definition structs.h:34
isNotHomog
@ isNotHomog
Definition structs.h:32
char_ptr_bin
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:73
loop
#define loop
Definition structs.h:71
sSubexpr_bin
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
syMake
void syMake(leftv v, const char *id, package pa)
Definition subexpr.cc:1613
sLastPrinted
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
siq
VAR BOOLEAN siq
Definition subexpr.cc:48
assumeStdFlag
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
subexpr.h
LANG_SINGULAR
@ LANG_SINGULAR
Definition subexpr.h:22
LANG_MIX
@ LANG_MIX
Definition subexpr.h:22
LANG_C
@ LANG_C
Definition subexpr.h:22
LANG_TOP
@ LANG_TOP
Definition subexpr.h:22
procinfo
Definition subexpr.h:54
syResolvente
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition syz.cc:403
syMres_with_map
syStrategy syMres_with_map(ideal arg, int maxlength, intvec *w, ideal &trans)
Definition syz.cc:1180
syResolution
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition syz.cc:625
syFix
void syFix(syStrategy r)
Definition syz.cc:1230
syMinBase
ideal syMinBase(ideal arg)
Definition syz.cc:1021
syz.h
syHilb
syStrategy syHilb(ideal arg, int *length)
Definition syz2.cc:950
sySchreyerResolvente
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition syz0.cc:855
sySchreyer
syStrategy sySchreyer(ideal arg, int maxlength)
Definition syz0.cc:1018
ssyStrategy::syRing
ring syRing
Definition syz.h:56
syDim
int syDim(syStrategy syzstr)
Definition syz1.cc:1850
syMinimize
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2393
syCopy
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1885
ssyStrategy::minres
resolvente minres
Definition syz.h:58
syKosz
syStrategy syKosz(ideal arg, int *length)
Definition syz3.cc:1766
sySize
int sySize(syStrategy syzstr)
Definition syz1.cc:1830
ssyStrategy::list_length
short list_length
Definition syz.h:62
ssyStrategy::res
resolvente res
Definition syz.h:47
ssyStrategy::fullres
resolvente fullres
Definition syz.h:57
ssyStrategy::weights
intvec ** weights
Definition syz.h:45
syStrategy
ssyStrategy * syStrategy
Definition syz.h:36
ssyStrategy::orderedRes
resolvente orderedRes
Definition syz.h:48
ssyStrategy::resPairs
SRes resPairs
Definition syz.h:49
syFrank
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)
Definition syz4.cc:792
syLaScala3
syStrategy syLaScala3(ideal arg, int *length)
Definition syz1.cc:2432
table.h
t_rep_gb
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition tgb.cc:3581
tgb.h
getRTimer
int getRTimer()
Definition timer.cc:150
timer.h
tok.h
IDHDL
#define IDHDL
Definition tok.h:31
NCALGEBRA_CMD
@ NCALGEBRA_CMD
Definition tok.h:138
ALIAS_CMD
@ ALIAS_CMD
Definition tok.h:34
BIGINT_CMD
@ BIGINT_CMD
Definition tok.h:38
CRING_CMD
@ CRING_CMD
Definition tok.h:56
LIST_CMD
@ LIST_CMD
Definition tok.h:118
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101
PACKAGE_CMD
@ PACKAGE_CMD
Definition tok.h:150
DEF_CMD
@ DEF_CMD
Definition tok.h:58
LRES_CMD
@ LRES_CMD
Definition tok.h:120
SUBST_CMD
@ SUBST_CMD
Definition tok.h:188
HRES_CMD
@ HRES_CMD
Definition tok.h:91
KRES_CMD
@ KRES_CMD
Definition tok.h:109
OPEN_CMD
@ OPEN_CMD
Definition tok.h:145
CNUMBER_CMD
@ CNUMBER_CMD
Definition tok.h:47
LINK_CMD
@ LINK_CMD
Definition tok.h:117
STD_CMD
@ STD_CMD
Definition tok.h:186
CHINREM_CMD
@ CHINREM_CMD
Definition tok.h:45
MRES_CMD
@ MRES_CMD
Definition tok.h:131
STRING_CMD
@ STRING_CMD
Definition tok.h:187
SRES_CMD
@ SRES_CMD
Definition tok.h:184
INTDIV_CMD
@ INTDIV_CMD
Definition tok.h:97
INT_CMD
@ INT_CMD
Definition tok.h:96
KERNEL_CMD
@ KERNEL_CMD
Definition tok.h:107
FAREY_CMD
@ FAREY_CMD
Definition tok.h:77
MAX_TOK
@ MAX_TOK
Definition tok.h:220
RES_CMD
@ RES_CMD
Definition tok.h:169
NONE
#define NONE
Definition tok.h:223
COMMAND
#define COMMAND
Definition tok.h:29
UNKNOWN
#define UNKNOWN
Definition tok.h:224
ANY_TYPE
#define ANY_TYPE
Definition tok.h:30
ntDiff
number ntDiff(number a, number d, const coeffs cf)
Definition transext.cc:897
transext.h
units.h
walkProc.h
fractalWalkProc
ideal fractalWalkProc(leftv first, leftv second)
Definition walk_ip.cc:161
walkProc
ideal walkProc(leftv first, leftv second)
Definition walk_ip.cc:55
iv2array
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200
weight.h
jjStdJanetBasis
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition wrapper.cc:50
omPrintStats
#define omPrintStats(F)
Definition xalloc.h:231
omPrintInfo
#define omPrintInfo(F)
Definition xalloc.h:232
omPrintBinStats
#define omPrintBinStats(F)
Definition xalloc.h:233
omUpdateInfo
#define omUpdateInfo()
Definition xalloc.h:230