My Project
Data Structures | Typedefs | Functions | Variables
ipshell.h File Reference
#include <stdio.h>
#include "kernel/ideals.h"
#include "Singular/lists.h"
#include "Singular/fevoices.h"

Go to the source code of this file.

Data Structures

struct  sValCmd1
 
struct  sValCmd2
 
struct  sValCmd3
 
struct  sValCmdM
 
struct  sValAssign_sys
 
struct  sValAssign
 

Typedefs

typedef BOOLEAN(* proc1) (leftv, leftv)
 
typedef BOOLEAN(* proc2) (leftv, leftv, leftv)
 
typedef BOOLEAN(* proc3) (leftv, leftv, leftv, leftv)
 
typedef BOOLEAN(* proci) (leftv, leftv, Subexpr)
 

Functions

BOOLEAN spectrumProc (leftv, leftv)
 
BOOLEAN spectrumfProc (leftv, leftv)
 
BOOLEAN spaddProc (leftv, leftv, leftv)
 
BOOLEAN spmulProc (leftv, leftv, leftv)
 
BOOLEAN semicProc (leftv, leftv, leftv)
 
BOOLEAN semicProc3 (leftv, leftv, leftv, leftv)
 
BOOLEAN iiAssignCR (leftv, leftv)
 
BOOLEAN iiARROW (leftv, char *, char *)
 
int IsCmd (const char *n, int &tok)
 
BOOLEAN iiPStart (idhdl pn, leftv sl)
 
BOOLEAN iiEStart (char *example, procinfo *pi)
 
BOOLEAN iiAllStart (procinfov pi, const char *p, feBufferTypes t, int l)
 
void type_cmd (leftv v)
 
void test_cmd (int i)
 
void list_cmd (int typ, const char *what, const char *prefix, BOOLEAN iterate, BOOLEAN fullname=FALSE)
 
void killlocals (int v)
 
int exprlist_length (leftv v)
 
const char * Tok2Cmdname (int i)
 
const char * iiTwoOps (int t)
 
int iiOpsTwoChar (const char *s)
 
BOOLEAN iiWRITE (leftv res, leftv exprlist)
 
BOOLEAN iiExport (leftv v, int toLev)
 
BOOLEAN iiExport (leftv v, int toLev, package pack)
 
BOOLEAN iiInternalExport (leftv v, int toLev, package pack)
 
static char * iiGetLibName (const procinfov pi)
 find the library of an proc More...
 
char * iiGetLibProcBuffer (procinfov pi, int part=1)
 
char * iiProcName (char *buf, char &ct, char *&e)
 
char * iiProcArgs (char *e, BOOLEAN withParenth)
 
BOOLEAN iiLibCmd (const char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
 
BOOLEAN jjLOAD (const char *s, BOOLEAN autoexport=FALSE)
 load lib/module given in v More...
 
BOOLEAN jjLOAD_TRY (const char *s)
 
BOOLEAN iiLocateLib (const char *lib, char *where)
 
leftv iiMap (map theMap, const char *what)
 
void iiMakeResolv (resolvente r, int length, int rlen, char *name, int typ0, intvec **weights=NULL)
 
BOOLEAN jjMINRES (leftv res, leftv v)
 
BOOLEAN jjBETTI (leftv res, leftv v)
 
BOOLEAN jjBETTI2 (leftv res, leftv u, leftv v)
 
BOOLEAN jjBETTI2_ID (leftv res, leftv u, leftv v)
 
BOOLEAN jjIMPORTFROM (leftv res, leftv u, leftv v)
 
BOOLEAN jjLIST_PL (leftv res, leftv v)
 
BOOLEAN jjVARIABLES_P (leftv res, leftv u)
 
BOOLEAN jjVARIABLES_ID (leftv res, leftv u)
 
int iiRegularity (lists L)
 
leftv singular_system (sleftv h)
 
BOOLEAN jjSYSTEM (leftv res, leftv v)
 
void iiDebug ()
 
BOOLEAN iiCheckRing (int i)
 
poly iiHighCorner (ideal i, int ak)
 
char * iiConvName (const char *libname)
 
BOOLEAN iiGetLibStatus (const char *lib)
 
BOOLEAN iiLoadLIB (FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
 
lists syConvRes (syStrategy syzstr, BOOLEAN toDel=FALSE, int add_row_shift=0)
 
syStrategy syConvList (lists li)
 
BOOLEAN syBetti1 (leftv res, leftv u)
 
BOOLEAN syBetti2 (leftv res, leftv u, leftv w)
 
BOOLEAN iiExprArith1 (leftv res, sleftv *a, int op)
 
BOOLEAN iiExprArith2 (leftv res, sleftv *a, int op, sleftv *b, BOOLEAN proccall=FALSE)
 
BOOLEAN iiExprArith3 (leftv res, int op, leftv a, leftv b, leftv c)
 
BOOLEAN iiExprArithM (leftv res, sleftv *a, int op)
 
BOOLEAN iiApply (leftv res, leftv a, int op, leftv proc)
 
BOOLEAN iiAssign (leftv left, leftv right, BOOLEAN toplevel=TRUE)
 
coeffs jjSetMinpoly (coeffs cf, number a)
 
BOOLEAN iiParameter (leftv p)
 
BOOLEAN iiAlias (leftv p)
 
int iiTokType (int op)
 
int iiDeclCommand (leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring=FALSE, BOOLEAN init_b=TRUE)
 
BOOLEAN iiMake_proc (idhdl pn, package pack, leftv sl)
 
void * iiCallLibProc1 (const char *n, void *arg, int arg_type, BOOLEAN &err)
 
leftv ii_CallLibProcM (const char *n, void **args, int *arg_types, const ring R, BOOLEAN &err)
 args: NULL terminated array of arguments arg_types: 0 terminated array of corresponding types More...
 
ideal ii_CallProcId2Id (const char *lib, const char *proc, ideal arg, const ring R)
 
int ii_CallProcId2Int (const char *lib, const char *proc, ideal arg, const ring R)
 
char * showOption ()
 
BOOLEAN setOption (leftv res, leftv v)
 
char * versionString ()
 
void singular_example (char *str)
 
BOOLEAN iiTryLoadLib (leftv v, const char *id)
 
int iiAddCproc (const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
 
void iiCheckPack (package &p)
 
void rSetHdl (idhdl h)
 
ring rInit (leftv pn, leftv rv, leftv ord)
 
idhdl rDefault (const char *s)
 
idhdl rFindHdl (ring r, idhdl n)
 
void rKill (idhdl h)
 
void rKill (ring r)
 
lists scIndIndset (ideal S, BOOLEAN all, ideal Q)
 
BOOLEAN mpKoszul (leftv res, leftv c, leftv b, leftv id)
 
BOOLEAN mpJacobi (leftv res, leftv a)
 
BOOLEAN jjRESULTANT (leftv res, leftv u, leftv v, leftv w)
 
BOOLEAN kQHWeight (leftv res, leftv v)
 
BOOLEAN kWeight (leftv res, leftv id)
 
BOOLEAN loSimplex (leftv res, leftv args)
 Implementation of the Simplex Algorithm. More...
 
BOOLEAN loNewtonP (leftv res, leftv arg1)
 compute Newton Polytopes of input polynomials More...
 
BOOLEAN nuMPResMat (leftv res, leftv arg1, leftv arg2)
 returns module representing the multipolynomial resultant matrix Arguments 2: ideal i, int k k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default) More...
 
BOOLEAN nuLagSolve (leftv res, leftv arg1, leftv arg2, leftv arg3)
 find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial using Laguerres' root-solver. More...
 
BOOLEAN nuVanderSys (leftv res, leftv arg1, leftv arg2, leftv arg3)
 COMPUTE: polynomial p with values given by v at points p1,..,pN derived from p; more precisely: consider p as point in K^n and v as N elements in K, let p1,..,pN be the points in K^n obtained by evaluating all monomials of degree 0,1,...,N at p in lexicographical order, then the procedure computes the polynomial f satisfying f(pi) = v[i] RETURN: polynomial f of degree d. More...
 
BOOLEAN nuUResSolve (leftv res, leftv args)
 solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing->N) == IDELEMS(ideal). More...
 
BOOLEAN jjCHARSERIES (leftv res, leftv u)
 
void paPrint (const char *n, package p)
 
BOOLEAN iiTestAssume (leftv a, leftv b)
 
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 More...
 
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 More...
 
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 More...
 
BOOLEAN iiCheckTypes (leftv args, const short *type_list, int report=0)
 check a list of arguemys against a given field of types return TRUE if the types match return FALSE (and, if report) report an error via Werror otherwise More...
 
BOOLEAN iiBranchTo (leftv r, leftv args)
 
lists rDecompose (const ring r)
 
lists rDecompose_list_cf (const ring r)
 
BOOLEAN rDecompose_CF (leftv res, const coeffs C)
 
ring rCompose (const lists L, const BOOLEAN check_comp=TRUE, const long bitmask=0x7fff, const int isLetterplace=FALSE)
 
void iiSetReturn (const leftv h)
 

Variables

EXTERN_VAR leftv iiCurrArgs
 
EXTERN_VAR idhdl iiCurrProc
 
EXTERN_VAR int iiOp
 
const char * currid
 
EXTERN_VAR int iiRETURNEXPR_len
 
EXTERN_INST_VAR sleftv iiRETURNEXPR
 
EXTERN_VAR ring * iiLocalRing
 
const char * lastreserved
 
EXTERN_VAR int myynest
 
EXTERN_VAR int printlevel
 
EXTERN_VAR int si_echo
 
EXTERN_VAR BOOLEAN yyInRingConstruction
 
const struct sValCmd2 dArith2 []
 
const struct sValCmd1 dArith1 []
 
const struct sValCmd3 dArith3 []
 
const struct sValCmdM dArithM []
 

Data Structure Documentation

◆ sValCmd1

struct sValCmd1

Definition at line 78 of file gentable.cc.

Data Fields
short arg
short cmd
int p
proc1 p
short res
short valid_for

◆ sValCmd2

struct sValCmd2

Definition at line 69 of file gentable.cc.

Data Fields
short arg1
short arg2
short cmd
int p
proc2 p
short res
short valid_for

◆ sValCmd3

struct sValCmd3

Definition at line 86 of file gentable.cc.

Data Fields
short arg1
short arg2
short arg3
short cmd
int p
proc3 p
short res
short valid_for

◆ sValCmdM

struct sValCmdM

Definition at line 96 of file gentable.cc.

Data Fields
short cmd
short number_of_args
int p
proc1 p
short res
short valid_for

◆ sValAssign_sys

struct sValAssign_sys

Definition at line 104 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

◆ sValAssign

struct sValAssign

Definition at line 111 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

Typedef Documentation

◆ proc1

typedef BOOLEAN(* proc1) (leftv, leftv)

Definition at line 122 of file ipshell.h.

◆ proc2

typedef BOOLEAN(* proc2) (leftv, leftv, leftv)

Definition at line 134 of file ipshell.h.

◆ proc3

typedef BOOLEAN(* proc3) (leftv, leftv, leftv, leftv)

Definition at line 145 of file ipshell.h.

◆ proci

typedef BOOLEAN(* proci) (leftv, leftv, Subexpr)

Definition at line 175 of file ipshell.h.

Function Documentation

◆ exprlist_length()

int exprlist_length ( leftv  v)

Definition at line 552 of file ipshell.cc.

553{
554 int rc = 0;
555 while (v!=NULL)
556 {
557 switch (v->Typ())
558 {
559 case INT_CMD:
560 case POLY_CMD:
561 case VECTOR_CMD:
562 case NUMBER_CMD:
563 rc++;
564 break;
565 case INTVEC_CMD:
566 case INTMAT_CMD:
567 rc += ((intvec *)(v->Data()))->length();
568 break;
569 case MATRIX_CMD:
570 case IDEAL_CMD:
571 case MODUL_CMD:
572 {
573 matrix mm = (matrix)(v->Data());
574 rc += mm->rows() * mm->cols();
575 }
576 break;
577 case LIST_CMD:
578 rc+=((lists)v->Data())->nr+1;
579 break;
580 default:
581 rc++;
582 }
583 v = v->next;
584 }
585 return rc;
586}
Variable next() const
Definition: factory.h:146
Definition: intvec.h:23
int & cols()
Definition: matpol.h:24
int & rows()
Definition: matpol.h:23
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ VECTOR_CMD
Definition: grammar.cc:292
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
ip_smatrix * matrix
Definition: matpol.h:43
slists * lists
Definition: mpr_numeric.h:146
#define NULL
Definition: omList.c:12
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ INT_CMD
Definition: tok.h:96

◆ ii_CallLibProcM()

leftv ii_CallLibProcM ( const char *  n,
void **  args,
int *  arg_types,
const ring  R,
BOOLEAN err 
)

args: NULL terminated array of arguments arg_types: 0 terminated array of corresponding types

Definition at line 701 of file iplib.cc.

702{
703 idhdl h=ggetid(n);
704 if ((h==NULL)
705 || (IDTYP(h)!=PROC_CMD))
706 {
707 err=2;
708 return NULL;
709 }
710 // ring handling
711 idhdl save_ringhdl=currRingHdl;
712 ring save_ring=currRing;
715 // argument:
716 if (arg_types[0]!=0)
717 {
718 sleftv tmp;
719 leftv tt=&tmp;
720 int i=1;
721 tmp.Init();
722 tmp.data=args[0];
723 tmp.rtyp=arg_types[0];
724 while(arg_types[i]!=0)
725 {
727 tt=tt->next;
728 tt->rtyp=arg_types[i];
729 tt->data=args[i];
730 i++;
731 }
732 // call proc
733 err=iiMake_proc(h,currPack,&tmp);
734 }
735 else
736 // call proc
738 // clean up ring
739 iiCallLibProcEnd(save_ringhdl,save_ring);
740 // return
741 if (err==FALSE)
742 {
744 memcpy(h,&iiRETURNEXPR,sizeof(sleftv));
746 return h;
747 }
748 return NULL;
749}
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:132
Definition: idrec.h:35
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int rtyp
Definition: subexpr.h:91
void Init()
Definition: subexpr.h:107
leftv next
Definition: subexpr.h:86
void * data
Definition: subexpr.h:88
@ PROC_CMD
Definition: grammar.cc:280
idhdl ggetid(const char *n)
Definition: ipid.cc:581
VAR idhdl currRingHdl
Definition: ipid.cc:59
VAR package currPack
Definition: ipid.cc:57
EXTERN_VAR omBin sleftv_bin
Definition: ipid.h:145
#define IDTYP(a)
Definition: ipid.h:119
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:606
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition: iplib.cc:504
INST_VAR sleftv iiRETURNEXPR
Definition: iplib.cc:474
static void iiCallLibProcBegin()
Definition: iplib.cc:589
STATIC_VAR Poly * h
Definition: janet.cc:971
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define R
Definition: sirandom.c:27
sleftv * leftv
Definition: structs.h:57

◆ ii_CallProcId2Id()

ideal ii_CallProcId2Id ( const char *  lib,
const char *  proc,
ideal  arg,
const ring  R 
)

Definition at line 661 of file iplib.cc.

662{
663 char *plib = iiConvName(lib);
664 idhdl h=ggetid(plib);
665 omFreeBinAddr(plib);
666 if (h==NULL)
667 {
669 if (bo) return NULL;
670 }
671 ring oldR=currRing;
673 BOOLEAN err;
674 ideal I=(ideal)iiCallLibProc1(proc,idCopy(arg),IDEAL_CMD,err);
675 rChangeCurrRing(oldR);
676 if (err) return NULL;
677 return I;
678}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
unsigned char * proc[NUM_PROC]
Definition: checklibs.c:16
ideal idCopy(ideal A)
Definition: ideals.h:60
char * iiConvName(const char *libname)
Definition: iplib.cc:1430
BOOLEAN iiLibCmd(const char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:885
void * iiCallLibProc1(const char *n, void *arg, int arg_type, BOOLEAN &err)
Definition: iplib.cc:627
#define omFreeBinAddr(addr)
Definition: omAllocDecl.h:258

◆ ii_CallProcId2Int()

int ii_CallProcId2Int ( const char *  lib,
const char *  proc,
ideal  arg,
const ring  R 
)

Definition at line 680 of file iplib.cc.

681{
682 char *plib = iiConvName(lib);
683 idhdl h=ggetid(plib);
684 omFreeBinAddr(plib);
685 if (h==NULL)
686 {
688 if (bo) return 0;
689 }
690 BOOLEAN err;
691 ring oldR=currRing;
693 int I=(int)(long)iiCallLibProc1(proc,idCopy(arg),IDEAL_CMD,err);
694 rChangeCurrRing(oldR);
695 if (err) return 0;
696 return I;
697}

◆ iiAddCproc()

int iiAddCproc ( const char *  libname,
const char *  procname,
BOOLEAN  pstatic,
BOOLEAN(*)(leftv res, leftv v func 
)

Definition at line 1064 of file iplib.cc.

1066{
1067 procinfov pi;
1068 idhdl h;
1069
1070 #ifndef SING_NDEBUG
1071 int dummy;
1072 if (IsCmd(procname,dummy))
1073 {
1074 Werror(">>%s< is a reserved name",procname);
1075 return 0;
1076 }
1077 #endif
1078
1079 h=IDROOT->get(procname,0);
1080 if ((h!=NULL)
1081 && (IDTYP(h)==PROC_CMD))
1082 {
1083 pi = IDPROC(h);
1084 #if 0
1085 if ((pi->language == LANG_SINGULAR)
1086 &&(BVERBOSE(V_REDEFINE)))
1087 Warn("extend `%s`",procname);
1088 #endif
1089 }
1090 else
1091 {
1092 h = enterid(procname,0, PROC_CMD, &IDROOT, TRUE);
1093 }
1094 if ( h!= NULL )
1095 {
1096 pi = IDPROC(h);
1097 if((pi->language == LANG_SINGULAR)
1098 ||(pi->language == LANG_NONE))
1099 {
1100 omfree(pi->libname);
1101 pi->libname = omStrDup(libname);
1102 omfree(pi->procname);
1103 pi->procname = omStrDup(procname);
1104 pi->language = LANG_C;
1105 pi->ref = 1;
1106 pi->is_static = pstatic;
1107 pi->data.o.function = func;
1108 }
1109 else if(pi->language == LANG_C)
1110 {
1111 if(pi->data.o.function == func)
1112 {
1113 pi->ref++;
1114 }
1115 else
1116 {
1117 omfree(pi->libname);
1118 pi->libname = omStrDup(libname);
1119 omfree(pi->procname);
1120 pi->procname = omStrDup(procname);
1121 pi->language = LANG_C;
1122 pi->ref = 1;
1123 pi->is_static = pstatic;
1124 pi->data.o.function = func;
1125 }
1126 }
1127 else
1128 Warn("internal error: unknown procedure type %d",pi->language);
1129 if (currPack->language==LANG_SINGULAR) currPack->language=LANG_MIX;
1130 return(1);
1131 }
1132 else
1133 {
1134 WarnS("iiAddCproc: failed.");
1135 }
1136 return(0);
1137}
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:9524
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:279
#define IDPROC(a)
Definition: ipid.h:140
#define IDROOT
Definition: ipid.h:19
#define pi
Definition: libparse.cc:1145
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omfree(addr)
Definition: omAllocDecl.h:237
#define BVERBOSE(a)
Definition: options.h:35
#define V_REDEFINE
Definition: options.h:45
void Werror(const char *fmt,...)
Definition: reporter.cc:189
@ LANG_SINGULAR
Definition: subexpr.h:22
@ LANG_NONE
Definition: subexpr.h:22
@ LANG_MIX
Definition: subexpr.h:22
@ LANG_C
Definition: subexpr.h:22

◆ iiAlias()

BOOLEAN iiAlias ( leftv  p)

Definition at line 844 of file ipid.cc.

845{
846 if (iiCurrArgs==NULL)
847 {
848 Werror("not enough arguments for proc %s",VoiceName());
849 p->CleanUp();
850 return TRUE;
851 }
853 iiCurrArgs=h->next;
854 h->next=NULL;
855 if (h->rtyp!=IDHDL)
856 {
858 h->CleanUp();
860 return res;
861 }
862 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
863 {
864 WerrorS("type mismatch");
865 return TRUE;
866 }
867 idhdl pp=(idhdl)p->data;
868 switch(pp->typ)
869 {
870 case CRING_CMD:
872 break;
873 case DEF_CMD:
874 case INT_CMD:
875 break;
876 case INTVEC_CMD:
877 case INTMAT_CMD:
878 delete IDINTVEC(pp);
879 break;
880 case NUMBER_CMD:
882 break;
883 case BIGINT_CMD:
885 break;
886 case MAP_CMD:
887 {
888 map im = IDMAP(pp);
889 omFreeBinAddr((ADDRESS)im->preimage);
890 im->preimage=NULL;// and continue
891 }
892 // continue as ideal:
893 case IDEAL_CMD:
894 case MODUL_CMD:
895 case MATRIX_CMD:
897 break;
898 case PROC_CMD:
899 case RESOLUTION_CMD:
900 case STRING_CMD:
902 break;
903 case LIST_CMD:
904 IDLIST(pp)->Clean();
905 break;
906 case LINK_CMD:
908 break;
909 // case ring: cannot happen
910 default:
911 Werror("unknown type %d",p->Typ());
912 return TRUE;
913 }
914 pp->typ=ALIAS_CMD;
915 IDDATA(pp)=(char*)h->data;
916 int eff_typ=h->Typ();
917 if ((RingDependend(eff_typ))
918 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
919 {
920 ipSwapId(pp,IDROOT,currRing->idroot);
921 }
922 h->CleanUp();
924 return FALSE;
925}
void * ADDRESS
Definition: auxiliary.h:119
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
int p
Definition: cfModGcd.cc:4078
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
Definition: lists.h:24
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:569
CanonicalForm res
Definition: facAbsFact.cc:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char * VoiceName()
Definition: fevoices.cc:58
@ MAP_CMD
Definition: grammar.cc:285
@ RESOLUTION_CMD
Definition: grammar.cc:290
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1963
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:679
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define IDMAP(a)
Definition: ipid.h:135
#define IDSTRING(a)
Definition: ipid.h:136
#define IDDATA(a)
Definition: ipid.h:126
#define IDINTVEC(a)
Definition: ipid.h:128
#define IDLINK(a)
Definition: ipid.h:138
#define IDIDEAL(a)
Definition: ipid.h:133
#define IDNUMBER(a)
Definition: ipid.h:132
#define IDLIST(a)
Definition: ipid.h:137
VAR leftv iiCurrArgs
Definition: ipshell.cc:80
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:222
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nDelete(n)
Definition: numbers.h:16
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
idrec * idhdl
Definition: ring.h:21
BOOLEAN RingDependend(int t)
Definition: subexpr.h:142
#define IDHDL
Definition: tok.h:31
@ ALIAS_CMD
Definition: tok.h:34
@ BIGINT_CMD
Definition: tok.h:38
@ CRING_CMD
Definition: tok.h:56
@ DEF_CMD
Definition: tok.h:58
@ LINK_CMD
Definition: tok.h:117
@ STRING_CMD
Definition: tok.h:185

◆ iiAllStart()

BOOLEAN iiAllStart ( procinfov  pi,
const char *  p,
feBufferTypes  t,
int  l 
)

Definition at line 298 of file iplib.cc.

299{
300 int save_trace=traceit;
301 int restore_traceit=0;
302 if (traceit_stop
304 {
305 traceit &=(~TRACE_SHOW_LINE);
306 traceit_stop=0;
307 restore_traceit=1;
308 }
309 // see below:
310 BITSET save1=si_opt_1;
311 BITSET save2=si_opt_2;
312 newBuffer( omStrDup(p /*pi->data.s.body*/), t /*BT_proc*/,
313 pi, l );
314 BOOLEAN err=yyparse();
315
316 if (sLastPrinted.rtyp!=0)
317 {
319 }
320
321 if (restore_traceit) traceit=save_trace;
322
323 // the access to optionStruct and verboseStruct do not work
324 // on x86_64-Linux for pic-code
325 if ((TEST_V_ALLWARN) &&
326 (t==BT_proc) &&
327 ((save1!=si_opt_1)||(save2!=si_opt_2)) &&
328 (pi->libname!=NULL) && (pi->libname[0]!='\0'))
329 {
330 if ((pi->libname!=NULL) && (pi->libname[0]!='\0'))
331 Warn("option changed in proc %s from %s",pi->procname,pi->libname);
332 else
333 Warn("option changed in proc %s",pi->procname);
334 int i;
335 for (i=0; optionStruct[i].setval!=0; i++)
336 {
337 if ((optionStruct[i].setval & si_opt_1)
338 && (!(optionStruct[i].setval & save1)))
339 {
340 Print(" +%s",optionStruct[i].name);
341 }
342 if (!(optionStruct[i].setval & si_opt_1)
343 && ((optionStruct[i].setval & save1)))
344 {
345 Print(" -%s",optionStruct[i].name);
346 }
347 }
348 for (i=0; verboseStruct[i].setval!=0; i++)
349 {
350 if ((verboseStruct[i].setval & si_opt_2)
351 && (!(verboseStruct[i].setval & save2)))
352 {
353 Print(" +%s",verboseStruct[i].name);
354 }
355 if (!(verboseStruct[i].setval & si_opt_2)
356 && ((verboseStruct[i].setval & save2)))
357 {
358 Print(" -%s",verboseStruct[i].name);
359 }
360 }
361 PrintLn();
362 }
363 return err;
364}
int l
Definition: cfEzgcd.cc:100
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
#define Print
Definition: emacs.cc:80
char name(const Variable &v)
Definition: factory.h:189
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:166
@ BT_proc
Definition: fevoices.h:20
int yyparse(void)
Definition: grammar.cc:2111
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:538
unsigned setval
Definition: ipid.h:153
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:507
VAR unsigned si_opt_2
Definition: options.c:6
VAR unsigned si_opt_1
Definition: options.c:5
#define TEST_V_ALLWARN
Definition: options.h:142
void PrintLn()
Definition: reporter.cc:310
#define TRACE_SHOW_LINE
Definition: reporter.h:33
EXTERN_VAR int traceit
Definition: reporter.h:24
EXTERN_VAR int traceit_stop
Definition: reporter.h:25
#define BITSET
Definition: structs.h:16
INST_VAR sleftv sLastPrinted
Definition: subexpr.cc:46

◆ iiApply()

BOOLEAN iiApply ( leftv  res,
leftv  a,
int  op,
leftv  proc 
)

Definition at line 6433 of file ipshell.cc.

6434{
6435 res->Init();
6436 res->rtyp=a->Typ();
6437 switch (res->rtyp /*a->Typ()*/)
6438 {
6439 case INTVEC_CMD:
6440 case INTMAT_CMD:
6441 return iiApplyINTVEC(res,a,op,proc);
6442 case BIGINTMAT_CMD:
6443 return iiApplyBIGINTMAT(res,a,op,proc);
6444 case IDEAL_CMD:
6445 case MODUL_CMD:
6446 case MATRIX_CMD:
6447 return iiApplyIDEAL(res,a,op,proc);
6448 case LIST_CMD:
6449 return iiApplyLIST(res,a,op,proc);
6450 }
6451 WerrorS("first argument to `apply` must allow an index");
6452 return TRUE;
6453}
int Typ()
Definition: subexpr.cc:1030
@ BIGINTMAT_CMD
Definition: grammar.cc:278
BOOLEAN iiApplyINTVEC(leftv res, leftv a, int op, leftv proc)
Definition: ipshell.cc:6352
BOOLEAN iiApplyLIST(leftv res, leftv a, int op, leftv proc)
Definition: ipshell.cc:6394
BOOLEAN iiApplyIDEAL(leftv, leftv, int, leftv)
Definition: ipshell.cc:6389
BOOLEAN iiApplyBIGINTMAT(leftv, leftv, int, leftv)
Definition: ipshell.cc:6384

◆ iiARROW()

BOOLEAN iiARROW ( leftv  r,
char *  a,
char *  s 
)

Definition at line 6482 of file ipshell.cc.

6483{
6484 size_t len=strlen(a)+strlen(s)+30; /* max. 27 currently */
6485 char *ss=(char*)omAlloc(len);
6486 // find end of s:
6487 int end_s=strlen(s);
6488 while ((end_s>0) && ((s[end_s]<=' ')||(s[end_s]==';'))) end_s--;
6489 s[end_s+1]='\0';
6490 char *name=(char *)omAlloc(len);
6491 snprintf(name,len,"%s->%s",a,s);
6492 // find start of last expression
6493 int start_s=end_s-1;
6494 while ((start_s>=0) && (s[start_s]!=';')) start_s--;
6495 if (start_s<0) // ';' not found
6496 {
6497 snprintf(ss,len,"parameter def %s;return(%s);\n",a,s);
6498 }
6499 else // s[start_s] is ';'
6500 {
6501 s[start_s]='\0';
6502 snprintf(ss,len,"parameter def %s;%s;return(%s);\n",a,s,s+start_s+1);
6503 }
6504 r->Init();
6505 // now produce procinfo for PROC_CMD:
6506 r->data = (void *)omAlloc0Bin(procinfo_bin);
6507 ((procinfo *)(r->data))->language=LANG_NONE;
6509 ((procinfo *)r->data)->data.s.body=ss;
6510 omFree(name);
6511 r->rtyp=PROC_CMD;
6512 //r->rtyp=STRING_CMD;
6513 //r->data=ss;
6514 return FALSE;
6515}
const CanonicalForm int s
Definition: facAbsFact.cc:51
procinfo * iiInitSingularProcinfo(procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic)
Definition: iplib.cc:1050
#define omAlloc(size)
Definition: omAllocDecl.h:210
VAR omBin procinfo_bin
Definition: subexpr.cc:42

◆ iiAssign()

BOOLEAN iiAssign ( leftv  left,
leftv  right,
BOOLEAN  toplevel = TRUE 
)

Definition at line 1963 of file ipassign.cc.

1964{
1965 if (errorreported) return TRUE;
1966 int ll=l->listLength();
1967 int rl;
1968 int lt=l->Typ();
1969 int rt=NONE;
1970 int is_qring=FALSE;
1971 BOOLEAN b=FALSE;
1972 if (l->rtyp==ALIAS_CMD)
1973 {
1974 Werror("`%s` is read-only",l->Name());
1975 }
1976
1977 if (l->rtyp==IDHDL)
1978 {
1979 atKillAll((idhdl)l->data);
1980 is_qring=hasFlag((idhdl)l->data,FLAG_QRING_DEF);
1981 IDFLAG((idhdl)l->data)=0;
1982 l->attribute=NULL;
1983 toplevel=FALSE;
1984 }
1985 else if (l->attribute!=NULL)
1986 atKillAll((idhdl)l);
1987 if (ll==1)
1988 {
1989 /* l[..] = ... */
1990 if(l->e!=NULL)
1991 {
1992 BOOLEAN like_lists=0;
1993 blackbox *bb=NULL;
1994 int bt;
1995 if (((bt=l->rtyp)>MAX_TOK)
1996 || ((l->rtyp==IDHDL) && ((bt=IDTYP((idhdl)l->data))>MAX_TOK)))
1997 {
1998 bb=getBlackboxStuff(bt);
1999 like_lists=BB_LIKE_LIST(bb); // bb like a list
2000 }
2001 else if (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD))
2002 || (l->rtyp==LIST_CMD))
2003 {
2004 like_lists=2; // bb in a list
2005 }
2006 if(like_lists)
2007 {
2008 if (traceit&TRACE_ASSIGN) PrintS("assign list[..]=...or similar\n");
2009 if (like_lists==1)
2010 {
2011 // check blackbox/newtype type:
2012 if(bb->blackbox_CheckAssign(bb,l,r)) return TRUE;
2013 }
2014 b=jiAssign_list(l,r);
2015 if((!b) && (like_lists==2))
2016 {
2017 //Print("jjA_L_LIST: - 2 \n");
2018 if((l->rtyp==IDHDL) && (l->data!=NULL))
2019 {
2020 ipMoveId((idhdl)l->data);
2021 l->attribute=IDATTR((idhdl)l->data);
2022 l->flag=IDFLAG((idhdl)l->data);
2023 }
2024 }
2025 r->CleanUp();
2026 Subexpr h;
2027 while (l->e!=NULL)
2028 {
2029 h=l->e->next;
2031 l->e=h;
2032 }
2033 return b;
2034 }
2035 }
2036 if (lt>MAX_TOK)
2037 {
2038 blackbox *bb=getBlackboxStuff(lt);
2039#ifdef BLACKBOX_DEVEL
2040 Print("bb-assign: bb=%lx\n",bb);
2041#endif
2042 return (bb==NULL) || bb->blackbox_Assign(l,r);
2043 }
2044 // end of handling elems of list and similar
2045 rl=r->listLength();
2046 if (rl==1)
2047 {
2048 /* system variables = ... */
2049 if(((l->rtyp>=VECHO)&&(l->rtyp<=VPRINTLEVEL))
2050 ||((l->rtyp>=VALTVARS)&&(l->rtyp<=VMINPOLY)))
2051 {
2052 b=iiAssign_sys(l,r);
2053 r->CleanUp();
2054 //l->CleanUp();
2055 return b;
2056 }
2057 rt=r->Typ();
2058 /* a = ... */
2059 if ((lt!=MATRIX_CMD)
2060 &&(lt!=BIGINTMAT_CMD)
2061 &&(lt!=CMATRIX_CMD)
2062 &&(lt!=INTMAT_CMD)
2063 &&((lt==rt)||(lt!=LIST_CMD)))
2064 {
2065 b=jiAssign_1(l,r,rt,toplevel,is_qring);
2066 if (l->rtyp==IDHDL)
2067 {
2068 if ((lt==DEF_CMD)||(lt==LIST_CMD))
2069 {
2070 ipMoveId((idhdl)l->data);
2071 }
2072 l->attribute=IDATTR((idhdl)l->data);
2073 l->flag=IDFLAG((idhdl)l->data);
2074 l->CleanUp();
2075 }
2076 r->CleanUp();
2077 return b;
2078 }
2079 if (((lt!=LIST_CMD)
2080 &&((rt==MATRIX_CMD)
2081 ||(rt==BIGINTMAT_CMD)
2082 ||(rt==CMATRIX_CMD)
2083 ||(rt==INTMAT_CMD)
2084 ||(rt==INTVEC_CMD)
2085 ||(rt==MODUL_CMD)))
2086 ||((lt==LIST_CMD)
2087 &&(rt==RESOLUTION_CMD))
2088 )
2089 {
2090 b=jiAssign_1(l,r,rt,toplevel);
2091 if((l->rtyp==IDHDL)&&(l->data!=NULL))
2092 {
2093 if ((lt==DEF_CMD) || (lt==LIST_CMD))
2094 {
2095 //Print("ipAssign - 3.0\n");
2096 ipMoveId((idhdl)l->data);
2097 }
2098 l->attribute=IDATTR((idhdl)l->data);
2099 l->flag=IDFLAG((idhdl)l->data);
2100 }
2101 r->CleanUp();
2102 Subexpr h;
2103 while (l->e!=NULL)
2104 {
2105 h=l->e->next;
2107 l->e=h;
2108 }
2109 return b;
2110 }
2111 }
2112 if (rt==NONE) rt=r->Typ();
2113 }
2114 else if (ll==(rl=r->listLength()))
2115 {
2116 b=jiAssign_rec(l,r);
2117 return b;
2118 }
2119 else
2120 {
2121 if (rt==NONE) rt=r->Typ();
2122 if (rt==INTVEC_CMD)
2123 return jiA_INTVEC_L(l,r);
2124 else if (rt==VECTOR_CMD)
2125 return jiA_VECTOR_L(l,r);
2126 else if ((rt==IDEAL_CMD)||(rt==MATRIX_CMD))
2127 return jiA_MATRIX_L(l,r);
2128 else if ((rt==STRING_CMD)&&(rl==1))
2129 return jiA_STRING_L(l,r);
2130 Werror("length of lists in assignment does not match (l:%d,r:%d)",
2131 ll,rl);
2132 return TRUE;
2133 }
2134
2135 leftv hh=r;
2136 BOOLEAN map_assign=FALSE;
2137 switch (lt)
2138 {
2139 case INTVEC_CMD:
2141 break;
2142 case INTMAT_CMD:
2143 {
2144 b=jjA_L_INTVEC(l,r,new intvec(IDINTVEC((idhdl)l->data)));
2145 break;
2146 }
2147 case BIGINTMAT_CMD:
2148 {
2149 b=jjA_L_BIGINTMAT(l, r, new bigintmat(IDBIMAT((idhdl)l->data)));
2150 break;
2151 }
2152 case MAP_CMD:
2153 {
2154 // first element in the list sl (r) must be a ring
2155 if ((rt == RING_CMD)&&(r->e==NULL))
2156 {
2157 omFreeBinAddr((ADDRESS)IDMAP((idhdl)l->data)->preimage);
2158 IDMAP((idhdl)l->data)->preimage = omStrDup (r->Fullname());
2159 /* advance the expressionlist to get the next element after the ring */
2160 hh = r->next;
2161 }
2162 else
2163 {
2164 WerrorS("expected ring-name");
2165 b=TRUE;
2166 break;
2167 }
2168 if (hh==NULL) /* map-assign: map f=r; */
2169 {
2170 WerrorS("expected image ideal");
2171 b=TRUE;
2172 break;
2173 }
2174 if ((hh->next==NULL)&&(hh->Typ()==IDEAL_CMD))
2175 {
2176 b=jiAssign_1(l,hh,IDEAL_CMD,toplevel); /* map-assign: map f=r,i; */
2178 return b;
2179 }
2180 //no break, handle the rest like an ideal:
2181 map_assign=TRUE; // and continue
2182 }
2183 case MATRIX_CMD:
2184 case IDEAL_CMD:
2185 case MODUL_CMD:
2186 {
2187 sleftv t;
2188 matrix olm = (matrix)l->Data();
2189 long rk;
2190 char *pr=((map)olm)->preimage;
2191 BOOLEAN module_assign=(/*l->Typ()*/ lt==MODUL_CMD);
2192 matrix lm ;
2193 long num;
2194 int j,k;
2195 int i=0;
2196 int mtyp=MATRIX_CMD; /*Type of left side object*/
2197 int etyp=POLY_CMD; /*Type of elements of left side object*/
2198
2199 if (lt /*l->Typ()*/==MATRIX_CMD)
2200 {
2201 rk=olm->rows();
2202 num=olm->cols()*rk /*olm->rows()*/;
2203 lm=mpNew(olm->rows(),olm->cols());
2204 int el;
2205 if ((traceit&TRACE_ASSIGN) && (num!=(el=exprlist_length(hh))))
2206 {
2207 Warn("expression list length(%d) does not match matrix size(%d)",el,num);
2208 }
2209 }
2210 else /* IDEAL_CMD or MODUL_CMD */
2211 {
2212 num=exprlist_length(hh);
2213 lm=(matrix)idInit(num,1);
2214 if (module_assign)
2215 {
2216 rk=0;
2217 mtyp=MODUL_CMD;
2218 etyp=VECTOR_CMD;
2219 }
2220 else
2221 rk=1;
2222 }
2223
2224 int ht;
2225 loop
2226 {
2227 if (hh==NULL)
2228 break;
2229 else
2230 {
2231 matrix rm;
2232 ht=hh->Typ();
2233 if ((j=iiTestConvert(ht,etyp))!=0)
2234 {
2235 b=iiConvert(ht,etyp,j,hh,&t);
2236 hh->next=t.next;
2237 if (b)
2238 { Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(etyp));
2239 break;
2240 }
2241 lm->m[i]=(poly)t.CopyD(etyp);
2242 pNormalize(lm->m[i]);
2243 if (module_assign) rk=si_max(rk,pMaxComp(lm->m[i]));
2244 i++;
2245 }
2246 else
2247 if ((j=iiTestConvert(ht,mtyp))!=0)
2248 {
2249 b=iiConvert(ht,mtyp,j,hh,&t);
2250 hh->next=t.next;
2251 if (b)
2252 { Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(mtyp));
2253 break;
2254 }
2255 rm = (matrix)t.CopyD(mtyp);
2256 if (module_assign)
2257 {
2258 j = si_min((int)num,rm->cols());
2259 rk=si_max(rk,rm->rank);
2260 }
2261 else
2262 j = si_min(num-i,(long)rm->rows() * (long)rm->cols());
2263 for(k=0;k<j;k++,i++)
2264 {
2265 lm->m[i]=rm->m[k];
2266 pNormalize(lm->m[i]);
2267 rm->m[k]=NULL;
2268 }
2269 idDelete((ideal *)&rm);
2270 }
2271 else
2272 {
2273 b=TRUE;
2274 Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(mtyp));
2275 break;
2276 }
2277 t.next=NULL;t.CleanUp();
2278 if (i==num) break;
2279 hh=hh->next;
2280 }
2281 }
2282 if (b)
2283 idDelete((ideal *)&lm);
2284 else
2285 {
2286 idDelete((ideal *)&olm);
2287 if (module_assign) lm->rank=rk;
2288 else if (map_assign) ((map)lm)->preimage=pr;
2289 l=l->LData();
2290 if (l->rtyp==IDHDL)
2291 IDMATRIX((idhdl)l->data)=lm;
2292 else
2293 l->data=(char *)lm;
2294 }
2295 break;
2296 }
2297 case STRING_CMD:
2298 b=jjA_L_STRING(l,r);
2299 break;
2300 //case DEF_CMD:
2301 case LIST_CMD:
2302 b=jjA_L_LIST(l,r);
2303 break;
2304 case NONE:
2305 case 0:
2306 Werror("cannot assign to %s",l->Fullname());
2307 b=TRUE;
2308 break;
2309 default:
2310 WerrorS("assign not impl.");
2311 b=TRUE;
2312 break;
2313 } /* end switch: typ */
2314 if (b && (!errorreported)) WerrorS("incompatible type in list assignment");
2315 r->CleanUp();
2316 return b;
2317}
#define atKillAll(H)
Definition: attrib.h:47
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
#define BB_LIKE_LIST(B)
Definition: blackbox.h:53
CanonicalForm num(const CanonicalForm &f)
int k
Definition: cfEzgcd.cc:99
CanonicalForm b
Definition: cfModGcd.cc:4103
Matrices of numbers.
Definition: bigintmat.h:51
long rank
Definition: matpol.h:19
poly * m
Definition: matpol.h:18
void * CopyD(int t)
Definition: subexpr.cc:710
const char * Name()
Definition: subexpr.h:120
int j
Definition: facHensel.cc:110
VAR short errorreported
Definition: feFopen.cc:23
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:301
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:140
@ VALTVARS
Definition: grammar.cc:305
@ VMINPOLY
Definition: grammar.cc:309
@ RING_CMD
Definition: grammar.cc:281
static BOOLEAN jiA_MATRIX_L(leftv l, leftv r)
Definition: ipassign.cc:1756
static BOOLEAN jiA_VECTOR_L(leftv l, leftv r)
Definition: ipassign.cc:1518
static BOOLEAN iiAssign_sys(leftv l, leftv r)
Definition: ipassign.cc:1418
static BOOLEAN jiAssign_rec(leftv l, leftv r)
Definition: ipassign.cc:1940
static BOOLEAN jiAssign_1(leftv l, leftv r, int rt, BOOLEAN toplevel, BOOLEAN is_qring=FALSE)
Definition: ipassign.cc:1235
static BOOLEAN jjA_L_LIST(leftv l, leftv r)
Definition: ipassign.cc:1559
static BOOLEAN jiA_STRING_L(leftv l, leftv r)
Definition: ipassign.cc:1832
static BOOLEAN jjA_L_BIGINTMAT(leftv l, leftv r, bigintmat *bim)
Definition: ipassign.cc:1673
static BOOLEAN jiAssign_list(leftv l, leftv r)
Definition: ipassign.cc:1868
static BOOLEAN jjA_L_STRING(leftv l, leftv r)
Definition: ipassign.cc:1722
static BOOLEAN jiA_INTVEC_L(leftv l, leftv r)
Definition: ipassign.cc:1492
static BOOLEAN jjA_L_INTVEC(leftv l, leftv r, intvec *iv)
Definition: ipassign.cc:1624
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition: ipconv.cc:435
void ipMoveId(idhdl tomove)
Definition: ipid.cc:704
#define IDMATRIX(a)
Definition: ipid.h:134
#define hasFlag(A, F)
Definition: ipid.h:112
#define IDBIMAT(a)
Definition: ipid.h:129
#define IDFLAG(a)
Definition: ipid.h:120
#define FLAG_QRING_DEF
Definition: ipid.h:109
#define IDATTR(a)
Definition: ipid.h:123
int exprlist_length(leftv v)
Definition: ipshell.cc:552
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define pMaxComp(p)
Definition: polys.h:299
#define pNormalize(p)
Definition: polys.h:317
void PrintS(const char *s)
Definition: reporter.cc:284
#define TRACE_ASSIGN
Definition: reporter.h:46
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define loop
Definition: structs.h:75
VAR omBin sSubexpr_bin
Definition: subexpr.cc:40
@ VPRINTLEVEL
Definition: tok.h:215
@ CMATRIX_CMD
Definition: tok.h:46
@ VECHO
Definition: tok.h:208
@ MAX_TOK
Definition: tok.h:218
#define NONE
Definition: tok.h:221

◆ iiAssignCR()

BOOLEAN iiAssignCR ( leftv  r,
leftv  arg 
)

Definition at line 6517 of file ipshell.cc.

6518{
6519 char* ring_name=omStrDup((char*)r->Name());
6520 int t=arg->Typ();
6521 if (t==RING_CMD)
6522 {
6523 sleftv tmp;
6524 tmp.Init();
6525 tmp.rtyp=IDHDL;
6526 idhdl h=rDefault(ring_name);
6527 tmp.data=(char*)h;
6528 if (h!=NULL)
6529 {
6530 tmp.name=h->id;
6531 BOOLEAN b=iiAssign(&tmp,arg);
6532 if (b) return TRUE;
6533 rSetHdl(ggetid(ring_name));
6534 omFree(ring_name);
6535 return FALSE;
6536 }
6537 else
6538 return TRUE;
6539 }
6540 else if (t==CRING_CMD)
6541 {
6542 sleftv tmp;
6543 sleftv n;
6544 n.Init();
6545 n.name=ring_name;
6546 if (iiDeclCommand(&tmp,&n,myynest,CRING_CMD,&IDROOT)) return TRUE;
6547 if (iiAssign(&tmp,arg)) return TRUE;
6548 //Print("create %s\n",r->Name());
6549 //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6550 return FALSE;
6551 }
6552 //Print("create %s\n",r->Name());
6553 //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6554 return TRUE;// not handled -> error for now
6555}
const char * name
Definition: subexpr.h:87
VAR int myynest
Definition: febase.cc:41
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition: ipshell.cc:1199
idhdl rDefault(const char *s)
Definition: ipshell.cc:1645
void rSetHdl(idhdl h)
Definition: ipshell.cc:5128

◆ iiBranchTo()

BOOLEAN iiBranchTo ( leftv  r,
leftv  args 
)

Definition at line 1274 of file ipshell.cc.

1275{
1276 // must be inside a proc, as we simultae an proc_end at the end
1277 if (myynest==0)
1278 {
1279 WerrorS("branchTo can only occur in a proc");
1280 return TRUE;
1281 }
1282 // <string1...stringN>,<proc>
1283 // known: args!=NULL, l>=1
1284 int l=args->listLength();
1285 int ll=0;
1287 if (ll!=(l-1)) return FALSE;
1288 leftv h=args;
1289 // set up the table for type test:
1290 short *t=(short*)omAlloc(l*sizeof(short));
1291 t[0]=l-1;
1292 int b;
1293 int i;
1294 for(i=1;i<l;i++,h=h->next)
1295 {
1296 if (h->Typ()!=STRING_CMD)
1297 {
1298 omFreeBinAddr(t);
1299 Werror("arg %d is not a string",i);
1300 return TRUE;
1301 }
1302 int tt;
1303 b=IsCmd((char *)h->Data(),tt);
1304 if(b) t[i]=tt;
1305 else
1306 {
1307 omFreeBinAddr(t);
1308 Werror("arg %d is not a type name",i);
1309 return TRUE;
1310 }
1311 }
1312 if (h->Typ()!=PROC_CMD)
1313 {
1314 omFreeBinAddr(t);
1315 Werror("last(%d.) arg.(%s) is not a proc(but %s(%d)), nesting=%d",
1316 i,h->name,Tok2Cmdname(h->Typ()),h->Typ(),myynest);
1317 return TRUE;
1318 }
1320 omFreeBinAddr(t);
1321 if (b && (h->rtyp==IDHDL) && (h->e==NULL))
1322 {
1323 // get the proc:
1324 iiCurrProc=(idhdl)h->data;
1325 idhdl currProc=iiCurrProc; /*iiCurrProc may be changed after yyparse*/
1326 procinfo * pi=IDPROC(currProc);
1327 // already loaded ?
1328 if( pi->data.s.body==NULL )
1329 {
1331 if (pi->data.s.body==NULL) return TRUE;
1332 }
1333 // set currPackHdl/currPack
1334 if ((pi->pack!=NULL)&&(currPack!=pi->pack))
1335 {
1336 currPack=pi->pack;
1339 //Print("set pack=%s\n",IDID(currPackHdl));
1340 }
1341 // see iiAllStart:
1342 BITSET save1=si_opt_1;
1343 BITSET save2=si_opt_2;
1344 newBuffer( omStrDup(pi->data.s.body), BT_proc,
1345 pi, pi->data.s.body_lineno-(iiCurrArgs==NULL) );
1346 BOOLEAN err=yyparse();
1348 si_opt_1=save1;
1349 si_opt_2=save2;
1350 // now save the return-expr.
1352 memcpy(&sLastPrinted,&iiRETURNEXPR,sizeof(sleftv));
1354 // warning about args.:
1355 if (iiCurrArgs!=NULL)
1356 {
1357 if (err==0) Warn("too many arguments for %s",IDID(currProc));
1361 }
1362 // similate proc_end:
1363 // - leave input
1364 void myychangebuffer();
1366 // - set the current buffer to its end (this is a pointer in a buffer,
1367 // not a file ptr) "branchTo" is only valid in proc)
1369 // - kill local vars
1371 // - return
1372 newBuffer(omStrDup("\n;return(_);\n"),BT_execute);
1373 return (err!=0);
1374 }
1375 return FALSE;
1376}
char * buffer
Definition: fevoices.h:69
long fptr
Definition: fevoices.h:70
int listLength()
Definition: subexpr.cc:51
VAR Voice * currentVoice
Definition: fevoices.cc:49
@ BT_execute
Definition: fevoices.h:23
VAR idhdl currPackHdl
Definition: ipid.cc:55
idhdl packFindHdl(package r)
Definition: ipid.cc:831
#define IDID(a)
Definition: ipid.h:122
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:197
VAR idhdl iiCurrProc
Definition: ipshell.cc:81
void iiCheckPack(package &p)
Definition: ipshell.cc:1631
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:6575
void killlocals(int v)
Definition: ipshell.cc:386
void myychangebuffer()
Definition: scanner.cc:2311

◆ iiCallLibProc1()

void * iiCallLibProc1 ( const char *  n,
void *  arg,
int  arg_type,
BOOLEAN err 
)

Definition at line 627 of file iplib.cc.

628{
629 idhdl h=ggetid(n);
630 if ((h==NULL)
631 || (IDTYP(h)!=PROC_CMD))
632 {
633 err=2;
634 return NULL;
635 }
636 // ring handling
637 idhdl save_ringhdl=currRingHdl;
638 ring save_ring=currRing;
640 // argument:
641 sleftv tmp;
642 tmp.Init();
643 tmp.data=arg;
644 tmp.rtyp=arg_type;
645 // call proc
646 err=iiMake_proc(h,currPack,&tmp);
647 // clean up ring
648 iiCallLibProcEnd(save_ringhdl,save_ring);
649 // return
650 if (err==FALSE)
651 {
652 void*r=iiRETURNEXPR.data;
655 return r;
656 }
657 return NULL;
658}

◆ iiCheckPack()

void iiCheckPack ( package p)

Definition at line 1631 of file ipshell.cc.

1632{
1633 if (p!=basePack)
1634 {
1635 idhdl t=basePack->idroot;
1636 while ((t!=NULL) && (IDTYP(t)!=PACKAGE_CMD) && (IDPACKAGE(t)!=p)) t=t->next;
1637 if (t==NULL)
1638 {
1639 WarnS("package not found\n");
1640 p=basePack;
1641 }
1642 }
1643}
idhdl next
Definition: idrec.h:38
VAR package basePack
Definition: ipid.cc:58
#define IDPACKAGE(a)
Definition: ipid.h:139
@ PACKAGE_CMD
Definition: tok.h:149

◆ iiCheckRing()

BOOLEAN iiCheckRing ( int  i)

Definition at line 1587 of file ipshell.cc.

1588{
1589 if (currRing==NULL)
1590 {
1591 #ifdef SIQ
1592 if (siq<=0)
1593 {
1594 #endif
1595 if (RingDependend(i))
1596 {
1597 WerrorS("no ring active (9)");
1598 return TRUE;
1599 }
1600 #ifdef SIQ
1601 }
1602 #endif
1603 }
1604 return FALSE;
1605}
VAR BOOLEAN siq
Definition: subexpr.cc:48

◆ iiCheckTypes()

BOOLEAN iiCheckTypes ( leftv  args,
const short *  type_list,
int  report = 0 
)

check a list of arguemys against a given field of types return TRUE if the types match return FALSE (and, if report) report an error via Werror otherwise

Parameters
type_list< [in] argument list (may be NULL) [in] field of types len, t1,t2,...
report;in] report error?

Definition at line 6575 of file ipshell.cc.

6576{
6577 int l=0;
6578 if (args==NULL)
6579 {
6580 if (type_list[0]==0) return TRUE;
6581 }
6582 else l=args->listLength();
6583 if (l!=(int)type_list[0])
6584 {
6585 if (report) iiReportTypes(0,l,type_list);
6586 return FALSE;
6587 }
6588 for(int i=1;i<=l;i++,args=args->next)
6589 {
6590 short t=type_list[i];
6591 if (t!=ANY_TYPE)
6592 {
6593 if (((t==IDHDL)&&(args->rtyp!=IDHDL))
6594 || (t!=args->Typ()))
6595 {
6596 if (report) iiReportTypes(i,args->Typ(),type_list);
6597 return FALSE;
6598 }
6599 }
6600 }
6601 return TRUE;
6602}
static void iiReportTypes(int nr, int t, const short *T)
Definition: ipshell.cc:6557
void report(const char *fmt, const char *name)
Definition: shared.cc:666
#define ANY_TYPE
Definition: tok.h:30

◆ iiConvName()

char * iiConvName ( const char *  libname)

Definition at line 1430 of file iplib.cc.

1431{
1432 char *tmpname = omStrDup(libname);
1433 char *p = strrchr(tmpname, DIR_SEP);
1434 char *r;
1435 if(p==NULL) p = tmpname; else p++;
1436 // p is now the start of the file name (without path)
1437 r=p;
1438 while(isalnum(*r)||(*r=='_')) r++;
1439 // r point the the end of the main part of the filename
1440 *r = '\0';
1441 r = omStrDup(p);
1442 *r = mytoupper(*r);
1443 // printf("iiConvName: '%s' '%s' => '%s'\n", libname, tmpname, r);
1444 omFree((ADDRESS)tmpname);
1445
1446 return(r);
1447}
#define DIR_SEP
Definition: feResource.h:6
static char mytoupper(char c)
Definition: iplib.cc:1411

◆ iiDebug()

void iiDebug ( )

Definition at line 1066 of file ipshell.cc.

1067{
1068#ifdef HAVE_SDB
1069 sdb_flags=1;
1070#endif
1071 Print("\n-- break point in %s --\n",VoiceName());
1073 char * s;
1075 s = (char *)omAlloc(BREAK_LINE_LENGTH+4);
1076 loop
1077 {
1078 memset(s,0,BREAK_LINE_LENGTH+4);
1080 if (s[BREAK_LINE_LENGTH-1]!='\0')
1081 {
1082 Print("line too long, max is %d chars\n",BREAK_LINE_LENGTH);
1083 }
1084 else
1085 break;
1086 }
1087 if (*s=='\n')
1088 {
1090 }
1091#if MDEBUG
1092 else if(strncmp(s,"cont;",5)==0)
1093 {
1095 }
1096#endif /* MDEBUG */
1097 else
1098 {
1099 strcat( s, "\n;~\n");
1101 }
1102}
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:32
void VoiceBackTrack()
Definition: fevoices.cc:77
VAR BOOLEAN iiDebugMarker
Definition: ipshell.cc:1064
#define BREAK_LINE_LENGTH
Definition: ipshell.cc:1065
VAR int sdb_flags
Definition: sdb.cc:31

◆ iiDeclCommand()

int iiDeclCommand ( leftv  sy,
leftv  name,
int  lev,
int  t,
idhdl root,
BOOLEAN  isring = FALSE,
BOOLEAN  init_b = TRUE 
)

Definition at line 1199 of file ipshell.cc.

1200{
1202 BOOLEAN is_qring=FALSE;
1203 const char *id = name->name;
1204
1205 sy->Init();
1206 if ((name->name==NULL)||(isdigit(name->name[0])))
1207 {
1208 WerrorS("object to declare is not a name");
1209 res=TRUE;
1210 }
1211 else
1212 {
1213 if (root==NULL) return TRUE;
1214 if (*root!=IDROOT)
1215 {
1216 if ((currRing==NULL) || (*root!=currRing->idroot))
1217 {
1218 Werror("can not define `%s` in other package",name->name);
1219 return TRUE;
1220 }
1221 }
1222 if (t==QRING_CMD)
1223 {
1224 t=RING_CMD; // qring is always RING_CMD
1225 is_qring=TRUE;
1226 }
1227
1228 if (TEST_V_ALLWARN
1229 && (name->rtyp!=0)
1230 && (name->rtyp!=IDHDL)
1232 {
1233 Warn("`%s` is %s in %s:%d:%s",name->name,Tok2Cmdname(name->rtyp),
1235 }
1236 {
1237 sy->data = (char *)enterid(id,lev,t,root,init_b);
1238 }
1239 if (sy->data!=NULL)
1240 {
1241 sy->rtyp=IDHDL;
1242 currid=sy->name=IDID((idhdl)sy->data);
1243 if (is_qring)
1244 {
1246 }
1247 // name->name=NULL; /* used in enterid */
1248 //sy->e = NULL;
1249 if (name->next!=NULL)
1250 {
1252 res=iiDeclCommand(sy->next,name->next,lev,t,root, isring);
1253 }
1254 }
1255 else res=TRUE;
1256 }
1257 name->CleanUp();
1258 return res;
1259}
char * filename
Definition: fevoices.h:63
BITSET flag
Definition: subexpr.h:90
VAR int yylineno
Definition: febase.cc:40
VAR char my_yylinebuf[80]
Definition: febase.cc:44
const char * currid
Definition: grammar.cc:171
#define IDLEV(a)
Definition: ipid.h:121
#define Sy_bit(x)
Definition: options.h:31
@ QRING_CMD
Definition: tok.h:158

◆ iiEStart()

BOOLEAN iiEStart ( char *  example,
procinfo pi 
)

Definition at line 754 of file iplib.cc.

755{
756 BOOLEAN err;
757 int old_echo=si_echo;
758
759 iiCheckNest();
760 procstack->push(example);
763 {
764 if (traceit&TRACE_SHOW_LINENO) printf("\n");
765 printf("entering example (level %d)\n",myynest);
766 }
767 myynest++;
768
769 err=iiAllStart(pi,example,BT_example,(pi != NULL ? pi->data.s.example_lineno: 0));
770
772 myynest--;
773 si_echo=old_echo;
775 {
776 if (traceit&TRACE_SHOW_LINENO) printf("\n");
777 printf("leaving -example- (level %d)\n",myynest);
778 }
780 {
782 {
785 }
786 else
787 {
790 }
791 }
792 procstack->pop();
793 return err;
794}
void pop()
Definition: ipid.cc:813
void push(char *)
Definition: ipid.cc:803
VAR int si_echo
Definition: febase.cc:35
@ BT_example
Definition: fevoices.h:21
VAR proclevel * procstack
Definition: ipid.cc:52
static void iiCheckNest()
Definition: iplib.cc:493
VAR ring * iiLocalRing
Definition: iplib.cc:473
BOOLEAN iiAllStart(procinfov pi, const char *p, feBufferTypes t, int l)
Definition: iplib.cc:298
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1702
#define TRACE_SHOW_LINENO
Definition: reporter.h:31
#define TRACE_SHOW_PROC
Definition: reporter.h:29

◆ iiExport() [1/2]

BOOLEAN iiExport ( leftv  v,
int  toLev 
)

Definition at line 1512 of file ipshell.cc.

1513{
1514 BOOLEAN nok=FALSE;
1515 leftv r=v;
1516 while (v!=NULL)
1517 {
1518 if ((v->name==NULL)||(v->rtyp==0)||(v->e!=NULL))
1519 {
1520 Werror("cannot export:%s of internal type %d",v->name,v->rtyp);
1521 nok=TRUE;
1522 }
1523 else
1524 {
1525 if(iiInternalExport(v, toLev))
1526 nok=TRUE;
1527 }
1528 v=v->next;
1529 }
1530 r->CleanUp();
1531 return nok;
1532}
char name() const
Definition: variable.cc:122
static BOOLEAN iiInternalExport(leftv v, int toLev)
Definition: ipshell.cc:1413

◆ iiExport() [2/2]

BOOLEAN iiExport ( leftv  v,
int  toLev,
package  pack 
)

Definition at line 1535 of file ipshell.cc.

1536{
1537// if ((pack==basePack)&&(pack!=currPack))
1538// { Warn("'exportto' to Top is depreciated in >>%s<<",my_yylinebuf);}
1539 BOOLEAN nok=FALSE;
1540 leftv rv=v;
1541 while (v!=NULL)
1542 {
1543 if ((v->name==NULL)||(v->rtyp==0)||(v->e!=NULL)
1544 )
1545 {
1546 Werror("cannot export:%s of internal type %d",v->name,v->rtyp);
1547 nok=TRUE;
1548 }
1549 else
1550 {
1551 idhdl old=pack->idroot->get( v->name,toLev);
1552 if (old!=NULL)
1553 {
1554 if ((pack==currPack) && (old==(idhdl)v->data))
1555 {
1556 if (BVERBOSE(V_REDEFINE)) Warn("`%s` is already global",IDID(old));
1557 break;
1558 }
1559 else if (IDTYP(old)==v->Typ())
1560 {
1561 if (BVERBOSE(V_REDEFINE))
1562 {
1563 Warn("redefining %s (%s)",IDID(old),my_yylinebuf);
1564 }
1565 v->name=omStrDup(v->name);
1566 killhdl2(old,&(pack->idroot),currRing);
1567 }
1568 else
1569 {
1570 rv->CleanUp();
1571 return TRUE;
1572 }
1573 }
1574 //Print("iiExport: pack=%s\n",IDID(root));
1575 if(iiInternalExport(v, toLev, pack))
1576 {
1577 rv->CleanUp();
1578 return TRUE;
1579 }
1580 }
1581 v=v->next;
1582 }
1583 rv->CleanUp();
1584 return nok;
1585}
idhdl get(const char *s, int lev)
Definition: ipid.cc:72
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:445

◆ iiExprArith1()

BOOLEAN iiExprArith1 ( leftv  res,
sleftv a,
int  op 
)

◆ 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

Parameters
[out]respre-allocated result
[in]aargument
[in]opoperation
[in]dA1table of possible proc assumes dArith1[0].cmd==op
[in]ata->Typ()
[in]dConvertTypestable of type conversions

Definition at line 8984 of file iparith.cc.

8985{
8986 res->Init();
8987 BOOLEAN call_failed=FALSE;
8988
8989 if (!errorreported)
8990 {
8991 BOOLEAN failed=FALSE;
8992 iiOp=op;
8993 int i = 0;
8994 while (dA1[i].cmd==op)
8995 {
8996 if (at==dA1[i].arg)
8997 {
8998 if (currRing!=NULL)
8999 {
9000 if (check_valid(dA1[i].valid_for,op)) break;
9001 }
9002 else
9003 {
9004 if (RingDependend(dA1[i].res))
9005 {
9006 WerrorS("no ring active (5)");
9007 break;
9008 }
9009 }
9010 if (traceit&TRACE_CALL)
9011 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
9012 res->rtyp=dA1[i].res;
9013 if ((call_failed=dA1[i].p(res,a)))
9014 {
9015 break;// leave loop, goto error handling
9016 }
9017 if (a->Next()!=NULL)
9018 {
9020 failed=iiExprArith1(res->next,a->next,op);
9021 }
9022 a->CleanUp();
9023 return failed;
9024 }
9025 i++;
9026 }
9027 // implicite type conversion --------------------------------------------
9028 if (dA1[i].cmd!=op)
9029 {
9031 i=0;
9032 //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
9033 while (dA1[i].cmd==op)
9034 {
9035 int ai;
9036 //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
9037 if ((dA1[i].valid_for & NO_CONVERSION)==0)
9038 {
9039 if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
9040 {
9041 if (currRing!=NULL)
9042 {
9043 if (check_valid(dA1[i].valid_for,op)) break;
9044 }
9045 else
9046 {
9047 if (RingDependend(dA1[i].res))
9048 {
9049 WerrorS("no ring active (6)");
9050 break;
9051 }
9052 }
9053 if (traceit&TRACE_CALL)
9054 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
9055 res->rtyp=dA1[i].res;
9056 failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
9057 || (call_failed=dA1[i].p(res,an)));
9058 // everything done, clean up temp. variables
9059 if (failed)
9060 {
9061 // leave loop, goto error handling
9062 break;
9063 }
9064 else
9065 {
9066 if (an->Next() != NULL)
9067 {
9068 res->next = (leftv)omAllocBin(sleftv_bin);
9069 failed=iiExprArith1(res->next,an->next,op);
9070 }
9071 // everything ok, clean up and return
9072 an->CleanUp();
9074 return failed;
9075 }
9076 }
9077 }
9078 i++;
9079 }
9080 an->CleanUp();
9082 }
9083 // error handling
9084 if (!errorreported)
9085 {
9086 if ((at==0) && (a->Fullname()!=sNoName_fe))
9087 {
9088 Werror("`%s` is not defined",a->Fullname());
9089 }
9090 else
9091 {
9092 i=0;
9093 const char *s = iiTwoOps(op);
9094 Werror("%s(`%s`) failed"
9095 ,s,Tok2Cmdname(at));
9096 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9097 {
9098 while (dA1[i].cmd==op)
9099 {
9100 if ((dA1[i].res!=0)
9101 && (dA1[i].p!=jjWRONG))
9102 Werror("expected %s(`%s`)"
9103 ,s,Tok2Cmdname(dA1[i].arg));
9104 i++;
9105 }
9106 }
9107 }
9108 }
9109 res->rtyp = UNKNOWN;
9110 }
9111 a->CleanUp();
9112 return TRUE;
9113}
leftv Next()
Definition: subexpr.h:136
const char * Fullname()
Definition: subexpr.h:125
const char sNoName_fe[]
Definition: fevoices.cc:57
const char * iiTwoOps(int t)
Definition: gentable.cc:261
static BOOLEAN jjWRONG(leftv, leftv)
Definition: iparith.cc:3694
#define NO_CONVERSION
Definition: iparith.cc:120
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:9114
static BOOLEAN check_valid(const int p, const int op)
Definition: iparith.cc:9928
VAR int iiOp
Definition: iparith.cc:222
const char * Tok2Cmdname(int tok)
Definition: iparith.cc:9648
const struct sConvertTypes dConvertTypes[]
Definition: table.h:1285
short res
Definition: gentable.cc:82
#define V_SHOW_USE
Definition: options.h:52
#define TRACE_CALL
Definition: reporter.h:44
#define UNKNOWN
Definition: tok.h:222

◆ iiExprArith2()

BOOLEAN iiExprArith2 ( leftv  res,
sleftv a,
int  op,
sleftv b,
BOOLEAN  proccall = FALSE 
)

◆ 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

Parameters
[out]respre-allocated result
[in]a2 arguments
[in]opoperation
[in]dA2table of possible proc assumes dA2[0].cmd==op
[in]ata->Typ()
[in]dConvertTypestable of type conversions

Definition at line 8911 of file iparith.cc.

8915{
8916 res->Init();
8917 leftv b=a->next;
8918 a->next=NULL;
8919 int bt=b->Typ();
8921 a->next=b;
8922 a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
8923 return bo;
8924}
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:8752

◆ iiExprArith3()

BOOLEAN iiExprArith3 ( leftv  res,
int  op,
leftv  a,
leftv  b,
leftv  c 
)

Definition at line 9324 of file iparith.cc.

9325{
9326 res->Init();
9327
9328 if (!errorreported)
9329 {
9330#ifdef SIQ
9331 if (siq>0)
9332 {
9333 //Print("siq:%d\n",siq);
9335 memcpy(&d->arg1,a,sizeof(sleftv));
9336 a->Init();
9337 memcpy(&d->arg2,b,sizeof(sleftv));
9338 b->Init();
9339 memcpy(&d->arg3,c,sizeof(sleftv));
9340 c->Init();
9341 d->op=op;
9342 d->argc=3;
9343 res->data=(char *)d;
9344 res->rtyp=COMMAND;
9345 return FALSE;
9346 }
9347#endif
9348 int at=a->Typ();
9349 // handling bb-objects ----------------------------------------------
9350 if (at>MAX_TOK)
9351 {
9352 blackbox *bb=getBlackboxStuff(at);
9353 if (bb!=NULL)
9354 {
9355 if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
9356 // otherwise, try defaul (attrib,..)
9357 }
9358 else
9359 return TRUE;
9360 if (errorreported) return TRUE;
9361 }
9362 int bt=b->Typ();
9363 int ct=c->Typ();
9364
9365 iiOp=op;
9366 int i=0;
9367 while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
9368 return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
9369 }
9370 a->CleanUp();
9371 b->CleanUp();
9372 c->CleanUp();
9373 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9374 return TRUE;
9375}
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:9171
VAR omBin sip_command_bin
Definition: ipid.cc:45
ip_command * command
Definition: ipid.h:23
const struct sValCmd3 dArith3[]
Definition: table.h:777
#define COMMAND
Definition: tok.h:29

◆ 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

Parameters
[out]respre-allocated result
[in]a3 arguments
[in]opoperation
[in]dA3table of possible proc assumes dA3[0].cmd==op
[in]ata->Typ()
[in]dConvertTypestable of type conversions

Definition at line 9376 of file iparith.cc.

9380{
9381 res->Init();
9382 leftv b=a->next;
9383 a->next=NULL;
9384 int bt=b->Typ();
9385 leftv c=b->next;
9386 b->next=NULL;
9387 int ct=c->Typ();
9388 BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
9389 b->next=c;
9390 a->next=b;
9391 a->CleanUp(); // to cleanup the chain, content already done
9392 return bo;
9393}

◆ iiExprArithM()

BOOLEAN iiExprArithM ( leftv  res,
sleftv a,
int  op 
)

◆ iiGetLibName()

static char * iiGetLibName ( const procinfov  pi)
inlinestatic

find the library of an proc

Definition at line 66 of file ipshell.h.

66{ return pi->libname; }

◆ iiGetLibProcBuffer()

char * iiGetLibProcBuffer ( procinfov  pi,
int  part = 1 
)

◆ iiGetLibStatus()

BOOLEAN iiGetLibStatus ( const char *  lib)

Definition at line 77 of file iplib.cc.

78{
79 idhdl hl;
80
81 char *plib = iiConvName(lib);
82 hl = basePack->idroot->get(plib,0);
83 omFreeBinAddr(plib);
84 if((hl==NULL) ||(IDTYP(hl)!=PACKAGE_CMD))
85 {
86 return FALSE;
87 }
88 if ((IDPACKAGE(hl)->language!=LANG_C)&&(IDPACKAGE(hl)->libname!=NULL))
89 return (strcmp(lib,IDPACKAGE(hl)->libname)==0);
90 return FALSE;
91}

◆ iiHighCorner()

poly iiHighCorner ( ideal  i,
int  ak 
)

Definition at line 1607 of file ipshell.cc.

1608{
1609 int i;
1610 if(!idIsZeroDim(I)) return NULL; // not zero-dim.
1611 poly po=NULL;
1613 {
1614 scComputeHC(I,currRing->qideal,ak,po);
1615 if (po!=NULL)
1616 {
1617 pGetCoeff(po)=nInit(1);
1618 for (i=rVar(currRing); i>0; i--)
1619 {
1620 if (pGetExp(po, i) > 0) pDecrExp(po,i);
1621 }
1622 pSetComp(po,ak);
1623 pSetm(po);
1624 }
1625 }
1626 else
1627 po=pOne();
1628 return po;
1629}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition: hdegree.cc:1101
static BOOLEAN idIsZeroDim(ideal i)
Definition: ideals.h:177
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
#define nInit(i)
Definition: numbers.h:24
#define pSetm(p)
Definition: polys.h:271
#define pSetComp(p, v)
Definition: polys.h:38
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pOne()
Definition: polys.h:315
#define pDecrExp(p, i)
Definition: polys.h:44
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:762

◆ iiInternalExport()

BOOLEAN iiInternalExport ( leftv  v,
int  toLev,
package  pack 
)

Definition at line 1466 of file ipshell.cc.

1467{
1468 idhdl h=(idhdl)v->data;
1469 if(h==NULL)
1470 {
1471 Warn("'%s': no such identifier\n", v->name);
1472 return FALSE;
1473 }
1474 package frompack=v->req_packhdl;
1475 if (frompack==NULL) frompack=currPack;
1476 if ((RingDependend(IDTYP(h)))
1477 || ((IDTYP(h)==LIST_CMD)
1478 && (lRingDependend(IDLIST(h)))
1479 )
1480 )
1481 {
1482 //Print("// ==> Ringdependent set nesting to 0\n");
1483 return (iiInternalExport(v, toLev));
1484 }
1485 else
1486 {
1487 IDLEV(h)=toLev;
1488 v->req_packhdl=rootpack;
1489 if (h==frompack->idroot)
1490 {
1491 frompack->idroot=h->next;
1492 }
1493 else
1494 {
1495 idhdl hh=frompack->idroot;
1496 while ((hh!=NULL) && (hh->next!=h))
1497 hh=hh->next;
1498 if ((hh!=NULL) && (hh->next==h))
1499 hh->next=h->next;
1500 else
1501 {
1502 Werror("`%s` not found",v->Name());
1503 return TRUE;
1504 }
1505 }
1506 h->next=rootpack->idroot;
1507 rootpack->idroot=h;
1508 }
1509 return FALSE;
1510}

◆ iiLibCmd()

BOOLEAN iiLibCmd ( const char *  newlib,
BOOLEAN  autoexport,
BOOLEAN  tellerror,
BOOLEAN  force 
)

Definition at line 885 of file iplib.cc.

886{
887 if (strcmp(newlib,"Singular")==0) return FALSE;
888 char libnamebuf[1024];
889 idhdl pl;
890 char *plib = iiConvName(newlib);
891 FILE * fp = feFopen( newlib, "r", libnamebuf, tellerror );
892 // int lines = 1;
893 BOOLEAN LoadResult = TRUE;
894
895 if (fp==NULL)
896 {
897 return TRUE;
898 }
899 pl = basePack->idroot->get(plib,0);
900 if (pl==NULL)
901 {
902 pl = enterid( plib,0, PACKAGE_CMD,
903 &(basePack->idroot), TRUE );
904 IDPACKAGE(pl)->language = LANG_SINGULAR;
905 IDPACKAGE(pl)->libname=omStrDup(newlib);
906 }
907 else
908 {
909 if(IDTYP(pl)!=PACKAGE_CMD)
910 {
911 omFreeBinAddr(plib);
912 WarnS("not of type package.");
913 fclose(fp);
914 return TRUE;
915 }
916 if (!force)
917 {
918 omFreeBinAddr(plib);
919 return FALSE;
920 }
921 }
922 LoadResult = iiLoadLIB(fp, libnamebuf, newlib, pl, autoexport, tellerror);
923
924 if(!LoadResult) IDPACKAGE(pl)->loaded = TRUE;
925 omFree((ADDRESS)plib);
926 return LoadResult;
927}
CanonicalForm fp
Definition: cfModGcd.cc:4102
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:974
VAR char libnamebuf[1024]
Definition: libparse.cc:1098

◆ iiLoadLIB()

BOOLEAN iiLoadLIB ( FILE *  fp,
const char *  libnamebuf,
const char *  newlib,
idhdl  pl,
BOOLEAN  autoexport,
BOOLEAN  tellerror 
)

Definition at line 974 of file iplib.cc.

976{
977 EXTERN_VAR FILE *yylpin;
978 libstackv ls_start = library_stack;
979 lib_style_types lib_style;
980
981 yylpin = fp;
982 #if YYLPDEBUG > 1
983 print_init();
984 #endif
987 else lpverbose=0;
988 // yylplex sets also text_buffer
989 if (text_buffer!=NULL) *text_buffer='\0';
990 yylplex(newlib, libnamebuf, &lib_style, pl, autoexport);
991 if(yylp_errno)
992 {
993 Werror("Library %s: ERROR occurred: in line %d, %d.", newlib, yylplineno,
994 current_pos(0));
996 {
1000 }
1001 else
1003 WerrorS("Cannot load library,... aborting.");
1004 reinit_yylp();
1005 fclose( yylpin );
1007 return TRUE;
1008 }
1009 if (BVERBOSE(V_LOAD_LIB))
1010 Print( "// ** loaded %s %s\n", libnamebuf, text_buffer);
1011 if( (lib_style == OLD_LIBSTYLE) && (BVERBOSE(V_LOAD_LIB)))
1012 {
1013 Warn( "library %s has old format. This format is still accepted,", newlib);
1014 WarnS( "but for functionality you may wish to change to the new");
1015 WarnS( "format. Please refer to the manual for further information.");
1016 }
1017 reinit_yylp();
1018 fclose( yylpin );
1019 fp = NULL;
1020 iiRunInit(IDPACKAGE(pl));
1021
1022 {
1023 libstackv ls;
1024 for(ls = library_stack; (ls != NULL) && (ls != ls_start); )
1025 {
1026 if(ls->to_be_done)
1027 {
1028 ls->to_be_done=FALSE;
1029 iiLibCmd(ls->get(),autoexport,tellerror,FALSE);
1030 ls = ls->pop(newlib);
1031 }
1032 }
1033#if 0
1034 PrintS("--------------------\n");
1035 for(ls = library_stack; ls != NULL; ls = ls->next)
1036 {
1037 Print("%s: LIB-stack:(%d), %s %s\n", newlib, ls->cnt, ls->get(),
1038 ls->to_be_done ? "not loaded" : "loaded");
1039 }
1040 PrintS("--------------------\n");
1041#endif
1042 }
1043
1044 if(fp != NULL) fclose(fp);
1045 return FALSE;
1046}
char * get()
Definition: subexpr.h:170
libstackv next
Definition: subexpr.h:164
libstackv pop(const char *p)
Definition: iplib.cc:1521
int cnt
Definition: subexpr.h:167
BOOLEAN to_be_done
Definition: subexpr.h:166
#define EXTERN_VAR
Definition: globaldefs.h:6
int current_pos(int i=0)
Definition: libparse.cc:3346
void print_init()
Definition: libparse.cc:3482
static void iiCleanProcs(idhdl &root)
Definition: iplib.cc:929
VAR libstackv library_stack
Definition: iplib.cc:68
const char * yylp_errlist[]
Definition: libparse.cc:1114
EXTERN_VAR int yylplineno
Definition: iplib.cc:65
static void iiRunInit(package p)
Definition: iplib.cc:958
EXTERN_VAR int yylp_errno
Definition: iplib.cc:64
void reinit_yylp()
Definition: libparse.cc:3376
VAR char * text_buffer
Definition: libparse.cc:1099
VAR int lpverbose
Definition: libparse.cc:1106
lib_style_types
Definition: libparse.h:9
@ OLD_LIBSTYLE
Definition: libparse.h:9
#define YYLP_BAD_CHAR
Definition: libparse.h:93
int yylplex(const char *libname, const char *libfile, lib_style_types *lib_style, idhdl pl, BOOLEAN autoexport=FALSE, lp_modes=LOAD_LIB)
#define V_DEBUG_LIB
Definition: options.h:48
#define V_LOAD_LIB
Definition: options.h:47

◆ iiLocateLib()

BOOLEAN iiLocateLib ( const char *  lib,
char *  where 
)

Definition at line 871 of file iplib.cc.

872{
873 char *plib = iiConvName(lib);
874 idhdl pl = basePack->idroot->get(plib,0);
875 if( (pl!=NULL) && (IDTYP(pl)==PACKAGE_CMD) &&
876 (IDPACKAGE(pl)->language == LANG_SINGULAR))
877 {
878 strncpy(where,IDPACKAGE(pl)->libname,127);
879 return TRUE;
880 }
881 else
882 return FALSE;;
883}

◆ iiMake_proc()

BOOLEAN iiMake_proc ( idhdl  pn,
package  pack,
leftv  sl 
)

Definition at line 504 of file iplib.cc.

505{
506 int err;
507 procinfov pi = IDPROC(pn);
508 if(pi->is_static && myynest==0)
509 {
510 Werror("'%s::%s()' is a local procedure and cannot be accessed by an user.",
511 pi->libname, pi->procname);
512 return TRUE;
513 }
514 iiCheckNest();
516 //Print("currRing(%d):%s(%x) in %s\n",myynest,IDID(currRingHdl),currRing,IDID(pn));
518 procstack->push(pi->procname);
520 || (pi->trace_flag&TRACE_SHOW_PROC))
521 {
523 Print("entering%-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
524 }
525#ifdef RDEBUG
527#endif
528 switch (pi->language)
529 {
530 default:
531 case LANG_NONE:
532 WerrorS("undefined proc");
533 err=TRUE;
534 break;
535
536 case LANG_SINGULAR:
537 if ((pi->pack!=NULL)&&(currPack!=pi->pack))
538 {
539 currPack=pi->pack;
542 //Print("set pack=%s\n",IDID(currPackHdl));
543 }
544 else if ((pack!=NULL)&&(currPack!=pack))
545 {
546 currPack=pack;
549 //Print("set pack=%s\n",IDID(currPackHdl));
550 }
551 err=iiPStart(pn,args);
552 break;
553 case LANG_C:
555 err = (pi->data.o.function)(res, args);
556 memcpy(&iiRETURNEXPR,res,sizeof(iiRETURNEXPR));
558 break;
559 }
561 || (pi->trace_flag&TRACE_SHOW_PROC))
562 {
564 Print("leaving %-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
565 }
566 //const char *n="NULL";
567 //if (currRingHdl!=NULL) n=IDID(currRingHdl);
568 //Print("currRing(%d):%s(%x) after %s\n",myynest,n,currRing,IDID(pn));
569#ifdef RDEBUG
571#endif
572 if (err)
573 {
575 //iiRETURNEXPR.Init(); //done by CleanUp
576 }
577 if (iiCurrArgs!=NULL)
578 {
579 if (!err) Warn("too many arguments for %s",IDID(pn));
583 }
584 procstack->pop();
585 if (err)
586 return TRUE;
587 return FALSE;
588}
static void iiShowLevRings()
Definition: iplib.cc:478
BOOLEAN iiPStart(idhdl pn, leftv v)
Definition: iplib.cc:371
#define TRACE_SHOW_RINGS
Definition: reporter.h:36

◆ iiMakeResolv()

void iiMakeResolv ( resolvente  r,
int  length,
int  rlen,
char *  name,
int  typ0,
intvec **  weights = NULL 
)

Definition at line 847 of file ipshell.cc.

849{
850 lists L=liMakeResolv(r,length,rlen,typ0,weights);
851 int i=0;
852 idhdl h;
853 size_t len=strlen(name)+5;
854 char * s=(char *)omAlloc(len);
855
856 while (i<=L->nr)
857 {
858 snprintf(s,len,"%s(%d)",name,i+1);
859 if (i==0)
860 h=enterid(s,myynest,typ0,&(currRing->idroot), FALSE);
861 else
863 if (h!=NULL)
864 {
865 h->data.uideal=(ideal)L->m[i].data;
866 h->attribute=L->m[i].attribute;
868 Print("//defining: %s as %d-th syzygy module\n",s,i+1);
869 }
870 else
871 {
872 idDelete((ideal *)&(L->m[i].data));
873 Warn("cannot define %s",s);
874 }
875 //L->m[i].data=NULL;
876 //L->m[i].rtyp=0;
877 //L->m[i].attribute=NULL;
878 i++;
879 }
880 omFreeSize((ADDRESS)L->m,(L->nr+1)*sizeof(sleftv));
882 omFreeSize((ADDRESS)s,strlen(name)+5);
883}
attr attribute
Definition: subexpr.h:89
sleftv * m
Definition: lists.h:46
int nr
Definition: lists.h:44
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
VAR omBin slists_bin
Definition: lists.cc:23
lists liMakeResolv(resolvente r, int length, int reallen, int typ0, intvec **weights, int add_row_shift)
Definition: lists.cc:239
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define V_DEF_RES
Definition: options.h:50

◆ iiMap()

leftv iiMap ( map  theMap,
const char *  what 
)

Definition at line 615 of file ipshell.cc.

616{
617 idhdl w,r;
618 leftv v;
619 int i;
620 nMapFunc nMap;
621
622 r=IDROOT->get(theMap->preimage,myynest);
623 if ((currPack!=basePack)
624 &&((r==NULL) || ((r->typ != RING_CMD) )))
625 r=basePack->idroot->get(theMap->preimage,myynest);
626 if ((r==NULL) && (currRingHdl!=NULL)
627 && (strcmp(theMap->preimage,IDID(currRingHdl))==0))
628 {
629 r=currRingHdl;
630 }
631 if ((r!=NULL) && (r->typ == RING_CMD))
632 {
633 ring src_ring=IDRING(r);
634 if ((nMap=n_SetMap(src_ring->cf, currRing->cf))==NULL)
635 {
636 Werror("can not map from ground field of %s to current ground field",
637 theMap->preimage);
638 return NULL;
639 }
640 if (IDELEMS(theMap)<src_ring->N)
641 {
642 theMap->m=(polyset)omReallocSize((ADDRESS)theMap->m,
643 IDELEMS(theMap)*sizeof(poly),
644 (src_ring->N)*sizeof(poly));
645#ifdef HAVE_SHIFTBBA
646 if (rIsLPRing(src_ring))
647 {
648 // src_ring [x,y,z,...]
649 // curr_ring [a,b,c,...]
650 //
651 // map=[a,b,c,d] -> [a,b,c,...]
652 // map=[a,b] -> [a,b,0,...]
653
654 short src_lV = src_ring->isLPring;
655 short src_ncGenCount = src_ring->LPncGenCount;
656 short src_nVars = src_lV - src_ncGenCount;
657 int src_nblocks = src_ring->N / src_lV;
658
659 short dest_nVars = currRing->isLPring - currRing->LPncGenCount;
660 short dest_ncGenCount = currRing->LPncGenCount;
661
662 // add missing NULL generators
663 for(i=IDELEMS(theMap); i < src_lV - src_ncGenCount; i++)
664 {
665 theMap->m[i]=NULL;
666 }
667
668 // remove superfluous generators
669 for(i = src_nVars; i < IDELEMS(theMap); i++)
670 {
671 if (theMap->m[i] != NULL)
672 {
673 p_Delete(&(theMap->m[i]), currRing);
674 theMap->m[i] = NULL;
675 }
676 }
677
678 // add ncgen mappings
679 for(i = src_nVars; i < src_lV; i++)
680 {
681 short ncGenIndex = i - src_nVars;
682 if (ncGenIndex < dest_ncGenCount)
683 {
684 poly p = p_One(currRing);
685 p_SetExp(p, dest_nVars + ncGenIndex + 1, 1, currRing);
686 p_Setm(p, currRing);
687 theMap->m[i] = p;
688 }
689 else
690 {
691 theMap->m[i] = NULL;
692 }
693 }
694
695 // copy the first block to all other blocks
696 for(i = 1; i < src_nblocks; i++)
697 {
698 for(int j = 0; j < src_lV; j++)
699 {
700 theMap->m[(i * src_lV) + j] = p_Copy(theMap->m[j], currRing);
701 }
702 }
703 }
704 else
705 {
706#endif
707 for(i=IDELEMS(theMap);i<src_ring->N;i++)
708 theMap->m[i]=NULL;
709#ifdef HAVE_SHIFTBBA
710 }
711#endif
712 IDELEMS(theMap)=src_ring->N;
713 }
714 if (what==NULL)
715 {
716 WerrorS("argument of a map must have a name");
717 }
718 else if ((w=src_ring->idroot->get(what,myynest))!=NULL)
719 {
720 char *save_r=NULL;
722 sleftv tmpW;
723 tmpW.Init();
724 tmpW.rtyp=IDTYP(w);
725 if (tmpW.rtyp==MAP_CMD)
726 {
727 tmpW.rtyp=IDEAL_CMD;
728 save_r=IDMAP(w)->preimage;
729 IDMAP(w)->preimage=0;
730 }
731 tmpW.data=IDDATA(w);
732 // check overflow
733 BOOLEAN overflow=FALSE;
734 if ((tmpW.rtyp==IDEAL_CMD)
735 || (tmpW.rtyp==MODUL_CMD)
736 || (tmpW.rtyp==MAP_CMD))
737 {
738 ideal id=(ideal)tmpW.data;
739 long *degs=(long*)omAlloc(IDELEMS(id)*sizeof(long));
740 for(int i=IDELEMS(id)-1;i>=0;i--)
741 {
742 poly p=id->m[i];
743 if (p!=NULL) degs[i]=p_Totaldegree(p,src_ring);
744 else degs[i]=0;
745 }
746 for(int j=IDELEMS(theMap)-1;j>=0 && !overflow;j--)
747 {
748 if (theMap->m[j]!=NULL)
749 {
750 long deg_monexp=pTotaldegree(theMap->m[j]);
751
752 for(int i=IDELEMS(id)-1;i>=0;i--)
753 {
754 poly p=id->m[i];
755 if ((p!=NULL) && (degs[i]!=0) &&
756 ((unsigned long)deg_monexp > (currRing->bitmask / ((unsigned long)degs[i])/2)))
757 {
758 overflow=TRUE;
759 break;
760 }
761 }
762 }
763 }
764 omFreeSize(degs,IDELEMS(id)*sizeof(long));
765 }
766 else if (tmpW.rtyp==POLY_CMD)
767 {
768 for(int j=IDELEMS(theMap)-1;j>=0 && !overflow;j--)
769 {
770 if (theMap->m[j]!=NULL)
771 {
772 long deg_monexp=pTotaldegree(theMap->m[j]);
773 poly p=(poly)tmpW.data;
774 long deg=0;
775 if ((p!=NULL) && ((deg=p_Totaldegree(p,src_ring))!=0) &&
776 ((unsigned long)deg_monexp > (currRing->bitmask / ((unsigned long)deg)/2)))
777 {
778 overflow=TRUE;
779 break;
780 }
781 }
782 }
783 }
784 if (overflow)
785#ifdef HAVE_SHIFTBBA
786 // in Letterplace rings the exponent is always 0 or 1! ignore this warning.
787 if (!rIsLPRing(currRing))
788 {
789#endif
790 Warn("possible OVERFLOW in map, max exponent is %ld",currRing->bitmask/2);
791#ifdef HAVE_SHIFTBBA
792 }
793#endif
794#if 0
795 if (((tmpW.rtyp==IDEAL_CMD)||(tmpW.rtyp==MODUL_CMD)) && idIs0(IDIDEAL(w)))
796 {
797 v->rtyp=tmpW.rtyp;
798 v->data=idInit(IDELEMS(IDIDEAL(w)),IDIDEAL(w)->rank);
799 }
800 else
801#endif
802 {
803 if ((tmpW.rtyp==IDEAL_CMD)
804 ||(tmpW.rtyp==MODUL_CMD)
805 ||(tmpW.rtyp==MATRIX_CMD)
806 ||(tmpW.rtyp==MAP_CMD))
807 {
808 v->rtyp=tmpW.rtyp;
809 char *tmp = theMap->preimage;
810 theMap->preimage=(char*)1L;
811 // map gets 1 as its rank (as an ideal)
812 v->data=maMapIdeal(IDIDEAL(w), src_ring, (ideal)theMap, currRing,nMap);
813 theMap->preimage=tmp; // map gets its preimage back
814 }
815 if (v->data==NULL) /*i.e. not IDEAL_CMD/MODUL_CMD/MATRIX_CMD/MAP */
816 {
817 if (maApplyFetch(MAP_CMD,theMap,v,&tmpW,src_ring,NULL,NULL,0,nMap))
818 {
819 Werror("cannot map %s(%d)",Tok2Cmdname(w->typ),w->typ);
821 if (save_r!=NULL) IDMAP(w)->preimage=save_r;
822 return NULL;
823 }
824 }
825 }
826 if (save_r!=NULL)
827 {
828 IDMAP(w)->preimage=save_r;
829 IDMAP((idhdl)v)->preimage=omStrDup(save_r);
830 v->rtyp=MAP_CMD;
831 }
832 return v;
833 }
834 else
835 {
836 Werror("%s undefined in %s",what,theMap->preimage);
837 }
838 }
839 else
840 {
841 Werror("cannot find preimage %s",theMap->preimage);
842 }
843 return NULL;
844}
int typ
Definition: idrec.h:43
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:697
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
const CanonicalForm & w
Definition: facAbsFact.cc:51
ideal maMapIdeal(const ideal map_id, const ring preimage_r, const ideal image_id, const ring image_r, const nMapFunc nMap)
polynomial map for ideals/module/matrix map_id: the ideal to map map_r: the base ring for map_id imag...
Definition: gen_maps.cc:87
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define IDRING(a)
Definition: ipid.h:127
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
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
poly p_One(const ring r)
Definition: p_polys.cc:1313
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:846
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1507
static long pTotaldegree(poly p)
Definition: polys.h:282
poly * polyset
Definition: polys.h:259
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ iiOpsTwoChar()

int iiOpsTwoChar ( const char *  s)

Definition at line 121 of file ipshell.cc.

122{
123/* not handling: &&, ||, ** */
124 if (s[1]=='\0') return s[0];
125 else if (s[2]!='\0') return 0;
126 switch(s[0])
127 {
128 case '.': if (s[1]=='.') return DOTDOT;
129 else return 0;
130 case ':': if (s[1]==':') return COLONCOLON;
131 else return 0;
132 case '-': if (s[1]=='-') return MINUSMINUS;
133 else return 0;
134 case '+': if (s[1]=='+') return PLUSPLUS;
135 else return 0;
136 case '=': if (s[1]=='=') return EQUAL_EQUAL;
137 else return 0;
138 case '<': if (s[1]=='=') return LE;
139 else if (s[1]=='>') return NOTEQUAL;
140 else return 0;
141 case '>': if (s[1]=='=') return GE;
142 else return 0;
143 case '!': if (s[1]=='=') return NOTEQUAL;
144 else return 0;
145 }
146 return 0;
147}
@ PLUSPLUS
Definition: grammar.cc:274
@ MINUSMINUS
Definition: grammar.cc:271
@ GE
Definition: grammar.cc:269
@ EQUAL_EQUAL
Definition: grammar.cc:268
@ LE
Definition: grammar.cc:270
@ NOTEQUAL
Definition: grammar.cc:273
@ DOTDOT
Definition: grammar.cc:267
@ COLONCOLON
Definition: grammar.cc:275

◆ iiParameter()

BOOLEAN iiParameter ( leftv  p)

Definition at line 1377 of file ipshell.cc.

1378{
1379 if (iiCurrArgs==NULL)
1380 {
1381 if (strcmp(p->name,"#")==0)
1382 return iiDefaultParameter(p);
1383 Werror("not enough arguments for proc %s",VoiceName());
1384 p->CleanUp();
1385 return TRUE;
1386 }
1388 leftv rest=h->next; /*iiCurrArgs is not NULL here*/
1389 BOOLEAN is_default_list=FALSE;
1390 if (strcmp(p->name,"#")==0)
1391 {
1392 is_default_list=TRUE;
1393 rest=NULL;
1394 }
1395 else
1396 {
1397 h->next=NULL;
1398 }
1400 if (is_default_list)
1401 {
1403 }
1404 else
1405 {
1406 iiCurrArgs=rest;
1407 }
1408 h->CleanUp();
1410 return res;
1411}
BOOLEAN iiDefaultParameter(leftv p)
Definition: ipshell.cc:1261

◆ iiProcArgs()

char * iiProcArgs ( char *  e,
BOOLEAN  withParenth 
)

Definition at line 114 of file iplib.cc.

115{
116 while ((*e==' ') || (*e=='\t') || (*e=='(')) e++;
117 if (*e<' ')
118 {
119 if (withParenth)
120 {
121 // no argument list, allow list #
122 return omStrDup("parameter list #;");
123 }
124 else
125 {
126 // empty list
127 return omStrDup("");
128 }
129 }
130 BOOLEAN in_args;
131 BOOLEAN args_found;
132 char *s;
133 char *argstr=(char *)omAlloc(127); // see ../omalloc/omTables.inc
134 int argstrlen=127;
135 *argstr='\0';
136 int par=0;
137 do
138 {
139 args_found=FALSE;
140 s=e; // set s to the starting point of the arg
141 // and search for the end
142 // skip leading spaces:
143 loop
144 {
145 if ((*s==' ')||(*s=='\t'))
146 s++;
147 else if ((*s=='\n')&&(*(s+1)==' '))
148 s+=2;
149 else // start of new arg or \0 or )
150 break;
151 }
152 e=s;
153 while ((*e!=',')
154 &&((par!=0) || (*e!=')'))
155 &&(*e!='\0'))
156 {
157 if (*e=='(') par++;
158 else if (*e==')') par--;
159 args_found=args_found || (*e>' ');
160 e++;
161 }
162 in_args=(*e==',');
163 if (args_found)
164 {
165 *e='\0';
166 // check for space:
167 if ((int)strlen(argstr)+12 /* parameter + ;*/ +(int)strlen(s)>= argstrlen)
168 {
169 argstrlen*=2;
170 char *a=(char *)omAlloc( argstrlen);
171 strcpy(a,argstr);
172 omFree((ADDRESS)argstr);
173 argstr=a;
174 }
175 // copy the result to argstr
176 if(strncmp(s,"alias ",6)!=0)
177 {
178 strcat(argstr,"parameter ");
179 }
180 strcat(argstr,s);
181 strcat(argstr,"; ");
182 e++; // e was pointing to ','
183 }
184 } while (in_args);
185 return argstr;
186}

◆ iiProcName()

char * iiProcName ( char *  buf,
char &  ct,
char *&  e 
)

Definition at line 100 of file iplib.cc.

101{
102 char *s=buf+5;
103 while (*s==' ') s++;
104 e=s+1;
105 while ((*e>' ') && (*e!='(')) e++;
106 ct=*e;
107 *e='\0';
108 return s;
109}
int status int void * buf
Definition: si_signals.h:59

◆ iiPStart()

BOOLEAN iiPStart ( idhdl  pn,
leftv  sl 
)

Definition at line 371 of file iplib.cc.

372{
374 int old_echo=si_echo;
375 BOOLEAN err=FALSE;
376 char save_flags=0;
377
378 /* init febase ======================================== */
379 /* we do not enter this case if filename != NULL !! */
380 if (pn!=NULL)
381 {
382 pi = IDPROC(pn);
383 if(pi!=NULL)
384 {
385 save_flags=pi->trace_flag;
386 if( pi->data.s.body==NULL )
387 {
389 if (pi->data.s.body==NULL) return TRUE;
390 }
391// omUpdateInfo();
392// int m=om_Info.UsedBytes;
393// Print("proc %s, mem=%d\n",IDID(pn),m);
394 }
395 }
396 else return TRUE;
397 /* generate argument list ======================================*/
398 //iiCurrArgs should be NULL here, as the assignment for the parameters
399 // of the prevouis call are already done befor calling another routine
400 if (v!=NULL)
401 {
403 memcpy(iiCurrArgs,v,sizeof(sleftv)); // keeps track of v->next etc.
404 v->Init();
405 }
406 else
407 {
409 }
410 /* start interpreter ======================================*/
411 myynest++;
412 if (myynest > SI_MAX_NEST)
413 {
414 WerrorS("nesting too deep");
415 err=TRUE;
416 }
417 else
418 {
419 iiCurrProc=pn;
420 err=iiAllStart(pi,pi->data.s.body,BT_proc,pi->data.s.body_lineno-(v!=NULL));
422
423 if (iiLocalRing[myynest-1] != currRing)
424 {
426 {
427 //idhdl hn;
428 const char *n;
429 const char *o;
430 idhdl nh=NULL, oh=NULL;
431 if (iiLocalRing[myynest-1]!=NULL)
433 if (oh!=NULL) o=oh->id;
434 else o="none";
435 if (currRing!=NULL)
437 if (nh!=NULL) n=nh->id;
438 else n="none";
439 Werror("ring change during procedure call %s: %s -> %s (level %d)",pi->procname,o,n,myynest);
441 err=TRUE;
442 }
444 }
445 if ((currRing==NULL)
446 && (currRingHdl!=NULL))
448 else
449 if ((currRing!=NULL) &&
451 ||(IDLEV(currRingHdl)>=myynest-1)))
452 {
455 }
456 //Print("kill locals for %s (level %d)\n",IDID(pn),myynest);
458#ifndef SING_NDEBUG
459 checkall();
460#endif
461 //Print("end kill locals for %s (%d)\n",IDID(pn),myynest);
462 }
463 myynest--;
464 si_echo=old_echo;
465 if (pi!=NULL)
466 pi->trace_flag=save_flags;
467// omUpdateInfo();
468// int m=om_Info.UsedBytes;
469// Print("exit %s, mem=%d\n",IDID(pn),m);
470 return err;
471}
const char * id
Definition: idrec.h:39
BOOLEAN RingDependend()
Definition: subexpr.cc:418
#define SI_MAX_NEST
Definition: iplib.cc:27

◆ iiRegularity()

int iiRegularity ( lists  L)

Definition at line 1038 of file ipshell.cc.

1039{
1040 int len,reg,typ0;
1041
1042 resolvente r=liFindRes(L,&len,&typ0);
1043
1044 if (r==NULL)
1045 return -2;
1046 intvec *weights=NULL;
1047 int add_row_shift=0;
1048 intvec *ww=(intvec *)atGet(&(L->m[0]),"isHomog",INTVEC_CMD);
1049 if (ww!=NULL)
1050 {
1051 weights=ivCopy(ww);
1052 add_row_shift = ww->min_in();
1053 (*weights) -= add_row_shift;
1054 }
1055 //Print("attr:%x\n",weights);
1056
1057 intvec *dummy=syBetti(r,len,&reg,weights);
1058 if (weights!=NULL) delete weights;
1059 delete dummy;
1060 omFreeSize((ADDRESS)r,len*sizeof(ideal));
1061 return reg+1+add_row_shift;
1062}
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:132
int min_in()
Definition: intvec.h:121
ideal * resolvente
Definition: ideals.h:18
intvec * ivCopy(const intvec *o)
Definition: intvec.h:145
resolvente liFindRes(lists L, int *len, int *typ0, intvec ***weights)
Definition: lists.cc:338
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition: syz.cc:771

◆ iiSetReturn()

void iiSetReturn ( const leftv  h)

Definition at line 6604 of file ipshell.cc.

6605{
6606 if ((source->next==NULL)&&(source->e==NULL))
6607 {
6608 if ((source->rtyp!=IDHDL)&&(source->rtyp!=ALIAS_CMD))
6609 {
6610 memcpy(&iiRETURNEXPR,source,sizeof(sleftv));
6611 source->Init();
6612 return;
6613 }
6614 if (source->rtyp==IDHDL)
6615 {
6616 if ((IDLEV((idhdl)source->data)==myynest)
6617 &&(IDTYP((idhdl)source->data)!=RING_CMD))
6618 {
6620 iiRETURNEXPR.rtyp=IDTYP((idhdl)source->data);
6621 iiRETURNEXPR.data=IDDATA((idhdl)source->data);
6622 iiRETURNEXPR.flag=IDFLAG((idhdl)source->data);
6623 iiRETURNEXPR.attribute=IDATTR((idhdl)source->data);
6624 IDATTR((idhdl)source->data)=NULL;
6625 IDDATA((idhdl)source->data)=NULL;
6626 source->name=NULL;
6627 source->attribute=NULL;
6628 return;
6629 }
6630 }
6631 }
6632 iiRETURNEXPR.Copy(source);
6633}
void Copy(leftv e)
Definition: subexpr.cc:685

◆ iiTestAssume()

BOOLEAN iiTestAssume ( leftv  a,
leftv  b 
)

Definition at line 6455 of file ipshell.cc.

6456{
6457 // assume a: level
6458 if ((a->Typ()==INT_CMD)&&((long)a->Data()>=0))
6459 {
6460 if ((TEST_V_ALLWARN) && (myynest==0)) WarnS("ASSUME at top level is of no use: see documentation");
6461 char assume_yylinebuf[80];
6462 strncpy(assume_yylinebuf,my_yylinebuf,79);
6463 int lev=(long)a->Data();
6464 int startlev=0;
6465 idhdl h=ggetid("assumeLevel");
6466 if ((h!=NULL)&&(IDTYP(h)==INT_CMD)) startlev=(long)IDINT(h);
6467 if(lev <=startlev)
6468 {
6469 BOOLEAN bo=b->Eval();
6470 if (bo) { WerrorS("syntax error in ASSUME");return TRUE;}
6471 if (b->Typ()!=INT_CMD) { WerrorS("ASUMME(<level>,<int expr>)");return TRUE; }
6472 if (b->Data()==NULL) { Werror("ASSUME failed:%s",assume_yylinebuf);return TRUE;}
6473 }
6474 }
6475 b->CleanUp();
6476 a->CleanUp();
6477 return FALSE;
6478}
void * Data()
Definition: subexpr.cc:1173
#define IDINT(a)
Definition: ipid.h:125

◆ iiTokType()

int iiTokType ( int  op)

Definition at line 233 of file iparith.cc.

234{
235 for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
236 {
237 if (sArithBase.sCmds[i].tokval==op)
238 return sArithBase.sCmds[i].toktype;
239 }
240 return 0;
241}
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:186
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:201
unsigned nCmdUsed
number of commands used
Definition: iparith.cc:191

◆ iiTryLoadLib()

BOOLEAN iiTryLoadLib ( leftv  v,
const char *  id 
)

Definition at line 823 of file iplib.cc.

824{
825 BOOLEAN LoadResult = TRUE;
826 char libnamebuf[1024];
827 size_t len=strlen(id)+5;
828 char *libname = (char *)omAlloc(len);
829 const char *suffix[] = { "", ".lib", ".so", ".sl", NULL };
830 int i = 0;
831 // FILE *fp;
832 // package pack;
833 // idhdl packhdl;
834 lib_types LT;
835 for(i=0; suffix[i] != NULL; i++)
836 {
837 snprintf(libname,len, "%s%s", id, suffix[i]);
838 *libname = mytolower(*libname);
839 if((LT = type_of_LIB(libname, libnamebuf)) > LT_NOTFOUND)
840 {
841 #ifdef HAVE_DYNAMIC_LOADING
842 char libnamebuf[1024];
843 #endif
844
845 if (LT==LT_SINGULAR)
846 LoadResult = iiLibCmd(libname, FALSE, FALSE,TRUE);
847 #ifdef HAVE_DYNAMIC_LOADING
848 else if ((LT==LT_ELF) || (LT==LT_HPUX))
849 LoadResult = load_modules(libname,libnamebuf,FALSE);
850 #endif
851 else if (LT==LT_BUILTIN)
852 {
853 LoadResult=load_builtin(libname,FALSE, iiGetBuiltinModInit(libname));
854 }
855 if(!LoadResult )
856 {
857 v->name = iiConvName(libname);
858 break;
859 }
860 }
861 }
862 omFree(libname);
863 return LoadResult;
864}
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1285
static char mytolower(char c)
Definition: iplib.cc:1417
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1295
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:807
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition: mod_lib.cc:27
lib_types
Definition: mod_raw.h:16
@ LT_HPUX
Definition: mod_raw.h:16
@ LT_SINGULAR
Definition: mod_raw.h:16
@ LT_BUILTIN
Definition: mod_raw.h:16
@ LT_ELF
Definition: mod_raw.h:16
@ LT_NOTFOUND
Definition: mod_raw.h:16

◆ iiTwoOps()

const char * iiTwoOps ( int  t)

Definition at line 261 of file gentable.cc.

262{
263 if (t<127)
264 {
265 STATIC_VAR char ch[2];
266 switch (t)
267 {
268 case '&':
269 return "and";
270 case '|':
271 return "or";
272 default:
273 ch[0]=t;
274 ch[1]='\0';
275 return ch;
276 }
277 }
278 switch (t)
279 {
280 case COLONCOLON: return "::";
281 case DOTDOT: return "..";
282 //case PLUSEQUAL: return "+=";
283 //case MINUSEQUAL: return "-=";
284 case MINUSMINUS: return "--";
285 case PLUSPLUS: return "++";
286 case EQUAL_EQUAL: return "==";
287 case LE: return "<=";
288 case GE: return ">=";
289 case NOTEQUAL: return "<>";
290 default: return Tok2Cmdname(t);
291 }
292}
#define STATIC_VAR
Definition: globaldefs.h:7

◆ iiWRITE()

BOOLEAN iiWRITE ( leftv  res,
leftv  exprlist 
)

Definition at line 588 of file ipshell.cc.

589{
590 sleftv vf;
591 if (iiConvert(v->Typ(),LINK_CMD,iiTestConvert(v->Typ(),LINK_CMD),v,&vf))
592 {
593 WerrorS("link expected");
594 return TRUE;
595 }
596 si_link l=(si_link)vf.Data();
597 if (vf.next == NULL)
598 {
599 WerrorS("write: need at least two arguments");
600 return TRUE;
601 }
602
603 BOOLEAN b=slWrite(l,vf.next); /* iiConvert preserves next */
604 if (b)
605 {
606 const char *s;
607 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
608 else s=sNoName_fe;
609 Werror("cannot write to %s",s);
610 }
611 vf.CleanUp();
612 return b;
613}

◆ IsCmd()

int IsCmd ( const char *  n,
int &  tok 
)

Definition at line 9524 of file iparith.cc.

9525{
9526 int i;
9527 int an=1;
9529
9530 loop
9531 //for(an=0; an<sArithBase.nCmdUsed; )
9532 {
9533 if(an>=en-1)
9534 {
9535 if (strcmp(n, sArithBase.sCmds[an].name) == 0)
9536 {
9537 i=an;
9538 break;
9539 }
9540 else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
9541 {
9542 i=en;
9543 break;
9544 }
9545 else
9546 {
9547 // -- blackbox extensions:
9548 // return 0;
9549 return blackboxIsCmd(n,tok);
9550 }
9551 }
9552 i=(an+en)/2;
9553 if (*n < *(sArithBase.sCmds[i].name))
9554 {
9555 en=i-1;
9556 }
9557 else if (*n > *(sArithBase.sCmds[i].name))
9558 {
9559 an=i+1;
9560 }
9561 else
9562 {
9563 int v=strcmp(n,sArithBase.sCmds[i].name);
9564 if(v<0)
9565 {
9566 en=i-1;
9567 }
9568 else if(v>0)
9569 {
9570 an=i+1;
9571 }
9572 else /*v==0*/
9573 {
9574 break;
9575 }
9576 }
9577 }
9579 tok=sArithBase.sCmds[i].tokval;
9580 if(sArithBase.sCmds[i].alias==2)
9581 {
9582 Warn("outdated identifier `%s` used - please change your code",
9583 sArithBase.sCmds[i].name);
9584 sArithBase.sCmds[i].alias=1;
9585 }
9586 #if 0
9587 if (currRingHdl==NULL)
9588 {
9589 #ifdef SIQ
9590 if (siq<=0)
9591 {
9592 #endif
9593 if ((tok>=BEGIN_RING) && (tok<=END_RING))
9594 {
9595 WerrorS("no ring active");
9596 return 0;
9597 }
9598 #ifdef SIQ
9599 }
9600 #endif
9601 }
9602 #endif
9603 if (!expected_parms)
9604 {
9605 switch (tok)
9606 {
9607 case IDEAL_CMD:
9608 case INT_CMD:
9609 case INTVEC_CMD:
9610 case MAP_CMD:
9611 case MATRIX_CMD:
9612 case MODUL_CMD:
9613 case POLY_CMD:
9614 case PROC_CMD:
9615 case RING_CMD:
9616 case STRING_CMD:
9617 cmdtok = tok;
9618 break;
9619 }
9620 }
9621 return sArithBase.sCmds[i].toktype;
9622}
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
@ END_RING
Definition: grammar.cc:310
@ BEGIN_RING
Definition: grammar.cc:282
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition: iparith.cc:193
EXTERN_VAR BOOLEAN expected_parms
Definition: iparith.cc:218
EXTERN_VAR int cmdtok
Definition: iparith.cc:217
const char * lastreserved
Definition: ipshell.cc:82

◆ jjBETTI()

BOOLEAN jjBETTI ( leftv  res,
leftv  v 
)

Definition at line 968 of file ipshell.cc.

969{
970 sleftv tmp;
971 tmp.Init();
972 tmp.rtyp=INT_CMD;
973 tmp.data=(void *)1;
974 if ((u->Typ()==IDEAL_CMD)
975 || (u->Typ()==MODUL_CMD))
976 return jjBETTI2_ID(res,u,&tmp);
977 else
978 return jjBETTI2(res,u,&tmp);
979}
BOOLEAN jjBETTI2_ID(leftv res, leftv u, leftv v)
Definition: ipshell.cc:981
BOOLEAN jjBETTI2(leftv res, leftv u, leftv v)
Definition: ipshell.cc:1002

◆ jjBETTI2()

BOOLEAN jjBETTI2 ( leftv  res,
leftv  u,
leftv  v 
)

Definition at line 1002 of file ipshell.cc.

1003{
1004 resolvente r;
1005 int len;
1006 int reg,typ0;
1007 lists l=(lists)u->Data();
1008
1009 intvec *weights=NULL;
1010 int add_row_shift=0;
1011 intvec *ww=NULL;
1012 if (l->nr>=0) ww=(intvec *)atGet(&(l->m[0]),"isHomog",INTVEC_CMD);
1013 if (ww!=NULL)
1014 {
1015 weights=ivCopy(ww);
1016 add_row_shift = ww->min_in();
1017 (*weights) -= add_row_shift;
1018 }
1019 //Print("attr:%x\n",weights);
1020
1021 r=liFindRes(l,&len,&typ0);
1022 if (r==NULL) return TRUE;
1023 intvec* res_im=syBetti(r,len,&reg,weights,(int)(long)v->Data());
1024 res->data=(void*)res_im;
1025 omFreeSize((ADDRESS)r,(len)*sizeof(ideal));
1026 //Print("rowShift: %d ",add_row_shift);
1027 for(int i=1;i<=res_im->rows();i++)
1028 {
1029 if (IMATELEM(*res_im,1,i)==0) { add_row_shift--; }
1030 else break;
1031 }
1032 //Print(" %d\n",add_row_shift);
1033 atSet(res,omStrDup("rowShift"),(void*)(long)add_row_shift,INT_CMD);
1034 if (weights!=NULL) delete weights;
1035 return FALSE;
1036}
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:153
int rows() const
Definition: intvec.h:96
#define IMATELEM(M, I, J)
Definition: intvec.h:85

◆ jjBETTI2_ID()

BOOLEAN jjBETTI2_ID ( leftv  res,
leftv  u,
leftv  v 
)

Definition at line 981 of file ipshell.cc.

982{
984 l->Init(1);
985 l->m[0].rtyp=u->Typ();
986 l->m[0].data=u->Data();
987 attr *a=u->Attribute();
988 if (a!=NULL)
989 l->m[0].attribute=*a;
990 sleftv tmp2;
991 tmp2.Init();
992 tmp2.rtyp=LIST_CMD;
993 tmp2.data=(void *)l;
995 l->m[0].data=NULL;
996 l->m[0].attribute=NULL;
997 l->m[0].rtyp=DEF_CMD;
998 l->Clean();
999 return r;
1000}
Definition: attrib.h:21
attr * Attribute()
Definition: subexpr.cc:1473
CFList tmp2
Definition: facFqBivar.cc:74

◆ jjCHARSERIES()

BOOLEAN jjCHARSERIES ( leftv  res,
leftv  u 
)

Definition at line 3349 of file ipshell.cc.

3350{
3351 res->data=singclap_irrCharSeries((ideal)u->Data(), currRing);
3352 return (res->data==NULL);
3353}
matrix singclap_irrCharSeries(ideal I, const ring r)
Definition: clapsing.cc:1571

◆ jjIMPORTFROM()

BOOLEAN jjIMPORTFROM ( leftv  res,
leftv  u,
leftv  v 
)

Definition at line 2369 of file ipassign.cc.

2370{
2371 //Print("importfrom %s::%s ->.\n",v->Name(),u->Name() );
2372 assume(u->Typ()==PACKAGE_CMD);
2373 char *vn=(char *)v->Name();
2374 idhdl h=((package)(u->Data()))->idroot->get(vn /*v->Name()*/, myynest);
2375 if (h!=NULL)
2376 {
2377 //check for existence
2378 if (((package)(u->Data()))==basePack)
2379 {
2380 WarnS("source and destination packages are identical");
2381 return FALSE;
2382 }
2383 idhdl t=basePack->idroot->get(vn /*v->Name()*/, myynest);
2384 if (t!=NULL)
2385 {
2386 if (BVERBOSE(V_REDEFINE)) Warn("redefining %s (%s)",vn,my_yylinebuf);
2387 killhdl(t);
2388 }
2389 sleftv tmp_expr;
2390 if (iiDeclCommand(&tmp_expr,v,myynest,DEF_CMD,&IDROOT)) return TRUE;
2391 sleftv h_expr;
2392 memset(&h_expr,0,sizeof(h_expr));
2393 h_expr.rtyp=IDHDL;
2394 h_expr.data=h;
2395 h_expr.name=vn;
2396 return iiAssign(&tmp_expr,&h_expr);
2397 }
2398 else
2399 {
2400 Werror("`%s` not found in `%s`",v->Name(), u->Name());
2401 return TRUE;
2402 }
2403 return FALSE;
2404}
void killhdl(idhdl h, package proot)
Definition: ipid.cc:414
#define assume(x)
Definition: mod2.h:389
ip_package * package
Definition: structs.h:43

◆ jjLIST_PL()

BOOLEAN jjLIST_PL ( leftv  res,
leftv  v 
)

Definition at line 7999 of file iparith.cc.

8000{
8001 int sl=0;
8002 if (v!=NULL) sl = v->listLength();
8003 lists L;
8004 if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
8005 {
8006 int add_row_shift = 0;
8007 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
8008 if (weights!=NULL) add_row_shift=weights->min_in();
8009 L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
8010 }
8011 else
8012 {
8014 leftv h=NULL;
8015 int i;
8016 int rt;
8017
8018 L->Init(sl);
8019 for (i=0;i<sl;i++)
8020 {
8021 if (h!=NULL)
8022 { /* e.g. not in the first step:
8023 * h is the pointer to the old sleftv,
8024 * v is the pointer to the next sleftv
8025 * (in this moment) */
8026 h->next=v;
8027 }
8028 h=v;
8029 v=v->next;
8030 h->next=NULL;
8031 rt=h->Typ();
8032 if (rt==0)
8033 {
8034 L->Clean();
8035 Werror("`%s` is undefined",h->Fullname());
8036 return TRUE;
8037 }
8038 if (rt==RING_CMD)
8039 {
8040 L->m[i].rtyp=rt;
8041 L->m[i].data=rIncRefCnt(((ring)h->Data()));
8042 }
8043 else
8044 L->m[i].Copy(h);
8045 }
8046 }
8047 res->data=(char *)L;
8048 return FALSE;
8049}
void Clean(ring r=currRing)
Definition: lists.h:26
INLINE_THIS void Init(int l=0)
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3184
static ring rIncRefCnt(ring r)
Definition: ring.h:839

◆ jjLOAD()

BOOLEAN jjLOAD ( const char *  s,
BOOLEAN  autoexport = FALSE 
)

load lib/module given in v

Definition at line 5512 of file iparith.cc.

5513{
5514 char libnamebuf[1024];
5516
5517#ifdef HAVE_DYNAMIC_LOADING
5518 extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5519#endif /* HAVE_DYNAMIC_LOADING */
5520 switch(LT)
5521 {
5522 default:
5523 case LT_NONE:
5524 Werror("%s: unknown type", s);
5525 break;
5526 case LT_NOTFOUND:
5527 Werror("cannot open %s", s);
5528 break;
5529
5530 case LT_SINGULAR:
5531 {
5532 char *plib = iiConvName(s);
5533 idhdl pl = IDROOT->get_level(plib,0);
5534 if (pl==NULL)
5535 {
5536 pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5537 IDPACKAGE(pl)->language = LANG_SINGULAR;
5538 IDPACKAGE(pl)->libname=omStrDup(s);
5539 }
5540 else if (IDTYP(pl)!=PACKAGE_CMD)
5541 {
5542 Werror("can not create package `%s`",plib);
5543 omFreeBinAddr(plib);
5544 return TRUE;
5545 }
5546 else /* package */
5547 {
5548 package pa=IDPACKAGE(pl);
5549 if ((pa->language==LANG_C)
5550 || (pa->language==LANG_MIX))
5551 {
5552 Werror("can not create package `%s` - binaries exists",plib);
5553 omFreeBinAddr(plib);
5554 return TRUE;
5555 }
5556 }
5557 omFreeBinAddr(plib);
5558 package savepack=currPack;
5559 currPack=IDPACKAGE(pl);
5560 IDPACKAGE(pl)->loaded=TRUE;
5561 char libnamebuf[1024];
5562 FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5563 BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5564 currPack=savepack;
5565 IDPACKAGE(pl)->loaded=(!bo);
5566 return bo;
5567 }
5568 case LT_BUILTIN:
5569 SModulFunc_t iiGetBuiltinModInit(const char*);
5570 return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5571 case LT_MACH_O:
5572 case LT_ELF:
5573 case LT_HPUX:
5574#ifdef HAVE_DYNAMIC_LOADING
5575 return load_modules(s, libnamebuf, autoexport);
5576#else /* HAVE_DYNAMIC_LOADING */
5577 WerrorS("Dynamic modules are not supported by this version of Singular");
5578 break;
5579#endif /* HAVE_DYNAMIC_LOADING */
5580 }
5581 return TRUE;
5582}
static BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:3722
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1295
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:81
@ LT_MACH_O
Definition: mod_raw.h:16
@ LT_NONE
Definition: mod_raw.h:16

◆ jjLOAD_TRY()

BOOLEAN jjLOAD_TRY ( const char *  s)

Definition at line 5588 of file iparith.cc.

5589{
5590 if (!iiGetLibStatus(s))
5591 {
5592 void (*WerrorS_save)(const char *s) = WerrorS_callback;
5595 BOOLEAN bo=jjLOAD(s,TRUE);
5596 if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5597 Print("loading of >%s< failed\n",s);
5598 WerrorS_callback=WerrorS_save;
5599 errorreported=0;
5600 }
5601 return FALSE;
5602}
VAR void(* WerrorS_callback)(const char *s)
Definition: feFopen.cc:21
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition: iparith.cc:5512
STATIC_VAR int WerrorS_dummy_cnt
Definition: iparith.cc:5583
static void WerrorS_dummy(const char *)
Definition: iparith.cc:5584
BOOLEAN iiGetLibStatus(const char *lib)
Definition: iplib.cc:77
#define TEST_OPT_PROT
Definition: options.h:103

◆ jjMINRES()

BOOLEAN jjMINRES ( leftv  res,
leftv  v 
)

Definition at line 947 of file ipshell.cc.

948{
949 int len=0;
950 int typ0;
951 lists L=(lists)v->Data();
952 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
953 int add_row_shift = 0;
954 if (weights==NULL)
955 weights=(intvec*)atGet(&(L->m[0]),"isHomog",INTVEC_CMD);
956 if (weights!=NULL) add_row_shift=weights->min_in();
957 resolvente rr=liFindRes(L,&len,&typ0);
958 if (rr==NULL) return TRUE;
959 resolvente r=iiCopyRes(rr,len);
960
961 syMinimizeResolvente(r,len,0);
962 omFreeSize((ADDRESS)rr,len*sizeof(ideal));
963 len++;
964 res->data=(char *)liMakeResolv(r,len,-1,typ0,NULL,add_row_shift);
965 return FALSE;
966}
static resolvente iiCopyRes(resolvente r, int l)
Definition: ipshell.cc:937
void syMinimizeResolvente(resolvente res, int length, int first)
Definition: syz.cc:355

◆ jjRESULTANT()

BOOLEAN jjRESULTANT ( leftv  res,
leftv  u,
leftv  v,
leftv  w 
)

Definition at line 3342 of file ipshell.cc.

3343{
3344 res->data=singclap_resultant((poly)u->CopyD(),(poly)v->CopyD(),
3345 (poly)w->CopyD(), currRing);
3346 return errorreported;
3347}
poly singclap_resultant(poly f, poly g, poly x, const ring r)
Definition: clapsing.cc:345

◆ jjSetMinpoly()

coeffs jjSetMinpoly ( coeffs  cf,
number  a 
)

Definition at line 175 of file ipassign.cc.

176{
177 if ( !nCoeff_is_transExt(cf) )
178 {
179 if(!nCoeff_is_algExt(cf) )
180 {
181 WerrorS("cannot set minpoly for these coeffients");
182 return NULL;
183 }
184 }
185 if (rVar(cf->extRing)!=1)
186 {
187 WerrorS("only univariate minpoly allowed");
188 return NULL;
189 }
190
191 number p = n_Copy(a,cf);
192 n_Normalize(p, cf);
193
194 if (n_IsZero(p, cf))
195 {
196 n_Delete(&p, cf);
197 return cf;
198 }
199
201
202 A.r = rCopy(cf->extRing); // Copy ground field!
203 // if minpoly was already set:
204 if( cf->extRing->qideal != NULL ) id_Delete(&(A.r->qideal),A.r);
205 ideal q = idInit(1,1);
206 if ((p==NULL) ||(NUM((fraction)p)==NULL))
207 {
208 WerrorS("Could not construct the alg. extension: minpoly==0");
209 // cleanup A: TODO
210 rDelete( A.r );
211 return NULL;
212 }
213 if (DEN((fraction)(p)) != NULL) // minpoly must be a fraction with poly numerator...!!
214 {
215 poly n=DEN((fraction)(p));
216 if(!p_IsConstant(n,cf->extRing))
217 {
218 WarnS("denominator must be constant - ignoring it");
219 }
220 p_Delete(&n,cf->extRing);
221 DEN((fraction)(p))=NULL;
222 }
223
224 q->m[0] = NUM((fraction)p);
225 A.r->qideal = q;
226
228 NUM((fractionObject *)p) = NULL; // not necessary, but still...
230
231 coeffs new_cf = nInitChar(n_algExt, &A);
232 if (new_cf==NULL)
233 {
234 WerrorS("Could not construct the alg. extension: illegal minpoly?");
235 // cleanup A: TODO
236 rDelete( A.r );
237 return NULL;
238 }
239 return new_cf;
240}
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
CanonicalForm cf
Definition: cfModGcd.cc:4083
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:448
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:35
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:414
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:907
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:575
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:915
omBin_t * omBin
Definition: omStructs.h:12
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1964
@ NUM
Definition: readcf.cc:170
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
ring rCopy(ring r)
Definition: ring.cc:1731
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define A
Definition: sirandom.c:24
VAR omBin fractionObjectBin
Definition: transext.cc:89

◆ jjSYSTEM()

BOOLEAN jjSYSTEM ( leftv  res,
leftv  v 
)

Definition at line 232 of file extra.cc.

233{
234 if(args->Typ() == STRING_CMD)
235 {
236 const char *sys_cmd=(char *)(args->Data());
237 leftv h=args->next;
238// ONLY documented system calls go here
239// Undocumented system calls go down into jjEXTENDED_SYSTEM (#ifdef HAVE_EXTENDED_SYSTEM)
240/*==================== nblocks ==================================*/
241 if (strcmp(sys_cmd, "nblocks") == 0)
242 {
243 ring r;
244 if (h == NULL)
245 {
246 if (currRingHdl != NULL)
247 {
248 r = IDRING(currRingHdl);
249 }
250 else
251 {
252 WerrorS("no ring active");
253 return TRUE;
254 }
255 }
256 else
257 {
258 if (h->Typ() != RING_CMD)
259 {
260 WerrorS("ring expected");
261 return TRUE;
262 }
263 r = (ring) h->Data();
264 }
265 res->rtyp = INT_CMD;
266 res->data = (void*) (long)(rBlocks(r) - 1);
267 return FALSE;
268 }
269/*==================== version ==================================*/
270 if(strcmp(sys_cmd,"version")==0)
271 {
272 res->rtyp=INT_CMD;
273 res->data=(void *)SINGULAR_VERSION;
274 return FALSE;
275 }
276 else
277/*==================== alarm ==================================*/
278 if(strcmp(sys_cmd,"alarm")==0)
279 {
280 if ((h!=NULL) &&(h->Typ()==INT_CMD))
281 {
282 // standard variant -> SIGALARM (standard: abort)
283 //alarm((unsigned)h->next->Data());
284 // process time (user +system): SIGVTALARM
285 struct itimerval t,o;
286 memset(&t,0,sizeof(t));
287 t.it_value.tv_sec =(unsigned)((unsigned long)h->Data());
288 setitimer(ITIMER_VIRTUAL,&t,&o);
289 return FALSE;
290 }
291 else
292 WerrorS("int expected");
293 }
294 else
295/*==================== content ==================================*/
296 if(strcmp(sys_cmd,"content")==0)
297 {
298 if ((h!=NULL) && ((h->Typ()==POLY_CMD)||(h->Typ()==VECTOR_CMD)))
299 {
300 int t=h->Typ();
301 poly p=(poly)h->CopyD();
302 if (p!=NULL)
303 {
306 }
307 res->data=(void *)p;
308 res->rtyp=t;
309 return FALSE;
310 }
311 return TRUE;
312 }
313 else
314/*==================== cpu ==================================*/
315 if(strcmp(sys_cmd,"cpu")==0)
316 {
317 #if 0
318 long cpu=1;
319 #ifdef _SC_NPROCESSORS_ONLN
320 cpu=sysconf(_SC_NPROCESSORS_ONLN);
321 #elif defined(_SC_NPROCESSORS_CONF)
322 cpu=sysconf(_SC_NPROCESSORS_CONF);
323 #endif
324 res->data=(void *)cpu;
325 #else
326 res->data=(void *)feOptValue(FE_OPT_CPUS);
327 #endif
328 res->rtyp=INT_CMD;
329 return FALSE;
330 }
331 else
332/*==================== executable ==================================*/
333 if(strcmp(sys_cmd,"executable")==0)
334 {
335 if ((h!=NULL) && (h->Typ()==STRING_CMD))
336 {
337 char tbuf[MAXPATHLEN];
338 char *s=omFindExec((char*)h->Data(),tbuf);
339 if(s==NULL) s=(char*)"";
340 res->data=(void *)omStrDup(s);
341 res->rtyp=STRING_CMD;
342 return FALSE;
343 }
344 return TRUE;
345 }
346 else
347 /*==================== flatten =============================*/
348 if(strcmp(sys_cmd,"flatten")==0)
349 {
350 if ((h!=NULL) &&(h->Typ()==SMATRIX_CMD))
351 {
352 res->data=(char*)sm_Flatten((ideal)h->Data(),currRing);
353 res->rtyp=SMATRIX_CMD;
354 return FALSE;
355 }
356 else
357 WerrorS("smatrix expected");
358 }
359 else
360 /*==================== unflatten =============================*/
361 if(strcmp(sys_cmd,"unflatten")==0)
362 {
363 const short t1[]={2,SMATRIX_CMD,INT_CMD};
364 if (iiCheckTypes(h,t1,1))
365 {
366 res->data=(char*)sm_UnFlatten((ideal)h->Data(),(int)(long)h->next->Data(),currRing);
367 res->rtyp=SMATRIX_CMD;
368 return res->data==NULL;
369 }
370 else return TRUE;
371 }
372 else
373 /*==================== neworder =============================*/
374 if(strcmp(sys_cmd,"neworder")==0)
375 {
376 if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
377 {
378 res->rtyp=STRING_CMD;
379 res->data=(void *)singclap_neworder((ideal)h->Data(), currRing);
380 return FALSE;
381 }
382 else
383 WerrorS("ideal expected");
384 }
385 else
386/*===== nc_hilb ===============================================*/
387 // Hilbert series of non-commutative monomial algebras
388 if(strcmp(sys_cmd,"nc_hilb") == 0)
389 {
390 ideal i; int lV;
391 bool ig = FALSE;
392 bool mgrad = FALSE;
393 bool autop = FALSE;
394 int trunDegHs=0;
395 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
396 i = (ideal)h->Data();
397 else
398 {
399 WerrorS("nc_Hilb:ideal expected");
400 return TRUE;
401 }
402 h = h->next;
403 if((h != NULL)&&(h->Typ() == INT_CMD))
404 lV = (int)(long)h->Data();
405 else
406 {
407 WerrorS("nc_Hilb:int expected");
408 return TRUE;
409 }
410 h = h->next;
411 while(h != NULL)
412 {
413 if((int)(long)h->Data() == 1)
414 ig = TRUE;
415 else if((int)(long)h->Data() == 2)
416 mgrad = TRUE;
417 else if(h->Typ()==STRING_CMD)
418 autop = TRUE;
419 else if(h->Typ() == INT_CMD)
420 trunDegHs = (int)(long)h->Data();
421 h = h->next;
422 }
423 if(h != NULL)
424 {
425 WerrorS("nc_Hilb:int 1,2, total degree for the truncation, and a string for printing the details are expected");
426 return TRUE;
427 }
428
429 HilbertSeries_OrbitData(i, lV, ig, mgrad, autop, trunDegHs);
430 return(FALSE);
431 }
432 else
433/* ====== verify ============================*/
434 if(strcmp(sys_cmd,"verifyGB")==0)
435 {
436 if (rIsNCRing(currRing))
437 {
438 WerrorS("system(\"verifyGB\",<ideal>,..) expects a commutative ring");
439 return TRUE;
440 }
441 if (h->Typ()!=IDEAL_CMD)
442 {
443 WerrorS("expected system(\"verifyGB\",<ideal>,..)");
444 return TRUE;
445 }
446 ideal F=(ideal)h->Data();
447 if (h->next==NULL)
448 {
449 #ifdef HAVE_VSPACE
450 int cpus = (long) feOptValue(FE_OPT_CPUS);
451 if (cpus>1)
452 res->data=(char*)(long) kVerify2(F,currRing->qideal);
453 else
454 #endif
455 res->data=(char*)(long) kVerify1(F,currRing->qideal);
456 }
457 else return TRUE;
458 res->rtyp=INT_CMD;
459 return FALSE;
460 }
461 else
462/*===== rcolon ===============================================*/
463 if(strcmp(sys_cmd,"rcolon") == 0)
464 {
465 const short t1[]={3,IDEAL_CMD,POLY_CMD,INT_CMD};
466 if (iiCheckTypes(h,t1,1))
467 {
468 ideal i = (ideal)h->Data();
469 h = h->next;
470 poly w=(poly)h->Data();
471 h = h->next;
472 int lV = (int)(long)h->Data();
473 res->rtyp = IDEAL_CMD;
474 res->data = RightColonOperation(i, w, lV);
475 return(FALSE);
476 }
477 else
478 return TRUE;
479 }
480 else
481
482/*==================== sh ==================================*/
483 if(strcmp(sys_cmd,"sh")==0)
484 {
486 {
487 WerrorS("shell execution is disallowed in restricted mode");
488 return TRUE;
489 }
490 res->rtyp=INT_CMD;
491 if (h==NULL) res->data = (void *)(long) system("sh");
492 else if (h->Typ()==STRING_CMD)
493 res->data = (void*)(long) system((char*)(h->Data()));
494 else
495 WerrorS("string expected");
496 return FALSE;
497 }
498 else
499/*========reduce procedure like the global one but with jet bounds=======*/
500 if(strcmp(sys_cmd,"reduce_bound")==0)
501 {
502 poly p;
503 ideal pid=NULL;
504 const short t1[]={3,POLY_CMD,IDEAL_CMD,INT_CMD};
505 const short t2[]={3,IDEAL_CMD,IDEAL_CMD,INT_CMD};
506 const short t3[]={3,VECTOR_CMD,MODUL_CMD,INT_CMD};
507 const short t4[]={3,MODUL_CMD,MODUL_CMD,INT_CMD};
508 if ((iiCheckTypes(h,t1,0))||((iiCheckTypes(h,t3,0))))
509 {
510 p = (poly)h->CopyD();
511 }
512 else if ((iiCheckTypes(h,t2,0))||(iiCheckTypes(h,t4,1)))
513 {
514 pid = (ideal)h->CopyD();
515 }
516 else return TRUE;
517 //int htype;
518 res->rtyp= h->Typ(); /*htype*/
519 ideal q = (ideal)h->next->CopyD();
520 int bound = (int)(long)h->next->next->Data();
521 if (pid==NULL) /*(htype == POLY_CMD || htype == VECTOR_CMD)*/
522 res->data = (char *)kNFBound(q,currRing->qideal,p,bound);
523 else /*(htype == IDEAL_CMD || htype == MODUL_CMD)*/
524 res->data = (char *)kNFBound(q,currRing->qideal,pid,bound);
525 return FALSE;
526 }
527 else
528/*==================== uname ==================================*/
529 if(strcmp(sys_cmd,"uname")==0)
530 {
531 res->rtyp=STRING_CMD;
532 res->data = omStrDup(S_UNAME);
533 return FALSE;
534 }
535 else
536/*==================== with ==================================*/
537 if(strcmp(sys_cmd,"with")==0)
538 {
539 if (h==NULL)
540 {
541 res->rtyp=STRING_CMD;
542 res->data=(void *)versionString();
543 return FALSE;
544 }
545 else if (h->Typ()==STRING_CMD)
546 {
547 #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else
548 char *s=(char *)h->Data();
549 res->rtyp=INT_CMD;
550 #ifdef HAVE_DBM
551 TEST_FOR("DBM")
552 #endif
553 #ifdef HAVE_DLD
554 TEST_FOR("DLD")
555 #endif
556 //TEST_FOR("factory")
557 //TEST_FOR("libfac")
558 #ifdef HAVE_READLINE
559 TEST_FOR("readline")
560 #endif
561 #ifdef TEST_MAC_ORDER
562 TEST_FOR("MAC_ORDER")
563 #endif
564 // unconditional since 3-1-0-6
565 TEST_FOR("Namespaces")
566 #ifdef HAVE_DYNAMIC_LOADING
567 TEST_FOR("DynamicLoading")
568 #endif
569 #ifdef HAVE_EIGENVAL
570 TEST_FOR("eigenval")
571 #endif
572 #ifdef HAVE_GMS
573 TEST_FOR("gms")
574 #endif
575 #ifdef OM_NDEBUG
576 TEST_FOR("om_ndebug")
577 #endif
578 #ifdef SING_NDEBUG
579 TEST_FOR("ndebug")
580 #endif
581 {};
582 return FALSE;
583 #undef TEST_FOR
584 }
585 return TRUE;
586 }
587 else
588 /*==================== browsers ==================================*/
589 if (strcmp(sys_cmd,"browsers")==0)
590 {
591 res->rtyp = STRING_CMD;
592 StringSetS("");
594 res->data = StringEndS();
595 return FALSE;
596 }
597 else
598 /*==================== pid ==================================*/
599 if (strcmp(sys_cmd,"pid")==0)
600 {
601 res->rtyp=INT_CMD;
602 res->data=(void *)(long) getpid();
603 return FALSE;
604 }
605 else
606 /*==================== getenv ==================================*/
607 if (strcmp(sys_cmd,"getenv")==0)
608 {
609 if ((h!=NULL) && (h->Typ()==STRING_CMD))
610 {
611 res->rtyp=STRING_CMD;
612 const char *r=getenv((char *)h->Data());
613 if (r==NULL) r="";
614 res->data=(void *)omStrDup(r);
615 return FALSE;
616 }
617 else
618 {
619 WerrorS("string expected");
620 return TRUE;
621 }
622 }
623 else
624 /*==================== setenv ==================================*/
625 if (strcmp(sys_cmd,"setenv")==0)
626 {
627 #ifdef HAVE_SETENV
628 const short t[]={2,STRING_CMD,STRING_CMD};
629 if (iiCheckTypes(h,t,1))
630 {
631 res->rtyp=STRING_CMD;
632 setenv((char *)h->Data(), (char *)h->next->Data(), 1);
633 res->data=(void *)omStrDup((char *)h->next->Data());
635 return FALSE;
636 }
637 else
638 {
639 return TRUE;
640 }
641 #else
642 WerrorS("setenv not supported on this platform");
643 return TRUE;
644 #endif
645 }
646 else
647 /*==================== Singular ==================================*/
648 if (strcmp(sys_cmd, "Singular") == 0)
649 {
650 res->rtyp=STRING_CMD;
651 const char *r=feResource("Singular");
652 if (r == NULL) r="";
653 res->data = (void*) omStrDup( r );
654 return FALSE;
655 }
656 else
657 if (strcmp(sys_cmd, "SingularLib") == 0)
658 {
659 res->rtyp=STRING_CMD;
660 const char *r=feResource("SearchPath");
661 if (r == NULL) r="";
662 res->data = (void*) omStrDup( r );
663 return FALSE;
664 }
665 else
666 if (strcmp(sys_cmd, "SingularBin") == 0)
667 {
668 res->rtyp=STRING_CMD;
669 const char *r=feResource('r');
670 if (r == NULL) r="/usr/local";
671 int l=strlen(r);
672 /* where to find Singular's programs: */
673 #define SINGULAR_PROCS_DIR "/libexec/singular/MOD"
674 int ll=si_max((int)strlen(SINGULAR_PROCS_DIR),(int)strlen(LIBEXEC_DIR));
675 char *s=(char*)omAlloc(l+ll+2);
676 if ((strstr(r,".libs/..")==NULL) /*not installed Singular (libtool)*/
677 &&(strstr(r,"Singular/..")==NULL)) /*not installed Singular (static)*/
678 {
679 strcpy(s,r);
680 strcat(s,SINGULAR_PROCS_DIR);
681 if (access(s,X_OK)==0)
682 {
683 strcat(s,"/");
684 }
685 else
686 {
687 /*second try: LIBEXEC_DIR*/
688 strcpy(s,LIBEXEC_DIR);
689 if (access(s,X_OK)==0)
690 {
691 strcat(s,"/");
692 }
693 else
694 {
695 s[0]='\0';
696 }
697 }
698 }
699 else
700 {
701 const char *r=feResource('b');
702 if (r == NULL)
703 {
704 s[0]='\0';
705 }
706 else
707 {
708 strcpy(s,r);
709 strcat(s,"/");
710 }
711 }
712 res->data = (void*)s;
713 return FALSE;
714 }
715 else
716 /*==================== options ==================================*/
717 if (strstr(sys_cmd, "--") == sys_cmd)
718 {
719 if (strcmp(sys_cmd, "--") == 0)
720 {
722 return FALSE;
723 }
724 feOptIndex opt = feGetOptIndex(&sys_cmd[2]);
725 if (opt == FE_OPT_UNDEF)
726 {
727 Werror("Unknown option %s", sys_cmd);
728 WerrorS("Use 'system(\"--\");' for listing of available options");
729 return TRUE;
730 }
731 // for Untyped Options (help version),
732 // setting it just triggers action
733 if (feOptSpec[opt].type == feOptUntyped)
734 {
735 feSetOptValue(opt,0);
736 return FALSE;
737 }
738 if (h == NULL)
739 {
740 if (feOptSpec[opt].type == feOptString)
741 {
742 res->rtyp = STRING_CMD;
743 const char *r=(const char*)feOptSpec[opt].value;
744 if (r == NULL) r="";
745 res->data = omStrDup(r);
746 }
747 else
748 {
749 res->rtyp = INT_CMD;
750 res->data = feOptSpec[opt].value;
751 }
752 return FALSE;
753 }
754 if (h->Typ() != STRING_CMD &&
755 h->Typ() != INT_CMD)
756 {
757 WerrorS("Need string or int argument to set option value");
758 return TRUE;
759 }
760 const char* errormsg;
761 if (h->Typ() == INT_CMD)
762 {
763 if (feOptSpec[opt].type == feOptString)
764 {
765 Werror("Need string argument to set value of option %s", sys_cmd);
766 return TRUE;
767 }
768 errormsg = feSetOptValue(opt, (int)((long) h->Data()));
769 if (errormsg != NULL)
770 Werror("Option '--%s=%d' %s", sys_cmd, (int) ((long)h->Data()), errormsg);
771 }
772 else
773 {
774 errormsg = feSetOptValue(opt, (char*) h->Data());
775 if (errormsg != NULL)
776 Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg);
777 }
778 if (errormsg != NULL) return TRUE;
779 return FALSE;
780 }
781 else
782 /*==================== HC ==================================*/
783 if (strcmp(sys_cmd,"HC")==0)
784 {
785 res->rtyp=INT_CMD;
786 res->data=(void *)(long) HCord;
787 return FALSE;
788 }
789 else
790 /*==================== random ==================================*/
791 if(strcmp(sys_cmd,"random")==0)
792 {
793 const short t[]={1,INT_CMD};
794 if (h!=NULL)
795 {
796 if (iiCheckTypes(h,t,1))
797 {
798 siRandomStart=(int)((long)h->Data());
801 return FALSE;
802 }
803 else
804 {
805 return TRUE;
806 }
807 }
808 res->rtyp=INT_CMD;
809 res->data=(void*)(long) siSeed;
810 return FALSE;
811 }
812 else
813 /*======================= demon_list =====================*/
814 if (strcmp(sys_cmd,"denom_list")==0)
815 {
816 res->rtyp=LIST_CMD;
817 extern lists get_denom_list();
818 res->data=(lists)get_denom_list();
819 return FALSE;
820 }
821 else
822 /*==================== complexNearZero ======================*/
823 if(strcmp(sys_cmd,"complexNearZero")==0)
824 {
825 const short t[]={2,NUMBER_CMD,INT_CMD};
826 if (iiCheckTypes(h,t,1))
827 {
829 {
830 WerrorS( "unsupported ground field!");
831 return TRUE;
832 }
833 else
834 {
835 res->rtyp=INT_CMD;
836 res->data=(void*)complexNearZero((gmp_complex*)h->Data(),
837 (int)((long)(h->next->Data())));
838 return FALSE;
839 }
840 }
841 else
842 {
843 return TRUE;
844 }
845 }
846 else
847 /*==================== getPrecDigits ======================*/
848 if(strcmp(sys_cmd,"getPrecDigits")==0)
849 {
850 if ( (currRing==NULL)
852 {
853 WerrorS( "unsupported ground field!");
854 return TRUE;
855 }
856 res->rtyp=INT_CMD;
857 res->data=(void*)(long)gmp_output_digits;
858 //if (gmp_output_digits!=getGMPFloatDigits())
859 //{ Print("%d, %d\n",getGMPFloatDigits(),gmp_output_digits);}
860 return FALSE;
861 }
862 else
863 /*==================== lduDecomp ======================*/
864 if(strcmp(sys_cmd, "lduDecomp")==0)
865 {
866 const short t[]={1,MATRIX_CMD};
867 if (iiCheckTypes(h,t,1))
868 {
869 matrix aMat = (matrix)h->Data();
870 matrix pMat; matrix lMat; matrix dMat; matrix uMat;
871 poly l; poly u; poly prodLU;
872 lduDecomp(aMat, pMat, lMat, dMat, uMat, l, u, prodLU);
874 L->Init(7);
875 L->m[0].rtyp = MATRIX_CMD; L->m[0].data=(void*)pMat;
876 L->m[1].rtyp = MATRIX_CMD; L->m[1].data=(void*)lMat;
877 L->m[2].rtyp = MATRIX_CMD; L->m[2].data=(void*)dMat;
878 L->m[3].rtyp = MATRIX_CMD; L->m[3].data=(void*)uMat;
879 L->m[4].rtyp = POLY_CMD; L->m[4].data=(void*)l;
880 L->m[5].rtyp = POLY_CMD; L->m[5].data=(void*)u;
881 L->m[6].rtyp = POLY_CMD; L->m[6].data=(void*)prodLU;
882 res->rtyp = LIST_CMD;
883 res->data = (char *)L;
884 return FALSE;
885 }
886 else
887 {
888 return TRUE;
889 }
890 }
891 else
892 /*==================== lduSolve ======================*/
893 if(strcmp(sys_cmd, "lduSolve")==0)
894 {
895 /* for solving a linear equation system A * x = b, via the
896 given LDU-decomposition of the matrix A;
897 There is one valid parametrisation:
898 1) exactly eight arguments P, L, D, U, l, u, lTimesU, b;
899 P, L, D, and U realise the LDU-decomposition of A, that is,
900 P * A = L * D^(-1) * U, and P, L, D, and U satisfy the
901 properties decribed in method 'luSolveViaLDUDecomp' in
902 linearAlgebra.h; see there;
903 l, u, and lTimesU are as described in the same location;
904 b is the right-hand side vector of the linear equation system;
905 The method will return a list of either 1 entry or three entries:
906 1) [0] if there is no solution to the system;
907 2) [1, x, H] if there is at least one solution;
908 x is any solution of the given linear system,
909 H is the matrix with column vectors spanning the homogeneous
910 solution space.
911 The method produces an error if matrix and vector sizes do not
912 fit. */
914 if (!iiCheckTypes(h,t,1))
915 {
916 return TRUE;
917 }
919 {
920 WerrorS("field required");
921 return TRUE;
922 }
923 matrix pMat = (matrix)h->Data();
924 matrix lMat = (matrix)h->next->Data();
925 matrix dMat = (matrix)h->next->next->Data();
926 matrix uMat = (matrix)h->next->next->next->Data();
927 poly l = (poly) h->next->next->next->next->Data();
928 poly u = (poly) h->next->next->next->next->next->Data();
929 poly lTimesU = (poly) h->next->next->next->next->next->next->Data();
930 matrix bVec = (matrix)h->next->next->next->next->next->next->next->Data();
931 matrix xVec; int solvable; matrix homogSolSpace;
932 if (pMat->rows() != pMat->cols())
933 {
934 Werror("first matrix (%d x %d) is not quadratic",
935 pMat->rows(), pMat->cols());
936 return TRUE;
937 }
938 if (lMat->rows() != lMat->cols())
939 {
940 Werror("second matrix (%d x %d) is not quadratic",
941 lMat->rows(), lMat->cols());
942 return TRUE;
943 }
944 if (dMat->rows() != dMat->cols())
945 {
946 Werror("third matrix (%d x %d) is not quadratic",
947 dMat->rows(), dMat->cols());
948 return TRUE;
949 }
950 if (dMat->cols() != uMat->rows())
951 {
952 Werror("third matrix (%d x %d) and fourth matrix (%d x %d) %s",
953 dMat->rows(), dMat->cols(), uMat->rows(), uMat->cols(),
954 "do not t");
955 return TRUE;
956 }
957 if (uMat->rows() != bVec->rows())
958 {
959 Werror("fourth matrix (%d x %d) and vector (%d x 1) do not fit",
960 uMat->rows(), uMat->cols(), bVec->rows());
961 return TRUE;
962 }
963 solvable = luSolveViaLDUDecomp(pMat, lMat, dMat, uMat, l, u, lTimesU,
964 bVec, xVec, homogSolSpace);
965
966 /* build the return structure; a list with either one or
967 three entries */
969 if (solvable)
970 {
971 ll->Init(3);
972 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
973 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
974 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
975 }
976 else
977 {
978 ll->Init(1);
979 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
980 }
981 res->rtyp = LIST_CMD;
982 res->data=(char*)ll;
983 return FALSE;
984 }
985 else
986 /*==== countedref: reference and shared ====*/
987 if (strcmp(sys_cmd, "shared") == 0)
988 {
989 #ifndef SI_COUNTEDREF_AUTOLOAD
992 #endif
993 res->rtyp = NONE;
994 return FALSE;
995 }
996 else if (strcmp(sys_cmd, "reference") == 0)
997 {
998 #ifndef SI_COUNTEDREF_AUTOLOAD
1001 #endif
1002 res->rtyp = NONE;
1003 return FALSE;
1004 }
1005 else
1006/*==================== semaphore =================*/
1007#ifdef HAVE_SIMPLEIPC
1008 if (strcmp(sys_cmd,"semaphore")==0)
1009 {
1010 if((h!=NULL) && (h->Typ()==STRING_CMD) && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
1011 {
1012 int v=1;
1013 if ((h->next->next!=NULL)&& (h->next->next->Typ()==INT_CMD))
1014 v=(int)(long)h->next->next->Data();
1015 res->data=(char *)(long)simpleipc_cmd((char *)h->Data(),(int)(long)h->next->Data(),v);
1016 res->rtyp=INT_CMD;
1017 return FALSE;
1018 }
1019 else
1020 {
1021 WerrorS("Usage: system(\"semaphore\",<cmd>,int)");
1022 return TRUE;
1023 }
1024 }
1025 else
1026#endif
1027/*==================== reserved port =================*/
1028 if (strcmp(sys_cmd,"reserve")==0)
1029 {
1030 const short t[]={1,INT_CMD};
1031 if (iiCheckTypes(h,t,1))
1032 {
1033 res->rtyp=INT_CMD;
1034 int p=ssiReservePort((int)(long)h->Data());
1035 res->data=(void*)(long)p;
1036 return (p==0);
1037 }
1038 return TRUE;
1039 }
1040 else
1041/*==================== reserved link =================*/
1042 if (strcmp(sys_cmd,"reservedLink")==0)
1043 {
1044 res->rtyp=LINK_CMD;
1046 res->data=(void*)p;
1047 return (p==NULL);
1048 }
1049 else
1050/*==================== install newstruct =================*/
1051 if (strcmp(sys_cmd,"install")==0)
1052 {
1053 const short t[]={4,STRING_CMD,STRING_CMD,PROC_CMD,INT_CMD};
1054 if (iiCheckTypes(h,t,1))
1055 {
1056 return newstruct_set_proc((char*)h->Data(),(char*)h->next->Data(),
1057 (int)(long)h->next->next->next->Data(),
1058 (procinfov)h->next->next->Data());
1059 }
1060 return TRUE;
1061 }
1062 else
1063/*==================== newstruct =================*/
1064 if (strcmp(sys_cmd,"newstruct")==0)
1065 {
1066 const short t[]={1,STRING_CMD};
1067 if (iiCheckTypes(h,t,1))
1068 {
1069 int id=0;
1070 char *n=(char*)h->Data();
1071 blackboxIsCmd(n,id);
1072 if (id>0)
1073 {
1074 blackbox *bb=getBlackboxStuff(id);
1075 if (BB_LIKE_LIST(bb))
1076 {
1077 newstruct_desc desc=(newstruct_desc)bb->data;
1078 newstructShow(desc);
1079 return FALSE;
1080 }
1081 else Werror("'%s' is not a newstruct",n);
1082 }
1083 else Werror("'%s' is not a blackbox object",n);
1084 }
1085 return TRUE;
1086 }
1087 else
1088/*==================== blackbox =================*/
1089 if (strcmp(sys_cmd,"blackbox")==0)
1090 {
1092 return FALSE;
1093 }
1094 else
1095 /*================= absBiFact ======================*/
1096 #if defined(HAVE_FLINT) || defined(HAVE_NTL)
1097 if (strcmp(sys_cmd, "absFact") == 0)
1098 {
1099 const short t[]={1,POLY_CMD};
1100 if (iiCheckTypes(h,t,1)
1101 && (currRing!=NULL)
1102 && (getCoeffType(currRing->cf)==n_transExt))
1103 {
1104 res->rtyp=LIST_CMD;
1105 intvec *v=NULL;
1106 ideal mipos= NULL;
1107 int n= 0;
1108 ideal f=singclap_absFactorize((poly)(h->Data()), mipos, &v, n, currRing);
1109 if (f==NULL) return TRUE;
1110 ivTest(v);
1112 l->Init(4);
1113 l->m[0].rtyp=IDEAL_CMD;
1114 l->m[0].data=(void *)f;
1115 l->m[1].rtyp=INTVEC_CMD;
1116 l->m[1].data=(void *)v;
1117 l->m[2].rtyp=IDEAL_CMD;
1118 l->m[2].data=(void*) mipos;
1119 l->m[3].rtyp=INT_CMD;
1120 l->m[3].data=(void*) (long) n;
1121 res->data=(void *)l;
1122 return FALSE;
1123 }
1124 else return TRUE;
1125 }
1126 else
1127 #endif
1128 /* =================== LLL via NTL ==============================*/
1129 #ifdef HAVE_NTL
1130 if (strcmp(sys_cmd, "LLL") == 0)
1131 {
1132 if (h!=NULL)
1133 {
1134 res->rtyp=h->Typ();
1135 if (h->Typ()==MATRIX_CMD)
1136 {
1137 res->data=(char *)singntl_LLL((matrix)h->Data(), currRing);
1138 return FALSE;
1139 }
1140 else if (h->Typ()==INTMAT_CMD)
1141 {
1142 res->data=(char *)singntl_LLL((intvec*)h->Data());
1143 return FALSE;
1144 }
1145 else return TRUE;
1146 }
1147 else return TRUE;
1148 }
1149 else
1150 #endif
1151 /* =================== LLL via Flint ==============================*/
1152 #ifdef HAVE_FLINT
1153 #if __FLINT_RELEASE >= 20500
1154 if (strcmp(sys_cmd, "LLL_Flint") == 0)
1155 {
1156 if (h!=NULL)
1157 {
1158 if(h->next == NULL)
1159 {
1160 res->rtyp=h->Typ();
1161 if (h->Typ()==BIGINTMAT_CMD)
1162 {
1163 res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1164 return FALSE;
1165 }
1166 else if (h->Typ()==INTMAT_CMD)
1167 {
1168 res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1169 return FALSE;
1170 }
1171 else return TRUE;
1172 }
1173 if(h->next->Typ()!= INT_CMD)
1174 {
1175 WerrorS("matrix,int or bigint,int expected");
1176 return TRUE;
1177 }
1178 if(h->next->Typ()== INT_CMD)
1179 {
1180 if(((int)((long)(h->next->Data())) != 0) && (int)((long)(h->next->Data()) != 1))
1181 {
1182 WerrorS("int is different from 0, 1");
1183 return TRUE;
1184 }
1185 res->rtyp=h->Typ();
1186 if((long)(h->next->Data()) == 0)
1187 {
1188 if (h->Typ()==BIGINTMAT_CMD)
1189 {
1190 res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1191 return FALSE;
1192 }
1193 else if (h->Typ()==INTMAT_CMD)
1194 {
1195 res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1196 return FALSE;
1197 }
1198 else return TRUE;
1199 }
1200 // This will give also the transformation matrix U s.t. res = U * m
1201 if((long)(h->next->Data()) == 1)
1202 {
1203 if (h->Typ()==BIGINTMAT_CMD)
1204 {
1205 bigintmat* m = (bigintmat*)h->Data();
1206 bigintmat* T = new bigintmat(m->rows(),m->rows(),m->basecoeffs());
1207 for(int i = 1; i<=m->rows(); i++)
1208 {
1209 n_Delete(&(BIMATELEM(*T,i,i)),T->basecoeffs());
1210 BIMATELEM(*T,i,i)=n_Init(1, T->basecoeffs());
1211 }
1212 m = singflint_LLL(m,T);
1214 L->Init(2);
1215 L->m[0].rtyp = BIGINTMAT_CMD; L->m[0].data = (void*)m;
1216 L->m[1].rtyp = BIGINTMAT_CMD; L->m[1].data = (void*)T;
1217 res->data=L;
1218 res->rtyp=LIST_CMD;
1219 return FALSE;
1220 }
1221 else if (h->Typ()==INTMAT_CMD)
1222 {
1223 intvec* m = (intvec*)h->Data();
1224 intvec* T = new intvec(m->rows(),m->rows(),(int)0);
1225 for(int i = 1; i<=m->rows(); i++)
1226 IMATELEM(*T,i,i)=1;
1227 m = singflint_LLL(m,T);
1229 L->Init(2);
1230 L->m[0].rtyp = INTMAT_CMD; L->m[0].data = (void*)m;
1231 L->m[1].rtyp = INTMAT_CMD; L->m[1].data = (void*)T;
1232 res->data=L;
1233 res->rtyp=LIST_CMD;
1234 return FALSE;
1235 }
1236 else return TRUE;
1237 }
1238 }
1239
1240 }
1241 else return TRUE;
1242 }
1243 else
1244 #endif
1245 #endif
1246/* ====== rref ============================*/
1247 #if defined(HAVE_FLINT) || defined(HAVE_NTL)
1248 if(strcmp(sys_cmd,"rref")==0)
1249 {
1250 const short t1[]={1,MATRIX_CMD};
1251 const short t2[]={1,SMATRIX_CMD};
1252 if (iiCheckTypes(h,t1,0))
1253 {
1254 matrix M=(matrix)h->Data();
1255 #if defined(HAVE_FLINT)
1256 res->data=(void*)singflint_rref(M,currRing);
1257 #elif defined(HAVE_NTL)
1258 res->data=(void*)singntl_rref(M,currRing);
1259 #endif
1260 res->rtyp=MATRIX_CMD;
1261 return FALSE;
1262 }
1263 else if (iiCheckTypes(h,t2,1))
1264 {
1265 ideal M=(ideal)h->Data();
1266 #if defined(HAVE_FLINT)
1267 res->data=(void*)singflint_rref(M,currRing);
1268 #elif defined(HAVE_NTL)
1269 res->data=(void*)singntl_rref(M,currRing);
1270 #endif
1271 res->rtyp=SMATRIX_CMD;
1272 return FALSE;
1273 }
1274 else
1275 {
1276 WerrorS("expected system(\"rref\",<matrix>/<smatrix>)");
1277 return TRUE;
1278 }
1279 }
1280 else
1281 #endif
1282 /*==================== pcv ==================================*/
1283 #ifdef HAVE_PCV
1284 if(strcmp(sys_cmd,"pcvLAddL")==0)
1285 {
1286 return pcvLAddL(res,h);
1287 }
1288 else
1289 if(strcmp(sys_cmd,"pcvPMulL")==0)
1290 {
1291 return pcvPMulL(res,h);
1292 }
1293 else
1294 if(strcmp(sys_cmd,"pcvMinDeg")==0)
1295 {
1296 return pcvMinDeg(res,h);
1297 }
1298 else
1299 if(strcmp(sys_cmd,"pcvP2CV")==0)
1300 {
1301 return pcvP2CV(res,h);
1302 }
1303 else
1304 if(strcmp(sys_cmd,"pcvCV2P")==0)
1305 {
1306 return pcvCV2P(res,h);
1307 }
1308 else
1309 if(strcmp(sys_cmd,"pcvDim")==0)
1310 {
1311 return pcvDim(res,h);
1312 }
1313 else
1314 if(strcmp(sys_cmd,"pcvBasis")==0)
1315 {
1316 return pcvBasis(res,h);
1317 }
1318 else
1319 #endif
1320 /*==================== hessenberg/eigenvalues ==================================*/
1321 #ifdef HAVE_EIGENVAL
1322 if(strcmp(sys_cmd,"hessenberg")==0)
1323 {
1324 return evHessenberg(res,h);
1325 }
1326 else
1327 #endif
1328 /*==================== eigenvalues ==================================*/
1329 #ifdef HAVE_EIGENVAL
1330 if(strcmp(sys_cmd,"eigenvals")==0)
1331 {
1332 return evEigenvals(res,h);
1333 }
1334 else
1335 #endif
1336 /*==================== rowelim ==================================*/
1337 #ifdef HAVE_EIGENVAL
1338 if(strcmp(sys_cmd,"rowelim")==0)
1339 {
1340 return evRowElim(res,h);
1341 }
1342 else
1343 #endif
1344 /*==================== rowcolswap ==================================*/
1345 #ifdef HAVE_EIGENVAL
1346 if(strcmp(sys_cmd,"rowcolswap")==0)
1347 {
1348 return evSwap(res,h);
1349 }
1350 else
1351 #endif
1352 /*==================== Gauss-Manin system ==================================*/
1353 #ifdef HAVE_GMS
1354 if(strcmp(sys_cmd,"gmsnf")==0)
1355 {
1356 return gmsNF(res,h);
1357 }
1358 else
1359 #endif
1360 /*==================== contributors =============================*/
1361 if(strcmp(sys_cmd,"contributors") == 0)
1362 {
1363 res->rtyp=STRING_CMD;
1364 res->data=(void *)omStrDup(
1365 "Olaf Bachmann, Michael Brickenstein, Hubert Grassmann, Kai Krueger, Victor Levandovskyy, Wolfgang Neumann, Thomas Nuessler, Wilfred Pohl, Jens Schmidt, Mathias Schulze, Thomas Siebert, Ruediger Stobbe, Moritz Wenk, Tim Wichmann");
1366 return FALSE;
1367 }
1368 else
1369 /*==================== spectrum =============================*/
1370 #ifdef HAVE_SPECTRUM
1371 if(strcmp(sys_cmd,"spectrum") == 0)
1372 {
1373 if ((h==NULL) || (h->Typ()!=POLY_CMD))
1374 {
1375 WerrorS("poly expected");
1376 return TRUE;
1377 }
1378 if (h->next==NULL)
1379 return spectrumProc(res,h);
1380 if (h->next->Typ()!=INT_CMD)
1381 {
1382 WerrorS("poly,int expected");
1383 return TRUE;
1384 }
1385 if(((long)h->next->Data())==1L)
1386 return spectrumfProc(res,h);
1387 return spectrumProc(res,h);
1388 }
1389 else
1390 /*==================== semic =============================*/
1391 if(strcmp(sys_cmd,"semic") == 0)
1392 {
1393 if ((h->next!=NULL)
1394 && (h->Typ()==LIST_CMD)
1395 && (h->next->Typ()==LIST_CMD))
1396 {
1397 if (h->next->next==NULL)
1398 return semicProc(res,h,h->next);
1399 else if (h->next->next->Typ()==INT_CMD)
1400 return semicProc3(res,h,h->next,h->next->next);
1401 }
1402 return TRUE;
1403 }
1404 else
1405 /*==================== spadd =============================*/
1406 if(strcmp(sys_cmd,"spadd") == 0)
1407 {
1408 const short t[]={2,LIST_CMD,LIST_CMD};
1409 if (iiCheckTypes(h,t,1))
1410 {
1411 return spaddProc(res,h,h->next);
1412 }
1413 return TRUE;
1414 }
1415 else
1416 /*==================== spmul =============================*/
1417 if(strcmp(sys_cmd,"spmul") == 0)
1418 {
1419 const short t[]={2,LIST_CMD,INT_CMD};
1420 if (iiCheckTypes(h,t,1))
1421 {
1422 return spmulProc(res,h,h->next);
1423 }
1424 return TRUE;
1425 }
1426 else
1427 #endif
1428/*==================== tensorModuleMult ========================= */
1429 #define HAVE_SHEAFCOH_TRICKS 1
1430
1431 #ifdef HAVE_SHEAFCOH_TRICKS
1432 if(strcmp(sys_cmd,"tensorModuleMult")==0)
1433 {
1434 const short t[]={2,INT_CMD,MODUL_CMD};
1435 // WarnS("tensorModuleMult!");
1436 if (iiCheckTypes(h,t,1))
1437 {
1438 int m = (int)( (long)h->Data() );
1439 ideal M = (ideal)h->next->Data();
1440 res->rtyp=MODUL_CMD;
1441 res->data=(void *)id_TensorModuleMult(m, M, currRing);
1442 return FALSE;
1443 }
1444 return TRUE;
1445 }
1446 else
1447 #endif
1448 /*==================== twostd =================*/
1449 #ifdef HAVE_PLURAL
1450 if (strcmp(sys_cmd, "twostd") == 0)
1451 {
1452 ideal I;
1453 if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
1454 {
1455 I=(ideal)h->CopyD();
1456 res->rtyp=IDEAL_CMD;
1457 if (rIsPluralRing(currRing)) res->data=twostd(I);
1458 else res->data=I;
1461 }
1462 else return TRUE;
1463 return FALSE;
1464 }
1465 else
1466 #endif
1467 /*==================== lie bracket =================*/
1468 #ifdef HAVE_PLURAL
1469 if (strcmp(sys_cmd, "bracket") == 0)
1470 {
1471 const short t[]={2,POLY_CMD,POLY_CMD};
1472 if (iiCheckTypes(h,t,1))
1473 {
1474 poly p=(poly)h->CopyD();
1475 h=h->next;
1476 poly q=(poly)h->Data();
1477 res->rtyp=POLY_CMD;
1479 return FALSE;
1480 }
1481 return TRUE;
1482 }
1483 else
1484 #endif
1485 /*==================== env ==================================*/
1486 #ifdef HAVE_PLURAL
1487 if (strcmp(sys_cmd, "env")==0)
1488 {
1489 if ((h!=NULL) && (h->Typ()==RING_CMD))
1490 {
1491 ring r = (ring)h->Data();
1492 res->data = rEnvelope(r);
1493 res->rtyp = RING_CMD;
1494 return FALSE;
1495 }
1496 else
1497 {
1498 WerrorS("`system(\"env\",<ring>)` expected");
1499 return TRUE;
1500 }
1501 }
1502 else
1503 #endif
1504/* ============ opp ======================== */
1505 #ifdef HAVE_PLURAL
1506 if (strcmp(sys_cmd, "opp")==0)
1507 {
1508 if ((h!=NULL) && (h->Typ()==RING_CMD))
1509 {
1510 ring r=(ring)h->Data();
1511 res->data=rOpposite(r);
1512 res->rtyp=RING_CMD;
1513 return FALSE;
1514 }
1515 else
1516 {
1517 WerrorS("`system(\"opp\",<ring>)` expected");
1518 return TRUE;
1519 }
1520 }
1521 else
1522 #endif
1523 /*==================== oppose ==================================*/
1524 #ifdef HAVE_PLURAL
1525 if (strcmp(sys_cmd, "oppose")==0)
1526 {
1527 if ((h!=NULL) && (h->Typ()==RING_CMD)
1528 && (h->next!= NULL))
1529 {
1530 ring Rop = (ring)h->Data();
1531 h = h->next;
1532 idhdl w;
1533 if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL)
1534 {
1535 poly p = (poly)IDDATA(w);
1536 res->data = pOppose(Rop, p, currRing); // into CurrRing?
1537 res->rtyp = POLY_CMD;
1538 return FALSE;
1539 }
1540 }
1541 else
1542 {
1543 WerrorS("`system(\"oppose\",<ring>,<poly>)` expected");
1544 return TRUE;
1545 }
1546 }
1547 else
1548 #endif
1549 /*==================== walk stuff =================*/
1550 /*==================== walkNextWeight =================*/
1551 #ifdef HAVE_WALK
1552 #ifdef OWNW
1553 if (strcmp(sys_cmd, "walkNextWeight") == 0)
1554 {
1555 const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1556 if (!iiCheckTypes(h,t,1)) return TRUE;
1557 if (((intvec*) h->Data())->length() != currRing->N ||
1558 ((intvec*) h->next->Data())->length() != currRing->N)
1559 {
1560 Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n",
1561 currRing->N);
1562 return TRUE;
1563 }
1564 res->data = (void*) walkNextWeight(((intvec*) h->Data()),
1565 ((intvec*) h->next->Data()),
1566 (ideal) h->next->next->Data());
1567 if (res->data == NULL || res->data == (void*) 1L)
1568 {
1569 res->rtyp = INT_CMD;
1570 }
1571 else
1572 {
1573 res->rtyp = INTVEC_CMD;
1574 }
1575 return FALSE;
1576 }
1577 else
1578 #endif
1579 #endif
1580 /*==================== walkNextWeight =================*/
1581 #ifdef HAVE_WALK
1582 #ifdef OWNW
1583 if (strcmp(sys_cmd, "walkInitials") == 0)
1584 {
1585 if (h == NULL || h->Typ() != IDEAL_CMD)
1586 {
1587 WerrorS("system(\"walkInitials\", ideal) expected");
1588 return TRUE;
1589 }
1590 res->data = (void*) walkInitials((ideal) h->Data());
1591 res->rtyp = IDEAL_CMD;
1592 return FALSE;
1593 }
1594 else
1595 #endif
1596 #endif
1597 /*==================== walkAddIntVec =================*/
1598 #ifdef HAVE_WALK
1599 #ifdef WAIV
1600 if (strcmp(sys_cmd, "walkAddIntVec") == 0)
1601 {
1602 const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1603 if (!iiCheckTypes(h,t,1)) return TRUE;
1604 intvec* arg1 = (intvec*) h->Data();
1605 intvec* arg2 = (intvec*) h->next->Data();
1606 res->data = (intvec*) walkAddIntVec(arg1, arg2);
1607 res->rtyp = INTVEC_CMD;
1608 return FALSE;
1609 }
1610 else
1611 #endif
1612 #endif
1613 /*==================== MwalkNextWeight =================*/
1614 #ifdef HAVE_WALK
1615 #ifdef MwaklNextWeight
1616 if (strcmp(sys_cmd, "MwalkNextWeight") == 0)
1617 {
1618 const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1619 if (!iiCheckTypes(h,t,1)) return TRUE;
1620 if (((intvec*) h->Data())->length() != currRing->N ||
1621 ((intvec*) h->next->Data())->length() != currRing->N)
1622 {
1623 Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n",
1624 currRing->N);
1625 return TRUE;
1626 }
1627 intvec* arg1 = (intvec*) h->Data();
1628 intvec* arg2 = (intvec*) h->next->Data();
1629 ideal arg3 = (ideal) h->next->next->Data();
1630 intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3);
1631 res->rtyp = INTVEC_CMD;
1632 res->data = result;
1633 return FALSE;
1634 }
1635 else
1636 #endif //MWalkNextWeight
1637 #endif
1638 /*==================== Mivdp =================*/
1639 #ifdef HAVE_WALK
1640 if(strcmp(sys_cmd, "Mivdp") == 0)
1641 {
1642 if (h == NULL || h->Typ() != INT_CMD)
1643 {
1644 WerrorS("system(\"Mivdp\", int) expected");
1645 return TRUE;
1646 }
1647 if ((int) ((long)(h->Data())) != currRing->N)
1648 {
1649 Werror("system(\"Mivdp\" ...) intvecs not of length %d\n",
1650 currRing->N);
1651 return TRUE;
1652 }
1653 int arg1 = (int) ((long)(h->Data()));
1654 intvec* result = (intvec*) Mivdp(arg1);
1655 res->rtyp = INTVEC_CMD;
1656 res->data = result;
1657 return FALSE;
1658 }
1659 else
1660 #endif
1661 /*==================== Mivlp =================*/
1662 #ifdef HAVE_WALK
1663 if(strcmp(sys_cmd, "Mivlp") == 0)
1664 {
1665 if (h == NULL || h->Typ() != INT_CMD)
1666 {
1667 WerrorS("system(\"Mivlp\", int) expected");
1668 return TRUE;
1669 }
1670 if ((int) ((long)(h->Data())) != currRing->N)
1671 {
1672 Werror("system(\"Mivlp\" ...) intvecs not of length %d\n",
1673 currRing->N);
1674 return TRUE;
1675 }
1676 int arg1 = (int) ((long)(h->Data()));
1677 intvec* result = (intvec*) Mivlp(arg1);
1678 res->rtyp = INTVEC_CMD;
1679 res->data = result;
1680 return FALSE;
1681 }
1682 else
1683 #endif
1684 /*==================== MpDiv =================*/
1685 #ifdef HAVE_WALK
1686 #ifdef MpDiv
1687 if(strcmp(sys_cmd, "MpDiv") == 0)
1688 {
1689 const short t[]={2,POLY_CMD,POLY_CMD};
1690 if (!iiCheckTypes(h,t,1)) return TRUE;
1691 poly arg1 = (poly) h->Data();
1692 poly arg2 = (poly) h->next->Data();
1693 poly result = MpDiv(arg1, arg2);
1694 res->rtyp = POLY_CMD;
1695 res->data = result;
1696 return FALSE;
1697 }
1698 else
1699 #endif
1700 #endif
1701 /*==================== MpMult =================*/
1702 #ifdef HAVE_WALK
1703 #ifdef MpMult
1704 if(strcmp(sys_cmd, "MpMult") == 0)
1705 {
1706 const short t[]={2,POLY_CMD,POLY_CMD};
1707 if (!iiCheckTypes(h,t,1)) return TRUE;
1708 poly arg1 = (poly) h->Data();
1709 poly arg2 = (poly) h->next->Data();
1710 poly result = MpMult(arg1, arg2);
1711 res->rtyp = POLY_CMD;
1712 res->data = result;
1713 return FALSE;
1714 }
1715 else
1716 #endif
1717 #endif
1718 /*==================== MivSame =================*/
1719 #ifdef HAVE_WALK
1720 if (strcmp(sys_cmd, "MivSame") == 0)
1721 {
1722 const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1723 if (!iiCheckTypes(h,t,1)) return TRUE;
1724 /*
1725 if (((intvec*) h->Data())->length() != currRing->N ||
1726 ((intvec*) h->next->Data())->length() != currRing->N)
1727 {
1728 Werror("system(\"MivSame\" ...) intvecs not of length %d\n",
1729 currRing->N);
1730 return TRUE;
1731 }
1732 */
1733 intvec* arg1 = (intvec*) h->Data();
1734 intvec* arg2 = (intvec*) h->next->Data();
1735 /*
1736 poly result = (poly) MivSame(arg1, arg2);
1737 res->rtyp = POLY_CMD;
1738 res->data = (poly) result;
1739 */
1740 res->rtyp = INT_CMD;
1741 res->data = (void*)(long) MivSame(arg1, arg2);
1742 return FALSE;
1743 }
1744 else
1745 #endif
1746 /*==================== M3ivSame =================*/
1747 #ifdef HAVE_WALK
1748 if (strcmp(sys_cmd, "M3ivSame") == 0)
1749 {
1750 const short t[]={3,INTVEC_CMD,INTVEC_CMD,INTVEC_CMD};
1751 if (!iiCheckTypes(h,t,1)) return TRUE;
1752 /*
1753 if (((intvec*) h->Data())->length() != currRing->N ||
1754 ((intvec*) h->next->Data())->length() != currRing->N ||
1755 ((intvec*) h->next->next->Data())->length() != currRing->N )
1756 {
1757 Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n",
1758 currRing->N);
1759 return TRUE;
1760 }
1761 */
1762 intvec* arg1 = (intvec*) h->Data();
1763 intvec* arg2 = (intvec*) h->next->Data();
1764 intvec* arg3 = (intvec*) h->next->next->Data();
1765 /*
1766 poly result = (poly) M3ivSame(arg1, arg2, arg3);
1767 res->rtyp = POLY_CMD;
1768 res->data = (poly) result;
1769 */
1770 res->rtyp = INT_CMD;
1771 res->data = (void*)(long) M3ivSame(arg1, arg2, arg3);
1772 return FALSE;
1773 }
1774 else
1775 #endif
1776 /*==================== MwalkInitialForm =================*/
1777 #ifdef HAVE_WALK
1778 if(strcmp(sys_cmd, "MwalkInitialForm") == 0)
1779 {
1780 const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1781 if (!iiCheckTypes(h,t,1)) return TRUE;
1782 if(((intvec*) h->next->Data())->length() != currRing->N)
1783 {
1784 Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n",
1785 currRing->N);
1786 return TRUE;
1787 }
1788 ideal id = (ideal) h->Data();
1789 intvec* int_w = (intvec*) h->next->Data();
1790 ideal result = (ideal) MwalkInitialForm(id, int_w);
1791 res->rtyp = IDEAL_CMD;
1792 res->data = result;
1793 return FALSE;
1794 }
1795 else
1796 #endif
1797 /*==================== MivMatrixOrder =================*/
1798 #ifdef HAVE_WALK
1799 /************** Perturbation walk **********/
1800 if(strcmp(sys_cmd, "MivMatrixOrder") == 0)
1801 {
1802 if(h==NULL || h->Typ() != INTVEC_CMD)
1803 {
1804 WerrorS("system(\"MivMatrixOrder\",intvec) expected");
1805 return TRUE;
1806 }
1807 intvec* arg1 = (intvec*) h->Data();
1808 intvec* result = MivMatrixOrder(arg1);
1809 res->rtyp = INTVEC_CMD;
1810 res->data = result;
1811 return FALSE;
1812 }
1813 else
1814 #endif
1815 /*==================== MivMatrixOrderdp =================*/
1816 #ifdef HAVE_WALK
1817 if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0)
1818 {
1819 if(h==NULL || h->Typ() != INT_CMD)
1820 {
1821 WerrorS("system(\"MivMatrixOrderdp\",intvec) expected");
1822 return TRUE;
1823 }
1824 int arg1 = (int) ((long)(h->Data()));
1826 res->rtyp = INTVEC_CMD;
1827 res->data = result;
1828 return FALSE;
1829 }
1830 else
1831 #endif
1832 /*==================== MPertVectors =================*/
1833 #ifdef HAVE_WALK
1834 if(strcmp(sys_cmd, "MPertVectors") == 0)
1835 {
1836 const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1837 if (!iiCheckTypes(h,t,1)) return TRUE;
1838 ideal arg1 = (ideal) h->Data();
1839 intvec* arg2 = (intvec*) h->next->Data();
1840 int arg3 = (int) ((long)(h->next->next->Data()));
1841 intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3);
1842 res->rtyp = INTVEC_CMD;
1843 res->data = result;
1844 return FALSE;
1845 }
1846 else
1847 #endif
1848 /*==================== MPertVectorslp =================*/
1849 #ifdef HAVE_WALK
1850 if(strcmp(sys_cmd, "MPertVectorslp") == 0)
1851 {
1852 const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1853 if (!iiCheckTypes(h,t,1)) return TRUE;
1854 ideal arg1 = (ideal) h->Data();
1855 intvec* arg2 = (intvec*) h->next->Data();
1856 int arg3 = (int) ((long)(h->next->next->Data()));
1857 intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3);
1858 res->rtyp = INTVEC_CMD;
1859 res->data = result;
1860 return FALSE;
1861 }
1862 else
1863 #endif
1864 /************** fractal walk **********/
1865 #ifdef HAVE_WALK
1866 if(strcmp(sys_cmd, "Mfpertvector") == 0)
1867 {
1868 const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1869 if (!iiCheckTypes(h,t,1)) return TRUE;
1870 ideal arg1 = (ideal) h->Data();
1871 intvec* arg2 = (intvec*) h->next->Data();
1872 intvec* result = Mfpertvector(arg1, arg2);
1873 res->rtyp = INTVEC_CMD;
1874 res->data = result;
1875 return FALSE;
1876 }
1877 else
1878 #endif
1879 /*==================== MivUnit =================*/
1880 #ifdef HAVE_WALK
1881 if(strcmp(sys_cmd, "MivUnit") == 0)
1882 {
1883 const short t[]={1,INT_CMD};
1884 if (!iiCheckTypes(h,t,1)) return TRUE;
1885 int arg1 = (int) ((long)(h->Data()));
1886 intvec* result = (intvec*) MivUnit(arg1);
1887 res->rtyp = INTVEC_CMD;
1888 res->data = result;
1889 return FALSE;
1890 }
1891 else
1892 #endif
1893 /*==================== MivWeightOrderlp =================*/
1894 #ifdef HAVE_WALK
1895 if(strcmp(sys_cmd, "MivWeightOrderlp") == 0)
1896 {
1897 const short t[]={1,INTVEC_CMD};
1898 if (!iiCheckTypes(h,t,1)) return TRUE;
1899 intvec* arg1 = (intvec*) h->Data();
1901 res->rtyp = INTVEC_CMD;
1902 res->data = result;
1903 return FALSE;
1904 }
1905 else
1906 #endif
1907 /*==================== MivWeightOrderdp =================*/
1908 #ifdef HAVE_WALK
1909 if(strcmp(sys_cmd, "MivWeightOrderdp") == 0)
1910 {
1911 if(h==NULL || h->Typ() != INTVEC_CMD)
1912 {
1913 WerrorS("system(\"MivWeightOrderdp\",intvec) expected");
1914 return TRUE;
1915 }
1916 intvec* arg1 = (intvec*) h->Data();
1917 //int arg2 = (int) h->next->Data();
1919 res->rtyp = INTVEC_CMD;
1920 res->data = result;
1921 return FALSE;
1922 }
1923 else
1924 #endif
1925 /*==================== MivMatrixOrderlp =================*/
1926 #ifdef HAVE_WALK
1927 if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0)
1928 {
1929 if(h==NULL || h->Typ() != INT_CMD)
1930 {
1931 WerrorS("system(\"MivMatrixOrderlp\",int) expected");
1932 return TRUE;
1933 }
1934 int arg1 = (int) ((long)(h->Data()));
1936 res->rtyp = INTVEC_CMD;
1937 res->data = result;
1938 return FALSE;
1939 }
1940 else
1941 #endif
1942 /*==================== MkInterRedNextWeight =================*/
1943 #ifdef HAVE_WALK
1944 if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0)
1945 {
1946 const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1947 if (!iiCheckTypes(h,t,1)) return TRUE;
1948 if (((intvec*) h->Data())->length() != currRing->N ||
1949 ((intvec*) h->next->Data())->length() != currRing->N)
1950 {
1951 Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n",
1952 currRing->N);
1953 return TRUE;
1954 }
1955 intvec* arg1 = (intvec*) h->Data();
1956 intvec* arg2 = (intvec*) h->next->Data();
1957 ideal arg3 = (ideal) h->next->next->Data();
1958 intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3);
1959 res->rtyp = INTVEC_CMD;
1960 res->data = result;
1961 return FALSE;
1962 }
1963 else
1964 #endif
1965 /*==================== MPertNextWeight =================*/
1966 #ifdef HAVE_WALK
1967 #ifdef MPertNextWeight
1968 if (strcmp(sys_cmd, "MPertNextWeight") == 0)
1969 {
1970 const short t[]={3,INTVEC_CMD,IDEAL_CMD,INT_CMD};
1971 if (!iiCheckTypes(h,t,1)) return TRUE;
1972 if (((intvec*) h->Data())->length() != currRing->N)
1973 {
1974 Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n",
1975 currRing->N);
1976 return TRUE;
1977 }
1978 intvec* arg1 = (intvec*) h->Data();
1979 ideal arg2 = (ideal) h->next->Data();
1980 int arg3 = (int) h->next->next->Data();
1981 intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3);
1982 res->rtyp = INTVEC_CMD;
1983 res->data = result;
1984 return FALSE;
1985 }
1986 else
1987 #endif //MPertNextWeight
1988 #endif
1989 /*==================== Mivperttarget =================*/
1990 #ifdef HAVE_WALK
1991 #ifdef Mivperttarget
1992 if (strcmp(sys_cmd, "Mivperttarget") == 0)
1993 {
1994 const short t[]={2,IDEAL_CMD,INT_CMD};
1995 if (!iiCheckTypes(h,t,1)) return TRUE;
1996 ideal arg1 = (ideal) h->Data();
1997 int arg2 = (int) h->next->Data();
1998 intvec* result = (intvec*) Mivperttarget(arg1, arg2);
1999 res->rtyp = INTVEC_CMD;
2000 res->data = result;
2001 return FALSE;
2002 }
2003 else
2004 #endif //Mivperttarget
2005 #endif
2006 /*==================== Mwalk =================*/
2007 #ifdef HAVE_WALK
2008 if (strcmp(sys_cmd, "Mwalk") == 0)
2009 {
2011 if (!iiCheckTypes(h,t,1)) return TRUE;
2012 if (((intvec*) h->next->Data())->length() != currRing->N &&
2013 ((intvec*) h->next->next->Data())->length() != currRing->N )
2014 {
2015 Werror("system(\"Mwalk\" ...) intvecs not of length %d\n",
2016 currRing->N);
2017 return TRUE;
2018 }
2019 ideal arg1 = (ideal) h->CopyD();
2020 intvec* arg2 = (intvec*) h->next->Data();
2021 intvec* arg3 = (intvec*) h->next->next->Data();
2022 ring arg4 = (ring) h->next->next->next->Data();
2023 int arg5 = (int) (long) h->next->next->next->next->Data();
2024 int arg6 = (int) (long) h->next->next->next->next->next->Data();
2025 ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2026 res->rtyp = IDEAL_CMD;
2027 res->data = result;
2028 return FALSE;
2029 }
2030 else
2031 #endif
2032 /*==================== Mpwalk =================*/
2033 #ifdef HAVE_WALK
2034 #ifdef MPWALK_ORIG
2035 if (strcmp(sys_cmd, "Mwalk") == 0)
2036 {
2037 const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};
2038 if (!iiCheckTypes(h,t,1)) return TRUE;
2039 if ((((intvec*) h->next->Data())->length() != currRing->N &&
2040 ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2041 (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2042 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N)))
2043 {
2044 Werror("system(\"Mwalk\" ...) intvecs not of length %d or %d\n",
2045 currRing->N,(currRing->N)*(currRing->N));
2046 return TRUE;
2047 }
2048 ideal arg1 = (ideal) h->Data();
2049 intvec* arg2 = (intvec*) h->next->Data();
2050 intvec* arg3 = (intvec*) h->next->next->Data();
2051 ring arg4 = (ring) h->next->next->next->Data();
2052 ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4);
2053 res->rtyp = IDEAL_CMD;
2054 res->data = result;
2055 return FALSE;
2056 }
2057 else
2058 #else
2059 if (strcmp(sys_cmd, "Mpwalk") == 0)
2060 {
2062 if (!iiCheckTypes(h,t,1)) return TRUE;
2063 if(((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2064 ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2065 {
2066 Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",currRing->N);
2067 return TRUE;
2068 }
2069 ideal arg1 = (ideal) h->Data();
2070 int arg2 = (int) (long) h->next->Data();
2071 int arg3 = (int) (long) h->next->next->Data();
2072 intvec* arg4 = (intvec*) h->next->next->next->Data();
2073 intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2074 int arg6 = (int) (long) h->next->next->next->next->next->Data();
2075 int arg7 = (int) (long) h->next->next->next->next->next->next->Data();
2076 int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data();
2077 ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
2078 res->rtyp = IDEAL_CMD;
2079 res->data = result;
2080 return FALSE;
2081 }
2082 else
2083 #endif
2084 #endif
2085 /*==================== Mrwalk =================*/
2086 #ifdef HAVE_WALK
2087 if (strcmp(sys_cmd, "Mrwalk") == 0)
2088 {
2090 if (!iiCheckTypes(h,t,1)) return TRUE;
2091 if(((intvec*) h->next->Data())->length() != currRing->N &&
2092 ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2093 ((intvec*) h->next->next->Data())->length() != currRing->N &&
2094 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )
2095 {
2096 Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2097 currRing->N,(currRing->N)*(currRing->N));
2098 return TRUE;
2099 }
2100 ideal arg1 = (ideal) h->Data();
2101 intvec* arg2 = (intvec*) h->next->Data();
2102 intvec* arg3 = (intvec*) h->next->next->Data();
2103 int arg4 = (int)(long) h->next->next->next->Data();
2104 int arg5 = (int)(long) h->next->next->next->next->Data();
2105 int arg6 = (int)(long) h->next->next->next->next->next->Data();
2106 int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2107 ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
2108 res->rtyp = IDEAL_CMD;
2109 res->data = result;
2110 return FALSE;
2111 }
2112 else
2113 #endif
2114 /*==================== MAltwalk1 =================*/
2115 #ifdef HAVE_WALK
2116 if (strcmp(sys_cmd, "MAltwalk1") == 0)
2117 {
2118 const short t[]={5,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD};
2119 if (!iiCheckTypes(h,t,1)) return TRUE;
2120 if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2121 ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2122 {
2123 Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n",
2124 currRing->N);
2125 return TRUE;
2126 }
2127 ideal arg1 = (ideal) h->Data();
2128 int arg2 = (int) ((long)(h->next->Data()));
2129 int arg3 = (int) ((long)(h->next->next->Data()));
2130 intvec* arg4 = (intvec*) h->next->next->next->Data();
2131 intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2132 ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5);
2133 res->rtyp = IDEAL_CMD;
2134 res->data = result;
2135 return FALSE;
2136 }
2137 else
2138 #endif
2139 /*==================== MAltwalk1 =================*/
2140 #ifdef HAVE_WALK
2141 #ifdef MFWALK_ALT
2142 if (strcmp(sys_cmd, "Mfwalk_alt") == 0)
2143 {
2144 const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2145 if (!iiCheckTypes(h,t,1)) return TRUE;
2146 if (((intvec*) h->next->Data())->length() != currRing->N &&
2147 ((intvec*) h->next->next->Data())->length() != currRing->N )
2148 {
2149 Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2150 currRing->N);
2151 return TRUE;
2152 }
2153 ideal arg1 = (ideal) h->Data();
2154 intvec* arg2 = (intvec*) h->next->Data();
2155 intvec* arg3 = (intvec*) h->next->next->Data();
2156 int arg4 = (int) h->next->next->next->Data();
2157 ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4);
2158 res->rtyp = IDEAL_CMD;
2159 res->data = result;
2160 return FALSE;
2161 }
2162 else
2163 #endif
2164 #endif
2165 /*==================== Mfwalk =================*/
2166 #ifdef HAVE_WALK
2167 if (strcmp(sys_cmd, "Mfwalk") == 0)
2168 {
2169 const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD};
2170 if (!iiCheckTypes(h,t,1)) return TRUE;
2171 if (((intvec*) h->next->Data())->length() != currRing->N &&
2172 ((intvec*) h->next->next->Data())->length() != currRing->N )
2173 {
2174 Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2175 currRing->N);
2176 return TRUE;
2177 }
2178 ideal arg1 = (ideal) h->Data();
2179 intvec* arg2 = (intvec*) h->next->Data();
2180 intvec* arg3 = (intvec*) h->next->next->Data();
2181 int arg4 = (int)(long) h->next->next->next->Data();
2182 int arg5 = (int)(long) h->next->next->next->next->Data();
2183 ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4, arg5);
2184 res->rtyp = IDEAL_CMD;
2185 res->data = result;
2186 return FALSE;
2187 }
2188 else
2189 #endif
2190 /*==================== Mfrwalk =================*/
2191 #ifdef HAVE_WALK
2192 if (strcmp(sys_cmd, "Mfrwalk") == 0)
2193 {
2195 if (!iiCheckTypes(h,t,1)) return TRUE;
2196/*
2197 if (((intvec*) h->next->Data())->length() != currRing->N &&
2198 ((intvec*) h->next->next->Data())->length() != currRing->N)
2199 {
2200 Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
2201 return TRUE;
2202 }
2203*/
2204 if((((intvec*) h->next->Data())->length() != currRing->N &&
2205 ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2206 (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2207 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2208 {
2209 Werror("system(\"Mfrwalk\" ...) intvecs not of length %d or %d\n",
2210 currRing->N,(currRing->N)*(currRing->N));
2211 return TRUE;
2212 }
2213
2214 ideal arg1 = (ideal) h->Data();
2215 intvec* arg2 = (intvec*) h->next->Data();
2216 intvec* arg3 = (intvec*) h->next->next->Data();
2217 int arg4 = (int)(long) h->next->next->next->Data();
2218 int arg5 = (int)(long) h->next->next->next->next->Data();
2219 int arg6 = (int)(long) h->next->next->next->next->next->Data();
2220 ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2221 res->rtyp = IDEAL_CMD;
2222 res->data = result;
2223 return FALSE;
2224 }
2225 else
2226 /*==================== Mprwalk =================*/
2227 if (strcmp(sys_cmd, "Mprwalk") == 0)
2228 {
2230 if (!iiCheckTypes(h,t,1)) return TRUE;
2231 if((((intvec*) h->next->Data())->length() != currRing->N &&
2232 ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2233 (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2234 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2235 {
2236 Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2237 currRing->N,(currRing->N)*(currRing->N));
2238 return TRUE;
2239 }
2240 ideal arg1 = (ideal) h->Data();
2241 intvec* arg2 = (intvec*) h->next->Data();
2242 intvec* arg3 = (intvec*) h->next->next->Data();
2243 int arg4 = (int)(long) h->next->next->next->Data();
2244 int arg5 = (int)(long) h->next->next->next->next->Data();
2245 int arg6 = (int)(long) h->next->next->next->next->next->Data();
2246 int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2247 int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data();
2248 int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data();
2249 ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
2250 res->rtyp = IDEAL_CMD;
2251 res->data = result;
2252 return FALSE;
2253 }
2254 else
2255 #endif
2256 /*==================== TranMImprovwalk =================*/
2257 #ifdef HAVE_WALK
2258 #ifdef TRAN_Orig
2259 if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2260 {
2261 const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2262 if (!iiCheckTypes(h,t,1)) return TRUE;
2263 if (((intvec*) h->next->Data())->length() != currRing->N &&
2264 ((intvec*) h->next->next->Data())->length() != currRing->N )
2265 {
2266 Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2267 currRing->N);
2268 return TRUE;
2269 }
2270 ideal arg1 = (ideal) h->Data();
2271 intvec* arg2 = (intvec*) h->next->Data();
2272 intvec* arg3 = (intvec*) h->next->next->Data();
2273 ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3);
2274 res->rtyp = IDEAL_CMD;
2275 res->data = result;
2276 return FALSE;
2277 }
2278 else
2279 #endif
2280 #endif
2281 /*==================== MAltwalk2 =================*/
2282 #ifdef HAVE_WALK
2283 if (strcmp(sys_cmd, "MAltwalk2") == 0)
2284 {
2285 const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2286 if (!iiCheckTypes(h,t,1)) return TRUE;
2287 if (((intvec*) h->next->Data())->length() != currRing->N &&
2288 ((intvec*) h->next->next->Data())->length() != currRing->N )
2289 {
2290 Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n",
2291 currRing->N);
2292 return TRUE;
2293 }
2294 ideal arg1 = (ideal) h->Data();
2295 intvec* arg2 = (intvec*) h->next->Data();
2296 intvec* arg3 = (intvec*) h->next->next->Data();
2297 ideal result = (ideal) MAltwalk2(arg1, arg2, arg3);
2298 res->rtyp = IDEAL_CMD;
2299 res->data = result;
2300 return FALSE;
2301 }
2302 else
2303 #endif
2304 /*==================== MAltwalk2 =================*/
2305 #ifdef HAVE_WALK
2306 if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2307 {
2308 const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2309 if (!iiCheckTypes(h,t,1)) return TRUE;
2310 if (((intvec*) h->next->Data())->length() != currRing->N &&
2311 ((intvec*) h->next->next->Data())->length() != currRing->N )
2312 {
2313 Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2314 currRing->N);
2315 return TRUE;
2316 }
2317 ideal arg1 = (ideal) h->Data();
2318 intvec* arg2 = (intvec*) h->next->Data();
2319 intvec* arg3 = (intvec*) h->next->next->Data();
2320 int arg4 = (int) ((long)(h->next->next->next->Data()));
2321 ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4);
2322 res->rtyp = IDEAL_CMD;
2323 res->data = result;
2324 return FALSE;
2325 }
2326 else
2327 #endif
2328 /*==================== TranMrImprovwalk =================*/
2329 #if 0
2330 #ifdef HAVE_WALK
2331 if (strcmp(sys_cmd, "TranMrImprovwalk") == 0)
2332 {
2333 if (h == NULL || h->Typ() != IDEAL_CMD ||
2334 h->next == NULL || h->next->Typ() != INTVEC_CMD ||
2335 h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ||
2336 h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD ||
2337 h->next->next->next == NULL || h->next->next->next->next->Typ() != INT_CMD ||
2338 h->next->next->next == NULL || h->next->next->next->next->next->Typ() != INT_CMD)
2339 {
2340 WerrorS("system(\"TranMrImprovwalk\", ideal, intvec, intvec) expected");
2341 return TRUE;
2342 }
2343 if (((intvec*) h->next->Data())->length() != currRing->N &&
2344 ((intvec*) h->next->next->Data())->length() != currRing->N )
2345 {
2346 Werror("system(\"TranMrImprovwalk\" ...) intvecs not of length %d\n", currRing->N);
2347 return TRUE;
2348 }
2349 ideal arg1 = (ideal) h->Data();
2350 intvec* arg2 = (intvec*) h->next->Data();
2351 intvec* arg3 = (intvec*) h->next->next->Data();
2352 int arg4 = (int)(long) h->next->next->next->Data();
2353 int arg5 = (int)(long) h->next->next->next->next->Data();
2354 int arg6 = (int)(long) h->next->next->next->next->next->Data();
2355 ideal result = (ideal) TranMrImprovwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2356 res->rtyp = IDEAL_CMD;
2357 res->data = result;
2358 return FALSE;
2359 }
2360 else
2361 #endif
2362 #endif
2363 /*================= Extended system call ========================*/
2364 {
2365 #ifndef MAKE_DISTRIBUTION
2366 return(jjEXTENDED_SYSTEM(res, args));
2367 #else
2368 Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
2369 #endif
2370 }
2371 } /* typ==string */
2372 return TRUE;
2373}
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:133
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:236
int m
Definition: cfEzgcd.cc:128
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
void factoryseed(int s)
random seed initializer
Definition: cf_random.cc:189
FILE * f
Definition: checklibs.c:9
matrix singntl_rref(matrix m, const ring R)
Definition: clapsing.cc:1997
matrix singntl_LLL(matrix m, const ring s)
Definition: clapsing.cc:1915
ideal singclap_absFactorize(poly f, ideal &mipos, intvec **exps, int &numFactors, const ring r)
Definition: clapsing.cc:2103
char * singclap_neworder(ideal I, const ring r)
Definition: clapsing.cc:1664
gmp_complex numbers based on
Definition: mpr_complex.h:179
VAR int siRandomStart
Definition: cntrlc.cc:93
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:727
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
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:535
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
Definition: countedref.cc:700
void countedref_shared_load()
Definition: countedref.cc:724
lists get_denom_list()
Definition: denom_list.cc:8
matrix evRowElim(matrix M, int i, int j, int k)
Definition: eigenval.cc:47
matrix evHessenberg(matrix M)
Definition: eigenval.cc:100
matrix evSwap(matrix M, int i, int j)
Definition: eigenval.cc:25
lists evEigenvals(matrix M)
Definition: eigenval_ip.cc:120
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
Definition: extra.cc:171
#define SINGULAR_PROCS_DIR
#define TEST_FOR(A)
static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
Definition: extra.cc:2383
return result
Definition: facAbsBiFact.cc:76
feOptIndex
Definition: feOptGen.h:15
@ FE_OPT_UNDEF
Definition: feOptGen.h:15
void fePrintOptValues()
Definition: feOpt.cc:344
feOptIndex feGetOptIndex(const char *name)
Definition: feOpt.cc:104
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:154
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
EXTERN_VAR struct fe_option feOptSpec[]
Definition: feOpt.h:17
void feReInitResources()
Definition: feResource.cc:185
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:236
char * getenv()
@ feOptUntyped
Definition: fegetopt.h:77
@ feOptString
Definition: fegetopt.h:77
void * value
Definition: fegetopt.h:93
void feStringAppendBrowsers(int warn)
Definition: fehelp.cc:341
matrix singflint_rref(matrix m, const ring R)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
lists gmsNF(ideal p, ideal g, matrix B, int D, int K)
Definition: gms.cc:22
@ SMATRIX_CMD
Definition: grammar.cc:291
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp, int trunDegHs)
Definition: hilb.cc:1326
ideal RightColonOperation(ideal S, poly w, int lV)
Definition: hilb.cc:1673
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
#define ivTest(v)
Definition: intvec.h:169
#define setFlag(A, F)
Definition: ipid.h:113
#define FLAG_TWOSTD
Definition: ipid.h:107
#define FLAG_STD
Definition: ipid.h:106
BOOLEAN spaddProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4430
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
Definition: ipshell.cc:4513
BOOLEAN spectrumfProc(leftv result, leftv first)
Definition: ipshell.cc:4186
BOOLEAN spmulProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4472
BOOLEAN spectrumProc(leftv result, leftv first)
Definition: ipshell.cc:4135
BOOLEAN semicProc(leftv res, leftv u, leftv v)
Definition: ipshell.cc:4553
char * versionString()
Definition: misc_ip.cc:770
STATIC_VAR jList * T
Definition: janet.cc:30
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition: kstd1.cc:3242
VAR int HCord
Definition: kutil.cc:246
BOOLEAN kVerify2(ideal F, ideal Q)
Definition: kverify.cc:138
BOOLEAN kVerify1(ideal F, ideal Q)
Definition: kverify.cc:21
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
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2251
bool luSolveViaLDUDecomp(const matrix pMat, const matrix lMat, const matrix dMat, const matrix uMat, const poly l, const poly u, const poly lTimesU, 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 LDU-decomposit...
void lduDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU)
LU-decomposition of a given (m x n)-matrix with performing only those divisions that yield zero remai...
ideal sm_UnFlatten(ideal a, int col, const ring R)
Definition: matpol.cc:1939
ideal sm_Flatten(ideal a, const ring R)
Definition: matpol.cc:1919
#define SINGULAR_VERSION
Definition: mod2.h:87
EXTERN_VAR size_t gmp_output_digits
Definition: mpr_base.h:115
bool complexNearZero(gmp_complex *c, int digits)
Definition: mpr_complex.cc:765
ideal twostd(ideal I)
Compute two-sided GB:
Definition: nc.cc:18
void newstructShow(newstruct_desc d)
Definition: newstruct.cc:826
BOOLEAN newstruct_set_proc(const char *bbname, const char *func, int args, procinfov pr)
Definition: newstruct.cc:846
char * omFindExec(const char *name, char *exec)
Definition: omFindExec.c:315
#define MAXPATHLEN
Definition: omRet2Info.c:22
void p_Content(poly ph, const ring r)
Definition: p_polys.cc:2295
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2845
poly pcvP2CV(poly p, int d0, int d1)
Definition: pcv.cc:280
int pcvBasis(lists b, int i, poly m, int d, int n)
Definition: pcv.cc:430
int pcvMinDeg(poly p)
Definition: pcv.cc:135
int pcvDim(int d0, int d1)
Definition: pcv.cc:400
lists pcvPMulL(poly p, lists l1)
Definition: pcv.cc:76
poly pcvCV2P(poly cv, int d0, int d1)
Definition: pcv.cc:297
lists pcvLAddL(lists l1, lists l2)
Definition: pcv.cc:31
void StringSetS(const char *st)
Definition: reporter.cc:128
const char feNotImplemented[]
Definition: reporter.cc:54
char * StringEndS()
Definition: reporter.cc:151
ring rOpposite(ring src)
Definition: ring.cc:5333
ring rEnvelope(ring R)
Definition: ring.cc:5723
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:545
static int rBlocks(const ring r)
Definition: ring.h:568
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:542
#define rField_is_Ring(R)
Definition: ring.h:485
int simpleipc_cmd(char *cmd, int id, int v)
Definition: semaphore.c:167
VAR int siSeed
Definition: sirandom.c:30
#define M
Definition: sirandom.c:25
int M3ivSame(intvec *temp, intvec *u, intvec *v)
Definition: walk.cc:914
intvec * MivWeightOrderdp(intvec *ivstart)
Definition: walk.cc:1456
intvec * MivUnit(int nV)
Definition: walk.cc:1496
ideal TranMImprovwalk(ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
Definition: walk.cc:8396
intvec * MivMatrixOrderdp(int nV)
Definition: walk.cc:1417
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
Definition: walk.cc:8031
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1088
intvec * MivWeightOrderlp(intvec *ivstart)
Definition: walk.cc:1436
ideal Mprwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout)
Definition: walk.cc:6388
intvec * MivMatrixOrder(intvec *iv)
Definition: walk.cc:963
ideal MAltwalk2(ideal Go, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:4280
ideal MAltwalk1(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:9671
ideal Mrwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, int reduction, int printout)
Definition: walk.cc:5603
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
Definition: walk.cc:8212
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
Definition: walk.cc:5302
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
Definition: walk.cc:5947
int MivSame(intvec *u, intvec *v)
Definition: walk.cc:893
intvec * Mivlp(int nR)
Definition: walk.cc:1022
ideal MwalkInitialForm(ideal G, intvec *ivw)
Definition: walk.cc:761
intvec * MivMatrixOrderlp(int nV)
Definition: walk.cc:1401
intvec * Mfpertvector(ideal G, intvec *ivtarget)
Definition: walk.cc:1512
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1299
intvec * Mivdp(int nR)
Definition: walk.cc:1007
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
Definition: walk.cc:2570
intvec * MwalkNextWeight(intvec *curr_weight, intvec *target_weight, ideal G)
intvec * Mivperttarget(ideal G, int ndeg)
intvec * MPertNextWeight(intvec *iva, ideal G, int deg)

◆ jjVARIABLES_ID()

BOOLEAN jjVARIABLES_ID ( leftv  res,
leftv  u 
)

Definition at line 6320 of file ipshell.cc.

6321{
6322 int *e=(int *)omAlloc0((rVar(currRing)+1)*sizeof(int));
6323 ideal I=(ideal)u->Data();
6324 int i;
6325 int n=0;
6326 for(i=I->nrows*I->ncols-1;i>=0;i--)
6327 {
6328 int n0=pGetVariables(I->m[i],e);
6329 if (n0>n) n=n0;
6330 }
6331 jjINT_S_TO_ID(n,e,res);
6332 return FALSE;
6333}
static void jjINT_S_TO_ID(int n, int *e, leftv res)
Definition: ipshell.cc:6290
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define pGetVariables(p, e)
Definition: polys.h:251

◆ jjVARIABLES_P()

BOOLEAN jjVARIABLES_P ( leftv  res,
leftv  u 
)

Definition at line 6312 of file ipshell.cc.

6313{
6314 int *e=(int *)omAlloc0((rVar(currRing)+1)*sizeof(int));
6315 int n=pGetVariables((poly)u->Data(),e);
6316 jjINT_S_TO_ID(n,e,res);
6317 return FALSE;
6318}

◆ killlocals()

void killlocals ( int  v)

Definition at line 386 of file ipshell.cc.

387{
388 BOOLEAN changed=FALSE;
390 ring cr=currRing;
391 if (sh!=NULL) changed=((IDLEV(sh)<v) || (IDRING(sh)->ref>0));
392 //if (changed) Print("currRing=%s(%x), lev=%d,ref=%d\n",IDID(sh),IDRING(sh),IDLEV(sh),IDRING(sh)->ref);
393
394 killlocals_rec(&(basePack->idroot),v,currRing);
395
397 {
398 int t=iiRETURNEXPR.Typ();
399 if (/*iiRETURNEXPR.Typ()*/ t==RING_CMD)
400 {
402 if (((ring)h->data)->idroot!=NULL)
403 killlocals0(v,&(((ring)h->data)->idroot),(ring)h->data);
404 }
405 else if (/*iiRETURNEXPR.Typ()*/ t==LIST_CMD)
406 {
408 changed |=killlocals_list(v,(lists)h->data);
409 }
410 }
411 if (changed)
412 {
414 if (currRingHdl==NULL)
416 else if(cr!=currRing)
417 rChangeCurrRing(cr);
418 }
419
420 if (myynest<=1) iiNoKeepRing=TRUE;
421 //Print("end killlocals >= %d\n",v);
422 //listall();
423}
VAR int iiRETURNEXPR_len
Definition: iplib.cc:475
BOOLEAN killlocals_list(int v, lists L)
Definition: ipshell.cc:366
STATIC_VAR BOOLEAN iiNoKeepRing
Definition: ipshell.cc:84
void killlocals_rec(idhdl *root, int v, ring r)
Definition: ipshell.cc:330
static void killlocals0(int v, idhdl *localhdl, const ring r)
Definition: ipshell.cc:295

◆ kQHWeight()

BOOLEAN kQHWeight ( leftv  res,
leftv  v 
)

Definition at line 3325 of file ipshell.cc.

3326{
3327 res->data=(char *)id_QHomWeight((ideal)v->Data(), currRing);
3328 if (res->data==NULL)
3329 res->data=(char *)new intvec(rVar(currRing));
3330 return FALSE;
3331}
intvec * id_QHomWeight(ideal id, const ring r)

◆ kWeight()

BOOLEAN kWeight ( leftv  res,
leftv  id 
)

Definition at line 3303 of file ipshell.cc.

3304{
3305 ideal F=(ideal)id->Data();
3306 intvec * iv = new intvec(rVar(currRing));
3307 polyset s;
3308 int sl, n, i;
3309 int *x;
3310
3311 res->data=(char *)iv;
3312 s = F->m;
3313 sl = IDELEMS(F) - 1;
3314 n = rVar(currRing);
3315 double wNsqr = (double)2.0 / (double)n;
3317 x = (int * )omAlloc(2 * (n + 1) * sizeof(int));
3318 wCall(s, sl, x, wNsqr, currRing);
3319 for (i = n; i!=0; i--)
3320 (*iv)[i-1] = x[i + n + 1];
3321 omFreeSize((ADDRESS)x, 2 * (n + 1) * sizeof(int));
3322 return FALSE;
3323}
Variable x
Definition: cfModGcd.cc:4082
THREAD_VAR double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight.cc:20
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition: weight.cc:108
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.cc:78

◆ list_cmd()

void list_cmd ( int  typ,
const char *  what,
const char *  prefix,
BOOLEAN  iterate,
BOOLEAN  fullname = FALSE 
)

Definition at line 425 of file ipshell.cc.

426{
427 package savePack=currPack;
428 idhdl h,start;
429 BOOLEAN all = typ<0;
430 BOOLEAN really_all=FALSE;
431
432 if ( typ==0 )
433 {
434 if (strcmp(what,"all")==0)
435 {
436 if (currPack!=basePack)
437 list_cmd(-1,NULL,prefix,iterate,fullname); // list current package
438 really_all=TRUE;
439 h=basePack->idroot;
440 }
441 else
442 {
443 h = ggetid(what);
444 if (h!=NULL)
445 {
446 if (iterate) list1(prefix,h,TRUE,fullname);
447 if (IDTYP(h)==ALIAS_CMD) PrintS("A");
448 if ((IDTYP(h)==RING_CMD)
449 //|| (IDTYP(h)==PACKAGE_CMD)
450 )
451 {
452 h=IDRING(h)->idroot;
453 }
454 else if(IDTYP(h)==PACKAGE_CMD)
455 {
457 //Print("list_cmd:package\n");
458 all=TRUE;typ=PROC_CMD;fullname=TRUE;really_all=TRUE;
459 h=IDPACKAGE(h)->idroot;
460 }
461 else
462 {
463 currPack=savePack;
464 return;
465 }
466 }
467 else
468 {
469 Werror("%s is undefined",what);
470 currPack=savePack;
471 return;
472 }
473 }
474 all=TRUE;
475 }
476 else if (RingDependend(typ))
477 {
478 h = currRing->idroot;
479 }
480 else
481 h = IDROOT;
482 start=h;
483 while (h!=NULL)
484 {
485 if ((all
486 && (IDTYP(h)!=PROC_CMD)
487 &&(IDTYP(h)!=PACKAGE_CMD)
488 &&(IDTYP(h)!=CRING_CMD)
489 )
490 || (typ == IDTYP(h))
491 || ((IDTYP(h)==CRING_CMD) && (typ==RING_CMD))
492 )
493 {
494 list1(prefix,h,start==currRingHdl, fullname);
495 if ((IDTYP(h)==RING_CMD)
496 && (really_all || (all && (h==currRingHdl)))
497 && ((IDLEV(h)==0)||(IDLEV(h)==myynest)))
498 {
499 list_cmd(0,IDID(h),"// ",FALSE);
500 }
501 if (IDTYP(h)==PACKAGE_CMD && really_all)
502 {
503 package save_p=currPack;
505 list_cmd(0,IDID(h),"// ",FALSE);
506 currPack=save_p;
507 }
508 }
509 h = IDNEXT(h);
510 }
511 currPack=savePack;
512}
#define IDNEXT(a)
Definition: ipid.h:118
void list_cmd(int typ, const char *what, const char *prefix, BOOLEAN iterate, BOOLEAN fullname)
Definition: ipshell.cc:425
static void list1(const char *s, idhdl h, BOOLEAN c, BOOLEAN fullname)
Definition: ipshell.cc:149

◆ loNewtonP()

BOOLEAN loNewtonP ( leftv  res,
leftv  arg1 
)

compute Newton Polytopes of input polynomials

Definition at line 4565 of file ipshell.cc.

4566{
4567 res->data= (void*)loNewtonPolytope( (ideal)arg1->Data() );
4568 return FALSE;
4569}
ideal loNewtonPolytope(const ideal id)
Definition: mpr_base.cc:3191

◆ loSimplex()

BOOLEAN loSimplex ( leftv  res,
leftv  args 
)

Implementation of the Simplex Algorithm.

For args, see class simplex.

Definition at line 4571 of file ipshell.cc.

4572{
4573 if ( !(rField_is_long_R(currRing)) )
4574 {
4575 WerrorS("Ground field not implemented!");
4576 return TRUE;
4577 }
4578
4579 simplex * LP;
4580 matrix m;
4581
4582 leftv v= args;
4583 if ( v->Typ() != MATRIX_CMD ) // 1: matrix
4584 return TRUE;
4585 else
4586 m= (matrix)(v->CopyD());
4587
4588 LP = new simplex(MATROWS(m),MATCOLS(m));
4589 LP->mapFromMatrix(m);
4590
4591 v= v->next;
4592 if ( v->Typ() != INT_CMD ) // 2: m = number of constraints
4593 return TRUE;
4594 else
4595 LP->m= (int)(long)(v->Data());
4596
4597 v= v->next;
4598 if ( v->Typ() != INT_CMD ) // 3: n = number of variables
4599 return TRUE;
4600 else
4601 LP->n= (int)(long)(v->Data());
4602
4603 v= v->next;
4604 if ( v->Typ() != INT_CMD ) // 4: m1 = number of <= constraints
4605 return TRUE;
4606 else
4607 LP->m1= (int)(long)(v->Data());
4608
4609 v= v->next;
4610 if ( v->Typ() != INT_CMD ) // 5: m2 = number of >= constraints
4611 return TRUE;
4612 else
4613 LP->m2= (int)(long)(v->Data());
4614
4615 v= v->next;
4616 if ( v->Typ() != INT_CMD ) // 6: m3 = number of == constraints
4617 return TRUE;
4618 else
4619 LP->m3= (int)(long)(v->Data());
4620
4621#ifdef mprDEBUG_PROT
4622 Print("m (constraints) %d\n",LP->m);
4623 Print("n (columns) %d\n",LP->n);
4624 Print("m1 (<=) %d\n",LP->m1);
4625 Print("m2 (>=) %d\n",LP->m2);
4626 Print("m3 (==) %d\n",LP->m3);
4627#endif
4628
4629 LP->compute();
4630
4631 lists lres= (lists)omAlloc( sizeof(slists) );
4632 lres->Init( 6 );
4633
4634 lres->m[0].rtyp= MATRIX_CMD; // output matrix
4635 lres->m[0].data=(void*)LP->mapToMatrix(m);
4636
4637 lres->m[1].rtyp= INT_CMD; // found a solution?
4638 lres->m[1].data=(void*)(long)LP->icase;
4639
4640 lres->m[2].rtyp= INTVEC_CMD;
4641 lres->m[2].data=(void*)LP->posvToIV();
4642
4643 lres->m[3].rtyp= INTVEC_CMD;
4644 lres->m[3].data=(void*)LP->zrovToIV();
4645
4646 lres->m[4].rtyp= INT_CMD;
4647 lres->m[4].data=(void*)(long)LP->m;
4648
4649 lres->m[5].rtyp= INT_CMD;
4650 lres->m[5].data=(void*)(long)LP->n;
4651
4652 res->data= (void*)lres;
4653
4654 return FALSE;
4655}
Linear Programming / Linear Optimization using Simplex - Algorithm.
Definition: mpr_numeric.h:195
intvec * zrovToIV()
BOOLEAN mapFromMatrix(matrix m)
int icase
Definition: mpr_numeric.h:201
void compute()
matrix mapToMatrix(matrix m)
intvec * posvToIV()
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27

◆ mpJacobi()

BOOLEAN mpJacobi ( leftv  res,
leftv  a 
)

Definition at line 3071 of file ipshell.cc.

3072{
3073 int i,j;
3074 matrix result;
3075 ideal id=(ideal)a->Data();
3076
3078 for (i=1; i<=IDELEMS(id); i++)
3079 {
3080 for (j=1; j<=rVar(currRing); j++)
3081 {
3082 MATELEM(result,i,j) = pDiff(id->m[i-1],j);
3083 }
3084 }
3085 res->data=(char *)result;
3086 return FALSE;
3087}
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define pDiff(a, b)
Definition: polys.h:296

◆ mpKoszul()

BOOLEAN mpKoszul ( leftv  res,
leftv  c,
leftv  b,
leftv  id 
)

Definition at line 3093 of file ipshell.cc.

3094{
3095 int n=(int)(long)b->Data();
3096 int d=(int)(long)c->Data();
3097 int k,l,sign,row,col;
3098 matrix result;
3099 ideal temp;
3100 BOOLEAN bo;
3101 poly p;
3102
3103 if ((d>n) || (d<1) || (n<1))
3104 {
3105 res->data=(char *)mpNew(1,1);
3106 return FALSE;
3107 }
3108 int *choise = (int*)omAlloc(d*sizeof(int));
3109 if (id==NULL)
3110 temp=idMaxIdeal(1);
3111 else
3112 temp=(ideal)id->Data();
3113
3114 k = binom(n,d);
3115 l = k*d;
3116 l /= n-d+1;
3117 result =mpNew(l,k);
3118 col = 1;
3119 idInitChoise(d,1,n,&bo,choise);
3120 while (!bo)
3121 {
3122 sign = 1;
3123 for (l=1;l<=d;l++)
3124 {
3125 if (choise[l-1]<=IDELEMS(temp))
3126 {
3127 p = pCopy(temp->m[choise[l-1]-1]);
3128 if (sign == -1) p = pNeg(p);
3129 sign *= -1;
3130 row = idGetNumberOfChoise(l-1,d,1,n,choise);
3131 MATELEM(result,row,col) = p;
3132 }
3133 }
3134 col++;
3135 idGetNextChoise(d,n,&bo,choise);
3136 }
3137 omFreeSize(choise,d*sizeof(int));
3138 if (id==NULL) idDelete(&temp);
3139
3140 res->data=(char *)result;
3141 return FALSE;
3142}
int binom(int n, int r)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:33
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
#define pNeg(p)
Definition: polys.h:198
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
static int sign(int x)
Definition: ring.cc:3427

◆ 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 using Laguerres' root-solver.

Good for polynomials with low and middle degree (<40). Arguments 3: poly arg1 , int arg2 , int arg3 arg2>0: defines precision of fractional part if ground field is Q arg3: number of iterations for approximation of roots (default=2) Returns a list of all (complex) roots of the polynomial arg1

Definition at line 4680 of file ipshell.cc.

4681{
4682 poly gls;
4683 gls= (poly)(arg1->Data());
4684 int howclean= (int)(long)arg3->Data();
4685
4686 if ( gls == NULL || pIsConstant( gls ) )
4687 {
4688 WerrorS("Input polynomial is constant!");
4689 return TRUE;
4690 }
4691
4693 {
4694 int* r=Zp_roots(gls, currRing);
4695 lists rlist;
4696 rlist= (lists)omAlloc( sizeof(slists) );
4697 rlist->Init( r[0] );
4698 for(int i=r[0];i>0;i--)
4699 {
4700 rlist->m[i-1].data=n_Init(r[i],currRing->cf);
4701 rlist->m[i-1].rtyp=NUMBER_CMD;
4702 }
4703 omFree(r);
4704 res->data=rlist;
4705 res->rtyp= LIST_CMD;
4706 return FALSE;
4707 }
4708 if ( !(rField_is_R(currRing) ||
4712 {
4713 WerrorS("Ground field not implemented!");
4714 return TRUE;
4715 }
4716
4719 {
4720 unsigned long int ii = (unsigned long int)arg2->Data();
4721 setGMPFloatDigits( ii, ii );
4722 }
4723
4724 int ldummy;
4725 int deg= currRing->pLDeg( gls, &ldummy, currRing );
4726 int i,vpos=0;
4727 poly piter;
4728 lists elist;
4729
4730 elist= (lists)omAlloc( sizeof(slists) );
4731 elist->Init( 0 );
4732
4733 if ( rVar(currRing) > 1 )
4734 {
4735 piter= gls;
4736 for ( i= 1; i <= rVar(currRing); i++ )
4737 if ( pGetExp( piter, i ) )
4738 {
4739 vpos= i;
4740 break;
4741 }
4742 while ( piter )
4743 {
4744 for ( i= 1; i <= rVar(currRing); i++ )
4745 if ( (vpos != i) && (pGetExp( piter, i ) != 0) )
4746 {
4747 WerrorS("The input polynomial must be univariate!");
4748 return TRUE;
4749 }
4750 pIter( piter );
4751 }
4752 }
4753
4754 rootContainer * roots= new rootContainer();
4755 number * pcoeffs= (number *)omAlloc( (deg+1) * sizeof( number ) );
4756 piter= gls;
4757 for ( i= deg; i >= 0; i-- )
4758 {
4759 if ( piter && pTotaldegree(piter) == i )
4760 {
4761 pcoeffs[i]= nCopy( pGetCoeff( piter ) );
4762 //nPrint( pcoeffs[i] );PrintS(" ");
4763 pIter( piter );
4764 }
4765 else
4766 {
4767 pcoeffs[i]= nInit(0);
4768 }
4769 }
4770
4771#ifdef mprDEBUG_PROT
4772 for (i=deg; i >= 0; i--)
4773 {
4774 nPrint( pcoeffs[i] );PrintS(" ");
4775 }
4776 PrintLn();
4777#endif
4778
4779 roots->fillContainer( pcoeffs, NULL, 1, deg, rootContainer::onepoly, 1 );
4780 roots->solver( howclean );
4781
4782 int elem= roots->getAnzRoots();
4783 char *dummy;
4784 int j;
4785
4786 lists rlist;
4787 rlist= (lists)omAlloc( sizeof(slists) );
4788 rlist->Init( elem );
4789
4791 {
4792 for ( j= 0; j < elem; j++ )
4793 {
4794 rlist->m[j].rtyp=NUMBER_CMD;
4795 rlist->m[j].data=(void *)nCopy((number)(roots->getRoot(j)));
4796 //rlist->m[j].data=(void *)(number)(roots->getRoot(j));
4797 }
4798 }
4799 else
4800 {
4801 for ( j= 0; j < elem; j++ )
4802 {
4803 dummy = complexToStr( (*roots)[j], gmp_output_digits, currRing->cf );
4804 rlist->m[j].rtyp=STRING_CMD;
4805 rlist->m[j].data=(void *)dummy;
4806 }
4807 }
4808
4809 elist->Clean();
4810 //omFreeSize( (ADDRESS) elist, sizeof(slists) );
4811
4812 // this is (via fillContainer) the same data as in root
4813 //for ( i= deg; i >= 0; i-- ) nDelete( &pcoeffs[i] );
4814 //omFreeSize( (ADDRESS) pcoeffs, (deg+1) * sizeof( number ) );
4815
4816 delete roots;
4817
4818 res->data= (void*)rlist;
4819
4820 return FALSE;
4821}
int * Zp_roots(poly p, const ring r)
Definition: clapsing.cc:2188
complex root finder for univariate polynomials based on laguers algorithm
Definition: mpr_numeric.h:66
gmp_complex * getRoot(const int i)
Definition: mpr_numeric.h:88
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
Definition: mpr_numeric.cc:300
int getAnzRoots()
Definition: mpr_numeric.h:97
bool solver(const int polishmode=PM_NONE)
Definition: mpr_numeric.cc:437
#define pIter(p)
Definition: monomials.h:37
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:704
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:60
#define nCopy(n)
Definition: numbers.h:15
#define nPrint(a)
only for debug, over any initalized currRing
Definition: numbers.h:46
#define pIsConstant(p)
like above, except that Comp must be 0
Definition: polys.h:238
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:518
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:500
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506

◆ nuMPResMat()

BOOLEAN nuMPResMat ( leftv  res,
leftv  arg1,
leftv  arg2 
)

returns module representing the multipolynomial resultant matrix Arguments 2: ideal i, int k k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default)

Definition at line 4657 of file ipshell.cc.

4658{
4659 ideal gls = (ideal)(arg1->Data());
4660 int imtype= (int)(long)arg2->Data();
4661
4662 uResultant::resMatType mtype= determineMType( imtype );
4663
4664 // check input ideal ( = polynomial system )
4665 if ( mprIdealCheck( gls, arg1->Name(), mtype, true ) != mprOk )
4666 {
4667 return TRUE;
4668 }
4669
4670 uResultant *resMat= new uResultant( gls, mtype, false );
4671 if (resMat!=NULL)
4672 {
4673 res->rtyp = MODUL_CMD;
4674 res->data= (void*)resMat->accessResMat()->getMatrix();
4675 if (!errorreported) delete resMat;
4676 }
4677 return errorreported;
4678}
virtual ideal getMatrix()
Definition: mpr_base.h:31
Base class for solving 0-dim poly systems using u-resultant.
Definition: mpr_base.h:63
resMatrixBase * accessResMat()
Definition: mpr_base.h:78
@ mprOk
Definition: mpr_base.h:98
uResultant::resMatType determineMType(int imtype)
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)

◆ nuUResSolve()

BOOLEAN nuUResSolve ( leftv  res,
leftv  args 
)

solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing->N) == IDELEMS(ideal).

Resultant method can be MPR_DENSE, which uses Macaulay Resultant (good for dense homogeneous polynoms) or MPR_SPARSE, which uses Sparse Resultant (Gelfand, Kapranov, Zelevinsky). Arguments 4: ideal i, int k, int l, int m k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default) l>0: defines precision of fractional part if ground field is Q m=0,1,2: number of iterations for approximation of roots (default=2) Returns a list containing the roots of the system.

Definition at line 4924 of file ipshell.cc.

4925{
4926 leftv v= args;
4927
4928 ideal gls;
4929 int imtype;
4930 int howclean;
4931
4932 // get ideal
4933 if ( v->Typ() != IDEAL_CMD )
4934 return TRUE;
4935 else gls= (ideal)(v->Data());
4936 v= v->next;
4937
4938 // get resultant matrix type to use (0,1)
4939 if ( v->Typ() != INT_CMD )
4940 return TRUE;
4941 else imtype= (int)(long)v->Data();
4942 v= v->next;
4943
4944 if (imtype==0)
4945 {
4946 ideal test_id=idInit(1,1);
4947 int j;
4948 for(j=IDELEMS(gls)-1;j>=0;j--)
4949 {
4950 if (gls->m[j]!=NULL)
4951 {
4952 test_id->m[0]=gls->m[j];
4953 intvec *dummy_w=id_QHomWeight(test_id, currRing);
4954 if (dummy_w!=NULL)
4955 {
4956 WerrorS("Newton polytope not of expected dimension");
4957 delete dummy_w;
4958 return TRUE;
4959 }
4960 }
4961 }
4962 }
4963
4964 // get and set precision in digits ( > 0 )
4965 if ( v->Typ() != INT_CMD )
4966 return TRUE;
4967 else if ( !(rField_is_R(currRing) || rField_is_long_R(currRing) || \
4969 {
4970 unsigned long int ii=(unsigned long int)v->Data();
4971 setGMPFloatDigits( ii, ii );
4972 }
4973 v= v->next;
4974
4975 // get interpolation steps (0,1,2)
4976 if ( v->Typ() != INT_CMD )
4977 return TRUE;
4978 else howclean= (int)(long)v->Data();
4979
4980 uResultant::resMatType mtype= determineMType( imtype );
4981 int i,count;
4982 lists listofroots= NULL;
4983 number smv= NULL;
4984 BOOLEAN interpolate_det= (mtype==uResultant::denseResMat)?TRUE:FALSE;
4985
4986 //emptylist= (lists)omAlloc( sizeof(slists) );
4987 //emptylist->Init( 0 );
4988
4989 //res->rtyp = LIST_CMD;
4990 //res->data= (void *)emptylist;
4991
4992 // check input ideal ( = polynomial system )
4993 if ( mprIdealCheck( gls, args->Name(), mtype ) != mprOk )
4994 {
4995 return TRUE;
4996 }
4997
4998 uResultant * ures;
4999 rootContainer ** iproots;
5000 rootContainer ** muiproots;
5001 rootArranger * arranger;
5002
5003 // main task 1: setup of resultant matrix
5004 ures= new uResultant( gls, mtype );
5005 if ( ures->accessResMat()->initState() != resMatrixBase::ready )
5006 {
5007 WerrorS("Error occurred during matrix setup!");
5008 return TRUE;
5009 }
5010
5011 // if dense resultant, check if minor nonsingular
5012 if ( mtype == uResultant::denseResMat )
5013 {
5014 smv= ures->accessResMat()->getSubDet();
5015#ifdef mprDEBUG_PROT
5016 PrintS("// Determinant of submatrix: ");nPrint(smv);PrintLn();
5017#endif
5018 if ( nIsZero(smv) )
5019 {
5020 WerrorS("Unsuitable input ideal: Minor of resultant matrix is singular!");
5021 return TRUE;
5022 }
5023 }
5024
5025 // main task 2: Interpolate specialized resultant polynomials
5026 if ( interpolate_det )
5027 iproots= ures->interpolateDenseSP( false, smv );
5028 else
5029 iproots= ures->specializeInU( false, smv );
5030
5031 // main task 3: Interpolate specialized resultant polynomials
5032 if ( interpolate_det )
5033 muiproots= ures->interpolateDenseSP( true, smv );
5034 else
5035 muiproots= ures->specializeInU( true, smv );
5036
5037#ifdef mprDEBUG_PROT
5038 int c= iproots[0]->getAnzElems();
5039 for (i=0; i < c; i++) pWrite(iproots[i]->getPoly());
5040 c= muiproots[0]->getAnzElems();
5041 for (i=0; i < c; i++) pWrite(muiproots[i]->getPoly());
5042#endif
5043
5044 // main task 4: Compute roots of specialized polys and match them up
5045 arranger= new rootArranger( iproots, muiproots, howclean );
5046 arranger->solve_all();
5047
5048 // get list of roots
5049 if ( arranger->success() )
5050 {
5051 arranger->arrange();
5052 listofroots= listOfRoots(arranger, gmp_output_digits );
5053 }
5054 else
5055 {
5056 WerrorS("Solver was unable to find any roots!");
5057 return TRUE;
5058 }
5059
5060 // free everything
5061 count= iproots[0]->getAnzElems();
5062 for (i=0; i < count; i++) delete iproots[i];
5063 omFreeSize( (ADDRESS) iproots, count * sizeof(rootContainer*) );
5064 count= muiproots[0]->getAnzElems();
5065 for (i=0; i < count; i++) delete muiproots[i];
5066 omFreeSize( (ADDRESS) muiproots, count * sizeof(rootContainer*) );
5067
5068 delete ures;
5069 delete arranger;
5070 if (smv!=NULL) nDelete( &smv );
5071
5072 res->data= (void *)listofroots;
5073
5074 //emptylist->Clean();
5075 // omFreeSize( (ADDRESS) emptylist, sizeof(slists) );
5076
5077 return FALSE;
5078}
virtual number getSubDet()
Definition: mpr_base.h:37
virtual IStateType initState() const
Definition: mpr_base.h:41
void solve_all()
Definition: mpr_numeric.cc:858
bool success()
Definition: mpr_numeric.h:162
void arrange()
Definition: mpr_numeric.cc:883
int getAnzElems()
Definition: mpr_numeric.h:95
rootContainer ** specializeInU(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:3060
rootContainer ** interpolateDenseSP(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:2922
@ denseResMat
Definition: mpr_base.h:65
lists listOfRoots(rootArranger *self, const unsigned int oprec)
Definition: ipshell.cc:5081
#define nIsZero(n)
Definition: numbers.h:19
void pWrite(poly p)
Definition: polys.h:308
int status int void size_t count
Definition: si_signals.h:59

◆ nuVanderSys()

BOOLEAN nuVanderSys ( leftv  res,
leftv  arg1,
leftv  arg2,
leftv  arg3 
)

COMPUTE: polynomial p with values given by v at points p1,..,pN derived from p; more precisely: consider p as point in K^n and v as N elements in K, let p1,..,pN be the points in K^n obtained by evaluating all monomials of degree 0,1,...,N at p in lexicographical order, then the procedure computes the polynomial f satisfying f(pi) = v[i] RETURN: polynomial f of degree d.

Definition at line 4823 of file ipshell.cc.

4824{
4825 int i;
4826 ideal p,w;
4827 p= (ideal)arg1->Data();
4828 w= (ideal)arg2->Data();
4829
4830 // w[0] = f(p^0)
4831 // w[1] = f(p^1)
4832 // ...
4833 // p can be a vector of numbers (multivariate polynom)
4834 // or one number (univariate polynom)
4835 // tdg = deg(f)
4836
4837 int n= IDELEMS( p );
4838 int m= IDELEMS( w );
4839 int tdg= (int)(long)arg3->Data();
4840
4841 res->data= (void*)NULL;
4842
4843 // check the input
4844 if ( tdg < 1 )
4845 {
4846 WerrorS("Last input parameter must be > 0!");
4847 return TRUE;
4848 }
4849 if ( n != rVar(currRing) )
4850 {
4851 Werror("Size of first input ideal must be equal to %d!",rVar(currRing));
4852 return TRUE;
4853 }
4854 if ( m != (int)pow((double)tdg+1,(double)n) )
4855 {
4856 Werror("Size of second input ideal must be equal to %d!",
4857 (int)pow((double)tdg+1,(double)n));
4858 return TRUE;
4859 }
4860 if ( !(rField_is_Q(currRing) /* ||
4861 rField_is_R() || rField_is_long_R() ||
4862 rField_is_long_C()*/ ) )
4863 {
4864 WerrorS("Ground field not implemented!");
4865 return TRUE;
4866 }
4867
4868 number tmp;
4869 number *pevpoint= (number *)omAlloc( n * sizeof( number ) );
4870 for ( i= 0; i < n; i++ )
4871 {
4872 pevpoint[i]=nInit(0);
4873 if ( (p->m)[i] )
4874 {
4875 tmp = pGetCoeff( (p->m)[i] );
4876 if ( nIsZero(tmp) || nIsOne(tmp) || nIsMOne(tmp) )
4877 {
4878 omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4879 WerrorS("Elements of first input ideal must not be equal to -1, 0, 1!");
4880 return TRUE;
4881 }
4882 } else tmp= NULL;
4883 if ( !nIsZero(tmp) )
4884 {
4885 if ( !pIsConstant((p->m)[i]))
4886 {
4887 omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4888 WerrorS("Elements of first input ideal must be numbers!");
4889 return TRUE;
4890 }
4891 pevpoint[i]= nCopy( tmp );
4892 }
4893 }
4894
4895 number *wresults= (number *)omAlloc( m * sizeof( number ) );
4896 for ( i= 0; i < m; i++ )
4897 {
4898 wresults[i]= nInit(0);
4899 if ( (w->m)[i] && !nIsZero(pGetCoeff((w->m)[i])) )
4900 {
4901 if ( !pIsConstant((w->m)[i]))
4902 {
4903 omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4904 omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4905 WerrorS("Elements of second input ideal must be numbers!");
4906 return TRUE;
4907 }
4908 wresults[i]= nCopy(pGetCoeff((w->m)[i]));
4909 }
4910 }
4911
4912 vandermonde vm( m, n, tdg, pevpoint, FALSE );
4913 number *ncpoly= vm.interpolateDense( wresults );
4914 // do not free ncpoly[]!!
4915 poly rpoly= vm.numvec2poly( ncpoly );
4916
4917 omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4918 omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4919
4920 res->data= (void*)rpoly;
4921 return FALSE;
4922}
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
vandermonde system solver for interpolating polynomials from their values
Definition: mpr_numeric.h:29
#define nIsMOne(n)
Definition: numbers.h:26
#define nIsOne(n)
Definition: numbers.h:25

◆ paPrint()

void paPrint ( const char *  n,
package  p 
)

Definition at line 6335 of file ipshell.cc.

6336{
6337 Print(" %s (",n);
6338 switch (p->language)
6339 {
6340 case LANG_SINGULAR: PrintS("S"); break;
6341 case LANG_C: PrintS("C"); break;
6342 case LANG_TOP: PrintS("T"); break;
6343 case LANG_MAX: PrintS("M"); break;
6344 case LANG_NONE: PrintS("N"); break;
6345 default: PrintS("U");
6346 }
6347 if(p->libname!=NULL)
6348 Print(",%s", p->libname);
6349 PrintS(")");
6350}
@ LANG_MAX
Definition: subexpr.h:22
@ LANG_TOP
Definition: subexpr.h:22

◆ rCompose()

ring rCompose ( const lists  L,
const BOOLEAN  check_comp = TRUE,
const long  bitmask = 0x7fff,
const int  isLetterplace = FALSE 
)

Definition at line 2785 of file ipshell.cc.

2786{
2787 if ((L->nr!=3)
2788#ifdef HAVE_PLURAL
2789 &&(L->nr!=5)
2790#endif
2791 )
2792 return NULL;
2793 int is_gf_char=0;
2794 // 0: char/ cf - ring
2795 // 1: list (var)
2796 // 2: list (ord)
2797 // 3: qideal
2798 // possibly:
2799 // 4: C
2800 // 5: D
2801
2802 ring R = (ring) omAlloc0Bin(sip_sring_bin);
2803
2804 // ------------------------------------------------------------------
2805 // 0: char:
2806 if (L->m[0].Typ()==CRING_CMD)
2807 {
2808 R->cf=(coeffs)L->m[0].Data();
2809 R->cf->ref++;
2810 }
2811 else if (L->m[0].Typ()==INT_CMD)
2812 {
2813 int ch = (int)(long)L->m[0].Data();
2814 assume( ch >= 0 );
2815
2816 if (ch == 0) // Q?
2817 R->cf = nInitChar(n_Q, NULL);
2818 else
2819 {
2820 int l = IsPrime(ch); // Zp?
2821 if( l != ch )
2822 {
2823 Warn("%d is invalid characteristic of ground field. %d is used.", ch, l);
2824 ch = l;
2825 }
2826 #ifndef TEST_ZN_AS_ZP
2827 R->cf = nInitChar(n_Zp, (void*)(long)ch);
2828 #else
2829 mpz_t modBase;
2830 mpz_init_set_ui(modBase,(long) ch);
2831 ZnmInfo info;
2832 info.base= modBase;
2833 info.exp= 1;
2834 R->cf=nInitChar(n_Zn,(void*) &info); //exponent is missing
2835 R->cf->is_field=1;
2836 R->cf->is_domain=1;
2837 R->cf->has_simple_Inverse=1;
2838 #endif
2839 }
2840 }
2841 else if (L->m[0].Typ()==LIST_CMD) // something complicated...
2842 {
2843 lists LL=(lists)L->m[0].Data();
2844
2845#ifdef HAVE_RINGS
2846 if (LL->m[0].Typ() == STRING_CMD) // 1st comes a string?
2847 {
2848 rComposeRing(LL, R); // Ring!?
2849 }
2850 else
2851#endif
2852 if (LL->nr < 3)
2853 rComposeC(LL,R); // R, long_R, long_C
2854 else
2855 {
2856 if (LL->m[0].Typ()==INT_CMD)
2857 {
2858 int ch = (int)(long)LL->m[0].Data();
2859 while ((ch!=fftable[is_gf_char]) && (fftable[is_gf_char])) is_gf_char++;
2860 if (fftable[is_gf_char]==0) is_gf_char=-1;
2861
2862 if(is_gf_char!= -1)
2863 {
2864 GFInfo param;
2865
2866 param.GFChar = ch;
2867 param.GFDegree = 1;
2868 param.GFPar_name = (const char*)(((lists)(LL->m[1].Data()))->m[0].Data());
2869
2870 // nfInitChar should be able to handle the case when ch is in fftables!
2871 R->cf = nInitChar(n_GF, (void*)&param);
2872 }
2873 }
2874
2875 if( R->cf == NULL )
2876 {
2877 ring extRing = rCompose((lists)L->m[0].Data(),FALSE,0x7fff);
2878
2879 if (extRing==NULL)
2880 {
2881 WerrorS("could not create the specified coefficient field");
2882 goto rCompose_err;
2883 }
2884
2885 if( extRing->qideal != NULL ) // Algebraic extension
2886 {
2887 AlgExtInfo extParam;
2888
2889 extParam.r = extRing;
2890
2891 R->cf = nInitChar(n_algExt, (void*)&extParam);
2892 }
2893 else // Transcendental extension
2894 {
2895 TransExtInfo extParam;
2896 extParam.r = extRing;
2897
2898 R->cf = nInitChar(n_transExt, &extParam);
2899 }
2900 }
2901 }
2902 }
2903 else
2904 {
2905 WerrorS("coefficient field must be described by `int` or `list`");
2906 goto rCompose_err;
2907 }
2908
2909 if( R->cf == NULL )
2910 {
2911 WerrorS("could not create coefficient field described by the input!");
2912 goto rCompose_err;
2913 }
2914
2915 // ------------------------- VARS ---------------------------
2916 if (rComposeVar(L,R)) goto rCompose_err;
2917 // ------------------------ ORDER ------------------------------
2918 if (rComposeOrder(L,check_comp,R)) goto rCompose_err;
2919
2920 // ------------------------ ??????? --------------------
2921
2922 if (!isLetterplace) rRenameVars(R);
2923 #ifdef HAVE_SHIFTBBA
2924 else
2925 {
2926 R->isLPring=isLetterplace;
2927 R->ShortOut=FALSE;
2928 R->CanShortOut=FALSE;
2929 }
2930 #endif
2931 if ((bitmask!=0)&&(R->wanted_maxExp==0)) R->wanted_maxExp=bitmask;
2932 rComplete(R);
2933
2934 // ------------------------ Q-IDEAL ------------------------
2935
2936 if (L->m[3].Typ()==IDEAL_CMD)
2937 {
2938 ideal q=(ideal)L->m[3].Data();
2939 if (q->m[0]!=NULL)
2940 {
2941 if (R->cf != currRing->cf) //->cf->ch!=currRing->cf->ch)
2942 {
2943 #if 0
2944 WerrorS("coefficient fields must be equal if q-ideal !=0");
2945 goto rCompose_err;
2946 #else
2947 ring orig_ring=currRing;
2949 int *perm=NULL;
2950 int *par_perm=NULL;
2951 int par_perm_size=0;
2952 nMapFunc nMap;
2953
2954 if ((nMap=nSetMap(orig_ring->cf))==NULL)
2955 {
2956 if (rEqual(orig_ring,currRing))
2957 {
2958 nMap=n_SetMap(currRing->cf, currRing->cf);
2959 }
2960 else
2961 // Allow imap/fetch to be make an exception only for:
2962 if ( (rField_is_Q_a(orig_ring) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2966 ||
2967 (rField_is_Zp_a(orig_ring) && // Zp(a..) -> Zp(a..) || Zp
2968 (rField_is_Zp(currRing, rInternalChar(orig_ring)) ||
2969 rField_is_Zp_a(currRing, rInternalChar(orig_ring)))) )
2970 {
2971 par_perm_size=rPar(orig_ring);
2972
2973// if ((orig_ring->minpoly != NULL) || (orig_ring->qideal != NULL))
2974// naSetChar(rInternalChar(orig_ring),orig_ring);
2975// else ntSetChar(rInternalChar(orig_ring),orig_ring);
2976
2977 nSetChar(currRing->cf);
2978 }
2979 else
2980 {
2981 WerrorS("coefficient fields must be equal if q-ideal !=0");
2982 goto rCompose_err;
2983 }
2984 }
2985 perm=(int *)omAlloc0((orig_ring->N+1)*sizeof(int));
2986 if (par_perm_size!=0)
2987 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2988 int i;
2989 #if 0
2990 // use imap:
2991 maFindPerm(orig_ring->names,orig_ring->N,orig_ring->parameter,orig_ring->P,
2992 currRing->names,currRing->N,currRing->parameter, currRing->P,
2993 perm,par_perm, currRing->ch);
2994 #else
2995 // use fetch
2996 if ((rPar(orig_ring)>0) && (rPar(currRing)==0))
2997 {
2998 for(i=si_min(rPar(orig_ring),rVar(currRing))-1;i>=0;i--) par_perm[i]=i+1;
2999 }
3000 else if (par_perm_size!=0)
3001 for(i=si_min(rPar(orig_ring),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
3002 for(i=si_min(orig_ring->N,rVar(currRing));i>0;i--) perm[i]=i;
3003 #endif
3004 ideal dest_id=idInit(IDELEMS(q),1);
3005 for(i=IDELEMS(q)-1; i>=0; i--)
3006 {
3007 dest_id->m[i]=p_PermPoly(q->m[i],perm,orig_ring, currRing,nMap,
3008 par_perm,par_perm_size);
3009 // PrintS("map:");pWrite(dest_id->m[i]);PrintLn();
3010 pTest(dest_id->m[i]);
3011 }
3012 R->qideal=dest_id;
3013 if (perm!=NULL)
3014 omFreeSize((ADDRESS)perm,(orig_ring->N+1)*sizeof(int));
3015 if (par_perm!=NULL)
3016 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
3017 rChangeCurrRing(orig_ring);
3018 #endif
3019 }
3020 else
3021 R->qideal=idrCopyR(q,currRing,R);
3022 }
3023 }
3024 else
3025 {
3026 WerrorS("q-ideal must be given as `ideal`");
3027 goto rCompose_err;
3028 }
3029
3030
3031 // ---------------------------------------------------------------
3032 #ifdef HAVE_PLURAL
3033 if (L->nr==5)
3034 {
3035 if (nc_CallPlural((matrix)L->m[4].Data(),
3036 (matrix)L->m[5].Data(),
3037 NULL,NULL,
3038 R,
3039 true, // !!!
3040 true, false,
3041 currRing, FALSE)) goto rCompose_err;
3042 // takes care about non-comm. quotient! i.e. calls "nc_SetupQuotient" due to last true
3043 }
3044 #endif
3045 return R;
3046
3047rCompose_err:
3048 if (R->N>0)
3049 {
3050 int i;
3051 if (R->names!=NULL)
3052 {
3053 i=R->N-1;
3054 while (i>=0) { omfree(R->names[i]); i--; }
3055 omFree(R->names);
3056 }
3057 }
3058 omfree(R->order);
3059 omfree(R->block0);
3060 omfree(R->block1);
3061 omfree(R->wvhdl);
3062 omFree(R);
3063 return NULL;
3064}
ring r
Definition: algext.h:37
int GFDegree
Definition: coeffs.h:95
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:32
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:30
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
const unsigned short fftable[]
Definition: ffields.cc:27
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
Definition: coeffs.h:437
const char * GFPar_name
Definition: coeffs.h:96
int GFChar
Definition: coeffs.h:94
Creation data needed for finite fields.
Definition: coeffs.h:93
const ExtensionInfo & info
< [in] sqrfree poly
static void rRenameVars(ring R)
Definition: ipshell.cc:2406
void rComposeC(lists L, ring R)
Definition: ipshell.cc:2261
static BOOLEAN rComposeOrder(const lists L, const BOOLEAN check_comp, ring R)
Definition: ipshell.cc:2493
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition: ipshell.cc:2785
void rComposeRing(lists L, ring R)
Definition: ipshell.cc:2313
static BOOLEAN rComposeVar(const lists L, ring R)
Definition: ipshell.cc:2448
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
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:163
#define nSetMap(R)
Definition: numbers.h:43
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4130
#define pTest(p)
Definition: polys.h:414
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
int IsPrime(int p)
Definition: prime.cc:61
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3450
VAR omBin sip_sring_bin
Definition: ring.cc:43
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
Definition: ring.cc:1746
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:529
static BOOLEAN rField_is_Zn(const ring r)
Definition: ring.h:512
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:599
static int rInternalChar(const ring r)
Definition: ring.h:689
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:539
struct for passing initialization parameters to naInitChar
Definition: transext.h:88

◆ rDecompose()

lists rDecompose ( const ring  r)

Definition at line 2162 of file ipshell.cc.

2163{
2164 assume( r != NULL );
2165 const coeffs C = r->cf;
2166 assume( C != NULL );
2167
2168 // sanity check: require currRing==r for rings with polynomial data
2169 if ( (r!=currRing) && (
2170 (nCoeff_is_algExt(C) && (C != currRing->cf))
2171 || (r->qideal != NULL)
2172#ifdef HAVE_PLURAL
2173 || (rIsPluralRing(r))
2174#endif
2175 )
2176 )
2177 {
2178 WerrorS("ring with polynomial data must be the base ring or compatible");
2179 return NULL;
2180 }
2181 // 0: char/ cf - ring
2182 // 1: list (var)
2183 // 2: list (ord)
2184 // 3: qideal
2185 // possibly:
2186 // 4: C
2187 // 5: D
2189 if (rIsPluralRing(r))
2190 L->Init(6);
2191 else
2192 L->Init(4);
2193 // ----------------------------------------
2194 // 0: char/ cf - ring
2195 if (rField_is_numeric(r))
2196 {
2197 rDecomposeC(&(L->m[0]),r);
2198 }
2199 else if (rField_is_Ring(r))
2200 {
2201 rDecomposeRing(&(L->m[0]),r);
2202 }
2203 else if ( r->cf->extRing!=NULL )// nCoeff_is_algExt(r->cf))
2204 {
2205 rDecomposeCF(&(L->m[0]), r->cf->extRing, r);
2206 }
2207 else if(rField_is_GF(r))
2208 {
2210 Lc->Init(4);
2211 // char:
2212 Lc->m[0].rtyp=INT_CMD;
2213 Lc->m[0].data=(void*)(long)r->cf->m_nfCharQ;
2214 // var:
2216 Lv->Init(1);
2217 Lv->m[0].rtyp=STRING_CMD;
2218 Lv->m[0].data=(void *)omStrDup(*rParameter(r));
2219 Lc->m[1].rtyp=LIST_CMD;
2220 Lc->m[1].data=(void*)Lv;
2221 // ord:
2223 Lo->Init(1);
2225 Loo->Init(2);
2226 Loo->m[0].rtyp=STRING_CMD;
2227 Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
2228
2229 intvec *iv=new intvec(1); (*iv)[0]=1;
2230 Loo->m[1].rtyp=INTVEC_CMD;
2231 Loo->m[1].data=(void *)iv;
2232
2233 Lo->m[0].rtyp=LIST_CMD;
2234 Lo->m[0].data=(void*)Loo;
2235
2236 Lc->m[2].rtyp=LIST_CMD;
2237 Lc->m[2].data=(void*)Lo;
2238 // q-ideal:
2239 Lc->m[3].rtyp=IDEAL_CMD;
2240 Lc->m[3].data=(void *)idInit(1,1);
2241 // ----------------------
2242 L->m[0].rtyp=LIST_CMD;
2243 L->m[0].data=(void*)Lc;
2244 }
2245 else if (rField_is_Zp(r) || rField_is_Q(r))
2246 {
2247 L->m[0].rtyp=INT_CMD;
2248 L->m[0].data=(void *)(long)r->cf->ch;
2249 }
2250 else
2251 {
2252 L->m[0].rtyp=CRING_CMD;
2253 L->m[0].data=(void *)r->cf;
2254 r->cf->ref++;
2255 }
2256 // ----------------------------------------
2257 rDecompose_23456(r,L);
2258 return L;
2259}
CanonicalForm Lc(const CanonicalForm &f)
static void rDecomposeC(leftv h, const ring R)
Definition: ipshell.cc:1854
void rDecomposeCF(leftv h, const ring r, const ring R)
Definition: ipshell.cc:1730
void rDecomposeRing(leftv h, const ring R)
Definition: ipshell.cc:1918
static void rDecompose_23456(const ring r, lists L)
Definition: ipshell.cc:2022
const char * rSimpleOrdStr(int ord)
Definition: ring.cc:77
@ ringorder_lp
Definition: ring.h:77
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:625
static BOOLEAN rField_is_numeric(const ring r)
Definition: ring.h:515
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:521

◆ rDecompose_CF()

BOOLEAN rDecompose_CF ( leftv  res,
const coeffs  C 
)

Definition at line 1950 of file ipshell.cc.

1951{
1952 assume( C != NULL );
1953
1954 // sanity check: require currRing==r for rings with polynomial data
1955 if ( nCoeff_is_algExt(C) && (C != currRing->cf))
1956 {
1957 WerrorS("ring with polynomial data must be the base ring or compatible");
1958 return TRUE;
1959 }
1960 if (nCoeff_is_numeric(C))
1961 {
1963 }
1964#ifdef HAVE_RINGS
1965 else if (nCoeff_is_Ring(C))
1966 {
1968 }
1969#endif
1970 else if ( C->extRing!=NULL )// nCoeff_is_algExt(r->cf))
1971 {
1972 rDecomposeCF(res, C->extRing, currRing);
1973 }
1974 else if(nCoeff_is_GF(C))
1975 {
1977 Lc->Init(4);
1978 // char:
1979 Lc->m[0].rtyp=INT_CMD;
1980 Lc->m[0].data=(void*)(long)C->m_nfCharQ;
1981 // var:
1983 Lv->Init(1);
1984 Lv->m[0].rtyp=STRING_CMD;
1985 Lv->m[0].data=(void *)omStrDup(*n_ParameterNames(C));
1986 Lc->m[1].rtyp=LIST_CMD;
1987 Lc->m[1].data=(void*)Lv;
1988 // ord:
1990 Lo->Init(1);
1992 Loo->Init(2);
1993 Loo->m[0].rtyp=STRING_CMD;
1994 Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
1995
1996 intvec *iv=new intvec(1); (*iv)[0]=1;
1997 Loo->m[1].rtyp=INTVEC_CMD;
1998 Loo->m[1].data=(void *)iv;
1999
2000 Lo->m[0].rtyp=LIST_CMD;
2001 Lo->m[0].data=(void*)Loo;
2002
2003 Lc->m[2].rtyp=LIST_CMD;
2004 Lc->m[2].data=(void*)Lo;
2005 // q-ideal:
2006 Lc->m[3].rtyp=IDEAL_CMD;
2007 Lc->m[3].data=(void *)idInit(1,1);
2008 // ----------------------
2009 res->rtyp=LIST_CMD;
2010 res->data=(void*)Lc;
2011 }
2012 else
2013 {
2014 res->rtyp=INT_CMD;
2015 res->data=(void *)(long)C->ch;
2016 }
2017 // ----------------------------------------
2018 return FALSE;
2019}
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:836
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:829
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:775
static void rDecomposeC_41(leftv h, const coeffs C)
Definition: ipshell.cc:1820
static void rDecomposeRing_41(leftv h, const coeffs C)
Definition: ipshell.cc:1890

◆ rDecompose_list_cf()

lists rDecompose_list_cf ( const ring  r)

Definition at line 2123 of file ipshell.cc.

2124{
2125 assume( r != NULL );
2126 const coeffs C = r->cf;
2127 assume( C != NULL );
2128
2129 // sanity check: require currRing==r for rings with polynomial data
2130 if ( (r!=currRing) && (
2131 (r->qideal != NULL)
2132#ifdef HAVE_PLURAL
2133 || (rIsPluralRing(r))
2134#endif
2135 )
2136 )
2137 {
2138 WerrorS("ring with polynomial data must be the base ring or compatible");
2139 return NULL;
2140 }
2141 // 0: char/ cf - ring
2142 // 1: list (var)
2143 // 2: list (ord)
2144 // 3: qideal
2145 // possibly:
2146 // 4: C
2147 // 5: D
2149 if (rIsPluralRing(r))
2150 L->Init(6);
2151 else
2152 L->Init(4);
2153 // ----------------------------------------
2154 // 0: char/ cf - ring
2155 L->m[0].rtyp=CRING_CMD;
2156 L->m[0].data=(char*)r->cf; r->cf->ref++;
2157 // ----------------------------------------
2158 rDecompose_23456(r,L);
2159 return L;
2160}

◆ rDefault()

idhdl rDefault ( const char *  s)

Definition at line 1645 of file ipshell.cc.

1646{
1647 idhdl tmp=NULL;
1648
1649 if (s!=NULL) tmp = enterid(s, myynest, RING_CMD, &IDROOT);
1650 if (tmp==NULL) return NULL;
1651
1652// if ((currRing->ppNoether)!=NULL) pDelete(&(currRing->ppNoether));
1654 {
1656 }
1657
1658 ring r = IDRING(tmp) = (ring) omAlloc0Bin(sip_sring_bin);
1659
1660 #ifndef TEST_ZN_AS_ZP
1661 r->cf = nInitChar(n_Zp, (void*)32003); // r->cf->ch = 32003;
1662 #else
1663 mpz_t modBase;
1664 mpz_init_set_ui(modBase, (long)32003);
1665 ZnmInfo info;
1666 info.base= modBase;
1667 info.exp= 1;
1668 r->cf=nInitChar(n_Zn,(void*) &info);
1669 r->cf->is_field=1;
1670 r->cf->is_domain=1;
1671 r->cf->has_simple_Inverse=1;
1672 #endif
1673 r->N = 3;
1674 /*r->P = 0; Alloc0 in idhdl::set, ipid.cc*/
1675 /*names*/
1676 r->names = (char **) omAlloc0(3 * sizeof(char_ptr));
1677 r->names[0] = omStrDup("x");
1678 r->names[1] = omStrDup("y");
1679 r->names[2] = omStrDup("z");
1680 /*weights: entries for 3 blocks: NULL*/
1681 r->wvhdl = (int **)omAlloc0(3 * sizeof(int_ptr));
1682 /*order: dp,C,0*/
1683 r->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
1684 r->block0 = (int *)omAlloc0(3 * sizeof(int *));
1685 r->block1 = (int *)omAlloc0(3 * sizeof(int *));
1686 /* ringorder dp for the first block: var 1..3 */
1687 r->order[0] = ringorder_dp;
1688 r->block0[0] = 1;
1689 r->block1[0] = 3;
1690 /* ringorder C for the second block: no vars */
1691 r->order[1] = ringorder_C;
1692 /* the last block: everything is 0 */
1693 r->order[2] = (rRingOrder_t)0;
1694
1695 /* complete ring intializations */
1696 rComplete(r);
1697 rSetHdl(tmp);
1698 return currRingHdl;
1699}
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_C
Definition: ring.h:73
@ ringorder_dp
Definition: ring.h:78
char * char_ptr
Definition: structs.h:53
int * int_ptr
Definition: structs.h:54

◆ rFindHdl()

idhdl rFindHdl ( ring  r,
idhdl  n 
)

Definition at line 1702 of file ipshell.cc.

1703{
1704 if ((r==NULL)||(r->VarOffset==NULL))
1705 return NULL;
1707 if (h!=NULL) return h;
1708 if (IDROOT!=basePack->idroot) h=rSimpleFindHdl(r,basePack->idroot,n);
1709 if (h!=NULL) return h;
1711 while(p!=NULL)
1712 {
1713 if ((p->cPack!=basePack)
1714 && (p->cPack!=currPack))
1715 h=rSimpleFindHdl(r,p->cPack->idroot,n);
1716 if (h!=NULL) return h;
1717 p=p->next;
1718 }
1719 idhdl tmp=basePack->idroot;
1720 while (tmp!=NULL)
1721 {
1722 if (IDTYP(tmp)==PACKAGE_CMD)
1723 h=rSimpleFindHdl(r,IDPACKAGE(tmp)->idroot,n);
1724 if (h!=NULL) return h;
1725 tmp=IDNEXT(tmp);
1726 }
1727 return NULL;
1728}
Definition: ipid.h:56
static idhdl rSimpleFindHdl(const ring r, const idhdl root, const idhdl n)
Definition: ipshell.cc:6271

◆ rInit()

ring rInit ( leftv  pn,
leftv  rv,
leftv  ord 
)

Definition at line 5627 of file ipshell.cc.

5628{
5629 int float_len=0;
5630 int float_len2=0;
5631 ring R = NULL;
5632 //BOOLEAN ffChar=FALSE;
5633
5634 /* ch -------------------------------------------------------*/
5635 // get ch of ground field
5636
5637 // allocated ring
5638 R = (ring) omAlloc0Bin(sip_sring_bin);
5639
5640 coeffs cf = NULL;
5641
5642 assume( pn != NULL );
5643 const int P = pn->listLength();
5644
5645 if (pn->Typ()==CRING_CMD)
5646 {
5647 cf=(coeffs)pn->CopyD();
5648 leftv pnn=pn;
5649 if(P>1) /*parameter*/
5650 {
5651 pnn = pnn->next;
5652 const int pars = pnn->listLength();
5653 assume( pars > 0 );
5654 char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5655
5656 if (rSleftvList2StringArray(pnn, names))
5657 {
5658 WerrorS("parameter expected");
5659 goto rInitError;
5660 }
5661
5662 TransExtInfo extParam;
5663
5664 extParam.r = rDefault( cf, pars, names); // Q/Zp [ p_1, ... p_pars ]
5665 for(int i=pars-1; i>=0;i--)
5666 {
5667 omFree(names[i]);
5668 }
5669 omFree(names);
5670
5671 cf = nInitChar(n_transExt, &extParam);
5672 }
5673 assume( cf != NULL );
5674 }
5675 else if (pn->Typ()==INT_CMD)
5676 {
5677 int ch = (int)(long)pn->Data();
5678 leftv pnn=pn;
5679
5680 /* parameter? -------------------------------------------------------*/
5681 pnn = pnn->next;
5682
5683 if (pnn == NULL) // no params!?
5684 {
5685 if (ch!=0)
5686 {
5687 int ch2=IsPrime(ch);
5688 if ((ch<2)||(ch!=ch2))
5689 {
5690 Warn("%d is invalid as characteristic of the ground field. 32003 is used.", ch);
5691 ch=32003;
5692 }
5693 #ifndef TEST_ZN_AS_ZP
5694 cf = nInitChar(n_Zp, (void*)(long)ch);
5695 #else
5696 mpz_t modBase;
5697 mpz_init_set_ui(modBase, (long)ch);
5698 ZnmInfo info;
5699 info.base= modBase;
5700 info.exp= 1;
5701 cf=nInitChar(n_Zn,(void*) &info);
5702 cf->is_field=1;
5703 cf->is_domain=1;
5704 cf->has_simple_Inverse=1;
5705 #endif
5706 }
5707 else
5708 cf = nInitChar(n_Q, (void*)(long)ch);
5709 }
5710 else
5711 {
5712 const int pars = pnn->listLength();
5713
5714 assume( pars > 0 );
5715
5716 // predefined finite field: (p^k, a)
5717 if ((ch!=0) && (ch!=IsPrime(ch)) && (pars == 1))
5718 {
5719 GFInfo param;
5720
5721 param.GFChar = ch;
5722 param.GFDegree = 1;
5723 param.GFPar_name = pnn->name;
5724
5725 cf = nInitChar(n_GF, &param);
5726 }
5727 else // (0/p, a, b, ..., z)
5728 {
5729 if ((ch!=0) && (ch!=IsPrime(ch)))
5730 {
5731 WerrorS("too many parameters");
5732 goto rInitError;
5733 }
5734
5735 char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5736
5737 if (rSleftvList2StringArray(pnn, names))
5738 {
5739 WerrorS("parameter expected");
5740 goto rInitError;
5741 }
5742
5743 TransExtInfo extParam;
5744
5745 extParam.r = rDefault( ch, pars, names); // Q/Zp [ p_1, ... p_pars ]
5746 for(int i=pars-1; i>=0;i--)
5747 {
5748 omFree(names[i]);
5749 }
5750 omFree(names);
5751
5752 cf = nInitChar(n_transExt, &extParam);
5753 }
5754 }
5755
5756 //if (cf==NULL) ->Error: Invalid ground field specification
5757 }
5758 else if ((pn->name != NULL)
5759 && ((strcmp(pn->name,"real")==0) || (strcmp(pn->name,"complex")==0)))
5760 {
5761 leftv pnn=pn->next;
5762 BOOLEAN complex_flag=(strcmp(pn->name,"complex")==0);
5763 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5764 {
5765 float_len=(int)(long)pnn->Data();
5766 float_len2=float_len;
5767 pnn=pnn->next;
5768 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5769 {
5770 float_len2=(int)(long)pnn->Data();
5771 pnn=pnn->next;
5772 }
5773 }
5774
5775 if (!complex_flag)
5776 complex_flag= (pnn!=NULL) && (pnn->name!=NULL);
5777 if( !complex_flag && (float_len2 <= (short)SHORT_REAL_LENGTH))
5778 cf=nInitChar(n_R, NULL);
5779 else // longR or longC?
5780 {
5781 LongComplexInfo param;
5782
5783 param.float_len = si_min (float_len, 32767);
5784 param.float_len2 = si_min (float_len2, 32767);
5785
5786 // set the parameter name
5787 if (complex_flag)
5788 {
5789 if (param.float_len < SHORT_REAL_LENGTH)
5790 {
5793 }
5794 if ((pnn == NULL) || (pnn->name == NULL))
5795 param.par_name=(const char*)"i"; //default to i
5796 else
5797 param.par_name = (const char*)pnn->name;
5798 }
5799
5800 cf = nInitChar(complex_flag ? n_long_C: n_long_R, (void*)&param);
5801 }
5802 assume( cf != NULL );
5803 }
5804#ifdef HAVE_RINGS
5805 else if ((pn->name != NULL) && (strcmp(pn->name, "integer") == 0))
5806 {
5807 // TODO: change to use coeffs_BIGINT!?
5808 mpz_t modBase;
5809 unsigned int modExponent = 1;
5810 mpz_init_set_si(modBase, 0);
5811 if (pn->next!=NULL)
5812 {
5813 leftv pnn=pn;
5814 if (pnn->next->Typ()==INT_CMD)
5815 {
5816 pnn=pnn->next;
5817 mpz_set_ui(modBase, (long) pnn->Data());
5818 if ((pnn->next!=NULL) && (pnn->next->Typ()==INT_CMD))
5819 {
5820 pnn=pnn->next;
5821 modExponent = (long) pnn->Data();
5822 }
5823 while ((pnn->next!=NULL) && (pnn->next->Typ()==INT_CMD))
5824 {
5825 pnn=pnn->next;
5826 mpz_mul_ui(modBase, modBase, (int)(long) pnn->Data());
5827 }
5828 }
5829 else if (pnn->next->Typ()==BIGINT_CMD)
5830 {
5831 number p=(number)pnn->next->CopyD();
5832 n_MPZ(modBase,p,coeffs_BIGINT);
5834 }
5835 }
5836 else
5838
5839 if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_sgn1(modBase) < 0))
5840 {
5841 WerrorS("Wrong ground ring specification (module is 1)");
5842 goto rInitError;
5843 }
5844 if (modExponent < 1)
5845 {
5846 WerrorS("Wrong ground ring specification (exponent smaller than 1");
5847 goto rInitError;
5848 }
5849 // module is 0 ---> integers ringtype = 4;
5850 // we have an exponent
5851 if (modExponent > 1 && cf == NULL)
5852 {
5853 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
5854 {
5855 /* this branch should be active for modExponent = 2..32 resp. 2..64,
5856 depending on the size of a long on the respective platform */
5857 //ringtype = 1; // Use Z/2^ch
5858 cf=nInitChar(n_Z2m,(void*)(long)modExponent);
5859 }
5860 else
5861 {
5862 if (mpz_sgn1(modBase)==0)
5863 {
5864 WerrorS("modulus must not be 0 or parameter not allowed");
5865 goto rInitError;
5866 }
5867 //ringtype = 3;
5868 ZnmInfo info;
5869 info.base= modBase;
5870 info.exp= modExponent;
5871 cf=nInitChar(n_Znm,(void*) &info); //exponent is missing
5872 }
5873 }
5874 // just a module m > 1
5875 else if (cf == NULL)
5876 {
5877 if (mpz_sgn1(modBase)==0)
5878 {
5879 WerrorS("modulus must not be 0 or parameter not allowed");
5880 goto rInitError;
5881 }
5882 //ringtype = 2;
5883 ZnmInfo info;
5884 info.base= modBase;
5885 info.exp= modExponent;
5886 cf=nInitChar(n_Zn,(void*) &info);
5887 }
5888 assume( cf != NULL );
5889 mpz_clear(modBase);
5890 }
5891#endif
5892 // ring NEW = OLD, (), (); where OLD is a polynomial ring...
5893 else if ((pn->Typ()==RING_CMD) && (P == 1))
5894 {
5895 ring r=(ring)pn->Data();
5896 if (r->qideal==NULL)
5897 {
5898 TransExtInfo extParam;
5899 extParam.r = r;
5900 extParam.r->ref++;
5901 cf = nInitChar(n_transExt, &extParam); // R(a)
5902 }
5903 else if (IDELEMS(r->qideal)==1)
5904 {
5905 AlgExtInfo extParam;
5906 extParam.r=r;
5907 extParam.r->ref++;
5908 cf = nInitChar(n_algExt, &extParam); // R[a]/<minideal>
5909 }
5910 else
5911 {
5912 WerrorS("algebraic extension ring must have one minpoly");
5913 goto rInitError;
5914 }
5915 }
5916 else
5917 {
5918 WerrorS("Wrong or unknown ground field specification");
5919#if 0
5920// debug stuff for unknown cf descriptions:
5921 sleftv* p = pn;
5922 while (p != NULL)
5923 {
5924 Print( "pn[%p]: type: %d [%s]: %p, name: %s", (void*)p, p->Typ(), Tok2Cmdname(p->Typ()), p->Data(), (p->name == NULL? "NULL" : p->name) );
5925 PrintLn();
5926 p = p->next;
5927 }
5928#endif
5929 goto rInitError;
5930 }
5931
5932 /*every entry in the new ring is initialized to 0*/
5933
5934 /* characteristic -----------------------------------------------*/
5935 /* input: 0 ch=0 : Q parameter=NULL ffChar=FALSE float_len
5936 * 0 1 : Q(a,...) *names FALSE
5937 * 0 -1 : R NULL FALSE 0
5938 * 0 -1 : R NULL FALSE prec. >6
5939 * 0 -1 : C *names FALSE prec. 0..?
5940 * p p : Fp NULL FALSE
5941 * p -p : Fp(a) *names FALSE
5942 * q q : GF(q=p^n) *names TRUE
5943 */
5944 if (cf==NULL)
5945 {
5946 WerrorS("Invalid ground field specification");
5947 goto rInitError;
5948// const int ch=32003;
5949// cf=nInitChar(n_Zp, (void*)(long)ch);
5950 }
5951
5952 assume( R != NULL );
5953
5954 R->cf = cf;
5955
5956 /* names and number of variables-------------------------------------*/
5957 {
5958 int l=rv->listLength();
5959
5960 if (l>MAX_SHORT)
5961 {
5962 Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
5963 goto rInitError;
5964 }
5965 R->N = l; /*rv->listLength();*/
5966 }
5967 R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
5968 if (rSleftvList2StringArray(rv, R->names))
5969 {
5970 WerrorS("name of ring variable expected");
5971 goto rInitError;
5972 }
5973
5974 /* check names and parameters for conflicts ------------------------- */
5975 rRenameVars(R); // conflicting variables will be renamed
5976 /* ordering -------------------------------------------------------------*/
5977 if (rSleftvOrdering2Ordering(ord, R))
5978 goto rInitError;
5979
5980 // Complete the initialization
5981 if (rComplete(R,1))
5982 goto rInitError;
5983
5984/*#ifdef HAVE_RINGS
5985// currently, coefficients which are ring elements require a global ordering:
5986 if (rField_is_Ring(R) && (R->OrdSgn==-1))
5987 {
5988 WerrorS("global ordering required for these coefficients");
5989 goto rInitError;
5990 }
5991#endif*/
5992
5993 rTest(R);
5994
5995 // try to enter the ring into the name list
5996 // need to clean up sleftv here, before this ring can be set to
5997 // new currRing or currRing can be killed beacuse new ring has
5998 // same name
5999 pn->CleanUp();
6000 rv->CleanUp();
6001 ord->CleanUp();
6002 //if ((tmp = enterid(s, myynest, RING_CMD, &IDROOT))==NULL)
6003 // goto rInitError;
6004
6005 //memcpy(IDRING(tmp),R,sizeof(*R));
6006 // set current ring
6007 //omFreeBin(R, ip_sring_bin);
6008 //return tmp;
6009 return R;
6010
6011 // error case:
6012 rInitError:
6013 if ((R != NULL)&&(R->cf!=NULL)) rDelete(R);
6014 pn->CleanUp();
6015 rv->CleanUp();
6016 ord->CleanUp();
6017 return NULL;
6018}
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:33
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:41
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition: coeffs.h:548
const char * par_name
parameter name
Definition: coeffs.h:103
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
const short MAX_SHORT
Definition: ipshell.cc:5615
BOOLEAN rSleftvOrdering2Ordering(sleftv *ord, ring R)
Definition: ipshell.cc:5307
static BOOLEAN rSleftvList2StringArray(leftv sl, char **p)
Definition: ipshell.cc:5579
#define SHORT_REAL_LENGTH
Definition: numbers.h:57
#define rTest(r)
Definition: ring.h:784
#define mpz_sgn1(A)
Definition: si_gmp.h:18

◆ rKill() [1/2]

void rKill ( idhdl  h)

Definition at line 6228 of file ipshell.cc.

6229{
6230 ring r = IDRING(h);
6231 int ref=0;
6232 if (r!=NULL)
6233 {
6234 // avoid, that sLastPrinted is the last reference to the base ring:
6235 // clean up before killing the last "named" refrence:
6237 && (sLastPrinted.data==(void*)r))
6238 {
6240 }
6241 ref=r->ref;
6242 if ((ref<=0)&&(r==currRing))
6243 {
6244 // cleanup DENOMINATOR_LIST
6246 {
6248 if (TEST_V_ALLWARN)
6249 Warn("deleting denom_list for ring change from %s",IDID(h));
6250 do
6251 {
6252 n_Delete(&(dd->n),currRing->cf);
6253 dd=dd->next;
6256 } while(DENOMINATOR_LIST!=NULL);
6257 }
6258 }
6259 rKill(r);
6260 }
6261 if (h==currRingHdl)
6262 {
6263 if (ref<=0) { currRing=NULL; currRingHdl=NULL;}
6264 else
6265 {
6267 }
6268 }
6269}
void rKill(ring r)
Definition: ipshell.cc:6182
VAR denominator_list DENOMINATOR_LIST
Definition: kutil.cc:84
denominator_list next
Definition: kutil.h:65

◆ rKill() [2/2]

void rKill ( ring  r)

Definition at line 6182 of file ipshell.cc.

6183{
6184 if ((r->ref<=0)&&(r->order!=NULL))
6185 {
6186#ifdef RDEBUG
6187 if (traceit &TRACE_SHOW_RINGS) Print("kill ring %lx\n",(long)r);
6188#endif
6189 int j;
6190 for (j=0;j<myynest;j++)
6191 {
6192 if (iiLocalRing[j]==r)
6193 {
6194 if (j==0) WarnS("killing the basering for level 0");
6196 }
6197 }
6198// any variables depending on r ?
6199 while (r->idroot!=NULL)
6200 {
6201 r->idroot->lev=myynest; // avoid warning about kill global objects
6202 killhdl2(r->idroot,&(r->idroot),r);
6203 }
6204 if (r==currRing)
6205 {
6206 // all dependend stuff is done, clean global vars:
6207 if ((currRing->ppNoether)!=NULL) pDelete(&(currRing->ppNoether));
6209 {
6211 }
6212 //if ((myynest>0) && (iiRETURNEXPR.RingDependend()))
6213 //{
6214 // WerrorS("return value depends on local ring variable (export missing ?)");
6215 // iiRETURNEXPR.CleanUp();
6216 //}
6217 currRing=NULL;
6219 }
6220
6221 /* nKillChar(r); will be called from inside of rDelete */
6222 rDelete(r);
6223 return;
6224 }
6225 rDecRefCnt(r);
6226}
#define pDelete(p_ptr)
Definition: polys.h:186
static void rDecRefCnt(ring r)
Definition: ring.h:840

◆ rSetHdl()

void rSetHdl ( idhdl  h)

Definition at line 5128 of file ipshell.cc.

5129{
5130 ring rg = NULL;
5131 if (h!=NULL)
5132 {
5133// Print(" new ring:%s (l:%d)\n",IDID(h),IDLEV(h));
5134 rg = IDRING(h);
5135 if (rg==NULL) return; //id <>NULL, ring==NULL
5136 omCheckAddrSize((ADDRESS)h,sizeof(idrec));
5137 if (IDID(h)) // OB: ????
5139 rTest(rg);
5140 }
5141 else return;
5142
5143 // clean up history
5144 if (currRing!=NULL)
5145 {
5147 {
5149 }
5150
5151 if (rg!=currRing)/*&&(currRing!=NULL)*/
5152 {
5153 if (rg->cf!=currRing->cf)
5154 {
5157 {
5158 if (TEST_V_ALLWARN)
5159 Warn("deleting denom_list for ring change to %s",IDID(h));
5160 do
5161 {
5162 n_Delete(&(dd->n),currRing->cf);
5163 dd=dd->next;
5166 } while(DENOMINATOR_LIST!=NULL);
5167 }
5168 }
5169 }
5170 }
5171
5172 // test for valid "currRing":
5173 if ((rg!=NULL) && (rg->idroot==NULL))
5174 {
5175 ring old=rg;
5176 rg=rAssure_HasComp(rg);
5177 if (old!=rg)
5178 {
5179 rKill(old);
5180 IDRING(h)=rg;
5181 }
5182 }
5183 /*------------ change the global ring -----------------------*/
5184 rChangeCurrRing(rg);
5185 currRingHdl = h;
5186}
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
ring rAssure_HasComp(const ring r)
Definition: ring.cc:4625

◆ scIndIndset()

lists scIndIndset ( ideal  S,
BOOLEAN  all,
ideal  Q 
)

Definition at line 1104 of file ipshell.cc.

1106{
1107 int i;
1108 indset save;
1110
1111 hexist = hInit(S, Q, &hNexist);
1112 if (hNexist == 0)
1113 {
1114 intvec *iv=new intvec(rVar(currRing));
1115 for(i=0; i<rVar(currRing); i++) (*iv)[i]=1;
1116 res->Init(1);
1117 res->m[0].rtyp=INTVEC_CMD;
1118 res->m[0].data=(intvec*)iv;
1119 return res;
1120 }
1122 hMu = 0;
1123 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1124 hvar = (varset)omAlloc((rVar(currRing) + 1) * sizeof(int));
1125 hpure = (scmon)omAlloc0((1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1126 hrad = hexist;
1127 hNrad = hNexist;
1128 radmem = hCreate(rVar(currRing) - 1);
1129 hCo = rVar(currRing) + 1;
1130 hNvar = rVar(currRing);
1132 hSupp(hrad, hNrad, hvar, &hNvar);
1133 if (hNvar)
1134 {
1135 hCo = hNvar;
1136 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
1139 }
1140 if (hCo && (hCo < rVar(currRing)))
1141 {
1143 }
1144 if (hMu!=0)
1145 {
1146 ISet = save;
1147 hMu2 = 0;
1148 if (all && (hCo+1 < rVar(currRing)))
1149 {
1152 i=hMu+hMu2;
1153 res->Init(i);
1154 if (hMu2 == 0)
1155 {
1157 }
1158 }
1159 else
1160 {
1161 res->Init(hMu);
1162 }
1163 for (i=0;i<hMu;i++)
1164 {
1165 res->m[i].data = (void *)save->set;
1166 res->m[i].rtyp = INTVEC_CMD;
1167 ISet = save;
1168 save = save->nx;
1170 }
1172 if (hMu2 != 0)
1173 {
1174 save = JSet;
1175 for (i=hMu;i<hMu+hMu2;i++)
1176 {
1177 res->m[i].data = (void *)save->set;
1178 res->m[i].rtyp = INTVEC_CMD;
1179 JSet = save;
1180 save = save->nx;
1182 }
1184 }
1185 }
1186 else
1187 {
1188 res->Init(0);
1190 }
1191 hKill(radmem, rVar(currRing) - 1);
1192 omFreeSize((ADDRESS)hpure, (1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1193 omFreeSize((ADDRESS)hvar, (rVar(currRing) + 1) * sizeof(int));
1194 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1196 return res;
1197}
void hIndMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:384
VAR omBin indlist_bin
Definition: hdegree.cc:29
VAR int hMu2
Definition: hdegree.cc:27
VAR int hCo
Definition: hdegree.cc:27
VAR indset ISet
Definition: hdegree.cc:353
VAR long hMu
Definition: hdegree.cc:28
VAR indset JSet
Definition: hdegree.cc:353
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:35
void hIndAllMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:564
monf hCreate(int Nvar)
Definition: hutil.cc:996
VAR varset hvar
Definition: hutil.cc:18
void hKill(monf xmem, int Nvar)
Definition: hutil.cc:1010
VAR int hNexist
Definition: hutil.cc:19
void hDelete(scfmon ev, int ev_length)
Definition: hutil.cc:140
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
Definition: hutil.cc:621
VAR scfmon hwork
Definition: hutil.cc:16
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition: hutil.cc:174
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
Definition: hutil.cc:565
VAR scmon hpure
Definition: hutil.cc:17
VAR scfmon hrad
Definition: hutil.cc:16
VAR monf radmem
Definition: hutil.cc:21
VAR int hNpure
Definition: hutil.cc:19
VAR int hNrad
Definition: hutil.cc:19
scfmon hInit(ideal S, ideal Q, int *Nexist)
Definition: hutil.cc:31
VAR scfmon hexist
Definition: hutil.cc:16
void hRadical(scfmon rad, int *Nrad, int Nvar)
Definition: hutil.cc:411
VAR int hNvar
Definition: hutil.cc:19
scmon * scfmon
Definition: hutil.h:15
indlist * indset
Definition: hutil.h:28
int * varset
Definition: hutil.h:16
int * scmon
Definition: hutil.h:14
STATIC_VAR jList * Q
Definition: janet.cc:30

◆ semicProc()

BOOLEAN semicProc ( leftv  res,
leftv  u,
leftv  v 
)

Definition at line 4553 of file ipshell.cc.

4554{
4555 sleftv tmp;
4556 tmp.Init();
4557 tmp.rtyp=INT_CMD;
4558 /* tmp.data = (void *)0; -- done by Init */
4559
4560 return semicProc3(res,u,v,&tmp);
4561}

◆ semicProc3()

BOOLEAN semicProc3 ( leftv  res,
leftv  u,
leftv  v,
leftv  w 
)

Definition at line 4513 of file ipshell.cc.

4514{
4515 semicState state;
4516 BOOLEAN qh=(((int)(long)w->Data())==1);
4517
4518 // -----------------
4519 // check arguments
4520 // -----------------
4521
4522 lists l1 = (lists)u->Data( );
4523 lists l2 = (lists)v->Data( );
4524
4525 if( (state=list_is_spectrum( l1 ))!=semicOK )
4526 {
4527 WerrorS( "first argument is not a spectrum" );
4528 list_error( state );
4529 }
4530 else if( (state=list_is_spectrum( l2 ))!=semicOK )
4531 {
4532 WerrorS( "second argument is not a spectrum" );
4533 list_error( state );
4534 }
4535 else
4536 {
4537 spectrum s1= spectrumFromList( l1 );
4538 spectrum s2= spectrumFromList( l2 );
4539
4540 res->rtyp = INT_CMD;
4541 if (qh)
4542 res->data = (void*)(long)(s1.mult_spectrumh( s2 ));
4543 else
4544 res->data = (void*)(long)(s1.mult_spectrum( s2 ));
4545 }
4546
4547 // -----------------
4548 // check status
4549 // -----------------
4550
4551 return (state!=semicOK);
4552}
Definition: semic.h:64
int mult_spectrum(spectrum &)
Definition: semic.cc:396
int mult_spectrumh(spectrum &)
Definition: semic.cc:425
semicState
Definition: ipshell.cc:3437
@ semicOK
Definition: ipshell.cc:3438
void list_error(semicState state)
Definition: ipshell.cc:3470
spectrum spectrumFromList(lists l)
Definition: ipshell.cc:3386
semicState list_is_spectrum(lists l)
Definition: ipshell.cc:4255

◆ setOption()

BOOLEAN setOption ( leftv  res,
leftv  v 
)

Definition at line 568 of file misc_ip.cc.

569{
570 const char *n;
571 do
572 {
573 if (v->Typ()==STRING_CMD)
574 {
575 n=(const char *)v->CopyD(STRING_CMD);
576 }
577 else
578 {
579 if (v->name==NULL)
580 return TRUE;
581 if (v->rtyp==0)
582 {
583 n=v->name;
584 v->name=NULL;
585 }
586 else
587 {
588 n=omStrDup(v->name);
589 }
590 }
591
592 int i;
593
594 if(strcmp(n,"get")==0)
595 {
596 intvec *w=new intvec(2);
597 (*w)[0]=si_opt_1;
598 (*w)[1]=si_opt_2;
599 res->rtyp=INTVEC_CMD;
600 res->data=(void *)w;
601 goto okay;
602 }
603 if(strcmp(n,"set")==0)
604 {
605 if((v->next!=NULL)
606 &&(v->next->Typ()==INTVEC_CMD))
607 {
608 v=v->next;
609 intvec *w=(intvec*)v->Data();
610 si_opt_1=(*w)[0];
611 si_opt_2=(*w)[1];
612#if 0
616 ) {
617 si_opt_1 &=~Sy_bit(OPT_INTSTRATEGY);
618 }
619#endif
620 goto okay;
621 }
622 }
623 if(strcmp(n,"none")==0)
624 {
625 si_opt_1=0;
626 si_opt_2=0;
627 goto okay;
628 }
629 for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
630 {
631 if (strcmp(n,optionStruct[i].name)==0)
632 {
633 if (optionStruct[i].setval & validOpts)
634 {
636 // optOldStd disables redthrough
637 if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
639 }
640 else
641 WarnS("cannot set option");
642#if 0
646 ) {
647 test &=~Sy_bit(OPT_INTSTRATEGY);
648 }
649#endif
650 goto okay;
651 }
652 else if ((strncmp(n,"no",2)==0)
653 && (strcmp(n+2,optionStruct[i].name)==0))
654 {
655 if (optionStruct[i].setval & validOpts)
656 {
658 }
659 else
660 WarnS("cannot clear option");
661 goto okay;
662 }
663 }
664 for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
665 {
666 if (strcmp(n,verboseStruct[i].name)==0)
667 {
669 #ifdef YYDEBUG
670 #if YYDEBUG
671 /*debugging the bison grammar --> grammar.cc*/
673 if (BVERBOSE(V_YACC)) yydebug=1;
674 else yydebug=0;
675 #endif
676 #endif
677 goto okay;
678 }
679 else if ((strncmp(n,"no",2)==0)
680 && (strcmp(n+2,verboseStruct[i].name)==0))
681 {
683 #ifdef YYDEBUG
684 #if YYDEBUG
685 /*debugging the bison grammar --> grammar.cc*/
687 if (BVERBOSE(V_YACC)) yydebug=1;
688 else yydebug=0;
689 #endif
690 #endif
691 goto okay;
692 }
693 }
694 Werror("unknown option `%s`",n);
695 okay:
696 if (currRing != NULL)
699 v=v->next;
700 } while (v!=NULL);
701
702 // set global variable to show memory usage
704 else om_sing_opt_show_mem = 0;
705
706 return FALSE;
707}
CanonicalForm test
Definition: cfModGcd.cc:4096
VAR int yydebug
Definition: grammar.cc:1805
unsigned resetval
Definition: ipid.h:154
VAR BITSET validOpts
Definition: kstd1.cc:60
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:538
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:507
int om_sing_opt_show_mem
#define OPT_INTSTRATEGY
Definition: options.h:92
#define TEST_OPT_INTSTRATEGY
Definition: options.h:110
#define V_SHOW_MEM
Definition: options.h:43
#define V_YACC
Definition: options.h:44
#define OPT_REDTHROUGH
Definition: options.h:82
#define TEST_RINGDEP_OPTS
Definition: options.h:100
#define OPT_OLDSTD
Definition: options.h:86
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:548

◆ showOption()

char * showOption ( )

Definition at line 709 of file misc_ip.cc.

710{
711 int i;
712 BITSET tmp;
713
714 StringSetS("//options:");
715 if ((si_opt_1!=0)||(si_opt_2!=0))
716 {
717 tmp=si_opt_1;
718 if(tmp)
719 {
720 for (i=0; optionStruct[i].setval!=0; i++)
721 {
722 if (optionStruct[i].setval & tmp)
723 {
725 tmp &=optionStruct[i].resetval;
726 }
727 }
728 for (i=0; i<32; i++)
729 {
730 if (tmp & Sy_bit(i)) StringAppend(" %d",i);
731 }
732 }
733 tmp=si_opt_2;
734 if (tmp)
735 {
736 for (i=0; verboseStruct[i].setval!=0; i++)
737 {
738 if (verboseStruct[i].setval & tmp)
739 {
741 tmp &=verboseStruct[i].resetval;
742 }
743 }
744 for (i=1; i<32; i++)
745 {
746 if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
747 }
748 }
749 return StringEndS();
750 }
751 StringAppendS(" none");
752 return StringEndS();
753}
#define StringAppend
Definition: emacs.cc:79
void StringAppendS(const char *st)
Definition: reporter.cc:107

◆ singular_example()

void singular_example ( char *  str)

Definition at line 430 of file misc_ip.cc.

431{
432 assume(str!=NULL);
433 char *s=str;
434 while (*s==' ') s++;
435 char *ss=s;
436 while (*ss!='\0') ss++;
437 while (*ss<=' ')
438 {
439 *ss='\0';
440 ss--;
441 }
442 idhdl h=IDROOT->get_level(s,0);
443 if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
444 {
445 char *lib=iiGetLibName(IDPROC(h));
446 if((lib!=NULL)&&(*lib!='\0'))
447 {
448 Print("// proc %s from lib %s\n",s,lib);
450 if (s!=NULL)
451 {
452 if (strlen(s)>5)
453 {
454 iiEStart(s,IDPROC(h));
455 omFree((ADDRESS)s);
456 return;
457 }
458 else omFree((ADDRESS)s);
459 }
460 }
461 }
462 else
463 {
464 char sing_file[MAXPATHLEN];
465 FILE *fd=NULL;
466 char *res_m=feResource('m', 0);
467 if (res_m!=NULL)
468 {
469 snprintf(sing_file,MAXPATHLEN, "%s/%s.sing", res_m, s);
470 fd = feFopen(sing_file, "r");
471 }
472 if (fd != NULL)
473 {
474
475 int old_echo = si_echo;
476 int length, got;
477 char* s;
478
479 fseek(fd, 0, SEEK_END);
480 length = ftell(fd);
481 fseek(fd, 0, SEEK_SET);
482 s = (char*) omAlloc((length+20)*sizeof(char));
483 got = fread(s, sizeof(char), length, fd);
484 fclose(fd);
485 if (got != length)
486 {
487 Werror("Error while reading file %s", sing_file);
488 }
489 else
490 {
491 s[length] = '\0';
492 strcat(s, "\n;return();\n\n");
493 si_echo = 2;
494 iiEStart(s, NULL);
495 si_echo = old_echo;
496 }
497 omFree(s);
498 }
499 else
500 {
501 Werror("no example for %s", str);
502 }
503 }
504}
BOOLEAN iiEStart(char *example, procinfo *pi)
Definition: iplib.cc:754
static char * iiGetLibName(const procinfov pi)
find the library of an proc
Definition: ipshell.h:66
#define SEEK_SET
Definition: mod2.h:115
#define SEEK_END
Definition: mod2.h:111
char * str(leftv arg)
Definition: shared.cc:704
int status int fd
Definition: si_signals.h:59

◆ singular_system()

leftv singular_system ( sleftv  h)

◆ spaddProc()

BOOLEAN spaddProc ( leftv  result,
leftv  first,
leftv  second 
)

Definition at line 4430 of file ipshell.cc.

4431{
4432 semicState state;
4433
4434 // -----------------
4435 // check arguments
4436 // -----------------
4437
4438 lists l1 = (lists)first->Data( );
4439 lists l2 = (lists)second->Data( );
4440
4441 if( (state=list_is_spectrum( l1 )) != semicOK )
4442 {
4443 WerrorS( "first argument is not a spectrum:" );
4444 list_error( state );
4445 }
4446 else if( (state=list_is_spectrum( l2 )) != semicOK )
4447 {
4448 WerrorS( "second argument is not a spectrum:" );
4449 list_error( state );
4450 }
4451 else
4452 {
4453 spectrum s1= spectrumFromList ( l1 );
4454 spectrum s2= spectrumFromList ( l2 );
4455 spectrum sum( s1+s2 );
4456
4457 result->rtyp = LIST_CMD;
4458 result->data = (char*)(getList(sum));
4459 }
4460
4461 return (state!=semicOK);
4462}
lists getList(spectrum &spec)
Definition: ipshell.cc:3398

◆ spectrumfProc()

BOOLEAN spectrumfProc ( leftv  result,
leftv  first 
)

Definition at line 4186 of file ipshell.cc.

4187{
4188 spectrumState state = spectrumOK;
4189
4190 // -------------------
4191 // check consistency
4192 // -------------------
4193
4194 // check for a local polynomial ring
4195
4196 if( currRing->OrdSgn != -1 )
4197 // ?? HS: the test above is also true for k[x][[y]], k[[x]][y]
4198 // or should we use:
4199 //if( !ringIsLocal( ) )
4200 {
4201 WerrorS( "only works for local orderings" );
4202 state = spectrumWrongRing;
4203 }
4204 else if( currRing->qideal != NULL )
4205 {
4206 WerrorS( "does not work in quotient rings" );
4207 state = spectrumWrongRing;
4208 }
4209 else
4210 {
4211 lists L = (lists)NULL;
4212 int flag = 2; // symmetric optimization
4213
4214 state = spectrumCompute( (poly)first->Data( ),&L,flag );
4215
4216 if( state==spectrumOK )
4217 {
4218 result->rtyp = LIST_CMD;
4219 result->data = (char*)L;
4220 }
4221 else
4222 {
4223 spectrumPrintError(state);
4224 }
4225 }
4226
4227 return (state!=spectrumOK);
4228}
spectrumState
Definition: ipshell.cc:3553
@ spectrumWrongRing
Definition: ipshell.cc:3560
@ spectrumOK
Definition: ipshell.cc:3554
spectrumState spectrumCompute(poly h, lists *L, int fast)
Definition: ipshell.cc:3812
void spectrumPrintError(spectrumState state)
Definition: ipshell.cc:4104

◆ spectrumProc()

BOOLEAN spectrumProc ( leftv  result,
leftv  first 
)

Definition at line 4135 of file ipshell.cc.

4136{
4137 spectrumState state = spectrumOK;
4138
4139 // -------------------
4140 // check consistency
4141 // -------------------
4142
4143 // check for a local ring
4144
4145 if( !ringIsLocal(currRing ) )
4146 {
4147 WerrorS( "only works for local orderings" );
4148 state = spectrumWrongRing;
4149 }
4150
4151 // no quotient rings are allowed
4152
4153 else if( currRing->qideal != NULL )
4154 {
4155 WerrorS( "does not work in quotient rings" );
4156 state = spectrumWrongRing;
4157 }
4158 else
4159 {
4160 lists L = (lists)NULL;
4161 int flag = 1; // weight corner optimization is safe
4162
4163 state = spectrumCompute( (poly)first->Data( ),&L,flag );
4164
4165 if( state==spectrumOK )
4166 {
4167 result->rtyp = LIST_CMD;
4168 result->data = (char*)L;
4169 }
4170 else
4171 {
4172 spectrumPrintError(state);
4173 }
4174 }
4175
4176 return (state!=spectrumOK);
4177}
BOOLEAN ringIsLocal(const ring r)
Definition: spectrum.cc:461

◆ spmulProc()

BOOLEAN spmulProc ( leftv  result,
leftv  first,
leftv  second 
)

Definition at line 4472 of file ipshell.cc.

4473{
4474 semicState state;
4475
4476 // -----------------
4477 // check arguments
4478 // -----------------
4479
4480 lists l = (lists)first->Data( );
4481 int k = (int)(long)second->Data( );
4482
4483 if( (state=list_is_spectrum( l ))!=semicOK )
4484 {
4485 WerrorS( "first argument is not a spectrum" );
4486 list_error( state );
4487 }
4488 else if( k < 0 )
4489 {
4490 WerrorS( "second argument should be positive" );
4491 state = semicMulNegative;
4492 }
4493 else
4494 {
4496 spectrum product( k*s );
4497
4498 result->rtyp = LIST_CMD;
4499 result->data = (char*)getList(product);
4500 }
4501
4502 return (state!=semicOK);
4503}
@ semicMulNegative
Definition: ipshell.cc:3439

◆ syBetti1()

BOOLEAN syBetti1 ( leftv  res,
leftv  u 
)

Definition at line 3172 of file ipshell.cc.

3173{
3174 sleftv tmp;
3175 tmp.Init();
3176 tmp.rtyp=INT_CMD;
3177 tmp.data=(void *)1;
3178 return syBetti2(res,u,&tmp);
3179}
BOOLEAN syBetti2(leftv res, leftv u, leftv w)
Definition: ipshell.cc:3149

◆ syBetti2()

BOOLEAN syBetti2 ( leftv  res,
leftv  u,
leftv  w 
)

Definition at line 3149 of file ipshell.cc.

3150{
3151 syStrategy syzstr=(syStrategy)u->Data();
3152
3153 BOOLEAN minim=(int)(long)w->Data();
3154 int row_shift=0;
3155 int add_row_shift=0;
3156 intvec *weights=NULL;
3157 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3158 if (ww!=NULL)
3159 {
3160 weights=ivCopy(ww);
3161 add_row_shift = ww->min_in();
3162 (*weights) -= add_row_shift;
3163 }
3164
3165 res->data=(void *)syBettiOfComputation(syzstr,minim,&row_shift,weights);
3166 //row_shift += add_row_shift;
3167 //Print("row_shift=%d, add_row_shift=%d\n",row_shift,add_row_shift);
3168 atSet(res,omStrDup("rowShift"),(void*)(long)add_row_shift,INT_CMD);
3169
3170 return FALSE;
3171}
intvec * syBettiOfComputation(syStrategy syzstr, BOOLEAN minim=TRUE, int *row_shift=NULL, intvec *weights=NULL)
Definition: syz1.cc:1755
ssyStrategy * syStrategy
Definition: syz.h:36

◆ syConvList()

syStrategy syConvList ( lists  li)

Definition at line 3256 of file ipshell.cc.

3257{
3258 int typ0;
3260
3261 resolvente fr = liFindRes(li,&(result->length),&typ0,&(result->weights));
3262 if (fr != NULL)
3263 {
3264
3265 result->fullres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
3266 for (int i=result->length-1;i>=0;i--)
3267 {
3268 if (fr[i]!=NULL)
3269 result->fullres[i] = idCopy(fr[i]);
3270 }
3271 result->list_length=result->length;
3272 omFreeSize((ADDRESS)fr,(result->length)*sizeof(ideal));
3273 }
3274 else
3275 {
3276 omFreeSize(result, sizeof(ssyStrategy));
3277 result = NULL;
3278 }
3279 return result;
3280}

◆ syConvRes()

lists syConvRes ( syStrategy  syzstr,
BOOLEAN  toDel = FALSE,
int  add_row_shift = 0 
)

Definition at line 3184 of file ipshell.cc.

3185{
3186 resolvente fullres = syzstr->fullres;
3187 resolvente minres = syzstr->minres;
3188
3189 const int length = syzstr->length;
3190
3191 if ((fullres==NULL) && (minres==NULL))
3192 {
3193 if (syzstr->hilb_coeffs==NULL)
3194 { // La Scala
3195 fullres = syReorder(syzstr->res, length, syzstr);
3196 }
3197 else
3198 { // HRES
3199 minres = syReorder(syzstr->orderedRes, length, syzstr);
3200 syKillEmptyEntres(minres, length);
3201 }
3202 }
3203
3204 resolvente tr;
3205 int typ0=IDEAL_CMD;
3206
3207 if (minres!=NULL)
3208 tr = minres;
3209 else
3210 tr = fullres;
3211
3212 resolvente trueres=NULL;
3213 intvec ** w=NULL;
3214
3215 if (length>0)
3216 {
3217 trueres = (resolvente)omAlloc0((length)*sizeof(ideal));
3218 for (int i=length-1;i>=0;i--)
3219 {
3220 if (tr[i]!=NULL)
3221 {
3222 trueres[i] = idCopy(tr[i]);
3223 }
3224 }
3225 if ( id_RankFreeModule(trueres[0], currRing) > 0)
3226 typ0 = MODUL_CMD;
3227 if (syzstr->weights!=NULL)
3228 {
3229 w = (intvec**)omAlloc0(length*sizeof(intvec*));
3230 for (int i=length-1;i>=0;i--)
3231 {
3232 if (syzstr->weights[i]!=NULL) w[i] = ivCopy(syzstr->weights[i]);
3233 }
3234 }
3235 }
3236
3237 lists li = liMakeResolv(trueres, length, syzstr->list_length,typ0,
3238 w, add_row_shift);
3239
3240 if (toDel)
3241 syKillComputation(syzstr);
3242 else
3243 {
3244 if( fullres != NULL && syzstr->fullres == NULL )
3245 syzstr->fullres = fullres;
3246
3247 if( minres != NULL && syzstr->minres == NULL )
3248 syzstr->minres = minres;
3249 }
3250 return li;
3251}
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
intvec ** hilb_coeffs
Definition: syz.h:46
resolvente minres
Definition: syz.h:58
void syKillComputation(syStrategy syzstr, ring r=currRing)
Definition: syz1.cc:1495
resolvente syReorder(resolvente res, int length, syStrategy syzstr, BOOLEAN toCopy=TRUE, resolvente totake=NULL)
Definition: syz1.cc:1641
void syKillEmptyEntres(resolvente res, int length)
Definition: syz1.cc:2198
short list_length
Definition: syz.h:62
resolvente res
Definition: syz.h:47
resolvente fullres
Definition: syz.h:57
intvec ** weights
Definition: syz.h:45
resolvente orderedRes
Definition: syz.h:48
int length
Definition: syz.h:60

◆ test_cmd()

void test_cmd ( int  i)

Definition at line 514 of file ipshell.cc.

515{
516 int ii;
517
518 if (i<0)
519 {
520 ii= -i;
521 if (ii < 32)
522 {
523 si_opt_1 &= ~Sy_bit(ii);
524 }
525 else if (ii < 64)
526 {
527 si_opt_2 &= ~Sy_bit(ii-32);
528 }
529 else
530 WerrorS("out of bounds\n");
531 }
532 else if (i<32)
533 {
534 ii=i;
535 if (Sy_bit(ii) & kOptions)
536 {
537 WarnS("Gerhard, use the option command");
538 si_opt_1 |= Sy_bit(ii);
539 }
540 else if (Sy_bit(ii) & validOpts)
541 si_opt_1 |= Sy_bit(ii);
542 }
543 else if (i<64)
544 {
545 ii=i-32;
546 si_opt_2 |= Sy_bit(ii);
547 }
548 else
549 WerrorS("out of bounds\n");
550}
VAR BITSET kOptions
Definition: kstd1.cc:45

◆ Tok2Cmdname()

const char * Tok2Cmdname ( int  i)

Definition at line 140 of file gentable.cc.

141{
142 if (tok < 0)
143 {
144 return cmds[0].name;
145 }
146 if (tok==COMMAND) return "command";
147 if (tok==ANY_TYPE) return "any_type";
148 if (tok==NONE) return "nothing";
149 //if (tok==IFBREAK) return "if_break";
150 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
151 //if (tok==ORDER_VECTOR) return "ordering";
152 //if (tok==REF_VAR) return "ref";
153 //if (tok==OBJECT) return "object";
154 //if (tok==PRINT_EXPR) return "print_expr";
155 if (tok==IDHDL) return "identifier";
156 // we do not blackbox objects during table generation:
157 //if (tok>MAX_TOK) return getBlackboxName(tok);
158 int i = 0;
159 while (cmds[i].tokval!=0)
160 {
161 if ((cmds[i].tokval == tok)&&(cmds[i].alias==0))
162 {
163 return cmds[i].name;
164 }
165 i++;
166 }
167 i=0;// try again for old/alias names:
168 while (cmds[i].tokval!=0)
169 {
170 if (cmds[i].tokval == tok)
171 {
172 return cmds[i].name;
173 }
174 i++;
175 }
176 #if 0
177 char *s=(char*)malloc(10);
178 snprintf(s,10,"(%d)",tok);
179 return s;
180 #else
181 return cmds[0].name;
182 #endif
183}
void * malloc(size_t size)
Definition: omalloc.c:85
VAR cmdnames cmds[]
Definition: table.h:994

◆ type_cmd()

void type_cmd ( leftv  v)

Definition at line 254 of file ipshell.cc.

255{
256 BOOLEAN oldShortOut = FALSE;
257
258 if (currRing != NULL)
259 {
260 oldShortOut = currRing->ShortOut;
261 currRing->ShortOut = 1;
262 }
263 int t=v->Typ();
264 Print("// %s %s ",v->Name(),Tok2Cmdname(t));
265 switch (t)
266 {
267 case MAP_CMD:Print(" from %s\n",((map)(v->Data()))->preimage); break;
268 case INTMAT_CMD: Print(" %d x %d\n",((intvec*)(v->Data()))->rows(),
269 ((intvec*)(v->Data()))->cols()); break;
270 case MATRIX_CMD:Print(" %u x %u\n" ,
271 MATROWS((matrix)(v->Data())),
272 MATCOLS((matrix)(v->Data())));break;
273 case MODUL_CMD: Print(", rk %d\n", (int)(((ideal)(v->Data()))->rank));break;
274 case LIST_CMD: Print(", size %d\n",((lists)(v->Data()))->nr+1); break;
275
276 case PROC_CMD:
277 case RING_CMD:
278 case IDEAL_CMD: PrintLn(); break;
279
280 //case INT_CMD:
281 //case STRING_CMD:
282 //case INTVEC_CMD:
283 //case POLY_CMD:
284 //case VECTOR_CMD:
285 //case PACKAGE_CMD:
286
287 default:
288 break;
289 }
290 v->Print();
291 if (currRing != NULL)
292 currRing->ShortOut = oldShortOut;
293}

◆ versionString()

char * versionString ( )

Definition at line 770 of file misc_ip.cc.

771{
772 StringSetS("");
773 StringAppend("Singular for %s version %s (%d, %d bit) %s",
774 S_UNAME, VERSION, // SINGULAR_VERSION,
775 SINGULAR_VERSION, sizeof(void*)*8,
776#ifdef MAKE_DISTRIBUTION
777 VERSION_DATE);
778#else
780#endif
781 StringAppendS("\nwith\n\t");
782
783#if defined(mpir_version)
784 StringAppend("MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
785#elif defined(gmp_version)
786 // #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
787 // StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
788 StringAppend("GMP(%s),", gmp_version);
789#endif
790#ifdef HAVE_NTL
791 StringAppend("NTL(%s),",NTL_VERSION);
792#endif
793
794#ifdef HAVE_FLINT
795 StringAppend("FLINT(%s),",FLINT_VERSION);
796#endif
797// StringAppendS("factory(" FACTORYVERSION "),");
798 StringAppendS("\n\t");
799#ifndef HAVE_OMALLOC
800 StringAppendS("xalloc,");
801#else
802 StringAppendS("omalloc,");
803#endif
804#if defined(HAVE_DYN_RL)
806 StringAppendS("no input,");
807 else if (fe_fgets_stdin==fe_fgets)
808 StringAppendS("fgets,");
810 StringAppend("dynamic readline%d),",RL_VERSION_MAJOR);
811 #ifdef HAVE_FEREAD
813 StringAppendS("emulated readline,");
814 #endif
815 else
816 StringAppendS("unknown fgets method,");
817#else
818 #if defined(HAVE_READLINE) && !defined(FEREAD)
819 StringAppend("static readline(%d),",RL_VERSION_MAJOR);
820 #else
821 #ifdef HAVE_FEREAD
822 StringAppendS("emulated readline,");
823 #else
824 StringAppendS("fgets,");
825 #endif
826 #endif
827#endif
828#ifdef HAVE_PLURAL
829 StringAppendS("Plural,");
830#endif
831#ifdef HAVE_VSPACE
832 #if defined(__GNUC__) && (__GNUC__<9) &&!defined(__clang__)
833 StringAppendS("vspace(1),");
834 #else
835 StringAppendS("vspace(2),");
836 #endif
837#endif
838#ifdef HAVE_DBM
839 StringAppendS("DBM,\n\t");
840#else
841 StringAppendS("\n\t");
842#endif
843#ifdef HAVE_DYNAMIC_LOADING
844 StringAppendS("dynamic modules,");
845#endif
846#ifdef HAVE_DYNANIC_PPROCS
847 StringAppendS("dynamic p_Procs,");
848#endif
849#if YYDEBUG
850 StringAppendS("YYDEBUG=1,");
851#endif
852#ifdef MDEBUG
853 StringAppend("MDEBUG=%d,",MDEBUG);
854#endif
855#ifdef OM_CHECK
856 StringAppend("OM_CHECK=%d,",OM_CHECK);
857#endif
858#ifdef OM_TRACK
859 StringAppend("OM_TRACK=%d,",OM_TRACK);
860#endif
861#ifdef OM_NDEBUG
862 StringAppendS("OM_NDEBUG,");
863#endif
864#ifdef SING_NDEBUG
865 StringAppendS("SING_NDEBUG,");
866#endif
867#ifdef PDEBUG
868 StringAppendS("PDEBUG,");
869#endif
870#ifdef KDEBUG
871 StringAppendS("KDEBUG,");
872#endif
873 StringAppendS("\n\t");
874#ifdef __OPTIMIZE__
875 StringAppendS("CC:OPTIMIZE,");
876#endif
877#ifdef __OPTIMIZE_SIZE__
878 StringAppendS("CC:OPTIMIZE_SIZE,");
879#endif
880#ifdef __NO_INLINE__
881 StringAppendS("CC:NO_INLINE,");
882#endif
883#ifdef HAVE_NTL
884 #ifdef NTL_AVOID_BRANCHING
885 #undef HAVE_GENERIC_ADD
886 #endif
887#endif
888#ifdef HAVE_GENERIC_ADD
889 StringAppendS("GenericAdd,");
890#else
891 StringAppendS("AvoidBranching,");
892#endif
893#ifdef HAVE_GENERIC_MULT
894 StringAppendS("GenericMult,");
895#else
896 StringAppendS("TableMult,");
897#endif
898#ifdef HAVE_INVTABLE
899 StringAppendS("invTable,");
900#else
901 StringAppendS("no invTable,");
902#endif
903 StringAppendS("\n\t");
904#ifdef HAVE_EIGENVAL
905 StringAppendS("eigenvalues,");
906#endif
907#ifdef HAVE_GMS
908 StringAppendS("Gauss-Manin system,");
909#endif
910#ifdef HAVE_RATGRING
911 StringAppendS("ratGB,");
912#endif
913 StringAppend("random=%d\n",siRandomStart);
914
915#define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
916 StringAppendS("built-in modules: {");
918 StringAppendS("}\n");
919#undef SI_SHOW_BUILTIN_MODULE
920
921 StringAppend("AC_CONFIGURE_ARGS = %s,\n"
922 "CC = %s,FLAGS : %s,\n"
923 "CXX = %s,FLAGS : %s,\n"
924 "DEFS : %s,CPPFLAGS : %s,\n"
925 "LDFLAGS : %s,LIBS : %s "
926#ifdef __GNUC__
927 "(ver: " __VERSION__ ")"
928#endif
929 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS " " PTHREAD_CFLAGS,
930 CXX,CXXFLAGS " " PTHREAD_CFLAGS, DEFS,CPPFLAGS, LDFLAGS,
931 LIBS " " PTHREAD_LIBS);
934 StringAppendS("\n");
935 return StringEndS();
936}
#define VERSION
Definition: factoryconf.h:277
char * fe_fgets_dummy(const char *, char *, int)
Definition: feread.cc:455
char * fe_fgets(const char *pr, char *s, int size)
Definition: feread.cc:309
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
Definition: feread.cc:269
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
Definition: feread.cc:253
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
#define SI_SHOW_BUILTIN_MODULE(name)
const char * singular_date
Definition: misc_ip.cc:767
#define MDEBUG
Definition: mod2.h:180
#define OM_TRACK
Definition: omalloc_debug.c:10
#define OM_CHECK
Definition: omalloc_debug.c:15
void feStringAppendResources(int warn)
Definition: reporter.cc:398

Variable Documentation

◆ currid

const char* currid
extern

Definition at line 171 of file grammar.cc.

◆ dArith1

const struct sValCmd1 dArith1[]
extern

Definition at line 37 of file table.h.

◆ dArith2

const struct sValCmd2 dArith2[]
extern

Definition at line 321 of file table.h.

◆ dArith3

const struct sValCmd3 dArith3[]
extern

Definition at line 777 of file table.h.

◆ dArithM

const struct sValCmdM dArithM[]
extern

Definition at line 909 of file table.h.

◆ iiCurrArgs

EXTERN_VAR leftv iiCurrArgs

Definition at line 29 of file ipshell.h.

◆ iiCurrProc

EXTERN_VAR idhdl iiCurrProc

Definition at line 30 of file ipshell.h.

◆ iiLocalRing

EXTERN_VAR ring* iiLocalRing

Definition at line 35 of file ipshell.h.

◆ iiOp

EXTERN_VAR int iiOp

Definition at line 31 of file ipshell.h.

◆ iiRETURNEXPR

EXTERN_INST_VAR sleftv iiRETURNEXPR

Definition at line 34 of file ipshell.h.

◆ iiRETURNEXPR_len

EXTERN_VAR int iiRETURNEXPR_len

Definition at line 33 of file ipshell.h.

◆ lastreserved

const char* lastreserved
extern

Definition at line 82 of file ipshell.cc.

◆ myynest

EXTERN_VAR int myynest

Definition at line 38 of file ipshell.h.

◆ printlevel

EXTERN_VAR int printlevel

Definition at line 39 of file ipshell.h.

◆ si_echo

EXTERN_VAR int si_echo

Definition at line 40 of file ipshell.h.

◆ yyInRingConstruction

EXTERN_VAR BOOLEAN yyInRingConstruction

Definition at line 43 of file ipshell.h.