10 #include "factory/factory.h"
114 case LE:
return "<=";
115 case GE:
return ">=";
124 if (
s[1]==
'\0')
return s[0];
125 else if (
s[2]!=
'\0')
return 0;
128 case '.':
if (
s[1]==
'.')
return DOTDOT;
134 case '+':
if (
s[1]==
'+')
return PLUSPLUS;
138 case '<':
if (
s[1]==
'=')
return LE;
141 case '>':
if (
s[1]==
'=')
return GE;
143 case '!':
if (
s[1]==
'=')
return NOTEQUAL;
155 if(fullname) sprintf(
buf2,
"%s::%s",
"",
IDID(
h));
199 && (strlen(
IDPROC(
h)->libname)>0))
210 memset(buffer,0,
sizeof(buffer));
212 if ((
s=strchr(buffer,
'\n'))!=
NULL)
220 Print(
"..., %d char(s)",
l);
237 { number2 n=(number2)
IDDATA(
h);
243 Print(
" %d x %d (%s)",
269 ((
intvec*)(
v->Data()))->cols());
break;
273 case MODUL_CMD:
Print(
", rk %d\n", (
int)(((ideal)(
v->Data()))->rank));
break;
376 && (((ring)d)->idroot!=
NULL))
402 if (((ring)
h->data)->idroot!=
NULL)
427 package savePack=currPack;
434 if (strcmp(what,
"all")==0)
469 Werror(
"%s is undefined",what);
503 package save_p=currPack;
537 WarnS(
"Gerhard, use the option command");
567 rc += ((
intvec *)(
v->Data()))->length();
578 rc+=((
lists)
v->Data())->nr+1;
599 WerrorS(
"write: need at least two arguments");
609 Werror(
"cannot write to %s",
s);
636 Werror(
"can not map from ground field of %s to current ground field",
640 if (
IDELEMS(theMap)<src_ring->N)
644 (src_ring->N)*
sizeof(poly));
654 short src_lV = src_ring->isLPring;
655 short src_ncGenCount = src_ring->LPncGenCount;
656 short src_nVars = src_lV - src_ncGenCount;
657 int src_nblocks = src_ring->N / src_lV;
660 short dest_ncGenCount =
currRing->LPncGenCount;
663 for(
i=
IDELEMS(theMap);
i < src_lV - src_ncGenCount;
i++)
671 if (theMap->m[
i] !=
NULL)
679 for(
i = src_nVars;
i < src_lV;
i++)
681 short ncGenIndex =
i - src_nVars;
682 if (ncGenIndex < dest_ncGenCount)
696 for(
i = 1;
i < src_nblocks;
i++)
698 for(
int j = 0;
j < src_lV;
j++)
716 WerrorS(
"argument of a map must have a name");
728 save_r=
IDMAP(
w)->preimage;
738 ideal
id=(ideal)tmpW.
data;
746 for(
int j=
IDELEMS(theMap)-1;
j>=0 && !overflow;
j--)
748 if (theMap->m[
j]!=
NULL)
755 if ((
p!=
NULL) && (degs[
i]!=0) &&
756 ((
unsigned long)deg_monexp > (
currRing->bitmask / ((
unsigned long)degs[
i])/2)))
768 for(
int j=
IDELEMS(theMap)-1;
j>=0 && !overflow;
j--)
770 if (theMap->m[
j]!=
NULL)
773 poly
p=(poly)tmpW.
data;
776 ((
unsigned long)deg_monexp > (
currRing->bitmask / ((
unsigned long)deg)/2)))
790 Warn(
"possible OVERFLOW in map, max exponent is %ld",
currRing->bitmask/2);
809 char *tmp = theMap->preimage;
810 theMap->preimage=(
char*)1L;
813 theMap->preimage=tmp;
828 IDMAP(
w)->preimage=save_r;
836 Werror(
"%s undefined in %s",what,theMap->preimage);
841 Werror(
"cannot find preimage %s",theMap->preimage);
857 sprintf(
s,
"%s(%d)",
name,
i+1);
864 h->data.uideal=(ideal)L->
m[
i].
data;
867 Print(
"//defining: %s as %d-th syzygy module\n",
s,
i+1);
872 Warn(
"cannot define %s",
s);
952 int add_row_shift = 0;
955 if (weights!=
NULL) add_row_shift=weights->
min_in();
984 l->m[0].rtyp=u->
Typ();
985 l->m[0].data=u->
Data();
988 l->m[0].attribute=*a;
995 l->m[0].attribute=
NULL;
1009 int add_row_shift=0;
1015 add_row_shift = ww->
min_in();
1016 (*weights) -= add_row_shift;
1023 res->data=(
void*)res_im;
1026 for(
int i=1;
i<=res_im->
rows();
i++)
1028 if (
IMATELEM(*res_im,1,
i)==0) { add_row_shift--; }
1033 if (weights!=
NULL)
delete weights;
1046 int add_row_shift=0;
1051 add_row_shift = ww->
min_in();
1052 (*weights) -= add_row_shift;
1057 if (weights!=
NULL)
delete weights;
1060 return reg+1+add_row_shift;
1064 #define BREAK_LINE_LENGTH 80
1091 else if(strncmp(
s,
"cont;",5)==0)
1098 strcat(
s,
"\n;~\n");
1168 res->m[
i].data = (
void *)save->set;
1180 res->m[
i].data = (
void *)save->set;
1206 const char *
id =
name->name;
1211 WerrorS(
"object to declare is not a name");
1221 Werror(
"can not define `%s` in other package",
name->name);
1282 WerrorS(
"branchTo can only occur in a proc");
1290 if (ll!=(
l-1))
return FALSE;
1293 short *t=(
short*)
omAlloc(
l*
sizeof(
short));
1297 for(
i=1;
i<
l;
i++,
h=
h->next)
1302 Werror(
"arg %d is not a string",
i);
1306 b=
IsCmd((
char *)
h->Data(),tt);
1311 Werror(
"arg %d is not a type name",
i);
1318 Werror(
"last(%d.) arg.(%s) is not a proc(but %s(%d)), nesting=%d",
1331 if(
pi->data.s.body==
NULL )
1360 if (err==0)
Warn(
"too many arguments for %s",
IDID(currProc));
1384 if (strcmp(
p->name,
"#")==0)
1393 if (strcmp(
p->name,
"#")==0)
1395 is_default_list=
TRUE;
1403 if (is_default_list)
1473 Warn(
"'%s': no such identifier\n",
v->
name);
1476 package frompack=v->req_packhdl;
1490 v->req_packhdl=rootpack;
1491 if (
h==frompack->idroot)
1493 frompack->idroot=
h->next;
1497 idhdl hh=frompack->idroot;
1504 Werror(
"`%s` not found",
v->Name());
1508 h->next=rootpack->idroot;
1522 Werror(
"cannot export:%s of internal type %d",
v->
name,
v->rtyp);
1551 Werror(
"cannot export:%s of internal type %d",
v->
name,
v->rtyp);
1564 else if (
IDTYP(old)==
v->Typ())
1602 WerrorS(
"no ring active (9)");
1644 WarnS(
"package not found\n");
1665 #ifndef TEST_ZN_AS_ZP
1669 mpz_init_set_ui(modBase, (
long)32003);
1676 r->cf->has_simple_Inverse=1;
1689 r->block0 = (
int *)
omAlloc0(3 *
sizeof(
int *));
1690 r->block1 = (
int *)
omAlloc0(3 *
sizeof(
int *));
1709 if ((r==
NULL)||(r->VarOffset==
NULL))
1748 L->
m[0].
data=(
void *)(
long)r->cf->ch;
1754 for(
i=0;
i<r->N;
i++)
1760 L->
m[1].
data=(
void *)LL;
1777 if (r->block1[
i]-r->block0[
i] >=0 )
1779 j=r->block1[
i]-r->block0[
i];
1782 if ((r->wvhdl!=
NULL) && (r->wvhdl[
i]!=
NULL))
1784 for(;
j>=0;
j--) (*iv)[
j]=r->wvhdl[
i][
j];
1786 else switch (r->order[
i])
1795 for(;
j>=0;
j--) (*iv)[
j]=1;
1805 LLL->
m[1].
data=(
void *)iv;
1806 LL->
m[
i].
data=(
void *)LLL;
1809 L->
m[2].
data=(
void *)LL;
1819 pSetCoeff0(q->m[0],(number)(r->qideal->m[0]));
1820 L->
m[3].
data=(
void *)q;
1839 L->
m[0].
data=(
void *)0;
1849 L->
m[1].
data=(
void *)LL;
1873 L->
m[0].
data=(
void *)0;
1883 L->
m[1].
data=(
void *)LL;
1917 LL->
m[1].
data=(
void *) C->modExponent;
1919 L->
m[1].
data=(
void *)LL;
1946 LL->
m[1].
data=(
void *)
R->cf->modExponent;
1948 L->
m[1].
data=(
void *)LL;
1962 WerrorS(
"ring with polynomial data must be the base ring or compatible");
1975 else if ( C->extRing!=
NULL )
1985 Lc->m[0].data=(
void*)(
long)C->m_nfCharQ;
1992 Lc->m[1].data=(
void*)Lv;
2003 Loo->
m[1].
data=(
void *)iv;
2006 Lo->
m[0].
data=(
void*)Loo;
2009 Lc->m[2].data=(
void*)Lo;
2015 res->data=(
void*)
Lc;
2020 res->data=(
void *)(
long)C->ch;
2041 WerrorS(
"ring with polynomial data must be the base ring or compatible");
2059 L->
m[0].
data=(
char*)r->cf; r->cf->ref++;
2065 for(
i=0;
i<r->N;
i++)
2071 L->
m[1].
data=(
void *)LL;
2091 assume( r->block0[
i] == r->block1[
i] );
2092 const int s = r->block0[
i];
2098 else if (r->block1[
i]-r->block0[
i] >=0 )
2100 int bl=
j=r->block1[
i]-r->block0[
i];
2108 j+=r->wvhdl[
i][bl+1];
2111 if ((r->wvhdl!=
NULL) && (r->wvhdl[
i]!=
NULL))
2113 for(;
j>=0;
j--) (*iv)[
j]=r->wvhdl[
i][
j+(
j>bl)];
2115 else switch (r->order[
i])
2122 for(;
j>=0;
j--) (*iv)[
j]=1;
2132 LLL->
m[1].
data=(
void *)iv;
2133 LL->m[
i].data=(
void *)LLL;
2136 L->
m[2].
data=(
void *)LL;
2140 if (r->qideal==
NULL)
2166 || (r->qideal !=
NULL)
2173 WerrorS(
"ring with polynomial data must be the base ring or compatible");
2198 else if ( r->cf->extRing!=
NULL )
2208 Lc->m[0].data=(
void*)(
long)r->cf->m_nfCharQ;
2215 Lc->m[1].data=(
void*)Lv;
2226 Loo->
m[1].
data=(
void *)iv;
2229 Lo->
m[0].
data=(
void*)Loo;
2232 Lc->m[2].data=(
void*)Lo;
2243 L->
m[0].
data=(
void *)(
long)r->cf->ch;
2250 for(
i=0;
i<r->N;
i++)
2256 L->
m[1].
data=(
void *)LL;
2277 assume( r->block0[
i] == r->block1[
i] );
2278 const int s = r->block0[
i];
2284 else if (r->block1[
i]-r->block0[
i] >=0 )
2286 int bl=
j=r->block1[
i]-r->block0[
i];
2294 j+=r->wvhdl[
i][bl+1];
2297 if ((r->wvhdl!=
NULL) && (r->wvhdl[
i]!=
NULL))
2299 for(;
j>=0;
j--) (*iv)[
j]=r->wvhdl[
i][
j+(
j>bl)];
2301 else switch (r->order[
i])
2310 for(;
j>=0;
j--) (*iv)[
j]=1;
2320 LLL->
m[1].
data=(
void *)iv;
2321 LL->
m[
i].
data=(
void *)LLL;
2324 L->
m[2].
data=(
void *)LL;
2328 if (r->qideal==
NULL)
2352 WerrorS(
"invalid coeff. field description, expecting 0");
2360 WerrorS(
"invalid coeff. field description, expecting precision list");
2368 WerrorS(
"invalid coeff. field description list, expected list(`int`,`int`)");
2371 int r1=(int)(
long)LL->
m[0].
data;
2372 int r2=(int)(
long)LL->
m[1].
data;
2382 WerrorS(
"invalid coeff. field description, expecting parameter name");
2404 unsigned int modExponent = 1;
2408 mpz_init_set_ui(modBase,0);
2419 number tmp= (number) LL->
m[0].
data;
2426 mpz_init_set_ui(modBase,(
unsigned long) LL->
m[0].
data);
2430 mpz_init_set_ui(modBase,0);
2434 modExponent = (
unsigned long) LL->
m[1].
data;
2442 if ((mpz_cmp_ui(modBase, 1) == 0) && (
mpz_sgn1(modBase) < 0))
2444 WerrorS(
"Wrong ground ring specification (module is 1)");
2447 if (modExponent < 1)
2449 WerrorS(
"Wrong ground ring specification (exponent smaller than 1)");
2458 else if (modExponent > 1)
2461 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*
sizeof(
unsigned long)))
2472 info.exp= modExponent;
2483 info.exp= modExponent;
2497 for(
i=0;
i<
R->N-1;
i++)
2499 for(
j=
i+1;
j<
R->N;
j++)
2501 if (strcmp(
R->names[
i],
R->names[
j])==0)
2506 R->names[
j]=(
char *)
omAlloc(2+strlen(
R->names[
i]));
2507 sprintf(
R->names[
j],
"@%s",
R->names[
i]);
2525 sprintf(
R->names[
j],
"@@(%d)",
i+1);
2551 poly
p=(poly)
v->m[
i].Data();
2557 Werror(
"var name %d must be a string or a ring variable",
i+1);
2563 Werror(
"var name %d must be `string` (not %d)",
i+1,
v->m[
i].Typ());
2570 WerrorS(
"variable must be given as `list`");
2586 for (
int j=0;
j < n-1;
j++)
2593 &&(strcmp((
char*)vv->
m[0].
Data(),
"L")==0))
2595 number nn=(number)vv->
m[1].
Data();
2602 Werror(
"illegal argument for pseudo ordering L: %d",vv->
m[1].
Typ());
2609 if (bitmask!=0) n--;
2613 R->block0=(
int *)
omAlloc0((n+1)*
sizeof(int));
2614 R->block1=(
int *)
omAlloc0((n+1)*
sizeof(int));
2617 for (j_in_R= n-2; j_in_R>=0; j_in_R--)
2620 for(j_in_R=0,j_in_L=0;j_in_R<n-1;j_in_R++,j_in_L++)
2625 WerrorS(
"ordering must be list of lists");
2632 if (strcmp((
char*)vv->
m[0].
Data(),
"L")==0)
2646 if (j_in_R==0)
R->block0[0]=1;
2663 if (jj<0)
R->block0[j_in_R]=1;
2664 else R->block0[j_in_R]=
R->block1[jj]+1;
2671 for(
int i=0;
i<
l;
i++) (*iv)[
i]=1;
2690 R->block1[j_in_R]=
si_max(
R->block0[j_in_R],
R->block0[j_in_R]+iv_len-1);
2691 if (
R->block1[j_in_R]>
R->N)
2693 if (
R->block0[j_in_R]>
R->N)
2698 R->block1[j_in_R]=
R->N;
2699 iv_len=
R->block1[j_in_R]-
R->block0[j_in_R]+1;
2704 switch (
R->order[j_in_R])
2713 R->wvhdl[j_in_R] =(
int *)
omAlloc(iv_len*
sizeof(
int));
2714 for (
i=0;
i<iv_len;
i++)
2716 R->wvhdl[j_in_R][
i]=(*iv)[
i];
2721 for (
i=0;
i<iv_len;
i++)
2723 R->wvhdl[j_in_R][
i]=(*iv)[
i];
2725 R->wvhdl[j_in_R][
i]=iv->
length() - iv_len;
2729 R->wvhdl[j_in_R][
i+1]=(*iv)[
i];
2734 for (
i=0;
i<iv->
length();
i++)
R->wvhdl[j_in_R][
i]=(*iv)[
i];
2735 R->block1[j_in_R]=
si_max(
R->block0[j_in_R],
R->block0[j_in_R]+(
int)
sqrt((
double)(iv->
length())));
2736 if (
R->block1[j_in_R]>
R->N)
2738 R->block1[j_in_R]=
R->N;
2751 for (
i=0;
i<iv_len;
i++)
2753 if (((*iv)[
i]!=1)&&(iv_len!=1))
2756 Warn(
"ignore weight %d for ord %d (%s) at pos %d\n>>%s<<",
2767 R->block1[j_in_R]=
R->block0[j_in_R]=0;
2771 R->block1[j_in_R]=
R->block0[j_in_R]=(*iv)[0];
2777 R->block1[j_in_R] =
R->block0[j_in_R] = 0;
2780 const int s = (*iv)[0];
2782 R->block1[j_in_R] =
R->block0[j_in_R] =
s;
2791 WerrorS(
"ring order not implemented");
2799 WerrorS(
"ordering name must be a (string,intvec)");
2808 if (
R->block1[j_in_R] !=
R->N)
2819 R->block0[j_in_R] <=
R->N)
2821 R->block1[j_in_R] =
R->N;
2825 Werror(
"ordering incomplete: size (%d) should be %d",
R->block1[j_in_R],
R->N);
2829 if (
R->block0[j_in_R]>
R->N)
2831 Werror(
"not enough variables (%d) for ordering block %d, scanned so far:",
R->N,j_in_R+1);
2832 for(
int ii=0;ii<=j_in_R;ii++)
2861 WerrorS(
"ordering must be given as `list`");
2864 if (bitmask!=0) {
R->bitmask=bitmask;
R->wanted_maxExp=bitmask; }
2896 int ch = (int)(
long)L->
m[0].
Data();
2906 Warn(
"%d is invalid characteristic of ground field. %d is used.", ch,
l);
2909 #ifndef TEST_ZN_AS_ZP
2913 mpz_init_set_ui(modBase,(
long) ch);
2920 R->cf->has_simple_Inverse=1;
2941 int ch = (int)(
long)LL->
m[0].
Data();
2942 while ((ch!=
fftable[is_gf_char]) && (
fftable[is_gf_char])) is_gf_char++;
2943 if (
fftable[is_gf_char]==0) is_gf_char=-1;
2964 WerrorS(
"could not create the specified coefficient field");
2968 if( extRing->qideal !=
NULL )
2972 extParam.
r = extRing;
2979 extParam.
r = extRing;
2989 WerrorS(
"coefficient field must be described by `int` or `list`");
2995 WerrorS(
"could not create coefficient field described by the input!");
3007 #ifdef HAVE_SHIFTBBA
3010 R->isLPring=isLetterplace;
3015 if ((bitmask!=0)&&(
R->wanted_maxExp==0))
R->wanted_maxExp=bitmask;
3022 ideal q=(ideal)L->
m[3].
Data();
3028 WerrorS(
"coefficient fields must be equal if q-ideal !=0");
3035 int par_perm_size=0;
3055 par_perm_size=
rPar(orig_ring);
3065 WerrorS(
"coefficient fields must be equal if q-ideal !=0");
3069 perm=(
int *)
omAlloc0((orig_ring->N+1)*
sizeof(int));
3070 if (par_perm_size!=0)
3071 par_perm=(
int *)
omAlloc0(par_perm_size*
sizeof(
int));
3075 maFindPerm(orig_ring->names,orig_ring->N,orig_ring->parameter,orig_ring->P,
3084 else if (par_perm_size!=0)
3092 par_perm,par_perm_size);
3110 WerrorS(
"q-ideal must be given as `ideal`");
3159 ideal
id=(ideal)a->
Data();
3179 int n=(int)(
long)
b->Data();
3180 int d=(int)(
long)c->
Data();
3187 if ((d>n) || (d<1) || (n<1))
3192 int *choise = (
int*)
omAlloc(d*
sizeof(
int));
3196 temp=(ideal)id->
Data();
3211 p =
pCopy(temp->m[choise[
l-1]-1]);
3237 BOOLEAN minim=(int)(
long)
w->Data();
3239 int add_row_shift=0;
3245 add_row_shift = ww->
min_in();
3246 (*weights) -= add_row_shift;
3275 if ((fullres==
NULL) && (minres==
NULL))
3387 ideal F=(ideal)id->
Data();
3393 res->data=(
char *)iv;
3397 double wNsqr = (double)2.0 / (
double)n;
3399 x = (
int * )
omAlloc(2 * (n + 1) *
sizeof(int));
3401 for (
i = n;
i!=0;
i--)
3402 (*iv)[
i-1] =
x[
i + n + 1];
3420 res->data=(
void *)
b;
3438 #ifdef HAVE_SPECTRUM
3446 spec.
mu = (int)(
long)(
l->m[0].Data( ));
3447 spec.
pg = (int)(
long)(
l->m[1].Data( ));
3448 spec.
n = (int)(
long)(
l->m[2].Data( ));
3456 for(
int i=0;
i<spec.
n;
i++ )
3459 spec.
w[
i] = (*mul)[
i];
3490 for(
int i=0;
i<spec.
n;
i++ )
3494 (*mult)[
i] = spec.
w[
i];
3504 L->
m[0].
data = (
void*)(
long)spec.
mu;
3505 L->
m[1].
data = (
void*)(
long)spec.
pg;
3506 L->
m[2].
data = (
void*)(
long)spec.
n;
3557 WerrorS(
"the list is too short" );
3560 WerrorS(
"the list is too long" );
3564 WerrorS(
"first element of the list should be int" );
3567 WerrorS(
"second element of the list should be int" );
3570 WerrorS(
"third element of the list should be int" );
3573 WerrorS(
"fourth element of the list should be intvec" );
3576 WerrorS(
"fifth element of the list should be intvec" );
3579 WerrorS(
"sixth element of the list should be intvec" );
3583 WerrorS(
"first element of the list should be positive" );
3586 WerrorS(
"wrong number of numerators" );
3589 WerrorS(
"wrong number of denominators" );
3592 WerrorS(
"wrong number of multiplicities" );
3596 WerrorS(
"the Milnor number should be positive" );
3599 WerrorS(
"the geometrical genus should be nonnegative" );
3602 WerrorS(
"all numerators should be positive" );
3605 WerrorS(
"all denominators should be positive" );
3608 WerrorS(
"all multiplicities should be positive" );
3612 WerrorS(
"it is not symmetric" );
3615 WerrorS(
"it is not monotonous" );
3619 WerrorS(
"the Milnor number is wrong" );
3622 WerrorS(
"the geometrical genus is wrong" );
3626 WerrorS(
"unspecific error" );
3662 ( fast==2 ? 2 : 1 ) );
3672 ( fast==0 || (*node)->weight<=smax ) )
3694 cmp =
pCmp( (*node)->mon,
f );
3717 (*node)->nf =
search->nf;
3721 while( cmp<0 &&
f!=(poly)
NULL );
3734 if( (*node)->weight<=(
Rational)1 ) pg++;
3735 if( (*node)->weight==smax ) z++;
3736 if( (*node)->weight>weight_prev ) n++;
3738 weight_prev = (*node)->weight;
3739 node = &((*node)->next);
3761 cmp =
pCmp( (*node)->mon,
f );
3774 while( cmp<0 &&
f!=(poly)
NULL );
3790 n = ( z > 0 ? 2*n - 1 : 2*n );
3805 ( fast==0 ||
search->weight<=smax );
3831 for( n1=0, n2=n-1; n1<n2; n1++, n2-- )
3834 (*den) [n2] = (*den)[n1];
3835 (*mult)[n2] = (*mult)[n1];
3843 if( fast==0 || fast==1 )
3847 for(
int n1=0, n2=n-1 ; n1<n2 && symmetric==
TRUE; n1++, n2-- )
3850 (*
den) [n1]!= (*
den)[n2] ||
3857 if( symmetric==
FALSE )
3867 (*L)->m[0].data = (
void*)(
long)
mu;
3884 (*L)->m[0].data = (
void*)(
long)
mu;
3885 (*L)->m[1].data = (
void*)(
long)pg;
3886 (*L)->m[2].data = (
void*)(
long)n;
3887 (*L)->m[3].data = (
void*)nom;
3888 (*L)->m[4].data = (
void*)
den;
3889 (*L)->m[5].data = (
void*)
mult;
3898 #ifdef SPECTRUM_DEBUG
3899 #ifdef SPECTRUM_PRINT
3900 #ifdef SPECTRUM_IOSTREAM
3901 cout <<
"spectrumCompute\n";
3902 if( fast==0 ) cout <<
" no optimization" << endl;
3903 if( fast==1 ) cout <<
" weight optimization" << endl;
3904 if( fast==2 ) cout <<
" symmetry optimization" << endl;
3906 fputs(
"spectrumCompute\n",stdout );
3907 if( fast==0 ) fputs(
" no optimization\n", stdout );
3908 if( fast==1 ) fputs(
" weight optimization\n", stdout );
3909 if( fast==2 ) fputs(
" symmetry optimization\n", stdout );
3953 #ifdef SPECTRUM_DEBUG
3954 #ifdef SPECTRUM_PRINT
3955 #ifdef SPECTRUM_IOSTREAM
3956 cout <<
"\n computing the Jacobi ideal...\n";
3958 fputs(
"\n computing the Jacobi ideal...\n",stdout );
3967 #ifdef SPECTRUM_DEBUG
3968 #ifdef SPECTRUM_PRINT
3969 #ifdef SPECTRUM_IOSTREAM
3972 fputs(
" ", stdout );
3983 #ifdef SPECTRUM_DEBUG
3984 #ifdef SPECTRUM_PRINT
3985 #ifdef SPECTRUM_IOSTREAM
3987 cout <<
" computing a standard basis..." << endl;
3989 fputs(
"\n", stdout );
3990 fputs(
" computing a standard basis...\n", stdout );
3998 #ifdef SPECTRUM_DEBUG
3999 #ifdef SPECTRUM_PRINT
4002 #ifdef SPECTRUM_IOSTREAM
4005 fputs(
" ",stdout );
4050 #ifdef SPECTRUM_DEBUG
4051 #ifdef SPECTRUM_PRINT
4052 #ifdef SPECTRUM_IOSTREAM
4053 cout <<
"\n computing the highest corner...\n";
4055 fputs(
"\n computing the highest corner...\n", stdout );
4060 poly hc = (poly)
NULL;
4064 if( hc!=(poly)
NULL )
4079 #ifdef SPECTRUM_DEBUG
4080 #ifdef SPECTRUM_PRINT
4081 #ifdef SPECTRUM_IOSTREAM
4084 fputs(
" ", stdout );
4094 #ifdef SPECTRUM_DEBUG
4095 #ifdef SPECTRUM_PRINT
4096 #ifdef SPECTRUM_IOSTREAM
4097 cout <<
"\n computing the newton polygon...\n";
4099 fputs(
"\n computing the newton polygon...\n", stdout );
4106 #ifdef SPECTRUM_DEBUG
4107 #ifdef SPECTRUM_PRINT
4116 #ifdef SPECTRUM_DEBUG
4117 #ifdef SPECTRUM_PRINT
4118 #ifdef SPECTRUM_IOSTREAM
4119 cout <<
"\n computing the weight corner...\n";
4121 fputs(
"\n computing the weight corner...\n", stdout );
4126 poly wc = ( fast==0 ?
pCopy( hc ) :
4131 #ifdef SPECTRUM_DEBUG
4132 #ifdef SPECTRUM_PRINT
4133 #ifdef SPECTRUM_IOSTREAM
4136 fputs(
" ", stdout );
4146 #ifdef SPECTRUM_DEBUG
4147 #ifdef SPECTRUM_PRINT
4148 #ifdef SPECTRUM_IOSTREAM
4149 cout <<
"\n computing NF...\n" << endl;
4151 fputs(
"\n computing NF...\n", stdout );
4160 #ifdef SPECTRUM_DEBUG
4161 #ifdef SPECTRUM_PRINT
4163 #ifdef SPECTRUM_IOSTREAM
4166 fputs(
"\n", stdout );
4191 WerrorS(
"polynomial is zero" );
4194 WerrorS(
"polynomial has constant term" );
4197 WerrorS(
"not a singularity" );
4200 WerrorS(
"the singularity is not isolated" );
4203 WerrorS(
"highest corner cannot be computed" );
4206 WerrorS(
"principal part is degenerate" );
4212 WerrorS(
"unknown error occurred" );
4229 WerrorS(
"only works for local orderings" );
4237 WerrorS(
"does not work in quotient rings" );
4283 WerrorS(
"only works for local orderings" );
4288 WerrorS(
"does not work in quotient rings" );
4347 else if(
l->nr > 5 )
4385 int mu = (int)(
long)(
l->m[0].Data( ));
4386 int pg = (int)(
long)(
l->m[1].Data( ));
4387 int n = (int)(
long)(
l->m[2].Data( ));
4398 if( n !=
num->length( ) )
4402 else if( n !=
den->length( ) )
4406 else if( n != mul->
length( ) )
4426 for(
i=0;
i<n;
i++ )
4428 if( (*
num)[
i] <= 0 )
4432 if( (*
den)[
i] <= 0 )
4436 if( (*mul)[
i] <= 0 )
4448 for(
i=0,
j=n-1;
i<=
j;
i++,
j-- )
4451 (*den)[
i] != (*den)[
j] ||
4452 (*mul)[
i] != (*mul)[
j] )
4462 for(
i=0,
j=1;
i<n/2;
i++,
j++ )
4464 if( (*
num)[
i]*(*den)[
j] >= (*num)[
j]*(*den)[
i] )
4474 for(
mu=0,
i=0;
i<n;
i++ )
4479 if(
mu != (
int)(long)(
l->m[0].Data( )) )
4488 for( pg=0,
i=0;
i<n;
i++ )
4490 if( (*
num)[
i]<=(*den)[
i] )
4496 if( pg != (
int)(long)(
l->m[1].Data( )) )
4525 WerrorS(
"first argument is not a spectrum:" );
4530 WerrorS(
"second argument is not a spectrum:" );
4563 int k = (int)(
long)second->
Data( );
4567 WerrorS(
"first argument is not a spectrum" );
4572 WerrorS(
"second argument should be positive" );
4598 BOOLEAN qh=(((int)(
long)
w->Data())==1);
4609 WerrorS(
"first argument is not a spectrum" );
4614 WerrorS(
"second argument is not a spectrum" );
4657 WerrorS(
"Ground field not implemented!");
4677 LP->
m= (int)(
long)(
v->Data());
4683 LP->
n= (int)(
long)(
v->Data());
4689 LP->
m1= (int)(
long)(
v->Data());
4695 LP->
m2= (int)(
long)(
v->Data());
4701 LP->
m3= (int)(
long)(
v->Data());
4703 #ifdef mprDEBUG_PROT
4704 Print(
"m (constraints) %d\n",LP->
m);
4705 Print(
"n (columns) %d\n",LP->
n);
4729 lres->
m[4].
data=(
void*)(
long)LP->
m;
4732 lres->
m[5].
data=(
void*)(
long)LP->
n;
4734 res->data= (
void*)lres;
4741 ideal gls = (ideal)(arg1->
Data());
4742 int imtype= (int)(
long)arg2->
Data();
4765 gls= (poly)(arg1->
Data());
4766 int howclean= (int)(
long)arg3->
Data();
4770 WerrorS(
"Input polynomial is constant!");
4779 rlist->
Init( r[0] );
4780 for(
int i=r[0];
i>0;
i--)
4795 WerrorS(
"Ground field not implemented!");
4802 unsigned long int ii = (
unsigned long int)arg2->
Data();
4827 if ( (vpos !=
i) && (
pGetExp( piter,
i ) != 0) )
4829 WerrorS(
"The input polynomial must be univariate!");
4837 number * pcoeffs= (number *)
omAlloc( (deg+1) *
sizeof( number ) );
4839 for (
i= deg;
i >= 0;
i-- )
4853 #ifdef mprDEBUG_PROT
4854 for (
i=deg;
i >= 0;
i--)
4862 roots->
solver( howclean );
4870 rlist->
Init( elem );
4874 for (
j= 0;
j < elem;
j++ )
4883 for (
j= 0;
j < elem;
j++ )
4887 rlist->
m[
j].
data=(
void *)dummy;
4900 res->data= (
void*)rlist;
4909 p= (ideal)arg1->
Data();
4910 w= (ideal)arg2->
Data();
4921 int tdg= (int)(
long)arg3->
Data();
4928 WerrorS(
"Last input parameter must be > 0!");
4936 if (
m != (
int)
pow((
double)tdg+1,(
double)n) )
4938 Werror(
"Size of second input ideal must be equal to %d!",
4939 (
int)
pow((
double)tdg+1,(
double)n));
4946 WerrorS(
"Ground field not implemented!");
4951 number *pevpoint= (number *)
omAlloc( n *
sizeof( number ) );
4952 for (
i= 0;
i < n;
i++ )
4961 WerrorS(
"Elements of first input ideal must not be equal to -1, 0, 1!");
4970 WerrorS(
"Elements of first input ideal must be numbers!");
4973 pevpoint[
i]=
nCopy( tmp );
4977 number *wresults= (number *)
omAlloc(
m *
sizeof( number ) );
4978 for (
i= 0;
i <
m;
i++ )
4987 WerrorS(
"Elements of second input ideal must be numbers!");
5002 res->data= (
void*)rpoly;
5017 else gls= (ideal)(
v->Data());
5023 else imtype= (int)(
long)
v->Data();
5028 ideal test_id=
idInit(1,1);
5032 if (gls->m[
j]!=
NULL)
5034 test_id->m[0]=gls->m[
j];
5038 WerrorS(
"Newton polytope not of expected dimension");
5052 unsigned long int ii=(
unsigned long int)
v->Data();
5060 else howclean= (int)(
long)
v->Data();
5089 WerrorS(
"Error occurred during matrix setup!");
5097 #ifdef mprDEBUG_PROT
5102 WerrorS(
"Unsuitable input ideal: Minor of resultant matrix is singular!");
5108 if ( interpolate_det )
5114 if ( interpolate_det )
5119 #ifdef mprDEBUG_PROT
5121 for (
i=0;
i < c;
i++)
pWrite(iproots[
i]->getPoly());
5123 for (
i=0;
i < c;
i++)
pWrite(muiproots[
i]->getPoly());
5127 arranger=
new rootArranger( iproots, muiproots, howclean );
5138 WerrorS(
"Solver was unable to find any roots!");
5144 for (
i=0;
i <
count;
i++)
delete iproots[
i];
5147 for (
i=0;
i <
count;
i++)
delete muiproots[
i];
5154 res->data= (
void *)listofroots;
5166 int count=
self->roots[0]->getAnzRoots();
5167 int elem=
self->roots[0]->getAnzElems();
5171 if ( self->found_roots )
5178 onepoint->
Init(elem);
5179 for (
j= 0;
j < elem;
j++ )
5195 listofroots->
m[
i].
data=(
void *)onepoint;
5203 listofroots->
Init( 0 );
5217 if (rg==
NULL)
return;
5241 Warn(
"deleting denom_list for ring change to %s",
IDID(
h));
5255 if ((rg!=
NULL) && (rg->idroot==
NULL))
5283 if((*iv)[
i]>=0) { neg=
FALSE;
break; }
5288 (*iv)[
i]= - (*iv)[
i];
5297 if((*iv)[
i]>=0) { neg=
FALSE;
break; }
5302 (*iv)[
i]= -(*iv)[
i];
5311 if((*iv)[
i]!=1) { all_one=
FALSE;
break; }
5317 (*iv2)[2]=iv->
length()-2;
5329 if((*iv)[
i]!=1) { all_one=
FALSE;
break; }
5335 (*iv2)[2]=iv->
length()-2;
5376 (*iv)[2] += (*iv2)[2];
5383 if (!change)
h=
h->next;
5391 int last = 0, o=0, n = 1,
i=0, typ = 1,
j;
5403 R->wanted_maxExp=(*iv)[2]*2+1;
5416 WerrorS(
"invalid combination of orderings");
5424 WerrorS(
"more than one ordering c/C specified");
5430 R->block0=(
int *)
omAlloc0(n*
sizeof(
int));
5431 R->block1=(
int *)
omAlloc0(n*
sizeof(
int));
5434 int *weights=(
int*)
omAlloc0((
R->N+1)*
sizeof(int));
5437 for (
j=0;
j < n-1;
j++)
5468 R->block0[n] =
last+1;
5471 R->wvhdl[n][
i-2] = (*iv)[
i];
5473 if (weights[
last]==0) weights[
last]=(*iv)[
i]*typ;
5486 R->block0[n] =
last+1;
5488 else last += (*iv)[0];
5493 if (weights[
i]==0) weights[
i]=typ;
5505 const int s = (*iv)[2];
5515 const int s = (*iv)[2];
5517 if( 1 <
s ||
s < -1 )
return TRUE;
5533 R->block0[n] =
last+1;
5538 R->wvhdl[n][
i-2]=(*iv)[
i];
5540 if (weights[
last]==0) weights[
last]=(*iv)[
i]*typ;
5542 last=
R->block0[n]-1;
5547 R->block0[n] =
last+1;
5550 if (
R->block1[n]-
R->block0[n]+2>=iv->
length())
5551 WarnS(
"missing module weights");
5552 for (
i=2;
i<=(
R->block1[n]-
R->block0[n]+2);
i++)
5554 R->wvhdl[n][
i-2]=(*iv)[
i];
5556 if (weights[
last]==0) weights[
last]=(*iv)[
i]*typ;
5558 R->wvhdl[n][
i-2]=iv->
length() -3 -(
R->block1[n]-
R->block0[n]);
5561 R->wvhdl[n][
i-1]=(*iv)[
i];
5563 last=
R->block0[n]-1;
5568 R->block0[n] =
last+1;
5576 if (weights[
last]==0) weights[
last]=(*iv)[
i]*typ;
5578 last=
R->block0[n]-1;
5584 if (Mtyp==0)
return TRUE;
5585 if (Mtyp==-1) typ = -1;
5589 R->wvhdl[n][
i-2]=(*iv)[
i];
5591 R->block0[n] =
last+1;
5594 for(
i=
R->block1[n];
i>=
R->block0[n];
i--)
5596 if (weights[
i]==0) weights[
i]=typ;
5606 Werror(
"Internal Error: Unknown ordering %d", (*iv)[1]);
5613 Werror(
"mismatch of number of vars (%d) and ordering (>=%d vars)",
5621 for(
i=1;
i<=
R->N;
i++)
5622 {
if (weights[
i]<0) {
R->OrdSgn=-1;
break; }}
5636 if (
R->block1[n] !=
R->N)
5647 R->block0[n] <=
R->N)
5649 R->block1[n] =
R->N;
5653 Werror(
"mismatch of number of vars (%d) and ordering (%d vars)",
5672 *
p = (
char*)sl->
name;
5740 WerrorS(
"parameter expected");
5747 for(
int i=pars-1;
i>=0;
i--)
5759 int ch = (int)(
long)pn->
Data();
5770 if ((ch<2)||(ch!=ch2))
5772 Warn(
"%d is invalid as characteristic of the ground field. 32003 is used.", ch);
5775 #ifndef TEST_ZN_AS_ZP
5779 mpz_init_set_ui(modBase, (
long)ch);
5786 cf->has_simple_Inverse=1;
5799 if ((ch!=0) && (ch!=
IsPrime(ch)) && (pars == 1))
5811 if ((ch!=0) && (ch!=
IsPrime(ch)))
5813 WerrorS(
"too many parameters");
5821 WerrorS(
"parameter expected");
5827 extParam.
r =
rDefault( ch, pars, names);
5828 for(
int i=pars-1;
i>=0;
i--)
5841 && ((strcmp(pn->
name,
"real")==0) || (strcmp(pn->
name,
"complex")==0)))
5844 BOOLEAN complex_flag=(strcmp(pn->
name,
"complex")==0);
5847 float_len=(int)(
long)pnn->
Data();
5848 float_len2=float_len;
5852 float_len2=(int)(
long)pnn->
Data();
5887 else if ((pn->
name !=
NULL) && (strcmp(pn->
name,
"integer") == 0))
5891 unsigned int modExponent = 1;
5892 mpz_init_set_si(modBase, 0);
5899 mpz_set_ui(modBase, (
long) pnn->
Data());
5903 modExponent = (long) pnn->
Data();
5908 mpz_mul_ui(modBase, modBase, (
int)(
long) pnn->
Data());
5921 if ((mpz_cmp_ui(modBase, 1) == 0) && (
mpz_sgn1(modBase) < 0))
5923 WerrorS(
"Wrong ground ring specification (module is 1)");
5926 if (modExponent < 1)
5928 WerrorS(
"Wrong ground ring specification (exponent smaller than 1");
5933 if (modExponent > 1 &&
cf ==
NULL)
5935 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*
sizeof(
unsigned long)))
5946 WerrorS(
"modulus must not be 0 or parameter not allowed");
5952 info.exp= modExponent;
5961 WerrorS(
"modulus must not be 0 or parameter not allowed");
5967 info.exp= modExponent;
5978 extParam.
r = (ring)pn->
Data();
5991 WerrorS(
"Wrong or unknown ground field specification");
5997 Print(
"pn[%p]: type: %d [%s]: %p, name: %s", (
void*)
p,
p->Typ(),
Tok2Cmdname(
p->Typ()),
p->Data(), (
p->name ==
NULL?
"NULL" :
p->name) );
6019 WerrorS(
"Invalid ground field specification");
6043 WerrorS(
"name of ring variable expected");
6096 int *perm=(
int *)
omAlloc0((org_ring->N+1)*
sizeof(int));
6113 WerrorS(
"name of ring variable expected");
6123 for(;
i<org_ring->N;
i++)
6125 if (strcmp(org_ring->names[
i],
R->names[
j])==0)
6133 Werror(
"variable %d (%s) not in basering",
j+1,
R->names[
j]);
6146 for(
j=
R->block0[
i];j<=R->block1[
i];
j++)
6150 if (min_var==-1) min_var=perm[
j];
6158 R->block0[
i]=min_var;
6159 R->block1[
i]=max_var;
6163 R->wvhdl[
i]=(
int*)
omAlloc0((max_var-min_var+1)*
sizeof(int));
6164 for(
j=org_ring->block0[
i];j<=org_ring->block1[
i];
j++)
6168 R->wvhdl[
i][perm[
j]-
R->block0[
i]]=
6169 org_ring->wvhdl[
i][
j-org_ring->block0[
i]];
6195 R->order[
j-1]=
R->order[
j];
6196 R->block0[
j-1]=
R->block0[
j];
6197 R->block1[
j-1]=
R->block1[
j];
6199 R->wvhdl[
j-1]=
R->wvhdl[
j];
6207 while (
R->order[n]==0) n--;
6210 if (
R->block1[n] !=
R->N)
6221 R->block0[n] <=
R->N)
6223 R->block1[n] =
R->N;
6227 Werror(
"mismatch of number of vars (%d) and ordering (%d vars) in block %d",
6228 R->N,
R->block1[n],n);
6234 R->OrdSgn = org_ring->OrdSgn;
6257 if ((r->ref<=0)&&(r->order!=
NULL))
6267 if (
j==0)
WarnS(
"killing the basering for level 0");
6272 while (r->idroot!=
NULL)
6275 killhdl2(r->idroot,&(r->idroot),r);
6322 Warn(
"deleting denom_list for ring change from %s",
IDID(
h));
6396 ideal I=(ideal)u->
Data();
6399 for(
i=I->nrows*I->ncols-1;
i>=0;
i--)
6411 switch (
p->language)
6420 if(
p->libname!=
NULL)
6421 Print(
",%s",
p->libname);
6436 tmp_in.
data=(
void*)(
long)(*aa)[
i];
6444 Werror(
"apply fails at index %d",
i+1);
6447 if (
i==0) { memcpy(
res,&tmp_out,
sizeof(tmp_out)); }
6452 memcpy(curr,&tmp_out,
sizeof(tmp_out));
6474 for(
int i=0;
i<=aa->
nr;
i++)
6477 tmp_in.
Copy(&(aa->
m[
i]));
6486 Werror(
"apply fails at index %d",
i+1);
6489 if (
i==0) { memcpy(
res,&tmp_out,
sizeof(tmp_out)); }
6494 memcpy(curr,&tmp_out,
sizeof(tmp_out));
6517 WerrorS(
"first argument to `apply` must allow an index");
6527 char assume_yylinebuf[80];
6529 int lev=(long)a->
Data();
6536 if (bo) {
WerrorS(
"syntax error in ASSUME");
return TRUE;}
6538 if (
b->Data()==
NULL) {
Werror(
"ASSUME failed:%s",assume_yylinebuf);
return TRUE;}
6550 char *ss=(
char*)
omAlloc(strlen(a)+strlen(
s)+30);
6552 int end_s=strlen(
s);
6553 while ((end_s>0) && ((
s[end_s]<=
' ')||(
s[end_s]==
';'))) end_s--;
6556 sprintf(
name,
"%s->%s",a,
s);
6558 int start_s=end_s-1;
6559 while ((start_s>=0) && (
s[start_s]!=
';')) start_s--;
6562 sprintf(ss,
"parameter def %s;return(%s);\n",a,
s);
6567 sprintf(ss,
"parameter def %s;%s;return(%s);\n",a,
s,
s+start_s+1);
6627 sprintf(
buf,
"wrong length of parameters(%d), expected ",t);
6629 sprintf(
buf,
"par. %d is of type `%s`, expected ",nr,
Tok2Cmdname(t));
6630 for(
int i=1;
i<=
T[0];
i++)
6635 if (
i<
T[0]) strcat(
buf,
",");
6645 if (type_list[0]==0)
return TRUE;
6648 if (
l!=(
int)type_list[0])
6653 for(
int i=1;
i<=
l;
i++,args=args->
next)
6655 short t=type_list[
i];
6659 || (t!=args->
Typ()))
Rational pow(const Rational &a, int e)
struct for passing initialization parameters to naInitChar
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
void atSet(idhdl root, char *name, void *data, int typ)
static int si_max(const int a, const int b)
static int si_min(const int a, const int b)
for(int i=0;i<=n;i++) degsf[i]
void mu(int **points, int sizePoints)
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
unsigned char * proc[NUM_PROC]
poly singclap_resultant(poly f, poly g, poly x, const ring r)
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
matrix singclap_irrCharSeries(ideal I, const ring r)
int * Zp_roots(poly p, const ring r)
idhdl get(const char *s, int lev)
void show(int mat=0, int spaces=0) const
virtual number getSubDet()
virtual ideal getMatrix()
virtual IStateType initState() const
complex root finder for univariate polynomials based on laguers algorithm
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
gmp_complex * getRoot(const int i)
bool solver(const int polishmode=PM_NONE)
Linear Programming / Linear Optimization using Simplex - Algorithm.
BOOLEAN mapFromMatrix(matrix m)
matrix mapToMatrix(matrix m)
Class used for (list of) interpreter objects.
void CleanUp(ring r=currRing)
void Clean(ring r=currRing)
INLINE_THIS void Init(int l=0)
void delete_node(spectrumPolyNode **)
int mult_spectrum(spectrum &)
int mult_spectrumh(spectrum &)
Base class for solving 0-dim poly systems using u-resultant.
rootContainer ** specializeInU(BOOLEAN matchUp=false, const number subDetVal=NULL)
rootContainer ** interpolateDenseSP(BOOLEAN matchUp=false, const number subDetVal=NULL)
resMatrixBase * accessResMat()
vandermonde system solver for interpolating polynomials from their values
poly numvec2poly(const number *q)
number * interpolateDense(const number *q)
Solves the Vandermode linear system \sum_{i=1}^{n} x_i^k-1 w_i = q_k, k=1,..,n.
Coefficient rings, fields and other domains suitable for Singular polynomials.
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 ....
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
static FORCE_INLINE char * nCoeffName(const coeffs cf)
@ n_R
single prescision (6,6) real numbers
@ n_Q
rational (GMP) numbers
@ n_Znm
only used if HAVE_RINGS is defined
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
@ n_Zn
only used if HAVE_RINGS is defined
@ n_long_R
real floating point (GMP) numbers
@ n_Z2m
only used if HAVE_RINGS is defined
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
@ n_Z
only used if HAVE_RINGS is defined
@ n_long_C
complex floating point (GMP) numbers
short float_len2
additional char-flags, rInit
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
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
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
const char * par_name
parameter name
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
const unsigned short fftable[]
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
short float_len
additional char-flags, rInit
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Creation data needed for finite fields.
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
const ExtensionInfo & info
< [in] sqrfree poly
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
char name(const Variable &v)
void WerrorS(const char *s)
VAR char my_yylinebuf[80]
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
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...
const char * Tok2Cmdname(int tok)
int iiTestConvert(int inputType, int outputType)
void hIndMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
void hIndAllMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
void hKill(monf xmem, int Nvar)
void hDelete(scfmon ev, int ev_length)
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
void hRadical(scfmon rad, int *Nrad, int Nvar)
#define idDelete(H)
delete an ideal
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
static BOOLEAN idIsZeroDim(ideal i)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
STATIC_VAR int * multiplicity
static BOOLEAN length(leftv result, leftv arg)
#define IMATELEM(M, I, J)
intvec * ivCopy(const intvec *o)
int IsCmd(const char *n, int &tok)
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
idhdl ggetid(const char *n)
void killhdl2(idhdl h, idhdl *ih, ring r)
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
VAR proclevel * procstack
idhdl packFindHdl(package r)
EXTERN_VAR omBin sleftv_bin
procinfo * iiInitSingularProcinfo(procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic)
INST_VAR sleftv iiRETURNEXPR
char * iiGetLibProcBuffer(procinfo *pi, int part)
lists rDecompose(const ring r)
@ semicListWrongNumberOfNumerators
@ semicListFirstElementWrongType
@ semicListSecondElementWrongType
@ semicListFourthElementWrongType
@ semicListWrongNumberOfDenominators
@ semicListThirdElementWrongType
@ semicListWrongNumberOfMultiplicities
@ semicListFifthElementWrongType
@ semicListSixthElementWrongType
BOOLEAN iiApplyINTVEC(leftv res, leftv a, int op, leftv proc)
BOOLEAN jjVARIABLES_P(leftv res, leftv u)
lists rDecompose_list_cf(const ring r)
int iiOpsTwoChar(const char *s)
BOOLEAN spaddProc(leftv result, leftv first, leftv second)
BOOLEAN jjMINRES(leftv res, leftv v)
BOOLEAN killlocals_list(int v, lists L)
BOOLEAN iiParameter(leftv p)
STATIC_VAR BOOLEAN iiNoKeepRing
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
static void rRenameVars(ring R)
void iiCheckPack(package &p)
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 (...
BOOLEAN iiApply(leftv res, leftv a, int op, leftv proc)
void list_cmd(int typ, const char *what, const char *prefix, BOOLEAN iterate, BOOLEAN fullname)
VAR BOOLEAN iiDebugMarker
ring rInit(leftv pn, leftv rv, leftv ord)
leftv iiMap(map theMap, const char *what)
int iiRegularity(lists L)
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
static void rDecomposeC_41(leftv h, const coeffs C)
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
BOOLEAN iiARROW(leftv r, char *a, char *s)
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
BOOLEAN syBetti1(leftv res, leftv u)
BOOLEAN iiApplyLIST(leftv res, leftv a, int op, leftv proc)
idhdl rDefault(const char *s)
static void rDecomposeC(leftv h, const ring R)
int exprlist_length(leftv v)
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
poly iiHighCorner(ideal I, int ak)
BOOLEAN spectrumfProc(leftv result, leftv first)
lists listOfRoots(rootArranger *self, const unsigned int oprec)
static void jjINT_S_TO_ID(int n, int *e, leftv res)
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
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: consi...
BOOLEAN jjCHARSERIES(leftv res, leftv u)
void rDecomposeCF(leftv h, const ring r, const ring R)
BOOLEAN iiApplyIDEAL(leftv, leftv, int, leftv)
static void list1(const char *s, idhdl h, BOOLEAN c, BOOLEAN fullname)
void list_error(semicState state)
BOOLEAN mpJacobi(leftv res, leftv a)
BOOLEAN iiBranchTo(leftv, leftv args)
BOOLEAN jjBETTI2_ID(leftv res, leftv u, leftv v)
BOOLEAN iiTestAssume(leftv a, leftv b)
void iiSetReturn(const leftv source)
BOOLEAN iiAssignCR(leftv r, leftv arg)
BOOLEAN spmulProc(leftv result, leftv first, leftv second)
spectrumState spectrumCompute(poly h, lists *L, int fast)
idhdl rFindHdl(ring r, idhdl n)
syStrategy syConvList(lists li)
BOOLEAN spectrumProc(leftv result, leftv first)
BOOLEAN iiDefaultParameter(leftv p)
void rComposeC(lists L, ring R)
BOOLEAN iiCheckRing(int i)
#define BREAK_LINE_LENGTH
spectrumState spectrumStateFromList(spectrumPolyList &speclist, lists *L, int fast)
BOOLEAN syBetti2(leftv res, leftv u, leftv w)
ring rSubring(ring org_ring, sleftv *rv)
BOOLEAN kWeight(leftv res, leftv id)
static leftv rOptimizeOrdAsSleftv(leftv ord)
BOOLEAN rSleftvOrdering2Ordering(sleftv *ord, ring R)
static BOOLEAN rComposeOrder(const lists L, const BOOLEAN check_comp, ring R)
spectrum spectrumFromList(lists l)
static idhdl rSimpleFindHdl(const ring r, const idhdl root, const idhdl n)
syStrategy syForceMin(lists li)
static void iiReportTypes(int nr, int t, const short *T)
void rDecomposeRing(leftv h, const ring R)
BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w)
static BOOLEAN iiInternalExport(leftv v, int toLev)
void copy_deep(spectrum &spec, lists l)
void killlocals_rec(idhdl *root, int v, ring r)
BOOLEAN nuMPResMat(leftv res, leftv arg1, leftv arg2)
returns module representing the multipolynomial resultant matrix Arguments 2: ideal i,...
semicState list_is_spectrum(lists l)
static void killlocals0(int v, idhdl *localhdl, const ring r)
BOOLEAN semicProc(leftv res, leftv u, leftv v)
BOOLEAN loSimplex(leftv res, leftv args)
Implementation of the Simplex Algorithm.
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
BOOLEAN loNewtonP(leftv res, leftv arg1)
compute Newton Polytopes of input polynomials
BOOLEAN iiApplyBIGINTMAT(leftv, leftv, int, leftv)
BOOLEAN jjBETTI2(leftv res, leftv u, leftv v)
const char * lastreserved
static BOOLEAN rSleftvList2StringArray(leftv sl, char **p)
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
BOOLEAN iiWRITE(leftv, leftv v)
void paPrint(const char *n, package p)
static resolvente iiCopyRes(resolvente r, int l)
const char * iiTwoOps(int t)
BOOLEAN kQHWeight(leftv res, leftv v)
void rComposeRing(lists L, ring R)
BOOLEAN iiExport(leftv v, int toLev)
BOOLEAN jjBETTI(leftv res, leftv u)
void spectrumPrintError(spectrumState state)
lists getList(spectrum &spec)
BOOLEAN nuUResSolve(leftv res, leftv args)
solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing-...
BOOLEAN jjVARIABLES_ID(leftv res, leftv u)
void rDecomposeRing_41(leftv h, const coeffs C)
static BOOLEAN rComposeVar(const lists L, ring R)
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
VAR denominator_list DENOMINATOR_LIST
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,...
BOOLEAN lRingDependend(lists L)
resolvente liFindRes(lists L, int *len, int *typ0, intvec ***weights)
char * lString(lists l, BOOLEAN typed, int dim)
lists liMakeResolv(resolvente r, int length, int reallen, int typ0, intvec **weights, int add_row_shift)
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)
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
matrix mpNew(int r, int c)
create a r x c zero-matrix
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
#define MATELEM(mat, i, j)
1-based access to matrix
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
ideal loNewtonPolytope(const ideal id)
EXTERN_VAR size_t gmp_output_digits
uResultant::resMatType determineMType(int imtype)
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)
gmp_float sqrt(const gmp_float &a)
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
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...
void report(const char *fmt, const char *name)
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nPrint(a)
only for debug, over any initalized currRing
#define SHORT_REAL_LENGTH
#define omFreeSize(addr, size)
#define omCheckAddr(addr)
#define omReallocSize(addr, o_size, size)
#define omCheckAddrSize(addr, size)
#define omFreeBin(addr, bin)
#define omRealloc0Size(addr, o_size, size)
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)
#define __pp_Mult_nn(p, n, r)
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
static void p_Setm(poly p, const ring r)
static void p_Delete(poly *p, const ring r)
static unsigned pLength(poly a)
static poly p_Init(const ring r, omBin bin)
static poly p_Copy(poly p, const ring r)
returns a copy of p
static long p_Totaldegree(poly p, const ring r)
#define __p_Mult_nn(p, n, r)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatiblity layer for legacy polynomial operations (over currRing)
static long pTotaldegree(poly p)
#define pIsConstant(p)
like above, except that Comp must be 0
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
#define pGetVariables(p, e)
#define pGetExp(p, i)
Exponent.
void pNorm(poly p, const ring R=currRing)
#define pCopy(p)
return a copy of the poly
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
void PrintS(const char *s)
void Werror(const char *fmt,...)
const char * rSimpleOrdStr(int ord)
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...
int rTypeOfMatrixOrder(const intvec *order)
ring rAssure_HasComp(const ring r)
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
BOOLEAN rCheckIV(const intvec *iv)
rRingOrder_t rOrderName(char *ordername)
void rDelete(ring r)
unconditionally deletes fields in r
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
void rSetSyzComp(int k, const ring r)
static BOOLEAN rField_is_Ring(const ring r)
static BOOLEAN rField_is_R(const ring r)
static int rBlocks(ring r)
static BOOLEAN rField_is_Zp_a(const ring r)
static BOOLEAN rField_is_Z(const ring r)
static BOOLEAN rField_is_Zp(const ring r)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static BOOLEAN rField_is_long_C(const ring r)
static ring rIncRefCnt(ring r)
static char const ** rParameter(const ring r)
(r->cf->parameter)
static BOOLEAN rField_is_Zn(const ring r)
static int rPar(const ring r)
(r->cf->P)
static int rInternalChar(const ring r)
static BOOLEAN rIsLPRing(const ring r)
@ ringorder_a64
for int64 weights
@ ringorder_rs
opposite of ls
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
@ ringorder_IS
Induced (Schreyer) ordering.
static BOOLEAN rField_is_Q_a(const ring r)
static BOOLEAN rField_is_Q(const ring r)
static void rDecRefCnt(ring r)
static BOOLEAN rField_is_long_R(const ring r)
static BOOLEAN rField_is_numeric(const ring r)
static BOOLEAN rField_is_GF(const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
int status int void size_t count
int status int void * buf
BOOLEAN slWrite(si_link l, leftv v)
ideal idInit(int idsize, int rank)
initialise an ideal / module
intvec * id_QHomWeight(ideal id, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
BOOLEAN hasAxis(ideal J, int k, const ring r)
int hasOne(ideal J, const ring r)
BOOLEAN ringIsLocal(const ring r)
poly computeWC(const newtonPolygon &np, Rational max_weight, const ring r)
void computeNF(ideal stdJ, poly hc, poly wc, spectrumPolyList *NF, const ring r)
BOOLEAN hasLinearTerm(poly h, const ring r)
BOOLEAN hasConstTerm(poly h, const ring r)
INST_VAR sleftv sLastPrinted
BOOLEAN RingDependend(int t)
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
void syMinimizeResolvente(resolvente res, int length, int first)
void syKillComputation(syStrategy syzstr, ring r=currRing)
resolvente syReorder(resolvente res, int length, syStrategy syzstr, BOOLEAN toCopy=TRUE, resolvente totake=NULL)
intvec * syBettiOfComputation(syStrategy syzstr, BOOLEAN minim=TRUE, int *row_shift=NULL, intvec *weights=NULL)
void syKillEmptyEntres(resolvente res, int length)
struct for passing initialization parameters to naInitChar
THREAD_VAR double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)