My Project
Loading...
Searching...
No Matches
ipshell.cc File Reference
#include "kernel/mod2.h"
#include "factory/factory.h"
#include "misc/options.h"
#include "misc/mylimits.h"
#include "misc/intvec.h"
#include "misc/prime.h"
#include "coeffs/numbers.h"
#include "coeffs/coeffs.h"
#include "coeffs/rmodulon.h"
#include "coeffs/longrat.h"
#include "polys/monomials/p_polys.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/maps.h"
#include "polys/prCopy.h"
#include "polys/matpol.h"
#include "polys/shiftop.h"
#include "polys/weight.h"
#include "polys/clapsing.h"
#include "polys/ext_fields/algext.h"
#include "polys/ext_fields/transext.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "kernel/numeric/mpr_base.h"
#include "kernel/numeric/mpr_numeric.h"
#include "kernel/GBEngine/syz.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/combinatorics/hutil.h"
#include "kernel/spectrum/semic.h"
#include "kernel/spectrum/splist.h"
#include "kernel/spectrum/spectrum.h"
#include "kernel/oswrapper/feread.h"
#include "Singular/lists.h"
#include "Singular/attrib.h"
#include "Singular/ipconv.h"
#include "Singular/links/silink.h"
#include "Singular/ipshell.h"
#include "Singular/maps_ip.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "Singular/subexpr.h"
#include "Singular/fevoices.h"
#include "Singular/sdb.h"
#include "Singular/feOpt.h"
#include <cmath>
#include <ctype.h>
#include "kernel/maps/gen_maps.h"
#include "libparse.h"

Go to the source code of this file.

Macros

#define BREAK_LINE_LENGTH   80

Enumerations

enum  semicState {
  semicOK , semicMulNegative , semicListTooShort , semicListTooLong ,
  semicListFirstElementWrongType , semicListSecondElementWrongType , semicListThirdElementWrongType , semicListFourthElementWrongType ,
  semicListFifthElementWrongType , semicListSixthElementWrongType , semicListNNegative , semicListWrongNumberOfNumerators ,
  semicListWrongNumberOfDenominators , semicListWrongNumberOfMultiplicities , semicListMuNegative , semicListPgNegative ,
  semicListNumNegative , semicListDenNegative , semicListMulNegative , semicListNotSymmetric ,
  semicListNotMonotonous , semicListMilnorWrong , semicListPGWrong
}
enum  spectrumState {
  spectrumOK , spectrumZero , spectrumBadPoly , spectrumNoSingularity ,
  spectrumNotIsolated , spectrumDegenerate , spectrumWrongRing , spectrumNoHC ,
  spectrumUnspecErr
}

Functions

const char * iiTwoOps (int t)
int iiOpsTwoChar (const char *s)
static void list1 (const char *s, idhdl h, BOOLEAN c, BOOLEAN fullname)
void type_cmd (leftv v)
static void killlocals0 (int v, idhdl *localhdl, const ring r)
void killlocals_rec (idhdl *root, int v, ring r)
BOOLEAN killlocals_list (int v, lists L)
void killlocals (int v)
void list_cmd (int typ, const char *what, const char *prefix, BOOLEAN iterate, BOOLEAN fullname)
void test_cmd (int i)
int exprlist_length (leftv v)
BOOLEAN iiWRITE (leftv res, leftv v)
leftv iiMap (map theMap, const char *what)
void iiMakeResolv (resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
static resolvente iiCopyRes (resolvente r, int l)
BOOLEAN jjMINRES (leftv res, leftv v)
BOOLEAN jjBETTI (leftv res, leftv u)
BOOLEAN jjBETTI2_ID (leftv res, leftv u, leftv v)
BOOLEAN jjBETTI2 (leftv res, leftv u, leftv v)
int iiRegularity (lists L)
void iiDebug ()
lists scIndIndset (ideal S, BOOLEAN all, ideal Q)
int iiDeclCommand (leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
BOOLEAN iiDefaultParameter (leftv p)
BOOLEAN iiBranchTo (leftv, leftv args)
BOOLEAN iiParameter (leftv p)
static BOOLEAN iiInternalExport (leftv v, int toLev)
BOOLEAN iiInternalExport (leftv v, int toLev, package rootpack)
BOOLEAN iiExport (leftv v, int toLev)
BOOLEAN iiExport (leftv v, int toLev, package pack)
BOOLEAN iiCheckRing (int i)
poly iiHighCorner (ideal I, int ak)
 the largest monomial in R/I
void iiCheckPack (package &p)
idhdl rDefault (const char *s)
static idhdl rSimpleFindHdl (const ring r, const idhdl root, const idhdl n)
idhdl rFindHdl (ring r, idhdl n)
void rDecomposeCF (leftv h, const ring r, const ring R)
static void rDecomposeC_41 (leftv h, const coeffs C)
static void rDecomposeC (leftv h, const ring R)
static void rDecomposeRing_41 (leftv h, const coeffs C)
void rDecomposeRing (leftv h, const ring R)
BOOLEAN rDecompose_CF (leftv res, const coeffs C)
static void rDecompose_23456 (const ring r, lists L)
lists rDecompose_list_cf (const ring r)
lists rDecompose (const ring r)
void rComposeC (lists L, ring R)
void rComposeRing (lists L, ring R)
static void rRenameVars (ring R)
static BOOLEAN rComposeVar (const lists L, ring R)
static BOOLEAN rComposeOrder (const lists L, const BOOLEAN check_comp, ring R)
ring rCompose (const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
BOOLEAN mpJacobi (leftv res, leftv a)
BOOLEAN mpKoszul (leftv res, leftv c, leftv b, leftv id)
BOOLEAN syBetti2 (leftv res, leftv u, leftv w)
BOOLEAN syBetti1 (leftv res, leftv u)
lists syConvRes (syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
syStrategy syConvList (lists li)
BOOLEAN kWeight (leftv res, leftv id)
BOOLEAN kQHWeight (leftv res, leftv v)
BOOLEAN jjRESULTANT (leftv res, leftv u, leftv v, leftv w)
BOOLEAN jjCHARSERIES (leftv res, leftv u)
void copy_deep (spectrum &spec, lists l)
spectrum spectrumFromList (lists l)
lists getList (spectrum &spec)
void list_error (semicState state)
spectrumState spectrumStateFromList (spectrumPolyList &speclist, lists *L, int fast)
spectrumState spectrumCompute (poly h, lists *L, int fast)
void spectrumPrintError (spectrumState state)
BOOLEAN spectrumProc (leftv result, leftv first)
BOOLEAN spectrumfProc (leftv result, leftv first)
semicState list_is_spectrum (lists l)
BOOLEAN spaddProc (leftv result, leftv first, leftv second)
BOOLEAN spmulProc (leftv result, leftv first, leftv second)
BOOLEAN semicProc3 (leftv res, leftv u, leftv v, leftv w)
BOOLEAN semicProc (leftv res, leftv u, leftv v)
BOOLEAN loNewtonP (leftv res, leftv arg1)
 compute Newton Polytopes of input polynomials
BOOLEAN loSimplex (leftv res, leftv args)
 Implementation of the Simplex Algorithm.
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)
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.
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.
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).
lists listOfRoots (rootArranger *self, const unsigned int oprec)
void rSetHdl (idhdl h)
static leftv rOptimizeOrdAsSleftv (leftv ord)
BOOLEAN rSleftvOrdering2Ordering (sleftv *ord, ring R)
static BOOLEAN rSleftvList2StringArray (leftv sl, char **p)
ring rInit (leftv pn, leftv rv, leftv ord)
ring rSubring (ring org_ring, sleftv *rv)
void rKill (ring r)
void rKill (idhdl h)
BOOLEAN jjPROC (leftv res, leftv u, leftv v)
static void jjINT_S_TO_ID (int n, int *e, leftv res)
BOOLEAN jjVARIABLES_P (leftv res, leftv u)
BOOLEAN jjVARIABLES_ID (leftv res, leftv u)
void paPrint (const char *n, package p)
BOOLEAN iiApplyINTVEC (leftv res, leftv a, int op, leftv proc)
BOOLEAN iiApplyBIGINTMAT (leftv, leftv, int, leftv)
BOOLEAN iiApplyIDEAL (leftv, leftv, int, leftv)
BOOLEAN iiApplyLIST (leftv res, leftv a, int op, leftv proc)
BOOLEAN iiApply (leftv res, leftv a, int op, leftv proc)
BOOLEAN iiTestAssume (leftv a, leftv b)
BOOLEAN iiARROW (leftv r, char *a, char *s)
BOOLEAN iiAssignCR (leftv r, leftv arg)
static void iiReportTypes (int nr, int t, const short *T)
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 (and, if report) report an error via Werror otherwise
void iiSetReturn (const leftv source)
int siSetCpus (int cpu)

Variables

VAR leftv iiCurrArgs =NULL
VAR idhdl iiCurrProc =NULL
const char * lastreserved =NULL
STATIC_VAR BOOLEAN iiNoKeepRing =TRUE
VAR BOOLEAN iiDebugMarker =TRUE
const short MAX_SHORT = 32767

Macro Definition Documentation

◆ BREAK_LINE_LENGTH

#define BREAK_LINE_LENGTH   80

Definition at line 1072 of file ipshell.cc.

Enumeration Type Documentation

◆ semicState

enum semicState
Enumerator
semicOK 
semicMulNegative 
semicListTooShort 
semicListTooLong 
semicListFirstElementWrongType 
semicListSecondElementWrongType 
semicListThirdElementWrongType 
semicListFourthElementWrongType 
semicListFifthElementWrongType 
semicListSixthElementWrongType 
semicListNNegative 
semicListWrongNumberOfNumerators 
semicListWrongNumberOfDenominators 
semicListWrongNumberOfMultiplicities 
semicListMuNegative 
semicListPgNegative 
semicListNumNegative 
semicListDenNegative 
semicListMulNegative 
semicListNotSymmetric 
semicListNotMonotonous 
semicListMilnorWrong 
semicListPGWrong 

Definition at line 3436 of file ipshell.cc.

3437{
3438 semicOK,
3440
3443
3450
3455
3461
3464
3467
3468} semicState;
semicState
Definition ipshell.cc:3437
@ semicListWrongNumberOfNumerators
Definition ipshell.cc:3452
@ semicListPGWrong
Definition ipshell.cc:3466
@ semicListFirstElementWrongType
Definition ipshell.cc:3444
@ semicListPgNegative
Definition ipshell.cc:3457
@ semicListSecondElementWrongType
Definition ipshell.cc:3445
@ semicListMilnorWrong
Definition ipshell.cc:3465
@ semicListMulNegative
Definition ipshell.cc:3460
@ semicListFourthElementWrongType
Definition ipshell.cc:3447
@ semicListWrongNumberOfDenominators
Definition ipshell.cc:3453
@ semicListNotMonotonous
Definition ipshell.cc:3463
@ semicListNotSymmetric
Definition ipshell.cc:3462
@ semicListNNegative
Definition ipshell.cc:3451
@ semicListDenNegative
Definition ipshell.cc:3459
@ semicListTooShort
Definition ipshell.cc:3441
@ semicListTooLong
Definition ipshell.cc:3442
@ semicListThirdElementWrongType
Definition ipshell.cc:3446
@ semicListMuNegative
Definition ipshell.cc:3456
@ semicListNumNegative
Definition ipshell.cc:3458
@ semicMulNegative
Definition ipshell.cc:3439
@ semicListWrongNumberOfMultiplicities
Definition ipshell.cc:3454
@ semicOK
Definition ipshell.cc:3438
@ semicListFifthElementWrongType
Definition ipshell.cc:3448
@ semicListSixthElementWrongType
Definition ipshell.cc:3449

◆ spectrumState

Enumerator
spectrumOK 
spectrumZero 
spectrumBadPoly 
spectrumNoSingularity 
spectrumNotIsolated 
spectrumDegenerate 
spectrumWrongRing 
spectrumNoHC 
spectrumUnspecErr 

Definition at line 3552 of file ipshell.cc.

3553{
3554 spectrumOK,
3563};
@ spectrumWrongRing
Definition ipshell.cc:3560
@ spectrumOK
Definition ipshell.cc:3554
@ spectrumDegenerate
Definition ipshell.cc:3559
@ spectrumUnspecErr
Definition ipshell.cc:3562
@ spectrumNotIsolated
Definition ipshell.cc:3558
@ spectrumBadPoly
Definition ipshell.cc:3556
@ spectrumNoSingularity
Definition ipshell.cc:3557
@ spectrumZero
Definition ipshell.cc:3555
@ spectrumNoHC
Definition ipshell.cc:3561

Function Documentation

◆ copy_deep()

void copy_deep ( spectrum & spec,
lists l )

Definition at line 3362 of file ipshell.cc.

3363{
3364 spec.mu = (int)(long)(l->m[0].Data( ));
3365 spec.pg = (int)(long)(l->m[1].Data( ));
3366 spec.n = (int)(long)(l->m[2].Data( ));
3367
3368 spec.copy_new( spec.n );
3369
3370 intvec *num = (intvec*)l->m[3].Data( );
3371 intvec *den = (intvec*)l->m[4].Data( );
3372 intvec *mul = (intvec*)l->m[5].Data( );
3373
3374 for( int i=0; i<spec.n; i++ )
3375 {
3376 spec.s[i] = (Rational)((*num)[i])/(Rational)((*den)[i]);
3377 spec.w[i] = (*mul)[i];
3378 }
3379}
CanonicalForm num(const CanonicalForm &f)
CanonicalForm den(const CanonicalForm &f)
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
int mu
Definition semic.h:67
void copy_new(int)
Definition semic.cc:54
Rational * s
Definition semic.h:70
int n
Definition semic.h:69
int pg
Definition semic.h:68
int * w
Definition semic.h:71

◆ exprlist_length()

int exprlist_length ( leftv v)

Definition at line 551 of file ipshell.cc.

552{
553 int rc = 0;
554 while (v!=NULL)
555 {
556 switch (v->Typ())
557 {
558 case INT_CMD:
559 case POLY_CMD:
560 case VECTOR_CMD:
561 case NUMBER_CMD:
562 rc++;
563 break;
564 case INTVEC_CMD:
565 case INTMAT_CMD:
566 rc += ((intvec *)(v->Data()))->length();
567 break;
568 case MATRIX_CMD:
569 case IDEAL_CMD:
570 case MODUL_CMD:
571 {
572 matrix mm = (matrix)(v->Data());
573 rc += mm->rows() * mm->cols();
574 }
575 break;
576 case LIST_CMD:
577 rc+=((lists)v->Data())->nr+1;
578 break;
579 default:
580 rc++;
581 }
582 v = v->next;
583 }
584 return rc;
585}
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:285
@ MATRIX_CMD
Definition grammar.cc:287
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ VECTOR_CMD
Definition grammar.cc:293
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
ip_smatrix * matrix
Definition matpol.h:43
slists * lists
#define NULL
Definition omList.c:12
@ LIST_CMD
Definition tok.h:118
@ INTVEC_CMD
Definition tok.h:101
@ INT_CMD
Definition tok.h:96

◆ getList()

lists getList ( spectrum & spec)

Definition at line 3398 of file ipshell.cc.

3399{
3401
3402 L->Init( 6 );
3403
3404 intvec *num = new intvec( spec.n );
3405 intvec *den = new intvec( spec.n );
3406 intvec *mult = new intvec( spec.n );
3407
3408 for( int i=0; i<spec.n; i++ )
3409 {
3410 (*num) [i] = spec.s[i].get_num_si( );
3411 (*den) [i] = spec.s[i].get_den_si( );
3412 (*mult)[i] = spec.w[i];
3413 }
3414
3415 L->m[0].rtyp = INT_CMD; // milnor number
3416 L->m[1].rtyp = INT_CMD; // geometrical genus
3417 L->m[2].rtyp = INT_CMD; // # of spectrum numbers
3418 L->m[3].rtyp = INTVEC_CMD; // numerators
3419 L->m[4].rtyp = INTVEC_CMD; // denomiantors
3420 L->m[5].rtyp = INTVEC_CMD; // multiplicities
3421
3422 L->m[0].data = (void*)(long)spec.mu;
3423 L->m[1].data = (void*)(long)spec.pg;
3424 L->m[2].data = (void*)(long)spec.n;
3425 L->m[3].data = (void*)num;
3426 L->m[4].data = (void*)den;
3427 L->m[5].data = (void*)mult;
3428
3429 return L;
3430}
int get_num_si()
Definition GMPrat.cc:138
int get_den_si()
Definition GMPrat.cc:152
int rtyp
Definition subexpr.h:91
void * data
Definition subexpr.h:88
sleftv * m
Definition lists.h:46
INLINE_THIS void Init(int l=0)
VAR omBin slists_bin
Definition lists.cc:23
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647
#define omAllocBin(bin)

◆ iiApply()

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

Definition at line 6431 of file ipshell.cc.

6432{
6433 res->Init();
6434 res->rtyp=a->Typ();
6435 switch (res->rtyp /*a->Typ()*/)
6436 {
6437 case INTVEC_CMD:
6438 case INTMAT_CMD:
6439 return iiApplyINTVEC(res,a,op,proc);
6440 case BIGINTMAT_CMD:
6441 return iiApplyBIGINTMAT(res,a,op,proc);
6442 case IDEAL_CMD:
6443 case MODUL_CMD:
6444 case MATRIX_CMD:
6445 return iiApplyIDEAL(res,a,op,proc);
6446 case LIST_CMD:
6447 return iiApplyLIST(res,a,op,proc);
6448 }
6449 WerrorS("first argument to `apply` must allow an index");
6450 return TRUE;
6451}
#define TRUE
Definition auxiliary.h:101
unsigned char * proc[NUM_PROC]
Definition checklibs.c:16
int Typ()
Definition subexpr.cc:1048
CanonicalForm res
Definition facAbsFact.cc:60
void WerrorS(const char *s)
Definition feFopen.cc:24
@ BIGINTMAT_CMD
Definition grammar.cc:278
BOOLEAN iiApplyINTVEC(leftv res, leftv a, int op, leftv proc)
Definition ipshell.cc:6350
BOOLEAN iiApplyLIST(leftv res, leftv a, int op, leftv proc)
Definition ipshell.cc:6392
BOOLEAN iiApplyIDEAL(leftv, leftv, int, leftv)
Definition ipshell.cc:6387
BOOLEAN iiApplyBIGINTMAT(leftv, leftv, int, leftv)
Definition ipshell.cc:6382

◆ iiApplyBIGINTMAT()

BOOLEAN iiApplyBIGINTMAT ( leftv ,
leftv ,
int ,
leftv  )

Definition at line 6382 of file ipshell.cc.

6383{
6384 WerrorS("not implemented");
6385 return TRUE;
6386}

◆ iiApplyIDEAL()

BOOLEAN iiApplyIDEAL ( leftv ,
leftv ,
int ,
leftv  )

Definition at line 6387 of file ipshell.cc.

6388{
6389 WerrorS("not implemented");
6390 return TRUE;
6391}

◆ iiApplyINTVEC()

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

Definition at line 6350 of file ipshell.cc.

6351{
6352 intvec *aa=(intvec*)a->Data();
6353 sleftv tmp_out;
6354 sleftv tmp_in;
6355 leftv curr=res;
6356 BOOLEAN bo=FALSE;
6357 for(int i=0;i<aa->length(); i++)
6358 {
6359 tmp_in.Init();
6360 tmp_in.rtyp=INT_CMD;
6361 tmp_in.data=(void*)(long)(*aa)[i];
6362 if (proc==NULL)
6363 bo=iiExprArith1(&tmp_out,&tmp_in,op);
6364 else
6365 bo=jjPROC(&tmp_out,proc,&tmp_in);
6366 if (bo)
6367 {
6368 res->CleanUp(currRing);
6369 Werror("apply fails at index %d",i+1);
6370 return TRUE;
6371 }
6372 if (i==0) { memcpy(res,&tmp_out,sizeof(tmp_out)); }
6373 else
6374 {
6376 curr=curr->next;
6377 memcpy(curr,&tmp_out,sizeof(tmp_out));
6378 }
6379 }
6380 return FALSE;
6381}
int BOOLEAN
Definition auxiliary.h:88
#define FALSE
Definition auxiliary.h:97
int length() const
Definition intvec.h:95
Class used for (list of) interpreter objects.
Definition subexpr.h:83
void * Data()
Definition subexpr.cc:1192
void Init()
Definition subexpr.h:107
leftv next
Definition subexpr.h:86
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9367
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition iparith.cc:1617
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
void Werror(const char *fmt,...)
Definition reporter.cc:189
sleftv * leftv
Definition structs.h:53

◆ iiApplyLIST()

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

Definition at line 6392 of file ipshell.cc.

6393{
6394 lists aa=(lists)a->Data();
6395 if (aa->nr==-1) /* empty list*/
6396 {
6398 l->Init();
6399 res->data=(void *)l;
6400 return FALSE;
6401 }
6402 sleftv tmp_out;
6403 sleftv tmp_in;
6404 leftv curr=res;
6405 BOOLEAN bo=FALSE;
6406 for(int i=0;i<=aa->nr; i++)
6407 {
6408 tmp_in.Init();
6409 tmp_in.Copy(&(aa->m[i]));
6410 if (proc==NULL)
6411 bo=iiExprArith1(&tmp_out,&tmp_in,op);
6412 else
6413 bo=jjPROC(&tmp_out,proc,&tmp_in);
6414 tmp_in.CleanUp();
6415 if (bo)
6416 {
6417 res->CleanUp(currRing);
6418 Werror("apply fails at index %d",i+1);
6419 return TRUE;
6420 }
6421 if (i==0) { memcpy(res,&tmp_out,sizeof(tmp_out)); }
6422 else
6423 {
6425 curr=curr->next;
6426 memcpy(curr,&tmp_out,sizeof(tmp_out));
6427 }
6428 }
6429 return FALSE;
6430}
void Copy(leftv e)
Definition subexpr.cc:689
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
int nr
Definition lists.h:44

◆ iiARROW()

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

Definition at line 6480 of file ipshell.cc.

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

◆ iiAssignCR()

BOOLEAN iiAssignCR ( leftv r,
leftv arg )

Definition at line 6515 of file ipshell.cc.

6516{
6517 char* ring_name=omStrDup((char*)r->Name());
6518 int t=arg->Typ();
6519 if (t==RING_CMD)
6520 {
6521 sleftv tmp;
6522 tmp.Init();
6523 tmp.rtyp=IDHDL;
6524 idhdl h=enterid(ring_name, myynest, RING_CMD, &IDROOT);
6525 IDRING(h)=NULL;
6526 tmp.data=(char*)h;
6527 if (h!=NULL)
6528 {
6529 tmp.name=h->id;
6530 BOOLEAN b=iiAssign(&tmp,arg);
6531 if (b) return TRUE;
6532 rSetHdl(ggetid(ring_name));
6533 omFree(ring_name);
6534 return FALSE;
6535 }
6536 else
6537 return TRUE;
6538 }
6539 else if (t==CRING_CMD)
6540 {
6541 sleftv tmp;
6542 sleftv n;
6543 n.Init();
6544 n.name=ring_name;
6545 if (iiDeclCommand(&tmp,&n,myynest,CRING_CMD,&IDROOT)) return TRUE;
6546 if (iiAssign(&tmp,arg)) return TRUE;
6547 //Print("create %s\n",r->Name());
6548 //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6549 return FALSE;
6550 }
6551 //Print("create %s\n",r->Name());
6552 //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6553 return TRUE;// not handled -> error for now
6554}
CanonicalForm b
Definition cfModGcd.cc:4111
const char * name
Definition subexpr.h:87
const char * Name()
Definition subexpr.h:120
VAR int myynest
Definition febase.cc:41
@ RING_CMD
Definition grammar.cc:282
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2099
idhdl ggetid(const char *n)
Definition ipid.cc:558
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:256
#define IDROOT
Definition ipid.h:19
#define IDRING(a)
Definition ipid.h:127
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition ipshell.cc:1206
void rSetHdl(idhdl h)
Definition ipshell.cc:5129
STATIC_VAR Poly * h
Definition janet.cc:971
#define omStrDup(s)
idrec * idhdl
Definition ring.h:22
#define IDHDL
Definition tok.h:31
@ CRING_CMD
Definition tok.h:56

◆ iiBranchTo()

BOOLEAN iiBranchTo ( leftv r,
leftv args )

Definition at line 1281 of file ipshell.cc.

1282{
1283 // must be inside a proc, as we simultae an proc_end at the end
1284 if (myynest==0)
1285 {
1286 WerrorS("branchTo can only occur in a proc");
1287 return TRUE;
1288 }
1289 // <string1...stringN>,<proc>
1290 // known: args!=NULL, l>=1
1291 int l=args->listLength();
1292 int ll=0;
1293 if (iiCurrArgs!=NULL) ll=iiCurrArgs->listLength();
1294 if (ll!=(l-1)) return FALSE;
1295 leftv h=args;
1296 // set up the table for type test:
1297 short *t=(short*)omAlloc(l*sizeof(short));
1298 t[0]=l-1;
1299 int b;
1300 int i;
1301 for(i=1;i<l;i++,h=h->next)
1302 {
1303 if (h->Typ()!=STRING_CMD)
1304 {
1305 omFreeBinAddr(t);
1306 Werror("arg %d is not a string",i);
1307 return TRUE;
1308 }
1309 int tt;
1310 b=IsCmd((char *)h->Data(),tt);
1311 if(b) t[i]=tt;
1312 else
1313 {
1314 omFreeBinAddr(t);
1315 Werror("arg %d is not a type name",i);
1316 return TRUE;
1317 }
1318 }
1319 if (h->Typ()!=PROC_CMD)
1320 {
1321 omFreeBinAddr(t);
1322 Werror("last(%d.) arg.(%s) is not a proc(but %s(%d)), nesting=%d",
1323 i,h->name,Tok2Cmdname(h->Typ()),h->Typ(),myynest);
1324 return TRUE;
1325 }
1327 omFreeBinAddr(t);
1328 if (b && (h->rtyp==IDHDL) && (h->e==NULL))
1329 {
1330 // get the proc:
1331 iiCurrProc=(idhdl)h->data;
1332 idhdl currProc=iiCurrProc; /*iiCurrProc may be changed after yyparse*/
1333 procinfo * pi=IDPROC(currProc);
1334 // already loaded ?
1335 if( pi->data.s.body==NULL )
1336 {
1338 if (pi->data.s.body==NULL) return TRUE;
1339 }
1340 // set currPackHdl/currPack
1341 if ((pi->pack!=NULL)&&(currPack!=pi->pack))
1342 {
1343 currPack=pi->pack;
1346 //Print("set pack=%s\n",IDID(currPackHdl));
1347 }
1348 // see iiAllStart:
1349 BITSET save1=si_opt_1;
1350 BITSET save2=si_opt_2;
1351 newBuffer( omStrDup(pi->data.s.body), BT_proc,
1352 pi, pi->data.s.body_lineno-(iiCurrArgs==NULL) );
1353 BOOLEAN err=yyparse();
1355 si_opt_1=save1;
1356 si_opt_2=save2;
1357 // now save the return-expr.
1358 sLastPrinted.CleanUp(currRing);
1359 memcpy(&sLastPrinted,&iiRETURNEXPR,sizeof(sleftv));
1360 iiRETURNEXPR.Init();
1361 // warning about args.:
1362 if (iiCurrArgs!=NULL)
1363 {
1364 if (err==0) Warn("too many arguments for %s",IDID(currProc));
1365 iiCurrArgs->CleanUp();
1368 }
1369 // similate proc_end:
1370 // - leave input
1371 void myychangebuffer();
1373 // - set the current buffer to its end (this is a pointer in a buffer,
1374 // not a file ptr) "branchTo" is only valid in proc)
1375 currentVoice->fptr=strlen(currentVoice->buffer);
1376 // - kill local vars
1378 // - return
1379 newBuffer(omStrDup("\n;return(_);\n"),BT_execute);
1380 return (err!=0);
1381 }
1382 return FALSE;
1383}
#define BITSET
Definition auxiliary.h:85
void * ADDRESS
Definition auxiliary.h:120
int listLength()
Definition subexpr.cc:51
#define Warn
Definition emacs.cc:77
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
VAR Voice * currentVoice
Definition fevoices.cc:49
@ BT_execute
Definition fevoices.h:23
@ BT_proc
Definition fevoices.h:20
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
int yyparse(void)
Definition grammar.cc:2149
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9775
VAR package currPack
Definition ipid.cc:55
VAR idhdl currPackHdl
Definition ipid.cc:53
idhdl packFindHdl(package r)
Definition ipid.cc:805
#define IDPROC(a)
Definition ipid.h:140
#define IDID(a)
Definition ipid.h:122
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:483
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition iplib.cc:197
VAR idhdl iiCurrProc
Definition ipshell.cc:82
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:6576
void killlocals(int v)
Definition ipshell.cc:387
VAR leftv iiCurrArgs
Definition ipshell.cc:81
#define pi
Definition libparse.cc:1145
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
void myychangebuffer()
Definition scanner.cc:2311
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
@ STRING_CMD
Definition tok.h:187

◆ 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}
int p
Definition cfModGcd.cc:4086
idhdl next
Definition idrec.h:38
#define WarnS
Definition emacs.cc:78
VAR package basePack
Definition ipid.cc:56
#define IDPACKAGE(a)
Definition ipid.h:139
#define IDTYP(a)
Definition ipid.h:119
@ PACKAGE_CMD
Definition tok.h:150

◆ iiCheckRing()

BOOLEAN iiCheckRing ( int i)

Definition at line 1585 of file ipshell.cc.

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

◆ iiCheckTypes()

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

check a list of arguemys against a given field of types return TRUE if the types match return FALSE (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 6576 of file ipshell.cc.

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

◆ iiCopyRes()

resolvente iiCopyRes ( resolvente r,
int l )
static

Definition at line 944 of file ipshell.cc.

945{
946 int i;
947 resolvente res=(ideal *)omAlloc0((l+1)*sizeof(ideal));
948
949 for (i=0; i<l; i++)
950 if (r[i]!=NULL) res[i]=idCopy(r[i]);
951 return res;
952}
ideal idCopy(ideal A)
Definition ideals.h:60
ideal * resolvente
Definition ideals.h:18
#define omAlloc0(size)

◆ iiDebug()

void iiDebug ( )

Definition at line 1073 of file ipshell.cc.

1074{
1075#ifdef HAVE_SDB
1076 sdb_flags=1;
1077#endif
1078 Print("\n-- break point in %s --\n",VoiceName());
1080 char * s;
1082 s = (char *)omAlloc(BREAK_LINE_LENGTH+4);
1083 loop
1084 {
1085 memset(s,0,BREAK_LINE_LENGTH+4);
1087 if (s[BREAK_LINE_LENGTH-1]!='\0')
1088 {
1089 Print("line too long, max is %d chars\n",BREAK_LINE_LENGTH);
1090 }
1091 else
1092 break;
1093 }
1094 if (*s=='\n')
1095 {
1097 }
1098#if MDEBUG
1099 else if(strncmp(s,"cont;",5)==0)
1100 {
1102 }
1103#endif /* MDEBUG */
1104 else
1105 {
1106 strcat( s, "\n;~\n");
1108 }
1109}
#define Print
Definition emacs.cc:80
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition feread.cc:32
const char * VoiceName()
Definition fevoices.cc:58
void VoiceBackTrack()
Definition fevoices.cc:77
VAR BOOLEAN iiDebugMarker
Definition ipshell.cc:1071
#define BREAK_LINE_LENGTH
Definition ipshell.cc:1072
VAR int sdb_flags
Definition sdb.cc:31
#define loop
Definition structs.h:71

◆ iiDeclCommand()

int iiDeclCommand ( leftv sy,
leftv name,
int lev,
int t,
idhdl * root,
BOOLEAN isring,
BOOLEAN init_b )

Definition at line 1206 of file ipshell.cc.

1207{
1209 BOOLEAN is_qring=FALSE;
1210 const char *id = name->name;
1211
1212 sy->Init();
1213 if ((name->name==NULL)||(isdigit(name->name[0])))
1214 {
1215 WerrorS("object to declare is not a name");
1216 res=TRUE;
1217 }
1218 else
1219 {
1220 if (root==NULL) return TRUE;
1221 if (*root!=IDROOT)
1222 {
1223 if ((currRing==NULL) || (*root!=currRing->idroot))
1224 {
1225 Werror("can not define `%s` in other package",name->name);
1226 return TRUE;
1227 }
1228 }
1229 if (t==QRING_CMD)
1230 {
1231 t=RING_CMD; // qring is always RING_CMD
1232 is_qring=TRUE;
1233 }
1234
1235 if (TEST_V_ALLWARN
1236 && (name->rtyp!=0)
1237 && (name->rtyp!=IDHDL)
1239 {
1240 Warn("`%s` is %s in %s:%d:%s",name->name,Tok2Cmdname(name->rtyp),
1242 }
1243 {
1244 sy->data = (char *)enterid(id,lev,t,root,init_b);
1245 }
1246 if (sy->data!=NULL)
1247 {
1248 sy->rtyp=IDHDL;
1249 currid=sy->name=IDID((idhdl)sy->data);
1250 if (is_qring)
1251 {
1253 }
1254 // name->name=NULL; /* used in enterid */
1255 //sy->e = NULL;
1256 if (name->next!=NULL)
1257 {
1259 res=iiDeclCommand(sy->next,name->next,lev,t,root, isring);
1260 }
1261 }
1262 else res=TRUE;
1263 }
1264 name->CleanUp();
1265 return res;
1266}
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
VAR idhdl currRingHdl
Definition ipid.cc:57
#define IDFLAG(a)
Definition ipid.h:120
#define FLAG_QRING_DEF
Definition ipid.h:109
#define IDLEV(a)
Definition ipid.h:121
#define TEST_V_ALLWARN
Definition options.h:145
#define Sy_bit(x)
Definition options.h:31
@ QRING_CMD
Definition tok.h:160

◆ iiDefaultParameter()

BOOLEAN iiDefaultParameter ( leftv p)

Definition at line 1268 of file ipshell.cc.

1269{
1270 attr at=NULL;
1271 if (iiCurrProc!=NULL)
1272 at=iiCurrProc->attribute->get("default_arg");
1273 if (at==NULL)
1274 return FALSE;
1275 sleftv tmp;
1276 tmp.Init();
1277 tmp.rtyp=at->atyp;
1278 tmp.data=at->CopyA();
1279 return iiAssign(p,&tmp);
1280}
sattr * attr
Definition attrib.h:16
void * CopyA()
Definition subexpr.cc:2192
int atyp
Definition attrib.h:27

◆ iiExport() [1/2]

BOOLEAN iiExport ( leftv v,
int toLev )

Definition at line 1510 of file ipshell.cc.

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

◆ iiExport() [2/2]

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

Definition at line 1533 of file ipshell.cc.

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

◆ iiHighCorner()

poly iiHighCorner ( ideal I,
int ak )

the largest monomial in R/I

Definition at line 1606 of file ipshell.cc.

1607{
1608 int i;
1609 if(!idIsZeroDim(I)) return NULL; // not zero-dim.
1610 poly po=NULL;
1612 {
1613 scComputeHC(I,currRing->qideal,ak,po);
1614 if (po!=NULL)
1615 {
1616 pGetCoeff(po)=nInit(1);
1617 for (i=rVar(currRing); i>0; i--)
1618 {
1619 int e;
1620 if ((e=pGetExp(po, i)) > 0) pSetExp(po,i,e-1);
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:1074
static BOOLEAN idIsZeroDim(ideal i)
Definition ideals.h:180
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:272
#define pSetComp(p, v)
Definition polys.h:39
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pSetExp(p, i, v)
Definition polys.h:43
#define pOne()
Definition polys.h:316
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:774
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603

◆ iiInternalExport() [1/2]

BOOLEAN iiInternalExport ( leftv v,
int toLev )
static

Definition at line 1411 of file ipshell.cc.

1412{
1413 idhdl h=(idhdl)v->data;
1414 //Print("iiInternalExport('%s',%d)%s\n", v->name, toLev,"");
1415 if (IDLEV(h)==0)
1416 {
1417 if ((myynest>0) && (BVERBOSE(V_REDEFINE))) Warn("`%s` is already global",IDID(h));
1418 }
1419 else
1420 {
1421 h=IDROOT->get(v->name,toLev);
1422 idhdl *root=&IDROOT;
1423 if ((h==NULL)&&(currRing!=NULL))
1424 {
1425 h=currRing->idroot->get(v->name,toLev);
1426 root=&currRing->idroot;
1427 }
1428 BOOLEAN keepring=FALSE;
1429 if ((h!=NULL)&&(IDLEV(h)==toLev))
1430 {
1431 if (IDTYP(h)==v->Typ())
1432 {
1433 if ((IDTYP(h)==RING_CMD)
1434 && (v->Data()==IDDATA(h)))
1435 {
1437 keepring=TRUE;
1438 IDLEV(h)=toLev;
1439 //WarnS("keepring");
1440 return FALSE;
1441 }
1442 if (BVERBOSE(V_REDEFINE))
1443 {
1444 Warn("redefining %s (%s)",IDID(h),my_yylinebuf);
1445 }
1446 if (iiLocalRing[0]==IDRING(h) && (!keepring)) iiLocalRing[0]=NULL;
1447 killhdl2(h,root,currRing);
1448 }
1449 else
1450 {
1451 WerrorS("object with a different type exists");
1452 return TRUE;
1453 }
1454 }
1455 h=(idhdl)v->data;
1456 IDLEV(h)=toLev;
1457 if (keepring) rDecRefCnt(IDRING(h));
1459 //Print("export %s\n",IDID(h));
1460 }
1461 return FALSE;
1462}
#define IDDATA(a)
Definition ipid.h:126
VAR ring * iiLocalRing
Definition iplib.cc:482
STATIC_VAR BOOLEAN iiNoKeepRing
Definition ipshell.cc:85
static ring rIncRefCnt(ring r)
Definition ring.h:854
static void rDecRefCnt(ring r)
Definition ring.h:855

◆ iiInternalExport() [2/2]

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

Definition at line 1464 of file ipshell.cc.

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

◆ iiMakeResolv()

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

Definition at line 854 of file ipshell.cc.

856{
857 lists L=liMakeResolv(r,length,rlen,typ0,weights);
858 int i=0;
859 idhdl h;
860 size_t len=strlen(name)+5;
861 char * s=(char *)omAlloc(len);
862
863 while (i<=L->nr)
864 {
865 snprintf(s,len,"%s(%d)",name,i+1);
866 if (i==0)
867 h=enterid(s,myynest,typ0,&(currRing->idroot), FALSE);
868 else
870 if (h!=NULL)
871 {
872 h->data.uideal=(ideal)L->m[i].data;
873 h->attribute=L->m[i].attribute;
874 if (BVERBOSE(V_DEF_RES))
875 Print("//defining: %s as %d-th syzygy module\n",s,i+1);
876 }
877 else
878 {
879 idDelete((ideal *)&(L->m[i].data));
880 Warn("cannot define %s",s);
881 }
882 //L->m[i].data=NULL;
883 //L->m[i].rtyp=0;
884 //L->m[i].attribute=NULL;
885 i++;
886 }
887 omFreeSize((ADDRESS)L->m,(L->nr+1)*sizeof(sleftv));
889 omFreeSize((ADDRESS)s,strlen(name)+5);
890}
attr attribute
Definition subexpr.h:89
#define idDelete(H)
delete an ideal
Definition ideals.h:29
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
lists liMakeResolv(resolvente r, int length, int reallen, int typ0, intvec **weights, int add_row_shift)
Definition lists.cc:239
#define omFreeSize(addr, size)
#define V_DEF_RES
Definition options.h:50

◆ iiMap()

leftv iiMap ( map theMap,
const char * what )

Definition at line 618 of file ipshell.cc.

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

◆ iiOpsTwoChar()

int iiOpsTwoChar ( const char * s)

Definition at line 122 of file ipshell.cc.

123{
124/* not handling: &&, ||, ** */
125 if (s[1]=='\0') return s[0];
126 else if (s[2]!='\0') return 0;
127 switch(s[0])
128 {
129 case '.': if (s[1]=='.') return DOTDOT;
130 else return 0;
131 case ':': if (s[1]==':') return COLONCOLON;
132 else return 0;
133 case '-': if (s[1]=='-') return MINUSMINUS;
134 else return 0;
135 case '+': if (s[1]=='+') return PLUSPLUS;
136 else return 0;
137 case '=': if (s[1]=='=') return EQUAL_EQUAL;
138 else return 0;
139 case '<': if (s[1]=='=') return LE;
140 else if (s[1]=='>') return NOTEQUAL;
141 else return 0;
142 case '>': if (s[1]=='=') return GE;
143 else return 0;
144 case '!': if (s[1]=='=') return NOTEQUAL;
145 else return 0;
146 }
147 return 0;
148}
@ 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 1384 of file ipshell.cc.

1385{
1386 if (iiCurrArgs==NULL)
1387 {
1388 if (strcmp(p->name,"#")==0)
1389 return iiDefaultParameter(p);
1390 Werror("not enough arguments for proc %s",VoiceName());
1391 p->CleanUp();
1392 return TRUE;
1393 }
1395 leftv rest=h->next; /*iiCurrArgs is not NULL here*/
1396 if (strcmp(p->name,"#")==0)
1397 {
1398 rest=NULL;
1399 }
1400 else
1401 {
1402 h->next=NULL;
1403 }
1405 iiCurrArgs=rest; // may be NULL
1406 h->CleanUp();
1408 return res;
1409}
BOOLEAN iiDefaultParameter(leftv p)
Definition ipshell.cc:1268

◆ iiRegularity()

int iiRegularity ( lists L)

Definition at line 1045 of file ipshell.cc.

1046{
1047 int len,reg,typ0;
1048
1049 resolvente r=liFindRes(L,&len,&typ0);
1050
1051 if (r==NULL)
1052 return -2;
1053 intvec *weights=NULL;
1054 int add_row_shift=0;
1055 intvec *ww=(intvec *)atGet(&(L->m[0]),"isHomog",INTVEC_CMD);
1056 if (ww!=NULL)
1057 {
1058 weights=ivCopy(ww);
1059 add_row_shift = ww->min_in();
1060 (*weights) -= add_row_shift;
1061 }
1062 //Print("attr:%x\n",weights);
1063
1064 intvec *dummy=syBetti(r,len,&reg,weights);
1065 if (weights!=NULL) delete weights;
1066 delete dummy;
1067 omFreeSize((ADDRESS)r,len*sizeof(ideal));
1068 return reg+1+add_row_shift;
1069}
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
int min_in()
Definition intvec.h:122
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
resolvente liFindRes(lists L, int *len, int *typ0, intvec ***weights)
Definition lists.cc:344
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition syz.cc:787

◆ iiReportTypes()

void iiReportTypes ( int nr,
int t,
const short * T )
static

Definition at line 6556 of file ipshell.cc.

6557{
6558 char buf[250];
6559 buf[0]='\0';
6560 if (nr==0)
6561 snprintf(buf,250,"wrong length of parameters(%d), expected ",t);
6562 else if (t==0)
6563 snprintf(buf,250,"par. %d is of undefined, expected ",nr);
6564 else
6565 snprintf(buf,250,"par. %d is of type `%s`, expected ",nr,Tok2Cmdname(t));
6566 for(int i=1;i<=T[0];i++)
6567 {
6568 strcat(buf,"`");
6569 strcat(buf,Tok2Cmdname(T[i]));
6570 strcat(buf,"`");
6571 if (i<T[0]) strcat(buf,",");
6572 }
6573 WerrorS(buf);
6574}
STATIC_VAR jList * T
Definition janet.cc:30
int status int void * buf
Definition si_signals.h:69

◆ iiSetReturn()

void iiSetReturn ( const leftv source)

Definition at line 6634 of file ipshell.cc.

6635{
6636 if ((source->next==NULL)&&(source->e==NULL))
6637 {
6638 if ((source->rtyp!=IDHDL)&&(source->rtyp!=ALIAS_CMD))
6639 {
6640 memcpy(&iiRETURNEXPR,source,sizeof(sleftv));
6641 source->Init();
6642 return;
6643 }
6644 if (source->rtyp==IDHDL)
6645 {
6646 if ((IDLEV((idhdl)source->data)==myynest)
6647 &&(IDTYP((idhdl)source->data)!=RING_CMD))
6648 {
6649 iiRETURNEXPR.Init();
6650 iiRETURNEXPR.rtyp=IDTYP((idhdl)source->data);
6651 iiRETURNEXPR.data=IDDATA((idhdl)source->data);
6652 iiRETURNEXPR.flag=IDFLAG((idhdl)source->data);
6653 iiRETURNEXPR.attribute=IDATTR((idhdl)source->data);
6654 IDATTR((idhdl)source->data)=NULL;
6655 IDDATA((idhdl)source->data)=NULL;
6656 source->name=NULL;
6657 source->attribute=NULL;
6658 return;
6659 }
6660 }
6661 }
6662 iiRETURNEXPR.Copy(source);
6663}
Subexpr e
Definition subexpr.h:105
#define IDATTR(a)
Definition ipid.h:123
@ ALIAS_CMD
Definition tok.h:34

◆ iiTestAssume()

BOOLEAN iiTestAssume ( leftv a,
leftv b )

Definition at line 6453 of file ipshell.cc.

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

◆ iiTwoOps()

const char * iiTwoOps ( int t)

Definition at line 89 of file ipshell.cc.

90{
91 if (t<127)
92 {
93 STATIC_VAR char ch[2];
94 switch (t)
95 {
96 case '&':
97 return "and";
98 case '|':
99 return "or";
100 default:
101 ch[0]=t;
102 ch[1]='\0';
103 return ch;
104 }
105 }
106 switch (t)
107 {
108 case COLONCOLON: return "::";
109 case DOTDOT: return "..";
110 //case PLUSEQUAL: return "+=";
111 //case MINUSEQUAL: return "-=";
112 case MINUSMINUS: return "--";
113 case PLUSPLUS: return "++";
114 case EQUAL_EQUAL: return "==";
115 case LE: return "<=";
116 case GE: return ">=";
117 case NOTEQUAL: return "<>";
118 default: return Tok2Cmdname(t);
119 }
120}
#define STATIC_VAR
Definition globaldefs.h:7

◆ iiWRITE()

BOOLEAN iiWRITE ( leftv res,
leftv v )

Definition at line 587 of file ipshell.cc.

588{
589 sleftv vf;
590 if (iiConvert(v->Typ(),LINK_CMD,iiTestConvert(v->Typ(),LINK_CMD),v,&vf))
591 {
592 WerrorS("link expected");
593 return TRUE;
594 }
595 si_link l=(si_link)vf.Data();
596 if (vf.next == NULL)
597 {
598 WerrorS("write: need at least two arguments");
599 return TRUE;
600 }
601
602 BOOLEAN b;
603 if (strcmp(l->mode,"string")==0)
604 b=ssiWrite2(l,res,vf.next);
605 else
606 b=slWrite(l,vf.next); /* iiConvert preserves next */
607 if (b)
608 {
609 const char *s;
610 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
611 else s=sNoName_fe;
612 Werror("cannot write to %s",s);
613 }
614 vf.CleanUp();
615 return b;
616}
const char sNoName_fe[]
Definition fevoices.cc:57
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:298
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:450
@ LINK_CMD
Definition tok.h:117

◆ jjBETTI()

BOOLEAN jjBETTI ( leftv res,
leftv u )

Definition at line 975 of file ipshell.cc.

976{
977 sleftv tmp;
978 tmp.Init();
979 tmp.rtyp=INT_CMD;
980 tmp.data=(void *)1;
981 if ((u->Typ()==IDEAL_CMD)
982 || (u->Typ()==MODUL_CMD))
983 return jjBETTI2_ID(res,u,&tmp);
984 else
985 return jjBETTI2(res,u,&tmp);
986}
BOOLEAN jjBETTI2_ID(leftv res, leftv u, leftv v)
Definition ipshell.cc:988
BOOLEAN jjBETTI2(leftv res, leftv u, leftv v)
Definition ipshell.cc:1009

◆ jjBETTI2()

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

Definition at line 1009 of file ipshell.cc.

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

◆ jjBETTI2_ID()

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

Definition at line 988 of file ipshell.cc.

989{
991 l->Init(1);
992 l->m[0].rtyp=u->Typ();
993 l->m[0].data=u->Data();
994 attr *a=u->Attribute();
995 if (a!=NULL)
996 l->m[0].attribute=*a;
997 sleftv tmp2;
998 tmp2.Init();
999 tmp2.rtyp=LIST_CMD;
1000 tmp2.data=(void *)l;
1002 l->m[0].data=NULL;
1003 l->m[0].attribute=NULL;
1004 l->m[0].rtyp=DEF_CMD;
1005 l->Clean();
1006 return r;
1007}
attr * Attribute()
Definition subexpr.cc:1505
CFList tmp2
Definition facFqBivar.cc:75
@ DEF_CMD
Definition tok.h:58

◆ 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:1614

◆ jjINT_S_TO_ID()

void jjINT_S_TO_ID ( int n,
int * e,
leftv res )
static

Definition at line 6288 of file ipshell.cc.

6289{
6290 if (n==0) n=1;
6291 ideal l=idInit(n,1);
6292 int i;
6293 poly p;
6294 for(i=rVar(currRing);i>0;i--)
6295 {
6296 if (e[i]>0)
6297 {
6298 n--;
6299 p=pOne();
6300 pSetExp(p,i,1);
6301 pSetm(p);
6302 l->m[n]=p;
6303 if (n==0) break;
6304 }
6305 }
6306 res->data=(char*)l;
6308 omFreeSize((ADDRESS)e,(rVar(currRing)+1)*sizeof(int));
6309}
#define setFlag(A, F)
Definition ipid.h:113
#define FLAG_STD
Definition ipid.h:106

◆ jjMINRES()

BOOLEAN jjMINRES ( leftv res,
leftv v )

Definition at line 954 of file ipshell.cc.

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

◆ jjPROC()

BOOLEAN jjPROC ( leftv res,
leftv u,
leftv v )
extern

Definition at line 1617 of file iparith.cc.

1618{
1619 void *d;
1620 Subexpr e;
1621 int typ;
1622 BOOLEAN t=FALSE;
1623 idhdl tmp_proc=NULL;
1624 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1625 {
1626 tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1627 tmp_proc->id="_auto";
1628 tmp_proc->typ=PROC_CMD;
1629 tmp_proc->data.pinf=(procinfo *)u->Data();
1630 tmp_proc->ref=1;
1631 d=u->data; u->data=(void *)tmp_proc;
1632 e=u->e; u->e=NULL;
1633 t=TRUE;
1634 typ=u->rtyp; u->rtyp=IDHDL;
1635 }
1636 BOOLEAN sl;
1637 if (u->req_packhdl==currPack)
1638 sl = iiMake_proc((idhdl)u->data,NULL,v);
1639 else
1640 sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1641 if (t)
1642 {
1643 u->rtyp=typ;
1644 u->data=d;
1645 u->e=e;
1646 omFreeSize(tmp_proc,sizeof(idrec));
1647 }
1648 if (sl) return TRUE;
1649 memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1650 iiRETURNEXPR.Init();
1651 return FALSE;
1652}
Definition idrec.h:35
utypes data
Definition idrec.h:40
short ref
Definition idrec.h:46
const char * id
Definition idrec.h:39
package req_packhdl
Definition subexpr.h:106
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:513

◆ 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:357
void * CopyD(int t)
Definition subexpr.cc:714
VAR short errorreported
Definition feFopen.cc:23

◆ jjVARIABLES_ID()

BOOLEAN jjVARIABLES_ID ( leftv res,
leftv u )

Definition at line 6318 of file ipshell.cc.

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

◆ jjVARIABLES_P()

BOOLEAN jjVARIABLES_P ( leftv res,
leftv u )

Definition at line 6310 of file ipshell.cc.

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

◆ killlocals()

void killlocals ( int v)

Definition at line 387 of file ipshell.cc.

388{
389 BOOLEAN changed=FALSE;
391 ring cr=currRing;
392 if (sh!=NULL) changed=((IDLEV(sh)<v) || (IDRING(sh)->ref>0));
393 //if (changed) Print("currRing=%s(%x), lev=%d,ref=%d\n",IDID(sh),IDRING(sh),IDLEV(sh),IDRING(sh)->ref);
394
395 killlocals_rec(&(basePack->idroot),v,currRing);
396
398 {
399 int t=iiRETURNEXPR.Typ();
400 if (/*iiRETURNEXPR.Typ()*/ t==RING_CMD)
401 {
403 if (((ring)h->data)->idroot!=NULL)
404 killlocals0(v,&(((ring)h->data)->idroot),(ring)h->data);
405 }
406 else if (/*iiRETURNEXPR.Typ()*/ t==LIST_CMD)
407 {
409 changed |=killlocals_list(v,(lists)h->data);
410 }
411 }
412 if (changed)
413 {
415 if (currRingHdl==NULL)
417 else if(cr!=currRing)
418 rChangeCurrRing(cr);
419 }
420
421 if (myynest<=1) iiNoKeepRing=TRUE;
422 //Print("end killlocals >= %d\n",v);
423 //listall();
424}
VAR int iiRETURNEXPR_len
Definition iplib.cc:484
BOOLEAN killlocals_list(int v, lists L)
Definition ipshell.cc:367
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1701
void killlocals_rec(idhdl *root, int v, ring r)
Definition ipshell.cc:331
static void killlocals0(int v, idhdl *localhdl, const ring r)
Definition ipshell.cc:296
void rChangeCurrRing(ring r)
Definition polys.cc:16

◆ killlocals0()

void killlocals0 ( int v,
idhdl * localhdl,
const ring r )
static

Definition at line 296 of file ipshell.cc.

297{
298 idhdl h = *localhdl;
299 while (h!=NULL)
300 {
301 int vv;
302 //Print("consider %s, lev: %d:",IDID(h),IDLEV(h));
303 if ((vv=IDLEV(h))>0)
304 {
305 if (vv < v)
306 {
307 if (iiNoKeepRing)
308 {
309 //PrintS(" break\n");
310 return;
311 }
312 h = IDNEXT(h);
313 //PrintLn();
314 }
315 else //if (vv >= v)
316 {
317 idhdl nexth = IDNEXT(h);
318 killhdl2(h,localhdl,r);
319 h = nexth;
320 //PrintS("kill\n");
321 }
322 }
323 else
324 {
325 h = IDNEXT(h);
326 //PrintLn();
327 }
328 }
329}
#define IDNEXT(a)
Definition ipid.h:118

◆ killlocals_list()

BOOLEAN killlocals_list ( int v,
lists L )

Definition at line 367 of file ipshell.cc.

368{
369 if (L==NULL) return FALSE;
370 BOOLEAN changed=FALSE;
371 int n=L->nr;
372 for(;n>=0;n--)
373 {
374 leftv h=&(L->m[n]);
375 void *d=h->data;
376 if ((h->rtyp==RING_CMD)
377 && (((ring)d)->idroot!=NULL))
378 {
379 if (d!=currRing) {changed=TRUE;rChangeCurrRing((ring)d);}
380 killlocals0(v,&(((ring)h->data)->idroot),(ring)h->data);
381 }
382 else if (h->rtyp==LIST_CMD)
383 changed|=killlocals_list(v,(lists)d);
384 }
385 return changed;
386}

◆ killlocals_rec()

void killlocals_rec ( idhdl * root,
int v,
ring r )

Definition at line 331 of file ipshell.cc.

332{
333 idhdl h=*root;
334 while (h!=NULL)
335 {
336 if (IDLEV(h)>=v)
337 {
338// Print("kill %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
339 idhdl n=IDNEXT(h);
340 killhdl2(h,root,r);
341 h=n;
342 }
343 else if (IDTYP(h)==PACKAGE_CMD)
344 {
345 // Print("into pack %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
346 if (IDPACKAGE(h)!=basePack)
347 killlocals_rec(&(IDRING(h)->idroot),v,r);
348 h=IDNEXT(h);
349 }
350 else if (IDTYP(h)==RING_CMD)
351 {
352 if ((IDRING(h)!=NULL) && (IDRING(h)->idroot!=NULL))
353 // we have to test IDRING(h)!=NULL: qring Q=groebner(...): killlocals
354 {
355 // Print("into ring %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
356 killlocals_rec(&(IDRING(h)->idroot),v,IDRING(h));
357 }
358 h=IDNEXT(h);
359 }
360 else
361 {
362// Print("skip %s lev %d for lev %d\n",IDID(h),IDLEV(h),v);
363 h=IDNEXT(h);
364 }
365 }
366}

◆ 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 3297 of file ipshell.cc.

3298{
3299 ideal F=(ideal)id->Data();
3300 intvec * iv = new intvec(rVar(currRing));
3301 polyset s;
3302 int sl, n, i;
3303 int *x;
3304
3305 res->data=(char *)iv;
3306 s = F->m;
3307 sl = IDELEMS(F) - 1;
3308 n = rVar(currRing);
3309 if (sl==-1)
3310 {
3311 for(int i=0;i<n;i++) (*iv)[i]=1;
3312 return FALSE;
3313 }
3314
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:4090
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

◆ list1()

void list1 ( const char * s,
idhdl h,
BOOLEAN c,
BOOLEAN fullname )
static

Definition at line 150 of file ipshell.cc.

151{
152 char buffer[22];
153 int l;
154 char buf2[128];
155
156 if(fullname) snprintf(buf2,128, "%s::%s", "", IDID(h));
157 else snprintf(buf2,128, "%s", IDID(h));
158
159 Print("%s%-30.30s [%d] ",s,buf2,IDLEV(h));
160 if (h == currRingHdl) PrintS("*");
161 PrintS(Tok2Cmdname((int)IDTYP(h)));
162
163 ipListFlag(h);
164 switch(IDTYP(h))
165 {
166 case ALIAS_CMD: Print(" for %s",IDID((idhdl)IDDATA(h))); break;
167 case INT_CMD: Print(" %d",IDINT(h)); break;
168 case INTVEC_CMD:Print(" (%d)",IDINTVEC(h)->length()); break;
169 case INTMAT_CMD:Print(" %d x %d",IDINTVEC(h)->rows(),IDINTVEC(h)->cols());
170 break;
171 case POLY_CMD:
172 case VECTOR_CMD:if (c)
173 {
174 PrintS(" ");wrp(IDPOLY(h));
175 if(IDPOLY(h) != NULL)
176 {
177 Print(", %d monomial(s)",pLength(IDPOLY(h)));
178 }
179 }
180 break;
181 case MODUL_CMD: Print(", rk %d", (int)(IDIDEAL(h)->rank));// and continue
182 case IDEAL_CMD: Print(", %u generator(s)",
183 IDELEMS(IDIDEAL(h))); break;
184 case MAP_CMD:
185 Print(" from %s",IDMAP(h)->preimage); break;
186 case MATRIX_CMD:Print(" %u x %u"
189 );
190 break;
191 case SMATRIX_CMD:Print(" %u x %u"
192 ,(int)(IDIDEAL(h)->rank)
193 ,IDELEMS(IDIDEAL(h))
194 );
195 break;
196 case PACKAGE_CMD:
198 break;
199 case PROC_CMD: if((IDPROC(h)->libname!=NULL)
200 && (strlen(IDPROC(h)->libname)>0))
201 Print(" from %s",IDPROC(h)->libname);
202 if(IDPROC(h)->language==LANG_C)
203 PrintS(" (C)");
204 if(IDPROC(h)->is_static)
205 PrintS(" (static)");
206 break;
207 case STRING_CMD:
208 {
209 char *s;
210 l=strlen(IDSTRING(h));
211 memset(buffer,0,sizeof(buffer));
212 strncpy(buffer,IDSTRING(h),si_min(l,20));
213 if ((s=strchr(buffer,'\n'))!=NULL)
214 {
215 *s='\0';
216 }
217 PrintS(" ");
218 PrintS(buffer);
219 if((s!=NULL) ||(l>20))
220 {
221 Print("..., %d char(s)",l);
222 }
223 break;
224 }
225 case LIST_CMD: Print(", size: %d",IDLIST(h)->nr+1);
226 break;
227 case RING_CMD:
228 if ((IDRING(h)==currRing) && (currRingHdl!=h))
229 PrintS("(*)"); /* this is an alias to currRing */
230 //Print(" ref:%d",IDRING(h)->ref);
231#ifdef RDEBUG
233 Print(" <%lx>",(long)(IDRING(h)));
234#endif
235 break;
236#ifdef SINGULAR_4_2
237 case CNUMBER_CMD:
238 { number2 n=(number2)IDDATA(h);
239 Print(" (%s)",nCoeffName(n->cf));
240 break;
241 }
242 case CMATRIX_CMD:
244 Print(" %d x %d (%s)",
245 b->rows(),b->cols(),
246 nCoeffName(b->basecoeffs()));
247 break;
248 }
249#endif
250 /*default: break;*/
251 }
252 PrintLn();
253}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
Matrices of numbers.
Definition bigintmat.h:51
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:965
CanonicalForm buf2
Definition facFqBivar.cc:76
void ipListFlag(idhdl h)
Definition ipid.cc:596
#define IDMATRIX(a)
Definition ipid.h:134
#define IDSTRING(a)
Definition ipid.h:136
#define IDINTVEC(a)
Definition ipid.h:128
#define IDPOLY(a)
Definition ipid.h:130
void paPrint(const char *n, package p)
Definition ipshell.cc:6333
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
static int pLength(poly a)
Definition p_polys.h:190
void wrp(poly p)
Definition polys.h:311
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_SHOW_RINGS
Definition reporter.h:36
@ LANG_C
Definition subexpr.h:22
@ CMATRIX_CMD
Definition tok.h:46
@ CNUMBER_CMD
Definition tok.h:47

◆ list_cmd()

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

Definition at line 426 of file ipshell.cc.

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

◆ list_error()

void list_error ( semicState state)

Definition at line 3470 of file ipshell.cc.

3471{
3472 switch( state )
3473 {
3474 case semicListTooShort:
3475 WerrorS( "the list is too short" );
3476 break;
3477 case semicListTooLong:
3478 WerrorS( "the list is too long" );
3479 break;
3480
3482 WerrorS( "first element of the list should be int" );
3483 break;
3485 WerrorS( "second element of the list should be int" );
3486 break;
3488 WerrorS( "third element of the list should be int" );
3489 break;
3491 WerrorS( "fourth element of the list should be intvec" );
3492 break;
3494 WerrorS( "fifth element of the list should be intvec" );
3495 break;
3497 WerrorS( "sixth element of the list should be intvec" );
3498 break;
3499
3500 case semicListNNegative:
3501 WerrorS( "first element of the list should be positive" );
3502 break;
3504 WerrorS( "wrong number of numerators" );
3505 break;
3507 WerrorS( "wrong number of denominators" );
3508 break;
3510 WerrorS( "wrong number of multiplicities" );
3511 break;
3512
3514 WerrorS( "the Milnor number should be positive" );
3515 break;
3517 WerrorS( "the geometrical genus should be nonnegative" );
3518 break;
3520 WerrorS( "all numerators should be positive" );
3521 break;
3523 WerrorS( "all denominators should be positive" );
3524 break;
3526 WerrorS( "all multiplicities should be positive" );
3527 break;
3528
3530 WerrorS( "it is not symmetric" );
3531 break;
3533 WerrorS( "it is not monotonous" );
3534 break;
3535
3537 WerrorS( "the Milnor number is wrong" );
3538 break;
3539 case semicListPGWrong:
3540 WerrorS( "the geometrical genus is wrong" );
3541 break;
3542
3543 default:
3544 WerrorS( "unspecific error" );
3545 break;
3546 }
3547}

◆ list_is_spectrum()

semicState list_is_spectrum ( lists l)

Definition at line 4256 of file ipshell.cc.

4257{
4258 // -------------------
4259 // check list length
4260 // -------------------
4261
4262 if( l->nr < 5 )
4263 {
4264 return semicListTooShort;
4265 }
4266 else if( l->nr > 5 )
4267 {
4268 return semicListTooLong;
4269 }
4270
4271 // -------------
4272 // check types
4273 // -------------
4274
4275 if( l->m[0].rtyp != INT_CMD )
4276 {
4278 }
4279 else if( l->m[1].rtyp != INT_CMD )
4280 {
4282 }
4283 else if( l->m[2].rtyp != INT_CMD )
4284 {
4286 }
4287 else if( l->m[3].rtyp != INTVEC_CMD )
4288 {
4290 }
4291 else if( l->m[4].rtyp != INTVEC_CMD )
4292 {
4294 }
4295 else if( l->m[5].rtyp != INTVEC_CMD )
4296 {
4298 }
4299
4300 // -------------------------
4301 // check number of entries
4302 // -------------------------
4303
4304 int mu = (int)(long)(l->m[0].Data( ));
4305 int pg = (int)(long)(l->m[1].Data( ));
4306 int n = (int)(long)(l->m[2].Data( ));
4307
4308 if( n <= 0 )
4309 {
4310 return semicListNNegative;
4311 }
4312
4313 intvec *num = (intvec*)l->m[3].Data( );
4314 intvec *den = (intvec*)l->m[4].Data( );
4315 intvec *mul = (intvec*)l->m[5].Data( );
4316
4317 if( n != num->length( ) )
4318 {
4320 }
4321 else if( n != den->length( ) )
4322 {
4324 }
4325 else if( n != mul->length( ) )
4326 {
4328 }
4329
4330 // --------
4331 // values
4332 // --------
4333
4334 if( mu <= 0 )
4335 {
4336 return semicListMuNegative;
4337 }
4338 if( pg < 0 )
4339 {
4340 return semicListPgNegative;
4341 }
4342
4343 int i;
4344
4345 for( i=0; i<n; i++ )
4346 {
4347 if( (*num)[i] <= 0 )
4348 {
4349 return semicListNumNegative;
4350 }
4351 if( (*den)[i] <= 0 )
4352 {
4353 return semicListDenNegative;
4354 }
4355 if( (*mul)[i] <= 0 )
4356 {
4357 return semicListMulNegative;
4358 }
4359 }
4360
4361 // ----------------
4362 // check symmetry
4363 // ----------------
4364
4365 int j;
4366
4367 for( i=0, j=n-1; i<=j; i++,j-- )
4368 {
4369 if( (*num)[i] != rVar(currRing)*((*den)[i]) - (*num)[j] ||
4370 (*den)[i] != (*den)[j] ||
4371 (*mul)[i] != (*mul)[j] )
4372 {
4373 return semicListNotSymmetric;
4374 }
4375 }
4376
4377 // ----------------
4378 // check monotony
4379 // ----------------
4380
4381 for( i=0, j=1; i<n/2; i++,j++ )
4382 {
4383 if( (*num)[i]*(*den)[j] >= (*num)[j]*(*den)[i] )
4384 {
4386 }
4387 }
4388
4389 // ---------------------
4390 // check Milnor number
4391 // ---------------------
4392
4393 for( mu=0, i=0; i<n; i++ )
4394 {
4395 mu += (*mul)[i];
4396 }
4397
4398 if( mu != (int)(long)(l->m[0].Data( )) )
4399 {
4400 return semicListMilnorWrong;
4401 }
4402
4403 // -------------------------
4404 // check geometrical genus
4405 // -------------------------
4406
4407 for( pg=0, i=0; i<n; i++ )
4408 {
4409 if( (*num)[i]<=(*den)[i] )
4410 {
4411 pg += (*mul)[i];
4412 }
4413 }
4414
4415 if( pg != (int)(long)(l->m[1].Data( )) )
4416 {
4417 return semicListPGWrong;
4418 }
4419
4420 return semicOK;
4421}
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028

◆ listOfRoots()

lists listOfRoots ( rootArranger * self,
const unsigned int oprec )

Definition at line 5082 of file ipshell.cc.

5083{
5084 int i,j;
5085 int count= self->roots[0]->getAnzRoots(); // number of roots
5086 int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5087
5088 lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5089
5090 if ( self->found_roots )
5091 {
5092 listofroots->Init( count );
5093
5094 for (i=0; i < count; i++)
5095 {
5096 lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5097 onepoint->Init(elem);
5098 for ( j= 0; j < elem; j++ )
5099 {
5100 if ( !rField_is_long_C(currRing) )
5101 {
5102 onepoint->m[j].rtyp=STRING_CMD;
5103 onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5104 }
5105 else
5106 {
5107 onepoint->m[j].rtyp=NUMBER_CMD;
5108 onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5109 }
5110 onepoint->m[j].next= NULL;
5111 onepoint->m[j].name= NULL;
5112 }
5113 listofroots->m[i].rtyp=LIST_CMD;
5114 listofroots->m[i].data=(void *)onepoint;
5115 listofroots->m[j].next= NULL;
5116 listofroots->m[j].name= NULL;
5117 }
5118
5119 }
5120 else
5121 {
5122 listofroots->Init( 0 );
5123 }
5124
5125 return listofroots;
5126}
rootContainer ** roots
gmp_complex * getRoot(const int i)
Definition mpr_numeric.h:88
int getAnzRoots()
Definition mpr_numeric.h:97
int getAnzElems()
Definition mpr_numeric.h:95
Definition lists.h:24
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
static BOOLEAN rField_is_long_C(const ring r)
Definition ring.h:556
int status int void size_t count
Definition si_signals.h:69

◆ loNewtonP()

BOOLEAN loNewtonP ( leftv res,
leftv arg1 )

compute Newton Polytopes of input polynomials

Definition at line 4566 of file ipshell.cc.

4567{
4568 res->data= (void*)loNewtonPolytope( (ideal)arg1->Data() );
4569 return FALSE;
4570}
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 4572 of file ipshell.cc.

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

◆ mpJacobi()

BOOLEAN mpJacobi ( leftv res,
leftv a )

Definition at line 3064 of file ipshell.cc.

3065{
3066 int i,j;
3067 matrix result;
3068 ideal id=(ideal)a->Data();
3069
3071 for (i=1; i<=IDELEMS(id); i++)
3072 {
3073 for (j=1; j<=rVar(currRing); j++)
3074 {
3075 MATELEM(result,i,j) = pDiff(id->m[i-1],j);
3076 }
3077 }
3078 res->data=(char *)result;
3079 return FALSE;
3080}
return result
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
#define pDiff(a, b)
Definition polys.h:297

◆ mpKoszul()

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

Definition at line 3086 of file ipshell.cc.

3087{
3088 int n=(int)(long)b->Data();
3089 int d=(int)(long)c->Data();
3090 int k,l,sign,row,col;
3091 matrix result;
3092 ideal temp;
3093 BOOLEAN bo;
3094 poly p;
3095
3096 if ((d>n) || (d<1) || (n<1))
3097 {
3098 res->data=(char *)mpNew(1,1);
3099 return FALSE;
3100 }
3101 int *choise = (int*)omAlloc(d*sizeof(int));
3102 if (id==NULL)
3103 temp=idMaxIdeal(1);
3104 else
3105 temp=(ideal)id->Data();
3106
3107 k = binom(n,d);
3108 l = k*d;
3109 l /= n-d+1;
3110 result =mpNew(l,k);
3111 col = 1;
3112 idInitChoise(d,1,n,&bo,choise);
3113 while (!bo)
3114 {
3115 sign = 1;
3116 for (l=1;l<=d;l++)
3117 {
3118 if (choise[l-1]<=IDELEMS(temp))
3119 {
3120 p = pCopy(temp->m[choise[l-1]-1]);
3121 if (sign == -1) p = pNeg(p);
3122 sign *= -1;
3123 row = idGetNumberOfChoise(l-1,d,1,n,choise);
3124 MATELEM(result,row,col) = p;
3125 }
3126 }
3127 col++;
3128 idGetNextChoise(d,n,&bo,choise);
3129 }
3130 omFreeSize(choise,d*sizeof(int));
3131 if (id==NULL) idDelete(&temp);
3132
3133 res->data=(char *)result;
3134 return FALSE;
3135}
int k
Definition cfEzgcd.cc:99
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:199
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
static int sign(int x)
Definition ring.cc:3504

◆ 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 4681 of file ipshell.cc.

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

◆ 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 4658 of file ipshell.cc.

4659{
4660 ideal gls = (ideal)(arg1->Data());
4661 int imtype= (int)(long)arg2->Data();
4662
4663 uResultant::resMatType mtype= determineMType( imtype );
4664
4665 // check input ideal ( = polynomial system )
4666 if ( mprIdealCheck( gls, arg1->Name(), mtype, true ) != mprOk )
4667 {
4668 return TRUE;
4669 }
4670
4671 uResultant *resMat= new uResultant( gls, mtype, false );
4672 if (resMat!=NULL)
4673 {
4674 res->rtyp = MODUL_CMD;
4675 res->data= (void*)resMat->accessResMat()->getMatrix();
4676 if (!errorreported) delete resMat;
4677 }
4678 return errorreported;
4679}
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 4925 of file ipshell.cc.

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

◆ 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 4824 of file ipshell.cc.

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

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

◆ rCompose()

ring rCompose ( const lists L,
const BOOLEAN check_comp,
const long bitmask,
const int isLetterplace )

Definition at line 2782 of file ipshell.cc.

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

◆ rComposeC()

void rComposeC ( lists L,
ring R )

Definition at line 2252 of file ipshell.cc.

2254{
2255 // ----------------------------------------
2256 // 0: char/ cf - ring
2257 if ((L->m[0].rtyp!=INT_CMD) || (L->m[0].data!=(char *)0))
2258 {
2259 WerrorS("invalid coeff. field description, expecting 0");
2260 return;
2261 }
2262// R->cf->ch=0;
2263 // ----------------------------------------
2264 // 0, (r1,r2) [, "i" ]
2265 if (L->m[1].rtyp!=LIST_CMD)
2266 {
2267 WerrorS("invalid coeff. field description, expecting precision list");
2268 return;
2269 }
2270 lists LL=(lists)L->m[1].data;
2271 if ((LL->nr!=1)
2272 || (LL->m[0].rtyp!=INT_CMD)
2273 || (LL->m[1].rtyp!=INT_CMD))
2274 {
2275 WerrorS("invalid coeff. field description list, expected list(`int`,`int`)");
2276 return;
2277 }
2278 int r1=(int)(long)LL->m[0].data;
2279 int r2=(int)(long)LL->m[1].data;
2280 r1=si_min(r1,32767);
2281 r2=si_min(r2,32767);
2282 LongComplexInfo par; memset(&par, 0, sizeof(par));
2283 par.float_len=r1;
2284 par.float_len2=r2;
2285 if (L->nr==2) // complex
2286 {
2287 if (L->m[2].rtyp!=STRING_CMD)
2288 {
2289 WerrorS("invalid coeff. field description, expecting parameter name");
2290 return;
2291 }
2292 par.par_name=(char*)L->m[2].data;
2293 R->cf = nInitChar(n_long_C, &par);
2294 }
2295 else if ((r1<=SHORT_REAL_LENGTH) && (r2<=SHORT_REAL_LENGTH)) /* && L->nr==1*/
2296 R->cf = nInitChar(n_R, NULL);
2297 else /* && L->nr==1*/
2298 {
2299 R->cf = nInitChar(n_long_R, &par);
2300 }
2301}
@ n_R
single prescision (6,6) real numbers
Definition coeffs.h:31
@ n_long_R
real floating point (GMP) numbers
Definition coeffs.h:33
@ n_long_C
complex floating point (GMP) numbers
Definition coeffs.h:41
short float_len2
additional char-flags, rInit
Definition coeffs.h:109
const char * par_name
parameter name
Definition coeffs.h:110
short float_len
additional char-flags, rInit
Definition coeffs.h:108
#define SHORT_REAL_LENGTH
Definition numbers.h:57

◆ rComposeOrder()

BOOLEAN rComposeOrder ( const lists L,
const BOOLEAN check_comp,
ring R )
inlinestatic

Definition at line 2482 of file ipshell.cc.

2483{
2484 assume(R!=NULL);
2485 long bitmask=0L;
2486 if (L->m[2].Typ()==LIST_CMD)
2487 {
2488 lists v=(lists)L->m[2].Data();
2489 int n= v->nr+2;
2490 int j_in_R,j_in_L;
2491 // do we have an entry "L",... ?: set bitmask
2492 for (int j=0; j < n-1; j++)
2493 {
2494 if (v->m[j].Typ()==LIST_CMD)
2495 {
2496 lists vv=(lists)v->m[j].Data();
2497 if ((vv->nr==1)
2498 &&(vv->m[0].Typ()==STRING_CMD)
2499 &&(strcmp((char*)vv->m[0].Data(),"L")==0))
2500 {
2501 number nn=(number)vv->m[1].Data();
2502 if (vv->m[1].Typ()==BIGINT_CMD)
2503 bitmask=n_Int(nn,coeffs_BIGINT);
2504 else if (vv->m[1].Typ()==INT_CMD)
2505 bitmask=(long)nn;
2506 else
2507 {
2508 Werror("illegal argument for pseudo ordering L: %d",vv->m[1].Typ());
2509 return TRUE;
2510 }
2511 break;
2512 }
2513 }
2514 }
2515 if (bitmask!=0) n--;
2516
2517 // initialize fields of R
2518 R->order=(rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
2519 R->block0=(int *)omAlloc0((n+1)*sizeof(int));
2520 R->block1=(int *)omAlloc0((n+1)*sizeof(int));
2521 R->wvhdl=(int**)omAlloc0((n+1)*sizeof(int_ptr));
2522 // init order, so that rBlocks works correctly
2523 for (j_in_R= n-2; j_in_R>=0; j_in_R--)
2524 R->order[j_in_R] = ringorder_unspec;
2525 // orderings
2526 for(j_in_R=0,j_in_L=0;j_in_R<n-1;j_in_R++,j_in_L++)
2527 {
2528 // todo: a(..), M
2529 if (v->m[j_in_L].Typ()!=LIST_CMD)
2530 {
2531 WerrorS("ordering must be list of lists");
2532 return TRUE;
2533 }
2534 lists vv=(lists)v->m[j_in_L].Data();
2535 if ((vv->nr==1)
2536 && (vv->m[0].Typ()==STRING_CMD))
2537 {
2538 if (strcmp((char*)vv->m[0].Data(),"L")==0)
2539 {
2540 j_in_R--;
2541 continue;
2542 }
2543 if ((vv->m[1].Typ()!=INTVEC_CMD) && (vv->m[1].Typ()!=INT_CMD)
2544 && (vv->m[1].Typ()!=INTMAT_CMD))
2545 {
2546 PrintS(lString(vv));
2547 Werror("ordering name must be a (string,intvec), not (string,%s)",Tok2Cmdname(vv->m[1].Typ()));
2548 return TRUE;
2549 }
2550 R->order[j_in_R]=rOrderName(omStrDup((char*)vv->m[0].Data())); // assume STRING
2551
2552 if (j_in_R==0) R->block0[0]=1;
2553 else
2554 {
2555 int jj=j_in_R-1;
2556 while((jj>=0)
2557 && ((R->order[jj]== ringorder_a)
2558 || (R->order[jj]== ringorder_aa)
2559 || (R->order[jj]== ringorder_am)
2560 || (R->order[jj]== ringorder_c)
2561 || (R->order[jj]== ringorder_C)
2562 || (R->order[jj]== ringorder_s)
2563 || (R->order[jj]== ringorder_S)
2564 ))
2565 {
2566 //Print("jj=%, skip %s\n",rSimpleOrdStr(R->order[jj]));
2567 jj--;
2568 }
2569 if (jj<0) R->block0[j_in_R]=1;
2570 else R->block0[j_in_R]=R->block1[jj]+1;
2571 }
2572 intvec *iv;
2573 if (vv->m[1].Typ()==INT_CMD)
2574 {
2575 int l=si_max(1,(int)(long)vv->m[1].Data());
2576 iv=new intvec(l);
2577 for(int i=0;i<l;i++) (*iv)[i]=1;
2578 }
2579 else
2580 iv=ivCopy((intvec*)vv->m[1].Data()); //assume INTVEC/INTMAT
2581 int iv_len=iv->length();
2582 if (iv_len==0)
2583 {
2584 Werror("empty intvec for ordering %d (%s)",j_in_R+1,rSimpleOrdStr(R->order[j_in_R]));
2585 return TRUE;
2586 }
2587 if (R->order[j_in_R]==ringorder_M)
2588 {
2589 if (vv->m[1].rtyp==INTMAT_CMD) iv->makeVector();
2590 iv_len=iv->length();
2591 }
2592 if ((R->order[j_in_R]!=ringorder_s)
2593 &&(R->order[j_in_R]!=ringorder_c)
2594 &&(R->order[j_in_R]!=ringorder_C))
2595 {
2596 if (R->order[j_in_R]==ringorder_M)
2597 {
2598 int sq=(int)sqrt((double)(iv_len));
2599 R->block1[j_in_R]=si_max(R->block0[j_in_R],R->block0[j_in_R]+sq-1);
2600 }
2601 else
2602 R->block1[j_in_R]=si_max(R->block0[j_in_R],R->block0[j_in_R]+iv_len-1);
2603 if (R->block1[j_in_R]>R->N)
2604 {
2605 if (R->block0[j_in_R]>R->N)
2606 {
2607 Print("R->block0[j_in_R]=%d,N=%d\n",R->block0[j_in_R],R->N);
2608 Werror("not enough variables for ordering %d (%s)",j_in_R,rSimpleOrdStr(R->order[j_in_R]));
2609 return TRUE;
2610 }
2611 R->block1[j_in_R]=R->N;
2612 iv_len=R->block1[j_in_R]-R->block0[j_in_R]+1;
2613 }
2614 //Print("block %d(%s) from %d to %d\n",j_in_R,
2615 // rSimpleOrdStr(R->order[j_in_R]),R->block0[j_in_R], R->block1[j_in_R]);
2616 }
2617 int i;
2618 switch (R->order[j_in_R])
2619 {
2620 case ringorder_ws:
2621 case ringorder_Ws:
2622 R->OrdSgn=-1; // and continue
2623 case ringorder_aa:
2624 case ringorder_a:
2625 case ringorder_wp:
2626 case ringorder_Wp:
2627 R->wvhdl[j_in_R] =( int *)omAlloc(iv_len*sizeof(int));
2628 for (i=0; i<iv_len;i++)
2629 {
2630 R->wvhdl[j_in_R][i]=(*iv)[i];
2631 }
2632 break;
2633 case ringorder_am:
2634 R->wvhdl[j_in_R] =( int *)omAlloc((iv->length()+1)*sizeof(int));
2635 for (i=0; i<iv_len;i++)
2636 {
2637 R->wvhdl[j_in_R][i]=(*iv)[i];
2638 }
2639 R->wvhdl[j_in_R][i]=iv->length() - iv_len;
2640 //printf("ivlen:%d,iv->len:%d,mod:%d\n",iv_len,iv->length(),R->wvhdl[j][i]);
2641 for (; i<iv->length(); i++)
2642 {
2643 R->wvhdl[j_in_R][i+1]=(*iv)[i];
2644 }
2645 break;
2646 case ringorder_M:
2647 R->wvhdl[j_in_R] =( int *)omAlloc((iv->length())*sizeof(int));
2648 for (i=0; i<iv->length();i++) R->wvhdl[j_in_R][i]=(*iv)[i];
2649 if (R->block1[j_in_R]>R->N)
2650 {
2651 R->block1[j_in_R]=R->N;
2652 }
2653 break;
2654 case ringorder_ls:
2655 case ringorder_ds:
2656 case ringorder_Ds:
2657 case ringorder_rs:
2658 R->OrdSgn=-1;
2659 case ringorder_lp:
2660 case ringorder_dp:
2661 case ringorder_Dp:
2662 case ringorder_rp:
2663 case ringorder_Ip:
2664 #if 0
2665 for (i=0; i<iv_len;i++)
2666 {
2667 if (((*iv)[i]!=1)&&(iv_len!=1))
2668 {
2669 iv->show(1);
2670 Warn("ignore weight %d for ord %d (%s) at pos %d\n>>%s<<",
2671 (*iv)[i],j_in_R+1,rSimpleOrdStr(R->order[j_in_R]),i+1,my_yylinebuf);
2672 break;
2673 }
2674 }
2675 #endif // break absfact.tst
2676 break;
2677 case ringorder_S:
2678 break;
2679 case ringorder_c:
2680 case ringorder_C:
2681 R->block1[j_in_R]=R->block0[j_in_R]=0;
2682 break;
2683
2684 case ringorder_s:
2685 R->block1[j_in_R]=R->block0[j_in_R]=(*iv)[0];
2686 rSetSyzComp(R->block0[j_in_R],R);
2687 break;
2688
2689 case ringorder_IS:
2690 {
2691 R->block1[j_in_R] = R->block0[j_in_R] = 0;
2692 if( iv->length() > 0 )
2693 {
2694 const int s = (*iv)[0];
2695 assume( -2 < s && s < 2 );
2696 R->block1[j_in_R] = R->block0[j_in_R] = s;
2697 }
2698 break;
2699 }
2700 case 0:
2701 case ringorder_unspec:
2702 break;
2703 case ringorder_L: /* cannot happen */
2704 case ringorder_a64: /*not implemented */
2705 WerrorS("ring order not implemented");
2706 return TRUE;
2707 }
2708 delete iv;
2709 }
2710 else
2711 {
2712 PrintS(lString(vv));
2713 WerrorS("ordering name must be a (string,intvec)");
2714 return TRUE;
2715 }
2716 }
2717 // sanity check
2718 j_in_R=n-2;
2719 if ((R->order[j_in_R]==ringorder_c)
2720 || (R->order[j_in_R]==ringorder_C)
2721 || (R->order[j_in_R]==ringorder_unspec)) j_in_R--;
2722 if (R->block1[j_in_R] != R->N)
2723 {
2724 if (((R->order[j_in_R]==ringorder_dp) ||
2725 (R->order[j_in_R]==ringorder_ds) ||
2726 (R->order[j_in_R]==ringorder_Dp) ||
2727 (R->order[j_in_R]==ringorder_Ds) ||
2728 (R->order[j_in_R]==ringorder_rp) ||
2729 (R->order[j_in_R]==ringorder_rs) ||
2730 (R->order[j_in_R]==ringorder_lp) ||
2731 (R->order[j_in_R]==ringorder_ls))
2732 &&
2733 R->block0[j_in_R] <= R->N)
2734 {
2735 R->block1[j_in_R] = R->N;
2736 }
2737 else
2738 {
2739 Werror("ordering incomplete: size (%d) should be %d",R->block1[j_in_R],R->N);
2740 return TRUE;
2741 }
2742 }
2743 if (R->block0[j_in_R]>R->N)
2744 {
2745 Werror("not enough variables (%d) for ordering block %d, scanned so far:",R->N,j_in_R+1);
2746 for(int ii=0;ii<=j_in_R;ii++)
2747 Werror("ord[%d]: %s from v%d to v%d",ii+1,rSimpleOrdStr(R->order[ii]),R->block0[ii],R->block1[ii]);
2748 return TRUE;
2749 }
2750 if (check_comp)
2751 {
2752 BOOLEAN comp_order=FALSE;
2753 int jj;
2754 for(jj=0;jj<n;jj++)
2755 {
2756 if ((R->order[jj]==ringorder_c) ||
2757 (R->order[jj]==ringorder_C)) { comp_order=TRUE; break; }
2758 }
2759 if (!comp_order)
2760 {
2761 R->order=(rRingOrder_t*)omRealloc0Size(R->order,n*sizeof(rRingOrder_t),(n+1)*sizeof(rRingOrder_t));
2762 R->block0=(int*)omRealloc0Size(R->block0,n*sizeof(int),(n+1)*sizeof(int));
2763 R->block1=(int*)omRealloc0Size(R->block1,n*sizeof(int),(n+1)*sizeof(int));
2764 R->wvhdl=(int**)omRealloc0Size(R->wvhdl,n*sizeof(int_ptr),(n+1)*sizeof(int_ptr));
2765 R->order[n-1]=ringorder_C;
2766 R->block0[n-1]=0;
2767 R->block1[n-1]=0;
2768 R->wvhdl[n-1]=NULL;
2769 n++;
2770 }
2771 }
2772 }
2773 else
2774 {
2775 WerrorS("ordering must be given as `list`");
2776 return TRUE;
2777 }
2778 if (bitmask!=0) { R->bitmask=bitmask; R->wanted_maxExp=bitmask; }
2779 return FALSE;
2780}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
void makeVector()
Definition intvec.h:103
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:550
char * lString(lists l, BOOLEAN typed, int dim)
Definition lists.cc:409
gmp_float sqrt(const gmp_float &a)
#define omRealloc0Size(addr, o_size, size)
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
const char * rSimpleOrdStr(int ord)
Definition ring.cc:78
rRingOrder_t rOrderName(char *ordername)
Definition ring.cc:512
void rSetSyzComp(int k, const ring r)
Definition ring.cc:5230
#define ringorder_rp
Definition ring.h:100
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_lp
Definition ring.h:78
@ ringorder_a
Definition ring.h:71
@ ringorder_am
Definition ring.h:90
@ ringorder_a64
for int64 weights
Definition ring.h:72
@ ringorder_C
Definition ring.h:74
@ ringorder_S
S?
Definition ring.h:76
@ ringorder_ds
Definition ring.h:86
@ ringorder_Dp
Definition ring.h:81
@ ringorder_unspec
Definition ring.h:96
@ ringorder_L
Definition ring.h:91
@ ringorder_Ds
Definition ring.h:87
@ ringorder_Ip
Definition ring.h:84
@ ringorder_dp
Definition ring.h:79
@ ringorder_c
Definition ring.h:73
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition ring.h:93
@ ringorder_Wp
Definition ring.h:83
@ ringorder_ws
Definition ring.h:88
@ ringorder_Ws
Definition ring.h:89
@ ringorder_IS
Induced (Schreyer) ordering.
Definition ring.h:95
@ ringorder_ls
degree, ip
Definition ring.h:85
@ ringorder_s
s?
Definition ring.h:77
@ ringorder_wp
Definition ring.h:82
@ ringorder_M
Definition ring.h:75
#define ringorder_rs
Definition ring.h:101
int * int_ptr
Definition structs.h:50
@ BIGINT_CMD
Definition tok.h:38

◆ rComposeRing()

void rComposeRing ( lists L,
ring R )

Definition at line 2303 of file ipshell.cc.

2305{
2306 // ----------------------------------------
2307 // 0: string: integer
2308 // no further entries --> Z
2309 mpz_t modBase;
2310 unsigned int modExponent = 1;
2311
2312 if (L->nr == 0)
2313 {
2314 mpz_init_set_ui(modBase,0);
2315 modExponent = 1;
2316 }
2317 // ----------------------------------------
2318 // 1:
2319 else
2320 {
2321 if (L->m[1].rtyp!=LIST_CMD) WerrorS("invalid data, expecting list of numbers");
2322 lists LL=(lists)L->m[1].data;
2323 if ((LL->nr >= 0) && LL->m[0].rtyp == BIGINT_CMD)
2324 {
2325 number tmp= (number) LL->m[0].data; // never use CopyD() on list elements
2326 // assume that tmp is integer, not rational
2327 mpz_init(modBase);
2328 n_MPZ (modBase, tmp, coeffs_BIGINT);
2329 }
2330 else if (LL->nr >= 0 && LL->m[0].rtyp == INT_CMD)
2331 {
2332 mpz_init_set_ui(modBase,(unsigned long) LL->m[0].data);
2333 }
2334 else
2335 {
2336 mpz_init_set_ui(modBase,0);
2337 }
2338 if (LL->nr >= 1)
2339 {
2340 modExponent = (unsigned long) LL->m[1].data;
2341 }
2342 else
2343 {
2344 modExponent = 1;
2345 }
2346 }
2347 // ----------------------------------------
2348 if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_sgn1(modBase) < 0))
2349 {
2350 WerrorS("Wrong ground ring specification (module is 1)");
2351 return;
2352 }
2353 if (modExponent < 1)
2354 {
2355 WerrorS("Wrong ground ring specification (exponent smaller than 1)");
2356 return;
2357 }
2358 // module is 0 ---> integers
2359 if (mpz_sgn1(modBase) == 0)
2360 {
2361 R->cf=nInitChar(n_Z,NULL);
2362 }
2363 // we have an exponent
2364 else if (modExponent > 1)
2365 {
2366 //R->cf->ch = R->cf->modExponent;
2367 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
2368 {
2369 /* this branch should be active for modExponent = 2..32 resp. 2..64,
2370 depending on the size of a long on the respective platform */
2371 R->cf=nInitChar(n_Z2m,(void*)(long)modExponent); // Use Z/2^ch
2372 }
2373 else
2374 {
2375 //ringtype 3
2376 ZnmInfo info;
2377 info.base= modBase;
2378 info.exp= modExponent;
2379 R->cf=nInitChar(n_Znm,(void*) &info);
2380 }
2381 }
2382 // just a module m > 1
2383 else
2384 {
2385 //ringtype = 2;
2386 //const int ch = mpz_get_ui(modBase);
2387 ZnmInfo info;
2388 info.base= modBase;
2389 info.exp= modExponent;
2390 R->cf=nInitChar(n_Zn,(void*) &info);
2391 }
2392 mpz_clear(modBase);
2393}
@ n_Znm
only used if HAVE_RINGS is defined
Definition coeffs.h:45
@ 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
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:554
#define mpz_sgn1(A)
Definition si_gmp.h:18

◆ rComposeVar()

BOOLEAN rComposeVar ( const lists L,
ring R )
inlinestatic

Definition at line 2437 of file ipshell.cc.

2438{
2439 assume(R!=NULL);
2440 if (L->m[1].Typ()==LIST_CMD)
2441 {
2442 lists v=(lists)L->m[1].Data();
2443 R->N = v->nr+1;
2444 if (R->N<=0)
2445 {
2446 WerrorS("no ring variables");
2447 return TRUE;
2448 }
2449 R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
2450 int i;
2451 for(i=0;i<R->N;i++)
2452 {
2453 if (v->m[i].Typ()==STRING_CMD)
2454 R->names[i]=omStrDup((char *)v->m[i].Data());
2455 else if (v->m[i].Typ()==POLY_CMD)
2456 {
2457 poly p=(poly)v->m[i].Data();
2458 int nr=pIsPurePower(p);
2459 if (nr>0)
2460 R->names[i]=omStrDup(currRing->names[nr-1]);
2461 else
2462 {
2463 Werror("var name %d must be a string or a ring variable",i+1);
2464 return TRUE;
2465 }
2466 }
2467 else
2468 {
2469 Werror("var name %d must be `string` (not %d)",i+1, v->m[i].Typ());
2470 return TRUE;
2471 }
2472 }
2473 }
2474 else
2475 {
2476 WerrorS("variable must be given as `list`");
2477 return TRUE;
2478 }
2479 return FALSE;
2480}
#define pIsPurePower(p)
Definition polys.h:249
char * char_ptr
Definition structs.h:49

◆ rDecompose()

lists rDecompose ( const ring r)

Definition at line 2153 of file ipshell.cc.

2154{
2155 assume( r != NULL );
2156 const coeffs C = r->cf;
2157 assume( C != NULL );
2158
2159 // sanity check: require currRing==r for rings with polynomial data
2160 if ( (r!=currRing) && (
2161 (nCoeff_is_algExt(C) && (C != currRing->cf))
2162 || (r->qideal != NULL)
2163#ifdef HAVE_PLURAL
2164 || (rIsPluralRing(r))
2165#endif
2166 )
2167 )
2168 {
2169 WerrorS("ring with polynomial data must be the base ring or compatible");
2170 return NULL;
2171 }
2172 // 0: char/ cf - ring
2173 // 1: list (var)
2174 // 2: list (ord)
2175 // 3: qideal
2176 // possibly:
2177 // 4: C
2178 // 5: D
2180 if (rIsPluralRing(r))
2181 L->Init(6);
2182 else
2183 L->Init(4);
2184 // ----------------------------------------
2185 // 0: char/ cf - ring
2186 if (rField_is_numeric(r))
2187 {
2188 rDecomposeC(&(L->m[0]),r);
2189 }
2190 else if (rField_is_Ring(r))
2191 {
2192 rDecomposeRing(&(L->m[0]),r);
2193 }
2194 else if ( r->cf->extRing!=NULL )// nCoeff_is_algExt(r->cf))
2195 {
2196 rDecomposeCF(&(L->m[0]), r->cf->extRing, r);
2197 }
2198 else if(rField_is_GF(r))
2199 {
2201 Lc->Init(4);
2202 // char:
2203 Lc->m[0].rtyp=INT_CMD;
2204 Lc->m[0].data=(void*)(long)r->cf->m_nfCharQ;
2205 // var:
2207 Lv->Init(1);
2208 Lv->m[0].rtyp=STRING_CMD;
2209 Lv->m[0].data=(void *)omStrDup(*rParameter(r));
2210 Lc->m[1].rtyp=LIST_CMD;
2211 Lc->m[1].data=(void*)Lv;
2212 // ord:
2214 Lo->Init(1);
2216 Loo->Init(2);
2217 Loo->m[0].rtyp=STRING_CMD;
2218 Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
2219
2220 intvec *iv=new intvec(1); (*iv)[0]=1;
2221 Loo->m[1].rtyp=INTVEC_CMD;
2222 Loo->m[1].data=(void *)iv;
2223
2224 Lo->m[0].rtyp=LIST_CMD;
2225 Lo->m[0].data=(void*)Loo;
2226
2227 Lc->m[2].rtyp=LIST_CMD;
2228 Lc->m[2].data=(void*)Lo;
2229 // q-ideal:
2230 Lc->m[3].rtyp=IDEAL_CMD;
2231 Lc->m[3].data=(void *)idInit(1,1);
2232 // ----------------------
2233 L->m[0].rtyp=LIST_CMD;
2234 L->m[0].data=(void*)Lc;
2235 }
2236 else if (rField_is_Zp(r) || rField_is_Q(r))
2237 {
2238 L->m[0].rtyp=INT_CMD;
2239 L->m[0].data=(void *)(long)r->cf->ch;
2240 }
2241 else
2242 {
2243 L->m[0].rtyp=CRING_CMD;
2244 L->m[0].data=(void *)r->cf;
2245 r->cf->ref++;
2246 }
2247 // ----------------------------------------
2248 rDecompose_23456(r,L);
2249 return L;
2250}
CanonicalForm Lc(const CanonicalForm &f)
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:908
static void rDecomposeC(leftv h, const ring R)
Definition ipshell.cc:1853
void rDecomposeCF(leftv h, const ring r, const ring R)
Definition ipshell.cc:1729
void rDecomposeRing(leftv h, const ring R)
Definition ipshell.cc:1915
static void rDecompose_23456(const ring r, lists L)
Definition ipshell.cc:2013
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:636
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:526
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:532
#define rField_is_Ring(R)
Definition ring.h:491

◆ rDecompose_23456()

void rDecompose_23456 ( const ring r,
lists L )
static

Definition at line 2013 of file ipshell.cc.

2014{
2015 // ----------------------------------------
2016 // 1: list (var)
2018 LL->Init(r->N);
2019 int i;
2020 for(i=0; i<r->N; i++)
2021 {
2022 LL->m[i].rtyp=STRING_CMD;
2023 LL->m[i].data=(void *)omStrDup(r->names[i]);
2024 }
2025 L->m[1].rtyp=LIST_CMD;
2026 L->m[1].data=(void *)LL;
2027 // ----------------------------------------
2028 // 2: list (ord)
2030 i=rBlocks(r)-1;
2031 LL->Init(i);
2032 i--;
2033 lists LLL;
2034 for(; i>=0; i--)
2035 {
2036 intvec *iv;
2037 int j;
2038 LL->m[i].rtyp=LIST_CMD;
2040 LLL->Init(2);
2041 LLL->m[0].rtyp=STRING_CMD;
2042 LLL->m[0].data=(void *)omStrDup(rSimpleOrdStr(r->order[i]));
2043
2044 if((r->order[i] == ringorder_IS)
2045 || (r->order[i] == ringorder_s)) //|| r->order[i] == ringorder_S)
2046 {
2047 assume( r->block0[i] == r->block1[i] );
2048 const int s = r->block0[i];
2049 assume( (-2 < s && s < 2)||(r->order[i] != ringorder_IS));
2050
2051 iv=new intvec(1);
2052 (*iv)[0] = s;
2053 }
2054 else if (r->block1[i]-r->block0[i] >=0 )
2055 {
2056 int bl=j=r->block1[i]-r->block0[i];
2057 if (r->order[i]==ringorder_M)
2058 {
2059 j=(j+1)*(j+1)-1;
2060 bl=j+1;
2061 }
2062 else if (r->order[i]==ringorder_am)
2063 {
2064 j+=r->wvhdl[i][bl+1];
2065 }
2066 iv=new intvec(j+1);
2067 if ((r->wvhdl!=NULL) && (r->wvhdl[i]!=NULL))
2068 {
2069 for(;j>=0; j--) (*iv)[j]=r->wvhdl[i][j+(j>bl)];
2070 }
2071 else switch (r->order[i])
2072 {
2073 case ringorder_dp:
2074 case ringorder_Dp:
2075 case ringorder_ds:
2076 case ringorder_Ds:
2077 case ringorder_lp:
2078 case ringorder_ls:
2079 case ringorder_rp:
2080 for(;j>=0; j--) (*iv)[j]=1;
2081 break;
2082 default: /* do nothing */;
2083 }
2084 }
2085 else
2086 {
2087 iv=new intvec(1);
2088 }
2089 LLL->m[1].rtyp=INTVEC_CMD;
2090 LLL->m[1].data=(void *)iv;
2091 LL->m[i].data=(void *)LLL;
2092 }
2093 L->m[2].rtyp=LIST_CMD;
2094 L->m[2].data=(void *)LL;
2095 // ----------------------------------------
2096 // 3: qideal
2097 L->m[3].rtyp=IDEAL_CMD;
2098 if (r->qideal==NULL)
2099 L->m[3].data=(void *)idInit(1,1);
2100 else
2101 L->m[3].data=(void *)idCopy(r->qideal);
2102 // ----------------------------------------
2103#ifdef HAVE_PLURAL // NC! in rDecompose
2104 if (rIsPluralRing(r))
2105 {
2106 L->m[4].rtyp=MATRIX_CMD;
2107 L->m[4].data=(void *)mp_Copy(r->GetNC()->C, r, r);
2108 L->m[5].rtyp=MATRIX_CMD;
2109 L->m[5].data=(void *)mp_Copy(r->GetNC()->D, r, r);
2110 }
2111#endif
2112}
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
static int rBlocks(const ring r)
Definition ring.h:579

◆ rDecompose_CF()

BOOLEAN rDecompose_CF ( leftv res,
const coeffs C )

Definition at line 1943 of file ipshell.cc.

1944{
1945 assume( C != NULL );
1946
1947 // sanity check: require currRing==r for rings with polynomial data
1948 if ( nCoeff_is_algExt(C) && (C != currRing->cf))
1949 {
1950 WerrorS("ring with polynomial data must be the base ring or compatible");
1951 return TRUE;
1952 }
1953 if (nCoeff_is_numeric(C))
1954 {
1956 }
1957 else if (nCoeff_is_Ring(C))
1958 {
1960 }
1961 else if ( C->extRing!=NULL )// nCoeff_is_algExt(r->cf))
1962 {
1963 rDecomposeCF(res, C->extRing, currRing);
1964 }
1965 else if(nCoeff_is_GF(C))
1966 {
1968 Lc->Init(4);
1969 // char:
1970 Lc->m[0].rtyp=INT_CMD;
1971 Lc->m[0].data=(void*)(long)C->m_nfCharQ;
1972 // var:
1974 Lv->Init(1);
1975 Lv->m[0].rtyp=STRING_CMD;
1976 Lv->m[0].data=(void *)omStrDup(*n_ParameterNames(C));
1977 Lc->m[1].rtyp=LIST_CMD;
1978 Lc->m[1].data=(void*)Lv;
1979 // ord:
1981 Lo->Init(1);
1983 Loo->Init(2);
1984 Loo->m[0].rtyp=STRING_CMD;
1985 Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
1986
1987 intvec *iv=new intvec(1); (*iv)[0]=1;
1988 Loo->m[1].rtyp=INTVEC_CMD;
1989 Loo->m[1].data=(void *)iv;
1990
1991 Lo->m[0].rtyp=LIST_CMD;
1992 Lo->m[0].data=(void*)Loo;
1993
1994 Lc->m[2].rtyp=LIST_CMD;
1995 Lc->m[2].data=(void*)Lo;
1996 // q-ideal:
1997 Lc->m[3].rtyp=IDEAL_CMD;
1998 Lc->m[3].data=(void *)idInit(1,1);
1999 // ----------------------
2000 res->rtyp=LIST_CMD;
2001 res->data=(void*)Lc;
2002 }
2003 else
2004 {
2005 res->rtyp=INT_CMD;
2006 res->data=(void *)(long)C->ch;
2007 }
2008 // ----------------------------------------
2009 return FALSE;
2010}
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition coeffs.h:837
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition coeffs.h:830
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition coeffs.h:770
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition coeffs.h:732
static void rDecomposeC_41(leftv h, const coeffs C)
Definition ipshell.cc:1819
static void rDecomposeRing_41(leftv h, const coeffs C)
Definition ipshell.cc:1888

◆ rDecompose_list_cf()

lists rDecompose_list_cf ( const ring r)

Definition at line 2114 of file ipshell.cc.

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

◆ rDecomposeC()

void rDecomposeC ( leftv h,
const ring R )
static

Definition at line 1853 of file ipshell.cc.

1855{
1857 if (rField_is_long_C(R)) L->Init(3);
1858 else L->Init(2);
1859 h->rtyp=LIST_CMD;
1860 h->data=(void *)L;
1861 // 0: char/ cf - ring
1862 // 1: list (var)
1863 // 2: list (ord)
1864 // ----------------------------------------
1865 // 0: char/ cf - ring
1866 L->m[0].rtyp=INT_CMD;
1867 L->m[0].data=(void *)0;
1868 // ----------------------------------------
1869 // 1:
1871 LL->Init(2);
1872 LL->m[0].rtyp=INT_CMD;
1873 LL->m[0].data=(void *)(long)si_max(R->cf->float_len,SHORT_REAL_LENGTH/2);
1874 LL->m[1].rtyp=INT_CMD;
1875 LL->m[1].data=(void *)(long)si_max(R->cf->float_len2,SHORT_REAL_LENGTH);
1876 L->m[1].rtyp=LIST_CMD;
1877 L->m[1].data=(void *)LL;
1878 // ----------------------------------------
1879 // 2: list (par)
1880 if (rField_is_long_C(R))
1881 {
1882 L->m[2].rtyp=STRING_CMD;
1883 L->m[2].data=(void *)omStrDup(*rParameter(R));
1884 }
1885 // ----------------------------------------
1886}

◆ rDecomposeC_41()

void rDecomposeC_41 ( leftv h,
const coeffs C )
static

Definition at line 1819 of file ipshell.cc.

1821{
1823 if (nCoeff_is_long_C(C)) L->Init(3);
1824 else L->Init(2);
1825 h->rtyp=LIST_CMD;
1826 h->data=(void *)L;
1827 // 0: char/ cf - ring
1828 // 1: list (var)
1829 // 2: list (ord)
1830 // ----------------------------------------
1831 // 0: char/ cf - ring
1832 L->m[0].rtyp=INT_CMD;
1833 L->m[0].data=(void *)0;
1834 // ----------------------------------------
1835 // 1:
1837 LL->Init(2);
1838 LL->m[0].rtyp=INT_CMD;
1839 LL->m[0].data=(void *)(long)si_max(C->float_len,SHORT_REAL_LENGTH/2);
1840 LL->m[1].rtyp=INT_CMD;
1841 LL->m[1].data=(void *)(long)si_max(C->float_len2,SHORT_REAL_LENGTH);
1842 L->m[1].rtyp=LIST_CMD;
1843 L->m[1].data=(void *)LL;
1844 // ----------------------------------------
1845 // 2: list (par)
1846 if (nCoeff_is_long_C(C))
1847 {
1848 L->m[2].rtyp=STRING_CMD;
1849 L->m[2].data=(void *)omStrDup(*n_ParameterNames(C));
1850 }
1851 // ----------------------------------------
1852}
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition coeffs.h:892

◆ rDecomposeCF()

void rDecomposeCF ( leftv h,
const ring r,
const ring R )

Definition at line 1729 of file ipshell.cc.

1730{
1732 L->Init(4);
1733 h->rtyp=LIST_CMD;
1734 h->data=(void *)L;
1735 // 0: char/ cf - ring
1736 // 1: list (var)
1737 // 2: list (ord)
1738 // 3: qideal
1739 // ----------------------------------------
1740 // 0: char/ cf - ring
1741 L->m[0].rtyp=INT_CMD;
1742 L->m[0].data=(void *)(long)r->cf->ch;
1743 // ----------------------------------------
1744 // 1: list (var)
1746 LL->Init(r->N);
1747 int i;
1748 for(i=0; i<r->N; i++)
1749 {
1750 LL->m[i].rtyp=STRING_CMD;
1751 LL->m[i].data=(void *)omStrDup(r->names[i]);
1752 }
1753 L->m[1].rtyp=LIST_CMD;
1754 L->m[1].data=(void *)LL;
1755 // ----------------------------------------
1756 // 2: list (ord)
1758 i=rBlocks(r)-1;
1759 LL->Init(i);
1760 i--;
1761 lists LLL;
1762 for(; i>=0; i--)
1763 {
1764 intvec *iv;
1765 int j;
1766 LL->m[i].rtyp=LIST_CMD;
1768 LLL->Init(2);
1769 LLL->m[0].rtyp=STRING_CMD;
1770 LLL->m[0].data=(void *)omStrDup(rSimpleOrdStr(r->order[i]));
1771 if (r->block1[i]-r->block0[i] >=0 )
1772 {
1773 j=r->block1[i]-r->block0[i];
1774 if(r->order[i]==ringorder_M) j=(j+1)*(j+1)-1;
1775 iv=new intvec(j+1);
1776 if ((r->wvhdl!=NULL) && (r->wvhdl[i]!=NULL))
1777 {
1778 for(;j>=0; j--) (*iv)[j]=r->wvhdl[i][j];
1779 }
1780 else switch (r->order[i])
1781 {
1782 case ringorder_dp:
1783 case ringorder_Dp:
1784 case ringorder_ds:
1785 case ringorder_Ds:
1786 case ringorder_lp:
1787 case ringorder_rp:
1788 case ringorder_ls:
1789 for(;j>=0; j--) (*iv)[j]=1;
1790 break;
1791 default: /* do nothing */;
1792 }
1793 }
1794 else
1795 {
1796 iv=new intvec(1);
1797 }
1798 LLL->m[1].rtyp=INTVEC_CMD;
1799 LLL->m[1].data=(void *)iv;
1800 LL->m[i].data=(void *)LLL;
1801 }
1802 L->m[2].rtyp=LIST_CMD;
1803 L->m[2].data=(void *)LL;
1804 // ----------------------------------------
1805 // 3: qideal
1806 L->m[3].rtyp=IDEAL_CMD;
1807 if (nCoeff_is_transExt(R->cf))
1808 L->m[3].data=(void *)idInit(1,1);
1809 else
1810 {
1811 ideal q=idInit(IDELEMS(r->qideal));
1812 q->m[0]=p_Init(R);
1813 pSetCoeff0(q->m[0],n_Copy((number)(r->qideal->m[0]),R->cf));
1814 L->m[3].data=(void *)q;
1815// I->m[0] = pNSet(R->minpoly);
1816 }
1817 // ----------------------------------------
1818}
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:916
#define pSetCoeff0(p, n)
Definition monomials.h:59
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341

◆ rDecomposeRing()

void rDecomposeRing ( leftv h,
const ring R )

Definition at line 1915 of file ipshell.cc.

1917{
1919 if (rField_is_Z(R)) L->Init(1);
1920 else L->Init(2);
1921 h->rtyp=LIST_CMD;
1922 h->data=(void *)L;
1923 // 0: char/ cf - ring
1924 // 1: list (module)
1925 // ----------------------------------------
1926 // 0: char/ cf - ring
1927 L->m[0].rtyp=STRING_CMD;
1928 L->m[0].data=(void *)omStrDup("integer");
1929 // ----------------------------------------
1930 // 1: module
1931 if (rField_is_Z(R)) return;
1933 LL->Init(2);
1934 LL->m[0].rtyp=BIGINT_CMD;
1935 LL->m[0].data=n_InitMPZ( R->cf->modBase, coeffs_BIGINT);
1936 LL->m[1].rtyp=INT_CMD;
1937 LL->m[1].data=(void *) R->cf->modExponent;
1938 L->m[1].rtyp=LIST_CMD;
1939 L->m[1].data=(void *)LL;
1940}
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition coeffs.h:545
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:520

◆ rDecomposeRing_41()

void rDecomposeRing_41 ( leftv h,
const coeffs C )
static

Definition at line 1888 of file ipshell.cc.

1890{
1892 if (nCoeff_is_Ring(C)) L->Init(1);
1893 else L->Init(2);
1894 h->rtyp=LIST_CMD;
1895 h->data=(void *)L;
1896 // 0: char/ cf - ring
1897 // 1: list (module)
1898 // ----------------------------------------
1899 // 0: char/ cf - ring
1900 L->m[0].rtyp=STRING_CMD;
1901 L->m[0].data=(void *)omStrDup("integer");
1902 // ----------------------------------------
1903 // 1: modulo
1904 if (nCoeff_is_Z(C)) return;
1906 LL->Init(2);
1907 LL->m[0].rtyp=BIGINT_CMD;
1908 LL->m[0].data=n_InitMPZ( C->modBase, coeffs_BIGINT);
1909 LL->m[1].rtyp=INT_CMD;
1910 LL->m[1].data=(void *) C->modExponent;
1911 L->m[1].rtyp=LIST_CMD;
1912 L->m[1].data=(void *)LL;
1913}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:814

◆ 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 (sLastPrinted.RingDependend())
1653 {
1654 sLastPrinted.CleanUp();
1655 }
1656
1657 ring r = IDRING(tmp) = (ring) omAlloc0Bin(sip_sring_bin);
1658
1659 #ifndef TEST_ZN_AS_ZP
1660 r->cf = nInitChar(n_Zp, (void*)32003); // r->cf->ch = 32003;
1661 #else
1662 mpz_t modBase;
1663 mpz_init_set_ui(modBase, (long)32003);
1664 ZnmInfo info;
1665 info.base= modBase;
1666 info.exp= 1;
1667 r->cf=nInitChar(n_Zn,(void*) &info);
1668 r->cf->is_field=1;
1669 r->cf->is_domain=1;
1670 r->cf->has_simple_Inverse=1;
1671 #endif
1672 r->N = 3;
1673 /*r->P = 0; Alloc0 in idhdl::set, ipid.cc*/
1674 /*names*/
1675 r->names = (char **) omAlloc0(3 * sizeof(char_ptr));
1676 r->names[0] = omStrDup("x");
1677 r->names[1] = omStrDup("y");
1678 r->names[2] = omStrDup("z");
1679 /*weights: entries for 3 blocks: NULL*/
1680 r->wvhdl = (int **)omAlloc0(3 * sizeof(int_ptr));
1681 /*order: dp,C,0*/
1682 r->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
1683 r->block0 = (int *)omAlloc0(3 * sizeof(int *));
1684 r->block1 = (int *)omAlloc0(3 * sizeof(int *));
1685 /* ringorder dp for the first block: var 1..3 */
1686 r->order[0] = ringorder_dp;
1687 r->block0[0] = 1;
1688 r->block1[0] = 3;
1689 /* ringorder C for the second block: no vars */
1690 r->order[1] = ringorder_C;
1691 /* the last block: everything is 0 */
1692 r->order[2] = (rRingOrder_t)0;
1693
1694 /* complete ring intializations */
1695 rComplete(r);
1696 rSetHdl(tmp);
1697 return currRingHdl;
1698}

◆ rFindHdl()

idhdl rFindHdl ( ring r,
idhdl n )

Definition at line 1701 of file ipshell.cc.

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

◆ rInit()

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

Definition at line 5628 of file ipshell.cc.

5629{
5630 int float_len=0;
5631 int float_len2=0;
5632 ring R = NULL;
5633 //BOOLEAN ffChar=FALSE;
5634
5635 /* ch -------------------------------------------------------*/
5636 // get ch of ground field
5637
5638 // allocated ring
5639 R = (ring) omAlloc0Bin(sip_sring_bin);
5640
5641 coeffs cf = NULL;
5642
5643 assume( pn != NULL );
5644 const int P = pn->listLength();
5645
5646 if (pn->Typ()==CRING_CMD)
5647 {
5648 cf=(coeffs)pn->CopyD();
5649 leftv pnn=pn;
5650 if(P>1) /*parameter*/
5651 {
5652 pnn = pnn->next;
5653 const int pars = pnn->listLength();
5654 assume( pars > 0 );
5655 char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5656
5657 if (rSleftvList2StringArray(pnn, names))
5658 {
5659 WerrorS("parameter expected");
5660 goto rInitError;
5661 }
5662
5663 TransExtInfo extParam;
5664
5665 extParam.r = rDefault( cf, pars, names); // Q/Zp [ p_1, ... p_pars ]
5666 for(int i=pars-1; i>=0;i--)
5667 {
5668 omFree(names[i]);
5669 }
5670 omFree(names);
5671
5672 cf = nInitChar(n_transExt, &extParam);
5673 }
5674 assume( cf != NULL );
5675 }
5676 else if (pn->Typ()==INT_CMD)
5677 {
5678 int ch = (int)(long)pn->Data();
5679 leftv pnn=pn;
5680
5681 /* parameter? -------------------------------------------------------*/
5682 pnn = pnn->next;
5683
5684 if (pnn == NULL) // no params!?
5685 {
5686 if (ch!=0)
5687 {
5688 int ch2=IsPrime(ch);
5689 if ((ch<2)||(ch!=ch2))
5690 {
5691 Warn("%d is invalid as characteristic of the ground field. 32003 is used.", ch);
5692 ch=32003;
5693 }
5694 #ifndef TEST_ZN_AS_ZP
5695 cf = nInitChar(n_Zp, (void*)(long)ch);
5696 #else
5697 mpz_t modBase;
5698 mpz_init_set_ui(modBase, (long)ch);
5699 ZnmInfo info;
5700 info.base= modBase;
5701 info.exp= 1;
5702 cf=nInitChar(n_Zn,(void*) &info);
5703 cf->is_field=1;
5704 cf->is_domain=1;
5705 cf->has_simple_Inverse=1;
5706 #endif
5707 }
5708 else
5709 cf = nInitChar(n_Q, (void*)(long)ch);
5710 }
5711 else
5712 {
5713 const int pars = pnn->listLength();
5714
5715 assume( pars > 0 );
5716
5717 // predefined finite field: (p^k, a)
5718 if ((ch!=0) && (ch!=IsPrime(ch)) && (pars == 1))
5719 {
5720 GFInfo param;
5721
5722 param.GFChar = ch;
5723 param.GFDegree = 1;
5724 param.GFPar_name = pnn->name;
5725
5726 cf = nInitChar(n_GF, &param);
5727 }
5728 else // (0/p, a, b, ..., z)
5729 {
5730 if ((ch!=0) && (ch!=IsPrime(ch)))
5731 {
5732 WerrorS("too many parameters");
5733 goto rInitError;
5734 }
5735
5736 char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5737
5738 if (rSleftvList2StringArray(pnn, names))
5739 {
5740 WerrorS("parameter expected");
5741 goto rInitError;
5742 }
5743
5744 TransExtInfo extParam;
5745
5746 extParam.r = rDefault( ch, pars, names); // Q/Zp [ p_1, ... p_pars ]
5747 for(int i=pars-1; i>=0;i--)
5748 {
5749 omFree(names[i]);
5750 }
5751 omFree(names);
5752
5753 cf = nInitChar(n_transExt, &extParam);
5754 }
5755 }
5756
5757 //if (cf==NULL) ->Error: Invalid ground field specification
5758 }
5759 else if ((pn->name != NULL)
5760 && ((strcmp(pn->name,"real")==0) || (strcmp(pn->name,"complex")==0)))
5761 {
5762 leftv pnn=pn->next;
5763 BOOLEAN complex_flag=(strcmp(pn->name,"complex")==0);
5764 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5765 {
5766 float_len=(int)(long)pnn->Data();
5767 float_len2=float_len;
5768 pnn=pnn->next;
5769 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5770 {
5771 float_len2=(int)(long)pnn->Data();
5772 pnn=pnn->next;
5773 }
5774 }
5775
5776 if (!complex_flag)
5777 complex_flag= (pnn!=NULL) && (pnn->name!=NULL);
5778 if( !complex_flag && (float_len <= (short)SHORT_REAL_LENGTH))
5779 cf=nInitChar(n_R, NULL);
5780 else // longR or longC?
5781 {
5782 LongComplexInfo param;
5783
5784 param.float_len = si_min (float_len, 32767);
5785 param.float_len2 = si_min (float_len2, 32767);
5786
5787 // set the parameter name
5788 if (complex_flag)
5789 {
5790 if (param.float_len < SHORT_REAL_LENGTH)
5791 {
5794 }
5795 if ((pnn == NULL) || (pnn->name == NULL))
5796 param.par_name=(const char*)"i"; //default to i
5797 else
5798 param.par_name = (const char*)pnn->name;
5799 }
5800
5801 cf = nInitChar(complex_flag ? n_long_C: n_long_R, (void*)&param);
5802 }
5803 assume( cf != NULL );
5804 }
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 // ring NEW = OLD, (), (); where OLD is a polynomial ring...
5892 else if ((pn->Typ()==RING_CMD) && (P == 1))
5893 {
5894 ring r=(ring)pn->Data();
5895 if (r->qideal==NULL)
5896 {
5897 TransExtInfo extParam;
5898 extParam.r = r;
5899 extParam.r->ref++;
5900 cf = nInitChar(n_transExt, &extParam); // R(a)
5901 }
5902 else if (IDELEMS(r->qideal)==1)
5903 {
5904 AlgExtInfo extParam;
5905 extParam.r=r;
5906 extParam.r->ref++;
5907 cf = nInitChar(n_algExt, &extParam); // R[a]/<minideal>
5908 }
5909 else
5910 {
5911 WerrorS("algebraic extension ring must have one minpoly");
5912 goto rInitError;
5913 }
5914 }
5915 else
5916 {
5917 WerrorS("Wrong or unknown ground field specification");
5918#if 0
5919// debug stuff for unknown cf descriptions:
5920 sleftv* p = pn;
5921 while (p != NULL)
5922 {
5923 Print( "pn[%p]: type: %d [%s]: %p, name: %s", (void*)p, p->Typ(), Tok2Cmdname(p->Typ()), p->Data(), (p->name == NULL? "NULL" : p->name) );
5924 PrintLn();
5925 p = p->next;
5926 }
5927#endif
5928 goto rInitError;
5929 }
5930
5931 /*every entry in the new ring is initialized to 0*/
5932
5933 /* characteristic -----------------------------------------------*/
5934 /* input: 0 ch=0 : Q parameter=NULL ffChar=FALSE float_len
5935 * 0 1 : Q(a,...) *names FALSE
5936 * 0 -1 : R NULL FALSE 0
5937 * 0 -1 : R NULL FALSE prec. >6
5938 * 0 -1 : C *names FALSE prec. 0..?
5939 * p p : Fp NULL FALSE
5940 * p -p : Fp(a) *names FALSE
5941 * q q : GF(q=p^n) *names TRUE
5942 */
5943 if (cf==NULL)
5944 {
5945 WerrorS("Invalid ground field specification");
5946 goto rInitError;
5947// const int ch=32003;
5948// cf=nInitChar(n_Zp, (void*)(long)ch);
5949 }
5950
5951 assume( R != NULL );
5952
5953 R->cf = cf;
5954
5955 /* names and number of variables-------------------------------------*/
5956 {
5957 int l=rv->listLength();
5958
5959 if (l>MAX_SHORT)
5960 {
5961 Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
5962 goto rInitError;
5963 }
5964 R->N = l; /*rv->listLength();*/
5965 }
5966 R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
5967 if (rSleftvList2StringArray(rv, R->names))
5968 {
5969 WerrorS("name of ring variable expected");
5970 goto rInitError;
5971 }
5972
5973 /* check names and parameters for conflicts ------------------------- */
5974 rRenameVars(R); // conflicting variables will be renamed
5975 /* ordering -------------------------------------------------------------*/
5976 if (rSleftvOrdering2Ordering(ord, R))
5977 goto rInitError;
5978
5979 // Complete the initialization
5980 if (rComplete(R,1))
5981 goto rInitError;
5982
5983/*#ifdef HAVE_RINGS
5984// currently, coefficients which are ring elements require a global ordering:
5985 if (rField_is_Ring(R) && (R->OrdSgn==-1))
5986 {
5987 WerrorS("global ordering required for these coefficients");
5988 goto rInitError;
5989 }
5990#endif*/
5991
5992 rTest(R);
5993
5994 // try to enter the ring into the name list
5995 // need to clean up sleftv here, before this ring can be set to
5996 // new currRing or currRing can be killed beacuse new ring has
5997 // same name
5998 pn->CleanUp();
5999 rv->CleanUp();
6000 ord->CleanUp();
6001 //if ((tmp = enterid(s, myynest, RING_CMD, &IDROOT))==NULL)
6002 // goto rInitError;
6003
6004 //memcpy(IDRING(tmp),R,sizeof(*R));
6005 // set current ring
6006 //omFreeBin(R, ip_sring_bin);
6007 //return tmp;
6008 return R;
6009
6010 // error case:
6011 rInitError:
6012 if ((R != NULL)&&(R->cf!=NULL)) rDelete(R);
6013 pn->CleanUp();
6014 rv->CleanUp();
6015 ord->CleanUp();
6016 return NULL;
6017}
CanonicalForm cf
Definition cfModGcd.cc:4091
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
idhdl rDefault(const char *s)
Definition ipshell.cc:1645
const short MAX_SHORT
Definition ipshell.cc:5616
BOOLEAN rSleftvOrdering2Ordering(sleftv *ord, ring R)
Definition ipshell.cc:5308
static BOOLEAN rSleftvList2StringArray(leftv sl, char **p)
Definition ipshell.cc:5580
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
#define rTest(r)
Definition ring.h:799

◆ rKill() [1/2]

void rKill ( idhdl h)

Definition at line 6226 of file ipshell.cc.

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

◆ rKill() [2/2]

void rKill ( ring r)

Definition at line 6181 of file ipshell.cc.

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

◆ rOptimizeOrdAsSleftv()

leftv rOptimizeOrdAsSleftv ( leftv ord)
static

Definition at line 5189 of file ipshell.cc.

5190{
5191 // change some bad orderings/combination into better ones
5192 leftv h=ord;
5193 while(h!=NULL)
5194 {
5195 BOOLEAN change=FALSE;
5196 intvec *iv = (intvec *)(h->data);
5197 // ws(-i) -> wp(i)
5198 if ((*iv)[1]==ringorder_ws)
5199 {
5200 BOOLEAN neg=TRUE;
5201 for(int i=2;i<iv->length();i++)
5202 if((*iv)[i]>=0) { neg=FALSE; break; }
5203 if (neg)
5204 {
5205 (*iv)[1]=ringorder_wp;
5206 for(int i=2;i<iv->length();i++)
5207 (*iv)[i]= - (*iv)[i];
5208 change=TRUE;
5209 }
5210 }
5211 // Ws(-i) -> Wp(i)
5212 if ((*iv)[1]==ringorder_Ws)
5213 {
5214 BOOLEAN neg=TRUE;
5215 for(int i=2;i<iv->length();i++)
5216 if((*iv)[i]>=0) { neg=FALSE; break; }
5217 if (neg)
5218 {
5219 (*iv)[1]=ringorder_Wp;
5220 for(int i=2;i<iv->length();i++)
5221 (*iv)[i]= -(*iv)[i];
5222 change=TRUE;
5223 }
5224 }
5225 // wp(1) -> dp
5226 if ((*iv)[1]==ringorder_wp)
5227 {
5228 BOOLEAN all_one=TRUE;
5229 for(int i=2;i<iv->length();i++)
5230 if((*iv)[i]!=1) { all_one=FALSE; break; }
5231 if (all_one)
5232 {
5233 intvec *iv2=new intvec(3);
5234 (*iv2)[0]=1;
5235 (*iv2)[1]=ringorder_dp;
5236 (*iv2)[2]=iv->length()-2;
5237 delete iv;
5238 iv=iv2;
5239 h->data=iv2;
5240 change=TRUE;
5241 }
5242 }
5243 // Wp(1) -> Dp
5244 if ((*iv)[1]==ringorder_Wp)
5245 {
5246 BOOLEAN all_one=TRUE;
5247 for(int i=2;i<iv->length();i++)
5248 if((*iv)[i]!=1) { all_one=FALSE; break; }
5249 if (all_one)
5250 {
5251 intvec *iv2=new intvec(3);
5252 (*iv2)[0]=1;
5253 (*iv2)[1]=ringorder_Dp;
5254 (*iv2)[2]=iv->length()-2;
5255 delete iv;
5256 iv=iv2;
5257 h->data=iv2;
5258 change=TRUE;
5259 }
5260 }
5261 // dp(1)/Dp(1)/rp(1) -> lp(1)
5262 if (((*iv)[1]==ringorder_dp)
5263 || ((*iv)[1]==ringorder_Dp)
5264 || ((*iv)[1]==ringorder_rp))
5265 {
5266 if (iv->length()==3)
5267 {
5268 if ((*iv)[2]==1)
5269 {
5270 if(h->next!=NULL)
5271 {
5272 intvec *iv2 = (intvec *)(h->next->data);
5273 if ((*iv2)[1]==ringorder_lp)
5274 {
5275 (*iv)[1]=ringorder_lp;
5276 change=TRUE;
5277 }
5278 }
5279 }
5280 }
5281 }
5282 // lp(i),lp(j) -> lp(i+j)
5283 if(((*iv)[1]==ringorder_lp)
5284 && (h->next!=NULL))
5285 {
5286 intvec *iv2 = (intvec *)(h->next->data);
5287 if ((*iv2)[1]==ringorder_lp)
5288 {
5289 leftv hh=h->next;
5290 h->next=hh->next;
5291 hh->next=NULL;
5292 if ((*iv2)[0]==1)
5293 (*iv)[2] += 1; // last block unspecified, at least 1
5294 else
5295 (*iv)[2] += (*iv2)[2];
5296 hh->CleanUp();
5298 change=TRUE;
5299 }
5300 }
5301 // -------------------
5302 if (!change) h=h->next;
5303 }
5304 return ord;
5305}

◆ rRenameVars()

void rRenameVars ( ring R)
static

Definition at line 2395 of file ipshell.cc.

2396{
2397 int i,j;
2398 BOOLEAN ch;
2399 do
2400 {
2401 ch=0;
2402 for(i=0;i<R->N-1;i++)
2403 {
2404 for(j=i+1;j<R->N;j++)
2405 {
2406 if (strcmp(R->names[i],R->names[j])==0)
2407 {
2408 ch=TRUE;
2409 Warn("name conflict var(%d) and var(%d): `%s`, rename to `@%s`in >>%s<<\nin %s:%d",i+1,j+1,R->names[i],R->names[i],my_yylinebuf,currentVoice->filename,yylineno);
2410 omFree(R->names[j]);
2411 size_t len=2+strlen(R->names[i]);
2412 R->names[j]=(char *)omAlloc(len);
2413 snprintf(R->names[j],len,"@%s",R->names[i]);
2414 }
2415 }
2416 }
2417 }
2418 while (ch);
2419 for(i=0;i<rPar(R); i++)
2420 {
2421 for(j=0;j<R->N;j++)
2422 {
2423 if (strcmp(rParameter(R)[i],R->names[j])==0)
2424 {
2425 Warn("name conflict par(%d) and var(%d): `%s`, rename the VARIABLE to `@@(%d)`in >>%s<<\nin %s:%d",i+1,j+1,R->names[j],i+1,my_yylinebuf,currentVoice->filename,yylineno);
2426// omFree(rParameter(R)[i]);
2427// rParameter(R)[i]=(char *)omAlloc(10);
2428// sprintf(rParameter(R)[i],"@@(%d)",i+1);
2429 omFree(R->names[j]);
2430 R->names[j]=(char *)omAlloc(16);
2431 snprintf(R->names[j],16,"@@(%d)",i+1);
2432 }
2433 }
2434 }
2435}

◆ rSetHdl()

void rSetHdl ( idhdl h)

Definition at line 5129 of file ipshell.cc.

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

◆ rSimpleFindHdl()

idhdl rSimpleFindHdl ( const ring r,
const idhdl root,
const idhdl n )
static

Definition at line 6269 of file ipshell.cc.

6270{
6271 idhdl h=root;
6272 while (h!=NULL)
6273 {
6274 if ((IDTYP(h)==RING_CMD)
6275 && (h!=n)
6276 && (IDRING(h)==r)
6277 )
6278 {
6279 return h;
6280 }
6281 h=IDNEXT(h);
6282 }
6283 return NULL;
6284}

◆ rSleftvList2StringArray()

BOOLEAN rSleftvList2StringArray ( leftv sl,
char ** p )
static

Definition at line 5580 of file ipshell.cc.

5581{
5582
5583 while(sl!=NULL)
5584 {
5585 if ((sl->rtyp == IDHDL)||(sl->rtyp==ALIAS_CMD))
5586 {
5587 *p = omStrDup(sl->Name());
5588 }
5589 else if (sl->name!=NULL)
5590 {
5591 *p = (char*)sl->name;
5592 sl->name=NULL;
5593 }
5594 else if (sl->rtyp==POLY_CMD)
5595 {
5596 sleftv s_sl;
5597 iiConvert(POLY_CMD,ANY_TYPE,-1,sl,&s_sl);
5598 if (s_sl.name != NULL)
5599 {
5600 *p = (char*)s_sl.name; s_sl.name=NULL;
5601 }
5602 else
5603 *p = NULL;
5604 sl->next = s_sl.next;
5605 s_sl.next = NULL;
5606 s_sl.CleanUp();
5607 if (*p == NULL) return TRUE;
5608 }
5609 else return TRUE;
5610 p++;
5611 sl=sl->next;
5612 }
5613 return FALSE;
5614}

◆ rSleftvOrdering2Ordering()

BOOLEAN rSleftvOrdering2Ordering ( sleftv * ord,
ring R )

Definition at line 5308 of file ipshell.cc.

5309{
5310 int last = 0, o=0, n = 1, i=0, typ = 1, j;
5311 ord=rOptimizeOrdAsSleftv(ord);
5312 sleftv *sl = ord;
5313
5314 // determine nBlocks
5315 while (sl!=NULL)
5316 {
5317 intvec *iv = (intvec *)(sl->data);
5318 if (((*iv)[1]==ringorder_c)||((*iv)[1]==ringorder_C))
5319 i++;
5320 else if ((*iv)[1]==ringorder_L)
5321 {
5322 R->wanted_maxExp=(*iv)[2]*2+1;
5323 n--;
5324 }
5325 else if (((*iv)[1]!=ringorder_a)
5326 && ((*iv)[1]!=ringorder_a64)
5327 && ((*iv)[1]!=ringorder_am))
5328 o++;
5329 n++;
5330 sl=sl->next;
5331 }
5332 // check whether at least one real ordering
5333 if (o==0)
5334 {
5335 WerrorS("invalid combination of orderings");
5336 return TRUE;
5337 }
5338 // if no c/C ordering is given, increment n
5339 if (i==0) n++;
5340 else if (i != 1)
5341 {
5342 // throw error if more than one is given
5343 WerrorS("more than one ordering c/C specified");
5344 return TRUE;
5345 }
5346
5347 // initialize fields of R
5348 R->order=(rRingOrder_t *)omAlloc0(n*sizeof(rRingOrder_t));
5349 R->block0=(int *)omAlloc0(n*sizeof(int));
5350 R->block1=(int *)omAlloc0(n*sizeof(int));
5351 R->wvhdl=(int**)omAlloc0(n*sizeof(int_ptr));
5352
5353 int *weights=(int*)omAlloc0((R->N+1)*sizeof(int));
5354
5355 // init order, so that rBlocks works correctly
5356 for (j=0; j < n-1; j++)
5357 R->order[j] = ringorder_unspec;
5358 // set last _C order, if no c/C order was given
5359 if (i == 0) R->order[n-2] = ringorder_C;
5360
5361 /* init orders */
5362 sl=ord;
5363 n=-1;
5364 while (sl!=NULL)
5365 {
5366 intvec *iv;
5367 iv = (intvec *)(sl->data);
5368 if ((*iv)[1]!=ringorder_L)
5369 {
5370 n++;
5371
5372 /* the format of an ordering:
5373 * iv[0]: factor
5374 * iv[1]: ordering
5375 * iv[2..end]: weights
5376 */
5377 R->order[n] = (rRingOrder_t)((*iv)[1]);
5378 typ=1;
5379 switch ((*iv)[1])
5380 {
5381 case ringorder_ws:
5382 case ringorder_Ws:
5383 typ=-1; // and continue
5384 case ringorder_wp:
5385 case ringorder_Wp:
5386 R->wvhdl[n]=(int*)omAlloc((iv->length()-1)*sizeof(int));
5387 R->block0[n] = last+1;
5388 for (i=2; i<iv->length(); i++)
5389 {
5390 R->wvhdl[n][i-2] = (*iv)[i];
5391 last++;
5392 if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5393 }
5394 R->block1[n] = si_min(last,R->N);
5395 break;
5396 case ringorder_ls:
5397 case ringorder_ds:
5398 case ringorder_Ds:
5399 case ringorder_rs:
5400 typ=-1; // and continue
5401 case ringorder_lp:
5402 case ringorder_dp:
5403 case ringorder_Dp:
5404 case ringorder_rp:
5405 R->block0[n] = last+1;
5406 if (iv->length() == 3) last+=(*iv)[2];
5407 else last += (*iv)[0];
5408 R->block1[n] = si_min(last,R->N);
5409 if (rCheckIV(iv)) return TRUE;
5410 for(i=si_min(rVar(R),R->block1[n]);i>=R->block0[n];i--)
5411 {
5412 if (weights[i]==0) weights[i]=typ;
5413 }
5414 break;
5415
5416 case ringorder_s: // no 'rank' params!
5417 {
5418
5419 if(iv->length() > 3)
5420 return TRUE;
5421
5422 if(iv->length() == 3)
5423 {
5424 const int s = (*iv)[2];
5425 R->block0[n] = s;
5426 R->block1[n] = s;
5427 }
5428 break;
5429 }
5430 case ringorder_IS:
5431 {
5432 if(iv->length() != 3) return TRUE;
5433
5434 const int s = (*iv)[2];
5435
5436 if( 1 < s || s < -1 ) return TRUE;
5437
5438 R->block0[n] = s;
5439 R->block1[n] = s;
5440 break;
5441 }
5442 case ringorder_S:
5443 case ringorder_c:
5444 case ringorder_C:
5445 {
5446 if (rCheckIV(iv)) return TRUE;
5447 break;
5448 }
5449 case ringorder_aa:
5450 case ringorder_a:
5451 {
5452 R->block0[n] = last+1;
5453 R->block1[n] = si_min(last+iv->length()-2 , R->N);
5454 R->wvhdl[n] = (int*)omAlloc((iv->length()-1)*sizeof(int));
5455 for (i=2; i<iv->length(); i++)
5456 {
5457 R->wvhdl[n][i-2]=(*iv)[i];
5458 last++;
5459 if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5460 }
5461 last=R->block0[n]-1;
5462 break;
5463 }
5464 case ringorder_am:
5465 {
5466 R->block0[n] = last+1;
5467 R->block1[n] = si_min(last+iv->length()-2 , R->N);
5468 R->wvhdl[n] = (int*)omAlloc(iv->length()*sizeof(int));
5469 if (R->block1[n]- R->block0[n]+2>=iv->length())
5470 WarnS("missing module weights");
5471 for (i=2; i<=(R->block1[n]-R->block0[n]+2); i++)
5472 {
5473 R->wvhdl[n][i-2]=(*iv)[i];
5474 last++;
5475 if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5476 }
5477 R->wvhdl[n][i-2]=iv->length() -3 -(R->block1[n]- R->block0[n]);
5478 for (; i<iv->length(); i++)
5479 {
5480 R->wvhdl[n][i-1]=(*iv)[i];
5481 }
5482 last=R->block0[n]-1;
5483 break;
5484 }
5485 case ringorder_a64:
5486 {
5487 R->block0[n] = last+1;
5488 R->block1[n] = si_min(last+iv->length()-2 , R->N);
5489 R->wvhdl[n] = (int*)omAlloc((iv->length()-1)*sizeof(int64));
5490 int64 *w=(int64 *)R->wvhdl[n];
5491 for (i=2; i<iv->length(); i++)
5492 {
5493 w[i-2]=(*iv)[i];
5494 last++;
5495 if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5496 }
5497 last=R->block0[n]-1;
5498 break;
5499 }
5500 case ringorder_M:
5501 {
5502 int Mtyp=rTypeOfMatrixOrder(iv);
5503 if (Mtyp==0) return TRUE;
5504 if (Mtyp==-1) typ = -1;
5505
5506 R->wvhdl[n] =( int *)omAlloc((iv->length()-1)*sizeof(int));
5507 for (i=2; i<iv->length();i++)
5508 R->wvhdl[n][i-2]=(*iv)[i];
5509
5510 R->block0[n] = last+1;
5511 last += (int)sqrt((double)(iv->length()-2));
5512 R->block1[n] = si_min(last,R->N);
5513 for(i=R->block1[n];i>=R->block0[n];i--)
5514 {
5515 if (weights[i]==0) weights[i]=typ;
5516 }
5517 break;
5518 }
5519
5520 case ringorder_no:
5521 R->order[n] = ringorder_unspec;
5522 return TRUE;
5523
5524 default:
5525 Werror("Internal Error: Unknown ordering %d", (*iv)[1]);
5526 R->order[n] = ringorder_unspec;
5527 return TRUE;
5528 }
5529 }
5530 if (last>R->N)
5531 {
5532 Werror("mismatch of number of vars (%d) and ordering (>=%d vars)",
5533 R->N,last);
5534 return TRUE;
5535 }
5536 sl=sl->next;
5537 }
5538 // find OrdSgn:
5539 R->OrdSgn = 1;
5540 for(i=1;i<=R->N;i++)
5541 { if (weights[i]<0) { R->OrdSgn=-1;break; }}
5542 omFree(weights);
5543
5544 // check for complete coverage
5545 while ( n >= 0 && (
5546 (R->order[n]==ringorder_c)
5547 || (R->order[n]==ringorder_C)
5548 || (R->order[n]==ringorder_s)
5549 || (R->order[n]==ringorder_S)
5550 || (R->order[n]==ringorder_IS)
5551 )) n--;
5552
5553 assume( n >= 0 );
5554
5555 if (R->block1[n] != R->N)
5556 {
5557 if (((R->order[n]==ringorder_dp) ||
5558 (R->order[n]==ringorder_ds) ||
5559 (R->order[n]==ringorder_Dp) ||
5560 (R->order[n]==ringorder_Ds) ||
5561 (R->order[n]==ringorder_rp) ||
5562 (R->order[n]==ringorder_rs) ||
5563 (R->order[n]==ringorder_lp) ||
5564 (R->order[n]==ringorder_ls))
5565 &&
5566 R->block0[n] <= R->N)
5567 {
5568 R->block1[n] = R->N;
5569 }
5570 else
5571 {
5572 Werror("mismatch of number of vars (%d) and ordering (%d vars)",
5573 R->N,R->block1[n]);
5574 return TRUE;
5575 }
5576 }
5577 return FALSE;
5578}
long int64
Definition auxiliary.h:68
STATIC_VAR poly last
Definition hdegree.cc:1138
static leftv rOptimizeOrdAsSleftv(leftv ord)
Definition ipshell.cc:5189
int rTypeOfMatrixOrder(const intvec *order)
Definition ring.cc:186
BOOLEAN rCheckIV(const intvec *iv)
Definition ring.cc:176
@ ringorder_no
Definition ring.h:70

◆ rSubring()

ring rSubring ( ring org_ring,
sleftv * rv )

Definition at line 6019 of file ipshell.cc.

6020{
6021 ring R = rCopy0(org_ring);
6022 int *perm=(int *)omAlloc0((org_ring->N+1)*sizeof(int));
6023 int n = rBlocks(org_ring), i=0, j;
6024
6025 /* names and number of variables-------------------------------------*/
6026 {
6027 int l=rv->listLength();
6028 if (l>MAX_SHORT)
6029 {
6030 Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
6031 goto rInitError;
6032 }
6033 R->N = l; /*rv->listLength();*/
6034 }
6035 omFree(R->names);
6036 R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
6037 if (rSleftvList2StringArray(rv, R->names))
6038 {
6039 WerrorS("name of ring variable expected");
6040 goto rInitError;
6041 }
6042
6043 /* check names for subring in org_ring ------------------------- */
6044 {
6045 i=0;
6046
6047 for(j=0;j<R->N;j++)
6048 {
6049 for(;i<org_ring->N;i++)
6050 {
6051 if (strcmp(org_ring->names[i],R->names[j])==0)
6052 {
6053 perm[i+1]=j+1;
6054 break;
6055 }
6056 }
6057 if (i>org_ring->N)
6058 {
6059 Werror("variable %d (%s) not in basering",j+1,R->names[j]);
6060 break;
6061 }
6062 }
6063 }
6064 //Print("perm=");
6065 //for(i=1;i<org_ring->N;i++) Print("v%d -> v%d\n",i,perm[i]);
6066 /* ordering -------------------------------------------------------------*/
6067
6068 for(i=0;i<n;i++)
6069 {
6070 int min_var=-1;
6071 int max_var=-1;
6072 for(j=R->block0[i];j<=R->block1[i];j++)
6073 {
6074 if (perm[j]>0)
6075 {
6076 if (min_var==-1) min_var=perm[j];
6077 max_var=perm[j];
6078 }
6079 }
6080 if (min_var!=-1)
6081 {
6082 //Print("block %d: old %d..%d, now:%d..%d\n",
6083 // i,R->block0[i],R->block1[i],min_var,max_var);
6084 R->block0[i]=min_var;
6085 R->block1[i]=max_var;
6086 if (R->wvhdl[i]!=NULL)
6087 {
6088 omFree(R->wvhdl[i]);
6089 R->wvhdl[i]=(int*)omAlloc0((max_var-min_var+1)*sizeof(int));
6090 for(j=org_ring->block0[i];j<=org_ring->block1[i];j++)
6091 {
6092 if (perm[j]>0)
6093 {
6094 R->wvhdl[i][perm[j]-R->block0[i]]=
6095 org_ring->wvhdl[i][j-org_ring->block0[i]];
6096 //Print("w%d=%d (orig_w%d)\n",perm[j],R->wvhdl[i][perm[j]-R->block0[i]],j);
6097 }
6098 }
6099 }
6100 }
6101 else
6102 {
6103 if(R->block0[i]>0)
6104 {
6105 //Print("skip block %d\n",i);
6106 R->order[i]=ringorder_unspec;
6107 if (R->wvhdl[i] !=NULL) omFree(R->wvhdl[i]);
6108 R->wvhdl[i]=NULL;
6109 }
6110 //else Print("keep block %d\n",i);
6111 }
6112 }
6113 i=n-1;
6114 while(i>0)
6115 {
6116 // removed unneded blocks
6117 if(R->order[i-1]==ringorder_unspec)
6118 {
6119 for(j=i;j<=n;j++)
6120 {
6121 R->order[j-1]=R->order[j];
6122 R->block0[j-1]=R->block0[j];
6123 R->block1[j-1]=R->block1[j];
6124 if (R->wvhdl[j-1] !=NULL) omFree(R->wvhdl[j-1]);
6125 R->wvhdl[j-1]=R->wvhdl[j];
6126 }
6127 R->order[n]=ringorder_unspec;
6128 n--;
6129 }
6130 i--;
6131 }
6132 n=rBlocks(org_ring)-1;
6133 while (R->order[n]==0) n--;
6134 while (R->order[n]==ringorder_unspec) n--;
6135 if ((R->order[n]==ringorder_c) || (R->order[n]==ringorder_C)) n--;
6136 if (R->block1[n] != R->N)
6137 {
6138 if (((R->order[n]==ringorder_dp) ||
6139 (R->order[n]==ringorder_ds) ||
6140 (R->order[n]==ringorder_Dp) ||
6141 (R->order[n]==ringorder_Ds) ||
6142 (R->order[n]==ringorder_rp) ||
6143 (R->order[n]==ringorder_rs) ||
6144 (R->order[n]==ringorder_lp) ||
6145 (R->order[n]==ringorder_ls))
6146 &&
6147 R->block0[n] <= R->N)
6148 {
6149 R->block1[n] = R->N;
6150 }
6151 else
6152 {
6153 Werror("mismatch of number of vars (%d) and ordering (%d vars) in block %d",
6154 R->N,R->block1[n],n);
6155 return NULL;
6156 }
6157 }
6158 omFree(perm);
6159 // find OrdSgn:
6160 R->OrdSgn = org_ring->OrdSgn; // IMPROVE!
6161 //for(i=1;i<=R->N;i++)
6162 //{ if (weights[i]<0) { R->OrdSgn=-1;break; }}
6163 //omFree(weights);
6164 // Complete the initialization
6165 if (rComplete(R,1))
6166 goto rInitError;
6167
6168 rTest(R);
6169
6170 if (rv != NULL) rv->CleanUp();
6171
6172 return R;
6173
6174 // error case:
6175 rInitError:
6176 if (R != NULL) rDelete(R);
6177 if (rv != NULL) rv->CleanUp();
6178 return NULL;
6179}
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427

◆ scIndIndset()

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

Definition at line 1111 of file ipshell.cc.

1113{
1114 int i;
1115 indset save;
1117
1118 hexist = hInit(S, Q, &hNexist);
1119 if (hNexist == 0)
1120 {
1121 intvec *iv=new intvec(rVar(currRing));
1122 for(i=0; i<rVar(currRing); i++) (*iv)[i]=1;
1123 res->Init(1);
1124 res->m[0].rtyp=INTVEC_CMD;
1125 res->m[0].data=(intvec*)iv;
1126 return res;
1127 }
1129 hMu = 0;
1130 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1131 hvar = (varset)omAlloc((rVar(currRing) + 1) * sizeof(int));
1132 hpure = (scmon)omAlloc0((1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1133 hrad = hexist;
1134 hNrad = hNexist;
1135 radmem = hCreate(rVar(currRing) - 1);
1136 hCo = rVar(currRing) + 1;
1137 hNvar = rVar(currRing);
1139 hSupp(hrad, hNrad, hvar, &hNvar);
1140 if (hNvar)
1141 {
1142 hCo = hNvar;
1143 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
1146 }
1147 if (hCo && (hCo < rVar(currRing)))
1148 {
1150 }
1151 if (hMu!=0)
1152 {
1153 ISet = save;
1154 hMu2 = 0;
1155 if (all && (hCo+1 < rVar(currRing)))
1156 {
1159 i=hMu+hMu2;
1160 res->Init(i);
1161 if (hMu2 == 0)
1162 {
1164 }
1165 }
1166 else
1167 {
1168 res->Init(hMu);
1169 }
1170 for (i=0;i<hMu;i++)
1171 {
1172 res->m[i].data = (void *)save->set;
1173 res->m[i].rtyp = INTVEC_CMD;
1174 ISet = save;
1175 save = save->nx;
1177 }
1179 if (hMu2 != 0)
1180 {
1181 save = JSet;
1182 for (i=hMu;i<hMu+hMu2;i++)
1183 {
1184 res->m[i].data = (void *)save->set;
1185 res->m[i].rtyp = INTVEC_CMD;
1186 JSet = save;
1187 save = save->nx;
1189 }
1191 }
1192 }
1193 else
1194 {
1195 res->Init(0);
1197 }
1198 hKill(radmem, rVar(currRing) - 1);
1199 omFreeSize((ADDRESS)hpure, (1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1200 omFreeSize((ADDRESS)hvar, (rVar(currRing) + 1) * sizeof(int));
1201 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1203 return res;
1204}
void hIndMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:382
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:351
VAR long hMu
Definition hdegree.cc:28
VAR indset JSet
Definition hdegree.cc:351
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:562
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
#define Q
Definition sirandom.c:26

◆ semicProc()

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

Definition at line 4554 of file ipshell.cc.

4555{
4556 sleftv tmp;
4557 tmp.Init();
4558 tmp.rtyp=INT_CMD;
4559 /* tmp.data = (void *)0; -- done by Init */
4560
4561 return semicProc3(res,u,v,&tmp);
4562}
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
Definition ipshell.cc:4514

◆ semicProc3()

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

Definition at line 4514 of file ipshell.cc.

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

◆ siSetCpus()

int siSetCpus ( int cpu)

Definition at line 6665 of file ipshell.cc.

6666{
6667 int old=(int)(long)feOptValue(FE_OPT_CPUS);
6668 feSetOptValue(FE_OPT_CPUS,cpu);
6669 return old;
6670}
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition feOpt.cc:154
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40

◆ spaddProc()

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

Definition at line 4431 of file ipshell.cc.

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

◆ spectrumCompute()

spectrumState spectrumCompute ( poly h,
lists * L,
int fast )

Definition at line 3812 of file ipshell.cc.

3813{
3814 int i;
3815
3816 #ifdef SPECTRUM_DEBUG
3817 #ifdef SPECTRUM_PRINT
3818 #ifdef SPECTRUM_IOSTREAM
3819 cout << "spectrumCompute\n";
3820 if( fast==0 ) cout << " no optimization" << endl;
3821 if( fast==1 ) cout << " weight optimization" << endl;
3822 if( fast==2 ) cout << " symmetry optimization" << endl;
3823 #else
3824 fputs( "spectrumCompute\n",stdout );
3825 if( fast==0 ) fputs( " no optimization\n", stdout );
3826 if( fast==1 ) fputs( " weight optimization\n", stdout );
3827 if( fast==2 ) fputs( " symmetry optimization\n", stdout );
3828 #endif
3829 #endif
3830 #endif
3831
3832 // ----------------------
3833 // check if h is zero
3834 // ----------------------
3835
3836 if( h==(poly)NULL )
3837 {
3838 return spectrumZero;
3839 }
3840
3841 // ----------------------------------
3842 // check if h has a constant term
3843 // ----------------------------------
3844
3845 if( hasConstTerm( h, currRing ) )
3846 {
3847 return spectrumBadPoly;
3848 }
3849
3850 // --------------------------------
3851 // check if h has a linear term
3852 // --------------------------------
3853
3854 if( hasLinearTerm( h, currRing ) )
3855 {
3856 *L = (lists)omAllocBin( slists_bin);
3857 (*L)->Init( 1 );
3858 (*L)->m[0].rtyp = INT_CMD; // milnor number
3859 /* (*L)->m[0].data = (void*)0;a -- done by Init */
3860
3861 return spectrumNoSingularity;
3862 }
3863
3864 // ----------------------------------
3865 // compute the jacobi ideal of (h)
3866 // ----------------------------------
3867
3868 ideal J = NULL;
3869 J = idInit( rVar(currRing),1 );
3870
3871 #ifdef SPECTRUM_DEBUG
3872 #ifdef SPECTRUM_PRINT
3873 #ifdef SPECTRUM_IOSTREAM
3874 cout << "\n computing the Jacobi ideal...\n";
3875 #else
3876 fputs( "\n computing the Jacobi ideal...\n",stdout );
3877 #endif
3878 #endif
3879 #endif
3880
3881 for( i=0; i<rVar(currRing); i++ )
3882 {
3883 J->m[i] = pDiff( h,i+1); //j );
3884
3885 #ifdef SPECTRUM_DEBUG
3886 #ifdef SPECTRUM_PRINT
3887 #ifdef SPECTRUM_IOSTREAM
3888 cout << " ";
3889 #else
3890 fputs(" ", stdout );
3891 #endif
3892 pWrite( J->m[i] );
3893 #endif
3894 #endif
3895 }
3896
3897 // --------------------------------------------
3898 // compute a standard basis stdJ of jac(h)
3899 // --------------------------------------------
3900
3901 #ifdef SPECTRUM_DEBUG
3902 #ifdef SPECTRUM_PRINT
3903 #ifdef SPECTRUM_IOSTREAM
3904 cout << endl;
3905 cout << " computing a standard basis..." << endl;
3906 #else
3907 fputs( "\n", stdout );
3908 fputs( " computing a standard basis...\n", stdout );
3909 #endif
3910 #endif
3911 #endif
3912
3913 ideal stdJ = kStd2(J,currRing->qideal,isNotHomog,NULL,NULL);
3914 idSkipZeroes( stdJ );
3915
3916 #ifdef SPECTRUM_DEBUG
3917 #ifdef SPECTRUM_PRINT
3918 for( i=0; i<IDELEMS(stdJ); i++ )
3919 {
3920 #ifdef SPECTRUM_IOSTREAM
3921 cout << " ";
3922 #else
3923 fputs( " ",stdout );
3924 #endif
3925
3926 pWrite( stdJ->m[i] );
3927 }
3928 #endif
3929 #endif
3930
3931 idDelete( &J );
3932
3933 // ------------------------------------------
3934 // check if the h has a singularity
3935 // ------------------------------------------
3936
3937 if( hasOne( stdJ, currRing ) )
3938 {
3939 // -------------------------------
3940 // h is smooth in the origin
3941 // return only the Milnor number
3942 // -------------------------------
3943
3944 *L = (lists)omAllocBin( slists_bin);
3945 (*L)->Init( 1 );
3946 (*L)->m[0].rtyp = INT_CMD; // milnor number
3947 /* (*L)->m[0].data = (void*)0;a -- done by Init */
3948
3949 return spectrumNoSingularity;
3950 }
3951
3952 // ------------------------------------------
3953 // check if the singularity h is isolated
3954 // ------------------------------------------
3955
3956 for( i=rVar(currRing); i>0; i-- )
3957 {
3958 if( hasAxis( stdJ,i, currRing )==FALSE )
3959 {
3960 return spectrumNotIsolated;
3961 }
3962 }
3963
3964 // ------------------------------------------
3965 // compute the highest corner hc of stdJ
3966 // ------------------------------------------
3967
3968 #ifdef SPECTRUM_DEBUG
3969 #ifdef SPECTRUM_PRINT
3970 #ifdef SPECTRUM_IOSTREAM
3971 cout << "\n computing the highest corner...\n";
3972 #else
3973 fputs( "\n computing the highest corner...\n", stdout );
3974 #endif
3975 #endif
3976 #endif
3977
3978 poly hc = (poly)NULL;
3979
3980 scComputeHC( stdJ,currRing->qideal, 0,hc );
3981
3982 if( hc!=(poly)NULL )
3983 {
3984 pGetCoeff(hc) = nInit(1);
3985
3986 for( i=rVar(currRing); i>0; i-- )
3987 {
3988 int e;
3989 if( (e=pGetExp( hc,i ))>0 ) pSetExp( hc,i,e-1 );
3990 }
3991 pSetm( hc );
3992 }
3993 else
3994 {
3995 return spectrumNoHC;
3996 }
3997
3998 #ifdef SPECTRUM_DEBUG
3999 #ifdef SPECTRUM_PRINT
4000 #ifdef SPECTRUM_IOSTREAM
4001 cout << " ";
4002 #else
4003 fputs( " ", stdout );
4004 #endif
4005 pWrite( hc );
4006 #endif
4007 #endif
4008
4009 // ----------------------------------------
4010 // compute the Newton polygon nph of h
4011 // ----------------------------------------
4012
4013 #ifdef SPECTRUM_DEBUG
4014 #ifdef SPECTRUM_PRINT
4015 #ifdef SPECTRUM_IOSTREAM
4016 cout << "\n computing the newton polygon...\n";
4017 #else
4018 fputs( "\n computing the newton polygon...\n", stdout );
4019 #endif
4020 #endif
4021 #endif
4022
4023 newtonPolygon nph( h, currRing );
4024
4025 #ifdef SPECTRUM_DEBUG
4026 #ifdef SPECTRUM_PRINT
4027 cout << nph;
4028 #endif
4029 #endif
4030
4031 // -----------------------------------------------
4032 // compute the weight corner wc of (stdj,nph)
4033 // -----------------------------------------------
4034
4035 #ifdef SPECTRUM_DEBUG
4036 #ifdef SPECTRUM_PRINT
4037 #ifdef SPECTRUM_IOSTREAM
4038 cout << "\n computing the weight corner...\n";
4039 #else
4040 fputs( "\n computing the weight corner...\n", stdout );
4041 #endif
4042 #endif
4043 #endif
4044
4045 poly wc = ( fast==0 ? pCopy( hc ) :
4046 ( fast==1 ? computeWC( nph,(Rational)rVar(currRing), currRing ) :
4047 /* fast==2 */computeWC( nph,
4048 ((Rational)rVar(currRing))/(Rational)2, currRing ) ) );
4049
4050 #ifdef SPECTRUM_DEBUG
4051 #ifdef SPECTRUM_PRINT
4052 #ifdef SPECTRUM_IOSTREAM
4053 cout << " ";
4054 #else
4055 fputs( " ", stdout );
4056 #endif
4057 pWrite( wc );
4058 #endif
4059 #endif
4060
4061 // -------------
4062 // compute NF
4063 // -------------
4064
4065 #ifdef SPECTRUM_DEBUG
4066 #ifdef SPECTRUM_PRINT
4067 #ifdef SPECTRUM_IOSTREAM
4068 cout << "\n computing NF...\n" << endl;
4069 #else
4070 fputs( "\n computing NF...\n", stdout );
4071 #endif
4072 #endif
4073 #endif
4074
4075 spectrumPolyList NF( &nph );
4076
4077 computeNF( stdJ,hc,wc,&NF, currRing );
4078
4079 #ifdef SPECTRUM_DEBUG
4080 #ifdef SPECTRUM_PRINT
4081 cout << NF;
4082 #ifdef SPECTRUM_IOSTREAM
4083 cout << endl;
4084 #else
4085 fputs( "\n", stdout );
4086 #endif
4087 #endif
4088 #endif
4089
4090 // ----------------------------
4091 // compute the spectrum of h
4092 // ----------------------------
4093// spectrumState spectrumStateFromList( spectrumPolyList& speclist, lists *L, int fast );
4094
4095 return spectrumStateFromList(NF, L, fast );
4096}
spectrumState spectrumStateFromList(spectrumPolyList &speclist, lists *L, int fast)
Definition ipshell.cc:3571
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
BOOLEAN hasAxis(ideal J, int k, const ring r)
Definition spectrum.cc:81
int hasOne(ideal J, const ring r)
Definition spectrum.cc:96
static BOOLEAN hasConstTerm(poly h, const ring r)
Definition spectrum.cc:63
poly computeWC(const newtonPolygon &np, Rational max_weight, const ring r)
Definition spectrum.cc:142
static BOOLEAN hasLinearTerm(poly h, const ring r)
Definition spectrum.cc:72
void computeNF(ideal stdJ, poly hc, poly wc, spectrumPolyList *NF, const ring r)
Definition spectrum.cc:309
@ isNotHomog
Definition structs.h:32

◆ spectrumfProc()

BOOLEAN spectrumfProc ( leftv result,
leftv first )

Definition at line 4187 of file ipshell.cc.

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

◆ spectrumFromList()

spectrum spectrumFromList ( lists l)

Definition at line 3386 of file ipshell.cc.

3387{
3389 copy_deep( result, l );
3390 return result;
3391}
void copy_deep(spectrum &spec, lists l)
Definition ipshell.cc:3362

◆ spectrumPrintError()

void spectrumPrintError ( spectrumState state)

Definition at line 4105 of file ipshell.cc.

4106{
4107 switch( state )
4108 {
4109 case spectrumZero:
4110 WerrorS( "polynomial is zero" );
4111 break;
4112 case spectrumBadPoly:
4113 WerrorS( "polynomial has constant term" );
4114 break;
4116 WerrorS( "not a singularity" );
4117 break;
4119 WerrorS( "the singularity is not isolated" );
4120 break;
4121 case spectrumNoHC:
4122 WerrorS( "highest corner cannot be computed" );
4123 break;
4124 case spectrumDegenerate:
4125 WerrorS( "principal part is degenerate" );
4126 break;
4127 case spectrumOK:
4128 break;
4129
4130 default:
4131 WerrorS( "unknown error occurred" );
4132 break;
4133 }
4134}

◆ spectrumProc()

BOOLEAN spectrumProc ( leftv result,
leftv first )

Definition at line 4136 of file ipshell.cc.

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

◆ spectrumStateFromList()

spectrumState spectrumStateFromList ( spectrumPolyList & speclist,
lists * L,
int fast )

Definition at line 3571 of file ipshell.cc.

3572{
3573 spectrumPolyNode **node = &speclist.root;
3575
3576 poly f,tmp;
3577 int found,cmp;
3578
3579 Rational smax( ( fast==0 ? 0 : rVar(currRing) ),
3580 ( fast==2 ? 2 : 1 ) );
3581
3582 Rational weight_prev( 0,1 );
3583
3584 int mu = 0; // the milnor number
3585 int pg = 0; // the geometrical genus
3586 int n = 0; // number of different spectral numbers
3587 int z = 0; // number of spectral number equal to smax
3588
3589 while( (*node)!=(spectrumPolyNode*)NULL &&
3590 ( fast==0 || (*node)->weight<=smax ) )
3591 {
3592 // ---------------------------------------
3593 // determine the first normal form which
3594 // contains the monomial node->mon
3595 // ---------------------------------------
3596
3597 found = FALSE;
3598 search = *node;
3599
3600 while( search!=(spectrumPolyNode*)NULL && found==FALSE )
3601 {
3602 if( search->nf!=(poly)NULL )
3603 {
3604 f = search->nf;
3605
3606 do
3607 {
3608 // --------------------------------
3609 // look for (*node)->mon in f
3610 // --------------------------------
3611
3612 cmp = pCmp( (*node)->mon,f );
3613
3614 if( cmp<0 )
3615 {
3616 f = pNext( f );
3617 }
3618 else if( cmp==0 )
3619 {
3620 // -----------------------------
3621 // we have found a normal form
3622 // -----------------------------
3623
3624 found = TRUE;
3625
3626 // normalize coefficient
3627
3628 number inv = nInvers( pGetCoeff( f ) );
3629 search->nf=__p_Mult_nn( search->nf,inv,currRing );
3630 nDelete( &inv );
3631
3632 // exchange normal forms
3633
3634 tmp = (*node)->nf;
3635 (*node)->nf = search->nf;
3636 search->nf = tmp;
3637 }
3638 }
3639 while( cmp<0 && f!=(poly)NULL );
3640 }
3641 search = search->next;
3642 }
3643
3644 if( found==FALSE )
3645 {
3646 // ------------------------------------------------
3647 // the weight of node->mon is a spectrum number
3648 // ------------------------------------------------
3649
3650 mu++;
3651
3652 if( (*node)->weight<=(Rational)1 ) pg++;
3653 if( (*node)->weight==smax ) z++;
3654 if( (*node)->weight>weight_prev ) n++;
3655
3656 weight_prev = (*node)->weight;
3657 node = &((*node)->next);
3658 }
3659 else
3660 {
3661 // -----------------------------------------------
3662 // determine all other normal form which contain
3663 // the monomial node->mon
3664 // replace for node->mon its normal form
3665 // -----------------------------------------------
3666
3667 while( search!=(spectrumPolyNode*)NULL )
3668 {
3669 if( search->nf!=(poly)NULL )
3670 {
3671 f = search->nf;
3672
3673 do
3674 {
3675 // --------------------------------
3676 // look for (*node)->mon in f
3677 // --------------------------------
3678
3679 cmp = pCmp( (*node)->mon,f );
3680
3681 if( cmp<0 )
3682 {
3683 f = pNext( f );
3684 }
3685 else if( cmp==0 )
3686 {
3687 search->nf = pSub( search->nf,
3688 __pp_Mult_nn( (*node)->nf,pGetCoeff( f ),currRing ) );
3689 pNorm( search->nf );
3690 }
3691 }
3692 while( cmp<0 && f!=(poly)NULL );
3693 }
3694 search = search->next;
3695 }
3696 speclist.delete_node( node );
3697 }
3698
3699 }
3700
3701 // --------------------------------------------------------
3702 // fast computation exploits the symmetry of the spectrum
3703 // --------------------------------------------------------
3704
3705 if( fast==2 )
3706 {
3707 mu = 2*mu - z;
3708 n = ( z > 0 ? 2*n - 1 : 2*n );
3709 }
3710
3711 // --------------------------------------------------------
3712 // compute the spectrum numbers with their multiplicities
3713 // --------------------------------------------------------
3714
3715 intvec *nom = new intvec( n );
3716 intvec *den = new intvec( n );
3717 intvec *mult = new intvec( n );
3718
3719 int count = 0;
3720 int multiplicity = 1;
3721
3722 for( search=speclist.root; search!=(spectrumPolyNode*)NULL &&
3723 ( fast==0 || search->weight<=smax );
3724 search=search->next )
3725 {
3726 if( search->next==(spectrumPolyNode*)NULL ||
3727 search->weight<search->next->weight )
3728 {
3729 (*nom) [count] = search->weight.get_num_si( );
3730 (*den) [count] = search->weight.get_den_si( );
3731 (*mult)[count] = multiplicity;
3732
3733 multiplicity=1;
3734 count++;
3735 }
3736 else
3737 {
3738 multiplicity++;
3739 }
3740 }
3741
3742 // --------------------------------------------------------
3743 // fast computation exploits the symmetry of the spectrum
3744 // --------------------------------------------------------
3745
3746 if( fast==2 )
3747 {
3748 int n1,n2;
3749 for( n1=0, n2=n-1; n1<n2; n1++, n2-- )
3750 {
3751 (*nom) [n2] = rVar(currRing)*(*den)[n1]-(*nom)[n1];
3752 (*den) [n2] = (*den)[n1];
3753 (*mult)[n2] = (*mult)[n1];
3754 }
3755 }
3756
3757 // -----------------------------------
3758 // test if the spectrum is symmetric
3759 // -----------------------------------
3760
3761 if( fast==0 || fast==1 )
3762 {
3763 int symmetric=TRUE;
3764
3765 for( int n1=0, n2=n-1 ; n1<n2 && symmetric==TRUE; n1++, n2-- )
3766 {
3767 if( (*mult)[n1]!=(*mult)[n2] ||
3768 (*den) [n1]!= (*den)[n2] ||
3769 (*nom)[n1]+(*nom)[n2]!=rVar(currRing)*(*den) [n1] )
3770 {
3771 symmetric = FALSE;
3772 }
3773 }
3774
3775 if( symmetric==FALSE )
3776 {
3777 // ---------------------------------------------
3778 // the spectrum is not symmetric => degenerate
3779 // principal part
3780 // ---------------------------------------------
3781
3782 *L = (lists)omAllocBin( slists_bin);
3783 (*L)->Init( 1 );
3784 (*L)->m[0].rtyp = INT_CMD; // milnor number
3785 (*L)->m[0].data = (void*)(long)mu;
3786
3787 return spectrumDegenerate;
3788 }
3789 }
3790
3791 *L = (lists)omAllocBin( slists_bin);
3792
3793 (*L)->Init( 6 );
3794
3795 (*L)->m[0].rtyp = INT_CMD; // milnor number
3796 (*L)->m[1].rtyp = INT_CMD; // geometrical genus
3797 (*L)->m[2].rtyp = INT_CMD; // number of spectrum values
3798 (*L)->m[3].rtyp = INTVEC_CMD; // nominators
3799 (*L)->m[4].rtyp = INTVEC_CMD; // denomiantors
3800 (*L)->m[5].rtyp = INTVEC_CMD; // multiplicities
3801
3802 (*L)->m[0].data = (void*)(long)mu;
3803 (*L)->m[1].data = (void*)(long)pg;
3804 (*L)->m[2].data = (void*)(long)n;
3805 (*L)->m[3].data = (void*)nom;
3806 (*L)->m[4].data = (void*)den;
3807 (*L)->m[5].data = (void*)mult;
3808
3809 return spectrumOK;
3810}
FILE * f
Definition checklibs.c:9
spectrumPolyNode * root
Definition splist.h:60
void delete_node(spectrumPolyNode **)
Definition splist.cc:256
bool found
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
STATIC_VAR int * multiplicity
#define pNext(p)
Definition monomials.h:36
#define nInvers(a)
Definition numbers.h:33
#define __pp_Mult_nn(p, n, r)
Definition p_polys.h:1004
#define __p_Mult_nn(p, n, r)
Definition p_polys.h:973
void pNorm(poly p)
Definition polys.h:363
#define pSub(a, b)
Definition polys.h:288
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition polys.h:116

◆ spmulProc()

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

Definition at line 4473 of file ipshell.cc.

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

◆ syBetti1()

BOOLEAN syBetti1 ( leftv res,
leftv u )

Definition at line 3166 of file ipshell.cc.

3167{
3168 sleftv tmp;
3169 tmp.Init();
3170 tmp.rtyp=INT_CMD;
3171 tmp.data=(void *)1;
3172 return syBetti2(res,u,&tmp);
3173}
BOOLEAN syBetti2(leftv res, leftv u, leftv w)
Definition ipshell.cc:3142

◆ syBetti2()

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

Definition at line 3142 of file ipshell.cc.

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

◆ syConvList()

syStrategy syConvList ( lists li)

Definition at line 3250 of file ipshell.cc.

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

◆ syConvRes()

lists syConvRes ( syStrategy syzstr,
BOOLEAN toDel,
int add_row_shift )

Definition at line 3178 of file ipshell.cc.

3179{
3180 resolvente fullres = syzstr->fullres;
3181 resolvente minres = syzstr->minres;
3182
3183 const int length = syzstr->length;
3184
3185 if ((fullres==NULL) && (minres==NULL))
3186 {
3187 if (syzstr->hilb_coeffs==NULL)
3188 { // La Scala
3189 fullres = syReorder(syzstr->res, length, syzstr);
3190 }
3191 else
3192 { // HRES
3193 minres = syReorder(syzstr->orderedRes, length, syzstr);
3194 syKillEmptyEntres(minres, length);
3195 }
3196 }
3197
3198 resolvente tr;
3199 int typ0=IDEAL_CMD;
3200
3201 if (minres!=NULL)
3202 tr = minres;
3203 else
3204 tr = fullres;
3205
3206 resolvente trueres=NULL;
3207 intvec ** w=NULL;
3208
3209 if (length>0)
3210 {
3211 trueres = (resolvente)omAlloc0((length)*sizeof(ideal));
3212 for (int i=length-1;i>=0;i--)
3213 {
3214 if (tr[i]!=NULL)
3215 {
3216 trueres[i] = idCopy(tr[i]);
3217 }
3218 }
3219 if ( id_RankFreeModule(trueres[0], currRing) > 0)
3220 typ0 = MODUL_CMD;
3221 if (syzstr->weights!=NULL)
3222 {
3223 w = (intvec**)omAlloc0(length*sizeof(intvec*));
3224 for (int i=length-1;i>=0;i--)
3225 {
3226 if (syzstr->weights[i]!=NULL) w[i] = ivCopy(syzstr->weights[i]);
3227 }
3228 }
3229 }
3230
3231 lists li = liMakeResolv(trueres, length, syzstr->list_length,typ0,
3232 w, add_row_shift);
3233
3234 if (toDel)
3235 syKillComputation(syzstr);
3236 else
3237 {
3238 if( fullres != NULL && syzstr->fullres == NULL )
3239 syzstr->fullres = fullres;
3240
3241 if( minres != NULL && syzstr->minres == NULL )
3242 syzstr->minres = minres;
3243 }
3244 return li;
3245}
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:1496
resolvente syReorder(resolvente res, int length, syStrategy syzstr, BOOLEAN toCopy=TRUE, resolvente totake=NULL)
Definition syz1.cc:1642
void syKillEmptyEntres(resolvente res, int length)
Definition syz1.cc:2200
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 513 of file ipshell.cc.

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

◆ type_cmd()

void type_cmd ( leftv v)

Definition at line 255 of file ipshell.cc.

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

Variable Documentation

◆ iiCurrArgs

VAR leftv iiCurrArgs =NULL

Definition at line 81 of file ipshell.cc.

◆ iiCurrProc

VAR idhdl iiCurrProc =NULL

Definition at line 82 of file ipshell.cc.

◆ iiDebugMarker

VAR BOOLEAN iiDebugMarker =TRUE

Definition at line 1071 of file ipshell.cc.

◆ iiNoKeepRing

STATIC_VAR BOOLEAN iiNoKeepRing =TRUE

Definition at line 85 of file ipshell.cc.

◆ lastreserved

const char* lastreserved =NULL

Definition at line 83 of file ipshell.cc.

◆ MAX_SHORT

const short MAX_SHORT = 32767

Definition at line 5616 of file ipshell.cc.