ipassign.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT: interpreter:
6 * assignment of expressions and lists to objects or lists
7 */
8 
9 #include <stdlib.h>
10 #include <string.h>
11 #include <ctype.h>
12 
13 
14 #include <kernel/mod2.h>
15 
16 #include <misc/auxiliary.h>
17 #include <omalloc/omalloc.h>
18 
19 #define TRANSEXT_PRIVATES
21 
22 #include <misc/options.h>
23 #include <misc/intvec.h>
24 
25 #include <coeffs/coeffs.h>
26 #include <coeffs/numbers.h>
27 #include <coeffs/bigintmat.h>
28 
29 
31 
32 #include <polys/monomials/ring.h>
33 #include <polys/matpol.h>
34 #include <polys/monomials/maps.h>
35 #include <polys/nc/nc.h>
36 #include <polys/nc/sca.h>
37 #include <polys/prCopy.h>
38 
39 #include <kernel/polys.h>
40 #include <kernel/ideals.h>
41 #include <kernel/GBEngine/kstd1.h>
42 #include <kernel/oswrapper/timer.h>
44 #include <kernel/GBEngine/syz.h>
45 
46 //#include "weight.h"
47 #include "tok.h"
48 #include "ipid.h"
49 #include "idrec.h"
50 #include "subexpr.h"
51 #include "lists.h"
52 #include "ipconv.h"
53 #include "attrib.h"
54 #include "links/silink.h"
55 #include "ipshell.h"
56 #include "blackbox.h"
57 #include "Singular/number2.h"
58 
59 /*=================== proc =================*/
61 {
62  si_echo=(int)((long)(a->Data()));
63  return FALSE;
64 }
66 {
67  printlevel=(int)((long)(a->Data()));
68  return FALSE;
69 }
71 {
72  colmax=(int)((long)(a->Data()));
73  return FALSE;
74 }
76 {
77  timerv=(int)((long)(a->Data()));
78  initTimer();
79  return FALSE;
80 }
81 #ifdef HAVE_GETTIMEOFDAY
83 {
84  rtimerv=(int)((long)(a->Data()));
85  initRTimer();
86  return FALSE;
87 }
88 #endif
90 {
91  Kstd1_deg=(int)((long)(a->Data()));
92  if (Kstd1_deg!=0)
94  else
96  return FALSE;
97 }
99 {
100  Kstd1_mu=(int)((long)(a->Data()));
101  if (Kstd1_mu!=0)
103  else
105  return FALSE;
106 }
108 {
109  traceit=(int)((long)(a->Data()));
110  return FALSE;
111 }
113 {
114  if (currRing != NULL)
115  {
116  BOOLEAN shortOut = (BOOLEAN)((long)a->Data());
117 #if HAVE_CAN_SHORT_OUT
118  if (!shortOut)
119  currRing->ShortOut = 0;
120  else
121  {
122  if (currRing->CanShortOut)
123  currRing->ShortOut = 1;
124  }
125 #else
126  currRing->ShortOut = shortOut;
127  coeffs cf = currRing->cf;
128  while (nCoeff_is_Extension(cf)) {
129  cf->extRing->ShortOut = shortOut;
130  assume(cf->extRing != NULL);
131  cf = cf->extRing->cf;
132  }
133 #endif
134  }
135  return FALSE;
136 }
137 static void jjMINPOLY_red(idhdl h)
138 {
139  switch(IDTYP(h))
140  {
141  case NUMBER_CMD:
142  {
143  number n=(number)IDDATA(h);
144  number one = nInit(1);
145  number nn=nMult(n,one);
146  nDelete(&n);nDelete(&one);
147  IDDATA(h)=(char*)nn;
148  break;
149  }
150  case VECTOR_CMD:
151  case POLY_CMD:
152  {
153  poly p=(poly)IDDATA(h);
154  IDDATA(h)=(char*)p_MinPolyNormalize(p, currRing);
155  break;
156  }
157  case IDEAL_CMD:
158  case MODUL_CMD:
159  case MAP_CMD:
160  case MATRIX_CMD:
161  {
162  int i;
163  ideal I=(ideal)IDDATA(h);
164  for(i=IDELEMS(I)-1;i>=0;i--)
165  I->m[i]=p_MinPolyNormalize(I->m[i], currRing);
166  break;
167  }
168  case LIST_CMD:
169  {
170  lists L=(lists)IDDATA(h);
171  int i=L->nr;
172  for(;i>=0;i--)
173  {
174  jjMINPOLY_red((idhdl)&(L->m[i]));
175  }
176  }
177  default:
178  //case RESOLUTION_CMD:
179  Werror("type %d too complex...set minpoly before",IDTYP(h)); break;
180  }
181 }
183 {
184  if( !nCoeff_is_transExt(currRing->cf) && (currRing->idroot == NULL) && n_IsZero((number)a->Data(), currRing->cf) )
185  {
186 #ifndef SING_NDEBUG
187  WarnS("Set minpoly over non-transcendental ground field to 0?!");
188  Warn("in >>%s<<",my_yylinebuf);
189 #endif
190  return FALSE;
191  }
192 
193 
194  if ( !nCoeff_is_transExt(currRing->cf) )
195  {
196  WarnS("Trying to set minpoly over non-transcendental ground field...");
197  if(!nCoeff_is_algExt(currRing->cf) )
198  {
199  WerrorS("cannot set minpoly for these coeffients");
200  return TRUE;
201  }
202  }
203  if ((rVar(currRing->cf->extRing)!=1)
204  && !n_IsZero((number)a->Data(), currRing->cf) )
205  {
206  WerrorS("only univarite minpoly allowed");
207  return TRUE;
208  }
209 
210  if ( currRing->idroot != NULL )
211  {
212 // return TRUE;
213 #ifndef SING_NDEBUG
214  idhdl p = currRing->idroot;
215 
216  WarnS("no minpoly allowed if there are local objects belonging to the basering: ");
217 
218  while(p != NULL)
219  {
220  PrintS(p->String(TRUE)); PrintLn();
221  p = p->next;
222  }
223 #endif
224  }
225 
226 // assume (currRing->idroot==NULL);
227 
228  number p = (number)a->CopyD(NUMBER_CMD);
229  n_Normalize(p, currRing->cf);
230 
231  if (n_IsZero(p, currRing->cf))
232  {
233  n_Delete(&p, currRing);
234  if( nCoeff_is_transExt(currRing->cf) )
235  {
236 #ifndef SING_NDEBUG
237  WarnS("minpoly is already 0...");
238 #endif
239  return FALSE;
240  }
241  WarnS("cannot set minpoly to 0 / alg. extension?");
242  return TRUE;
243  }
244 
245  // remove all object currently in the ring
246  while(currRing->idroot!=NULL)
247  {
248 #ifndef SING_NDEBUG
249  Warn("killing a local object due to minpoly change: %s", IDID(currRing->idroot));
250 #endif
251  killhdl2(currRing->idroot,&(currRing->idroot),currRing);
252  }
253 
254  AlgExtInfo A;
255 
256  A.r = rCopy(currRing->cf->extRing); // Copy ground field!
257  // if minpoly was already set:
258  if( currRing->cf->extRing->qideal != NULL ) id_Delete(&(A.r->qideal),A.r);
259  ideal q = idInit(1,1);
260  if ((p==NULL) ||(NUM((fraction)p)==NULL))
261  {
262  Werror("Could not construct the alg. extension: minpoly==0");
263  // cleanup A: TODO
264  rDelete( A.r );
265  return TRUE;
266  }
267  if (DEN((fraction)(p)) != NULL) // minpoly must be a fraction with poly numerator...!!
268  {
269  poly z=NUM((fraction)p);
270  poly n=DEN((fraction)(p));
271  z=p_Mult_nn(z,pGetCoeff(n),currRing->cf->extRing);
272  NUM((fraction)p)=z;
273  DEN((fraction)(p))=NULL;
274  p_Delete(&n,currRing->cf->extRing);
275  }
276 
277  q->m[0] = NUM((fraction)p);
278  A.r->qideal = q;
279 
280 #if 0
281  PrintS("\nTrying to conver the currRing into an algebraic field: ");
282  PrintS("Ground poly. ring: \n");
283  rWrite( A.r );
284  PrintS("\nGiven MinPOLY: ");
285  p_Write( A.i->m[0], A.r );
286 #endif
287 
288  // :(
289 // NUM((fractionObject *)p) = NULL; // makes 0/ NULL fraction - which should not happen!
290 // n_Delete(&p, currRing->cf); // doesn't expect 0/ NULL :(
291  if(true)
292  {
293  extern omBin fractionObjectBin;
294  NUM((fractionObject *)p) = NULL; // not necessary, but still...
295  omFreeBin((ADDRESS)p, fractionObjectBin);
296  }
297 
298 
299  coeffs new_cf = nInitChar(n_algExt, &A);
300 
301  if (new_cf==NULL)
302  {
303  Werror("Could not construct the alg. extension: llegal minpoly?");
304  // cleanup A: TODO
305  rDelete( A.r );
306  return TRUE;
307  }
308  else
309  {
310  nKillChar(currRing->cf); currRing->cf=new_cf;
311  }
312 
313  return FALSE;
314 }
316 {
317  poly p=(poly)a->CopyD(POLY_CMD);
318  pDelete(&(currRing->ppNoether));
319  (currRing->ppNoether)=p;
320  return FALSE;
321 }
322 /*=================== proc =================*/
323 static void jiAssignAttr(leftv l,leftv r)
324 {
325  // get the attribute of th right side
326  // and set it to l
327  leftv rv=r->LData();
328  if (rv!=NULL)
329  {
330  if (rv->e==NULL)
331  {
332  if (rv->attribute!=NULL)
333  {
334  attr la;
335  if (r->rtyp!=IDHDL)
336  {
337  la=rv->attribute;
338  rv->attribute=NULL;
339  }
340  else
341  {
342  la=rv->attribute->Copy();
343  }
344  l->attribute=la;
345  }
346  l->flag=rv->flag;
347  }
348  }
349  if (l->rtyp==IDHDL)
350  {
351  idhdl h=(idhdl)l->data;
352  IDATTR(h)=l->attribute;
353  IDFLAG(h)=l->flag;
354  }
355 }
356 static BOOLEAN jiA_INT(leftv res, leftv a, Subexpr e)
357 {
358  if (e==NULL)
359  {
360  res->data=(void *)a->Data();
361  jiAssignAttr(res,a);
362  }
363  else
364  {
365  int i=e->start-1;
366  if (i<0)
367  {
368  Werror("index[%d] must be positive",i+1);
369  return TRUE;
370  }
371  intvec *iv=(intvec *)res->data;
372  if (e->next==NULL)
373  {
374  if (i>=iv->length())
375  {
376  intvec *iv1=new intvec(i+1);
377  (*iv1)[i]=(int)((long)(a->Data()));
378  intvec *ivn=ivAdd(iv,iv1);
379  delete iv;
380  delete iv1;
381  res->data=(void *)ivn;
382  }
383  else
384  (*iv)[i]=(int)((long)(a->Data()));
385  }
386  else
387  {
388  int c=e->next->start;
389  if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
390  {
391  Werror("wrong range [%d,%d] in intmat %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
392  return TRUE;
393  }
394  else
395  IMATELEM(*iv,i+1,c) = (int)((long)(a->Data()));
396  }
397  }
398  return FALSE;
399 }
400 static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr)
401 {
402  number p=(number)a->CopyD(NUMBER_CMD);
403  if (res->data!=NULL) nDelete((number *)&res->data);
404  nNormalize(p);
405  res->data=(void *)p;
406  jiAssignAttr(res,a);
407  return FALSE;
408 }
409 #ifdef SINGULAR_4_1
410 static BOOLEAN jiA_NUMBER2(leftv res, leftv a, Subexpr e)
411 {
412  number2 n=(number2)a->CopyD(CNUMBER_CMD);
413  if (e==NULL)
414  {
415  if (res->data!=NULL)
416  {
417  number2 nn=(number2)res->data;
418  n2Delete(nn);
419  }
420  res->data=(void *)n;
421  jiAssignAttr(res,a);
422  }
423  else
424  {
425  int i=e->start-1;
426  if (i<0)
427  {
428  Werror("index[%d] must be positive",i+1);
429  return TRUE;
430  }
431  bigintmat *iv=(bigintmat *)res->data;
432  if (e->next==NULL)
433  {
434  WerrorS("only one index given");
435  return TRUE;
436  }
437  else
438  {
439  int c=e->next->start;
440  if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
441  {
442  Werror("wrong range [%d,%d] in cmatrix %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
443  return TRUE;
444  }
445  else if (iv->basecoeffs()==n->cf)
446  {
447  n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
448  BIMATELEM(*iv,i+1,c) = n->n;
449  }
450  else
451  {
452  WerrorS("different base");
453  return TRUE;
454  }
455  }
456  }
457  jiAssignAttr(res,a);
458  return FALSE;
459 }
460 static BOOLEAN jiA_NUMBER2_I(leftv res, leftv a, Subexpr e)
461 {
462  if (e==NULL)
463  {
464  if (res->data!=NULL)
465  {
466  number2 nn=(number2)res->data;
467  number2 n=n2Init((long)a->Data(),nn->cf);
468  n2Delete(nn);
469  res->data=(void *)n;
470  }
471  else
472  {
473  WerrorS("no (c)ring avialable for conversion from int");
474  return TRUE;
475  }
476  }
477  else
478  {
479  int i=e->start-1;
480  if (i<0)
481  {
482  Werror("index[%d] must be positive",i+1);
483  return TRUE;
484  }
485  bigintmat *iv=(bigintmat *)res->data;
486  if (e->next==NULL)
487  {
488  WerrorS("only one index given");
489  return TRUE;
490  }
491  else
492  {
493  int c=e->next->start;
494  if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
495  {
496  Werror("wrong range [%d,%d] in cmatrix %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
497  return TRUE;
498  }
499  else
500  {
501  n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
502  BIMATELEM(*iv,i+1,c) = n_Init((long)a->Data(),iv->basecoeffs());
503  }
504  }
505  }
506  return FALSE;
507 }
508 static BOOLEAN jiA_NUMBER2_N(leftv res, leftv a, Subexpr e)
509 {
510  if (e==NULL)
511  {
512  if (res->data!=NULL)
513  {
514  number2 nn=(number2)res->data;
515  if (currRing->cf==nn->cf)
516  {
517  number2 n=(number2)omAlloc(sizeof(*n));
518  n->cf=currRing->cf; n->cf++;
519  n->n=(number)a->CopyD(NUMBER_CMD);
520  n2Delete(nn);
521  res->data=(void *)n;
522  }
523  else
524  {
525  WerrorS("different base");
526  return TRUE;
527  }
528  }
529  else
530  {
531  WerrorS("no (c)ring avialable for conversion from number");
532  return TRUE;
533  }
534  }
535  else
536  {
537  int i=e->start-1;
538  if (i<0)
539  {
540  Werror("index[%d] must be positive",i+1);
541  return TRUE;
542  }
543  bigintmat *iv=(bigintmat *)res->data;
544  if (e->next==NULL)
545  {
546  WerrorS("only one index given");
547  return TRUE;
548  }
549  else
550  {
551  int c=e->next->start;
552  if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
553  {
554  Werror("wrong range [%d,%d] in cmatrix %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
555  return TRUE;
556  }
557  else if (iv->basecoeffs()==currRing->cf)
558  {
559  n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
560  BIMATELEM(*iv,i+1,c) = (number)(a->CopyD(NUMBER_CMD));
561  }
562  else
563  {
564  WerrorS("different base");
565  return TRUE;
566  }
567  }
568  }
569  return FALSE;
570 }
571 #endif
572 static BOOLEAN jiA_BIGINT(leftv res, leftv a, Subexpr e)
573 {
574  number p=(number)a->CopyD(BIGINT_CMD);
575  if (e==NULL)
576  {
577  if (res->data!=NULL) n_Delete((number *)&res->data,coeffs_BIGINT);
578  res->data=(void *)p;
579  }
580  else
581  {
582  int i=e->start-1;
583  if (i<0)
584  {
585  Werror("index[%d] must be positive",i+1);
586  return TRUE;
587  }
588  bigintmat *iv=(bigintmat *)res->data;
589  if (e->next==NULL)
590  {
591  WerrorS("only one index given");
592  return TRUE;
593  }
594  else
595  {
596  int c=e->next->start;
597  if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
598  {
599  Werror("wrong range [%d,%d] in bigintmat %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
600  return TRUE;
601  }
602  else
603  {
604  n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
605  BIMATELEM(*iv,i+1,c) = p;
606  }
607  }
608  }
609  jiAssignAttr(res,a);
610  return FALSE;
611 }
613 {
615  if (res->data!=NULL) ((lists)res->data)->Clean();
616  int add_row_shift = 0;
617  intvec *weights=(intvec*)atGet(a,"isHomog",INTVEC_CMD);
618  if (weights!=NULL) add_row_shift=weights->min_in();
619  res->data=(void *)syConvRes(r,TRUE,add_row_shift);
620  //jiAssignAttr(res,a);
621  return FALSE;
622 }
623 static BOOLEAN jiA_LIST(leftv res, leftv a,Subexpr)
624 {
625  lists l=(lists)a->CopyD(LIST_CMD);
626  if (res->data!=NULL) ((lists)res->data)->Clean();
627  res->data=(void *)l;
628  jiAssignAttr(res,a);
629  return FALSE;
630 }
631 static BOOLEAN jiA_POLY(leftv res, leftv a,Subexpr e)
632 {
633  poly p=(poly)a->CopyD(POLY_CMD);
634  pNormalize(p);
635  if (e==NULL)
636  {
637  if ((p!=NULL) && TEST_V_QRING && (currRing->qideal!=NULL)
638  && (!hasFlag(a,FLAG_QRING)))
639  {
641  setFlag(res,FLAG_QRING);
642  }
643  if (res->data!=NULL) pDelete((poly*)&res->data);
644  res->data=(void*)p;
645  jiAssignAttr(res,a);
646  }
647  else
648  {
649  int i,j;
650  matrix m=(matrix)res->data;
651  i=e->start;
652  if (e->next==NULL)
653  {
654  j=i; i=1;
655  // for all ideal like data types: check indices
656  if (j>MATCOLS(m))
657  {
658  if (TEST_V_ALLWARN)
659  {
660  Warn("increase ideal %d -> %d in %s",MATCOLS(m),j,my_yylinebuf);
661  }
662  pEnlargeSet(&(m->m),MATCOLS(m),j-MATCOLS(m));
663  MATCOLS(m)=j;
664  }
665  else if (j<=0)
666  {
667  Werror("index[%d] must be positive",j/*e->start*/);
668  return TRUE;
669  }
670  }
671  else
672  {
673  // for matrices: indices are correct (see ipExprArith3(..,'['..) )
674  j=e->next->start;
675  }
676  if ((p!=NULL) && TEST_V_QRING && (currRing->qideal!=NULL))
677  {
679  }
680  pDelete(&MATELEM(m,i,j));
681  MATELEM(m,i,j)=p;
682  /* for module: update rank */
683  if ((p!=NULL) && (pGetComp(p)!=0))
684  {
685  m->rank=si_max(m->rank,pMaxComp(p));
686  }
687  }
688  return FALSE;
689 }
690 static BOOLEAN jiA_1x1INTMAT(leftv res, leftv a,Subexpr e)
691 {
692  if (/*(*/ res->rtyp!=INTMAT_CMD /*)*/) /*|| (e!=NULL) - TRUE because of type int */
693  {
694  // no error message: assignment simply fails
695  return TRUE;
696  }
697  intvec* am=(intvec*)a->CopyD(INTMAT_CMD);
698  if ((am->rows()!=1) || (am->cols()!=1))
699  {
700  WerrorS("must be 1x1 intmat");
701  delete am;
702  return TRUE;
703  }
704  intvec* m=(intvec *)res->data;
705  // indices are correct (see ipExprArith3(..,'['..) )
706  int i=e->start;
707  int j=e->next->start;
708  IMATELEM(*m,i,j)=IMATELEM(*am,1,1);
709  delete am;
710  return FALSE;
711 }
712 static BOOLEAN jiA_1x1MATRIX(leftv res, leftv a,Subexpr e)
713 {
714  if (/*(*/ res->rtyp!=MATRIX_CMD /*)*/) /*|| (e!=NULL) - TRUE because of type poly */
715  {
716  // no error message: assignment simply fails
717  return TRUE;
718  }
719  matrix am=(matrix)a->CopyD(MATRIX_CMD);
720  if ((MATROWS(am)!=1) || (MATCOLS(am)!=1))
721  {
722  WerrorS("must be 1x1 matrix");
723  idDelete((ideal *)&am);
724  return TRUE;
725  }
726  matrix m=(matrix)res->data;
727  // indices are correct (see ipExprArith3(..,'['..) )
728  int i=e->start;
729  int j=e->next->start;
730  pDelete(&MATELEM(m,i,j));
731  pNormalize(MATELEM(am,1,1));
732  MATELEM(m,i,j)=MATELEM(am,1,1);
733  MATELEM(am,1,1)=NULL;
734  idDelete((ideal *)&am);
735  return FALSE;
736 }
737 static BOOLEAN jiA_STRING(leftv res, leftv a, Subexpr e)
738 {
739  if (e==NULL)
740  {
741  void* tmp = res->data;
742  res->data=(void *)a->CopyD(STRING_CMD);
743  jiAssignAttr(res,a);
744  omfree(tmp);
745  }
746  else
747  {
748  char *s=(char *)res->data;
749  if ((e->start>0)&&(e->start<=(int)strlen(s)))
750  s[e->start-1]=(char)(*((char *)a->Data()));
751  else
752  {
753  Werror("string index %d out of range 1..%d",e->start,(int)strlen(s));
754  return TRUE;
755  }
756  }
757  return FALSE;
758 }
759 static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr)
760 {
761  extern procinfo *iiInitSingularProcinfo(procinfo *pi, const char *libname,
762  const char *procname, int line,
763  long pos, BOOLEAN pstatic=FALSE);
764  if(res->data!=NULL) piKill((procinfo *)res->data);
765  if(a->Typ()==STRING_CMD)
766  {
767  res->data = (void *)omAlloc0Bin(procinfo_bin);
768  ((procinfo *)(res->data))->language=LANG_NONE;
769  iiInitSingularProcinfo((procinfo *)res->data,"",res->name,0,0);
770  ((procinfo *)res->data)->data.s.body=(char *)a->CopyD(STRING_CMD);
771  }
772  else
773  res->data=(void *)a->CopyD(PROC_CMD);
774  jiAssignAttr(res,a);
775  return FALSE;
776 }
777 static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr)
778 {
779  //if ((res->data==NULL) || (res->Typ()==a->Typ()))
780  {
781  if (res->data!=NULL) delete ((intvec *)res->data);
782  res->data=(void *)a->CopyD(INTVEC_CMD);
783  jiAssignAttr(res,a);
784  return FALSE;
785  }
786 #if 0
787  else
788  {
789  intvec *r=(intvec *)(res->data);
790  intvec *s=(intvec *)(a->Data());
791  int i=si_min(r->length(), s->length())-1;
792  for(;i>=0;i--)
793  {
794  (*r)[i]=(*s)[i];
795  }
796  return FALSE; //(r->length()< s->length());
797  }
798 #endif
799 }
801 {
802  if (res->data!=NULL) delete ((bigintmat *)res->data);
803  res->data=(void *)a->CopyD(BIGINTMAT_CMD);
804  jiAssignAttr(res,a);
805  return FALSE;
806 }
807 static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr)
808 {
809  if (res->data!=NULL) idDelete((ideal*)&res->data);
810  res->data=(void *)a->CopyD(MATRIX_CMD);
811  if (a->rtyp==IDHDL) id_Normalize((ideal)a->Data(), currRing);
812  else id_Normalize((ideal)res->data, currRing);
813  jiAssignAttr(res,a);
814  if (((res->rtyp==IDEAL_CMD)||(res->rtyp==MODUL_CMD))
815  && (IDELEMS((ideal)(res->data))==1)
816  && (currRing->qideal==NULL)
817  && (!rIsPluralRing(currRing))
818  )
819  {
820  setFlag(res,FLAG_STD);
821  }
822  if (TEST_V_QRING && (currRing->qideal!=NULL)&& (!hasFlag(res,FLAG_QRING))) jjNormalizeQRingId(res);
823  return FALSE;
824 }
826 {
827  if (res->data!=NULL) syKillComputation((syStrategy)res->data);
828  res->data=(void *)a->CopyD(RESOLUTION_CMD);
829  jiAssignAttr(res,a);
830  return FALSE;
831 }
832 static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr)
833 /* module = poly */
834 {
835  if (res->data!=NULL) idDelete((ideal*)&res->data);
836  ideal I=idInit(1,1);
837  I->m[0]=(poly)a->CopyD(POLY_CMD);
838  if (I->m[0]!=NULL) pSetCompP(I->m[0],1);
839  pNormalize(I->m[0]);
840  res->data=(void *)I;
841  if (TEST_V_QRING && (currRing->qideal!=NULL))
842  {
843  if (hasFlag(a,FLAG_QRING)) setFlag(res,FLAG_QRING);
844  else jjNormalizeQRingId(res);
845  }
846  return FALSE;
847 }
848 static BOOLEAN jiA_IDEAL_M(leftv res, leftv a, Subexpr)
849 {
850  if (res->data!=NULL) idDelete((ideal*)&res->data);
852  if (TEST_V_ALLWARN)
853  if (MATROWS(m)>1)
854  Warn("assign matrix with %d rows to an ideal in >>%s<<",MATROWS(m),my_yylinebuf);
855  IDELEMS((ideal)m)=MATROWS(m)*MATCOLS(m);
856  ((ideal)m)->rank=1;
857  MATROWS(m)=1;
858  id_Normalize((ideal)m, currRing);
859  res->data=(void *)m;
860  if (TEST_V_QRING && (currRing->qideal!=NULL)) jjNormalizeQRingId(res);
861  return FALSE;
862 }
863 static BOOLEAN jiA_LINK(leftv res, leftv a, Subexpr)
864 {
865  si_link l=(si_link)res->data;
866 
867  if (l!=NULL) slCleanUp(l);
868 
869  if (a->Typ() == STRING_CMD)
870  {
871  if (l == NULL)
872  {
874  res->data = (void *) l;
875  }
876  return slInit(l, (char *) a->Data());
877  }
878  else if (a->Typ() == LINK_CMD)
879  {
880  if (l != NULL) omFreeBin(l, sip_link_bin);
881  res->data = slCopy((si_link)a->Data());
882  return FALSE;
883  }
884  return TRUE;
885 }
886 // assign map -> map
887 static BOOLEAN jiA_MAP(leftv res, leftv a, Subexpr)
888 {
889  if (res->data!=NULL)
890  {
891  omFree((ADDRESS)((map)res->data)->preimage);
892  ((map)res->data)->preimage=NULL;
893  idDelete((ideal*)&res->data);
894  }
895  res->data=(void *)a->CopyD(MAP_CMD);
896  jiAssignAttr(res,a);
897  return FALSE;
898 }
899 // assign ideal -> map
900 static BOOLEAN jiA_MAP_ID(leftv res, leftv a, Subexpr)
901 {
902  map f=(map)res->data;
903  char *rn=f->preimage; // save the old/already assigned preimage ring name
904  f->preimage=NULL;
905  idDelete((ideal *)&f);
906  res->data=(void *)a->CopyD(IDEAL_CMD);
907  f=(map)res->data;
908  id_Normalize((ideal)f, currRing);
909  f->preimage = rn;
910  return FALSE;
911 }
912 static BOOLEAN jiA_QRING(leftv res, leftv a,Subexpr e)
913 {
914  // the follwing can only happen, if:
915  // - the left side is of type qring AND not an id
916  if ((e!=NULL)||(res->rtyp!=IDHDL))
917  {
918  WerrorS("qring_id expected");
919  return TRUE;
920  }
921  ring old_ring=(ring)res->Data();
922 
923  coeffs newcf = currRing->cf;
924  ideal id = (ideal)a->Data(); //?
925  const int cpos = idPosConstant(id);
927  if (cpos >= 0)
928  {
929  newcf = n_CoeffRingQuot1(p_GetCoeff(id->m[cpos], currRing), currRing->cf);
930  if(newcf == NULL)
931  return TRUE;
932  }
933  //qr=(ring)res->Data();
934  //if (qr!=NULL) omFreeBin((ADDRESS)qr, ip_sring_bin);
935  ring qr = rCopy(currRing);
936  assume(qr->cf == currRing->cf);
937 
938  if ( qr->cf != newcf )
939  {
940  nKillChar ( qr->cf ); // ???
941  qr->cf = newcf;
942  }
943  // we have to fill it, but the copy also allocates space
944  idhdl h=(idhdl)res->data; // we have res->rtyp==IDHDL
945  IDRING(h)=qr;
946 
947  ideal qid;
948 
949 #ifdef HAVE_RINGS
950  if((rField_is_Ring(currRing)) && (cpos != -1))
951  {
952  int i, j;
953  int *perm = (int *)omAlloc0((qr->N+1)*sizeof(int));
954 
955  for(i=qr->N;i>0;i--)
956  perm[i]=i;
957 
958  nMapFunc nMap = n_SetMap(currRing->cf, newcf);
959  qid = idInit(IDELEMS(id)-1,1);
960  for(i = 0, j = 0; i<IDELEMS(id); i++)
961  if( i != cpos )
962  qid->m[j++] = p_PermPoly(id->m[i], perm, currRing, qr, nMap, NULL, 0);
963  }
964  else
965 #endif
966  qid = idrCopyR(id,currRing,qr);
967 
968  idSkipZeroes(qid);
969  //idPrint(qid);
970  if ((idElem(qid)>1) || rIsSCA(currRing) || (currRing->qideal!=NULL))
971  assumeStdFlag(a);
972 
973  if (currRing->qideal!=NULL) /* we are already in a qring! */
974  {
975  ideal tmp=idSimpleAdd(qid,currRing->qideal);
976  // both ideals should be GB, so dSimpleAdd is sufficient
977  idDelete(&qid);
978  qid=tmp;
979  // delete the qr copy of quotient ideal!!!
980  idDelete(&qr->qideal);
981  }
982  if (idElem(qid)==0)
983  {
984  qr->qideal = NULL;
985  id_Delete(&qid,currRing);
986  IDTYP(h)=RING_CMD;
987  }
988  else
989  qr->qideal = qid;
990 
991  // qr is a copy of currRing with the new qideal!
992  #ifdef HAVE_PLURAL
993  if(rIsPluralRing(currRing) &&(qr->qideal!=NULL))
994  {
995  if (!hasFlag(a,FLAG_TWOSTD))
996  {
997  Warn("%s is no twosided standard basis",a->Name());
998  }
999 
1000  if( nc_SetupQuotient(qr, currRing) )
1001  {
1002 // WarnS("error in nc_SetupQuotient");
1003  }
1004  }
1005  #endif
1006  //rWrite(qr);
1007  rSetHdl((idhdl)res->data);
1008  if (old_ring!=NULL)
1009  {
1010  rDelete(old_ring);
1011  }
1012  return FALSE;
1013 }
1014 
1015 static BOOLEAN jiA_RING(leftv res, leftv a, Subexpr e)
1016 {
1017  BOOLEAN have_id=TRUE;
1018  if ((e!=NULL)||(res->rtyp!=IDHDL))
1019  {
1020  //WerrorS("id expected");
1021  //return TRUE;
1022  have_id=FALSE;
1023  }
1024  ring r=(ring)a->Data();
1025  if (have_id)
1026  {
1027  idhdl rl=(idhdl)res->data;
1028  if (IDRING(rl)!=NULL) rKill(rl);
1029  IDRING(rl)=r;
1030  if ((IDLEV((idhdl)a->data)!=myynest) && (r==currRing))
1031  currRingHdl=(idhdl)res->data;
1032  }
1033  else
1034  {
1035  if (e==NULL) res->data=(char *)r;
1036  else
1037  {
1038  WerrorS("id expected");
1039  return TRUE;
1040  }
1041  }
1042  r->ref++;
1043  jiAssignAttr(res,a);
1044  return FALSE;
1045 }
1046 static BOOLEAN jiA_PACKAGE(leftv res, leftv a, Subexpr)
1047 {
1048  res->data=(void *)a->CopyD(PACKAGE_CMD);
1049  jiAssignAttr(res,a);
1050  return FALSE;
1051 }
1052 static BOOLEAN jiA_DEF(leftv res, leftv, Subexpr)
1053 {
1054  res->data=(void *)0;
1055  return FALSE;
1056 }
1057 #ifdef SINGULAR_4_1
1058 static BOOLEAN jiA_CRING(leftv res, leftv a, Subexpr e)
1059 {
1060  res->data=(void *)a->CopyD(CRING_CMD);
1061  jiAssignAttr(res,a);
1062  return FALSE;
1063 }
1064 #endif
1065 
1066 /*=================== table =================*/
1067 #define IPASSIGN
1068 #define D(A) A
1069 #define NULL_VAL NULL
1070 #include "table.h"
1071 /*=================== operations ============================*/
1072 /*2
1073 * assign a = b
1074 */
1076 {
1077  int rt=r->Typ();
1078  if (rt==0)
1079  {
1080  if (!errorreported) Werror("`%s` is undefined",r->Fullname());
1081  return TRUE;
1082  }
1083 
1084  int lt=l->Typ();
1085  if (lt==0)
1086  {
1087  if (!errorreported) Werror("left side `%s` is undefined",l->Fullname());
1088  return TRUE;
1089  }
1090  if(rt==NONE)
1091  {
1092  WarnS("right side is not a datum, assignment ignored");
1093  Warn("in line >>%s<<",my_yylinebuf);
1094  // if (!errorreported)
1095  // WerrorS("right side is not a datum");
1096  //return TRUE;
1097  return FALSE;
1098  }
1099 
1100  if (lt==DEF_CMD)
1101  {
1102  if (TEST_V_ALLWARN
1103  && (rt!=RING_CMD)
1104  && (rt!=QRING_CMD)
1105  && (l->name!=NULL)
1106  && (l->e==NULL)
1107  && (iiCurrArgs==NULL) /* not in proc header */
1108  )
1109  {
1110  Warn("use `%s` instead of `def` in %s:%d:%s",Tok2Cmdname(rt),
1112  }
1113  if (l->rtyp==IDHDL)
1114  {
1115  IDTYP((idhdl)l->data)=rt;
1116  }
1117  else if (l->name!=NULL)
1118  {
1119  sleftv ll;
1120  iiDeclCommand(&ll,l,myynest,rt,&IDROOT);
1121  memcpy(l,&ll,sizeof(sleftv));
1122  }
1123  else
1124  {
1125  l->rtyp=rt;
1126  }
1127  lt=rt;
1128  }
1129  else
1130  {
1131  if ((l->data==r->data)&&(l->e==NULL)&&(r->e==NULL))
1132  return FALSE;
1133  }
1134  leftv ld=l;
1135  if (l->rtyp==IDHDL)
1136  {
1137  if ((lt!=QRING_CMD)&&(lt!=RING_CMD))
1138  ld=(leftv)l->data;
1139  }
1140  else if (toplevel)
1141  {
1142  WerrorS("error in assign: left side is not an l-value");
1143  return TRUE;
1144  }
1145  if (lt>MAX_TOK)
1146  {
1147  blackbox *bb=getBlackboxStuff(lt);
1148 #ifdef BLACKBOX_DEVEL
1149  Print("bb-assign: bb=%lx\n",bb);
1150 #endif
1151  return (bb==NULL) || bb->blackbox_Assign(l,r);
1152  }
1153  int start=0;
1154  while ((dAssign[start].res!=lt)
1155  && (dAssign[start].res!=0)) start++;
1156  int i=start;
1157  while ((dAssign[i].res==lt)
1158  && (dAssign[i].arg!=rt)) i++;
1159  if (dAssign[i].res==lt)
1160  {
1161  if (traceit&TRACE_ASSIGN) Print("assign %s=%s\n",Tok2Cmdname(lt),Tok2Cmdname(rt));
1162  BOOLEAN b;
1163  b=dAssign[i].p(ld,r,l->e);
1164  if(l!=ld) /* i.e. l is IDHDL, l->data is ld */
1165  {
1166  l->flag=ld->flag;
1167  l->attribute=ld->attribute;
1168  }
1169  return b;
1170  }
1171  // implicite type conversion ----------------------------------------------
1172  if (dAssign[i].res!=lt)
1173  {
1174  int ri;
1176  BOOLEAN failed=FALSE;
1177  i=start;
1178  //while ((dAssign[i].res!=lt)
1179  // && (dAssign[i].res!=0)) i++;
1180  while (dAssign[i].res==lt)
1181  {
1182  if ((ri=iiTestConvert(rt,dAssign[i].arg))!=0)
1183  {
1184  failed= iiConvert(rt,dAssign[i].arg,ri,r,rn);
1185  if(!failed)
1186  {
1187  failed= dAssign[i].p(ld,rn,l->e);
1188  if (traceit&TRACE_ASSIGN)
1189  Print("assign %s=%s ok? %d\n",Tok2Cmdname(lt),Tok2Cmdname(rn->rtyp),!failed);
1190  }
1191  // everything done, clean up temp. variables
1192  rn->CleanUp();
1194  if (failed)
1195  {
1196  // leave loop, goto error handling
1197  break;
1198  }
1199  else
1200  {
1201  if(l!=ld) /* i.e. l is IDHDL, l->data is ld */
1202  {
1203  l->flag=ld->flag;
1204  l->attribute=ld->attribute;
1205  }
1206  // everything ok, return
1207  return FALSE;
1208  }
1209  }
1210  i++;
1211  }
1212  // error handling ---------------------------------------------------
1213  if (!errorreported)
1214  {
1215  if ((l->rtyp==IDHDL) && (l->e==NULL))
1216  Werror("`%s`(%s) = `%s` is not supported",
1217  Tok2Cmdname(lt),l->Name(),Tok2Cmdname(rt));
1218  else
1219  Werror("`%s` = `%s` is not supported"
1220  ,Tok2Cmdname(lt),Tok2Cmdname(rt));
1221  if (BVERBOSE(V_SHOW_USE))
1222  {
1223  i=0;
1224  while ((dAssign[i].res!=lt)
1225  && (dAssign[i].res!=0)) i++;
1226  while (dAssign[i].res==lt)
1227  {
1228  Werror("expected `%s` = `%s`"
1229  ,Tok2Cmdname(lt),Tok2Cmdname(dAssign[i].arg));
1230  i++;
1231  }
1232  }
1233  }
1234  }
1235  return TRUE;
1236 }
1237 /*2
1238 * assign sys_var = val
1239 */
1241 {
1242  int rt=r->Typ();
1243 
1244  if (rt==0)
1245  {
1246  if (!errorreported) Werror("`%s` is undefined",r->Fullname());
1247  return TRUE;
1248  }
1249  int i=0;
1250  int lt=l->rtyp;
1251  while (((dAssign_sys[i].res!=lt)
1252  || (dAssign_sys[i].arg!=rt))
1253  && (dAssign_sys[i].res!=0)) i++;
1254  if (dAssign_sys[i].res!=0)
1255  {
1256  if (!dAssign_sys[i].p(l,r))
1257  {
1258  // everything ok, clean up
1259  return FALSE;
1260  }
1261  }
1262  // implicite type conversion ----------------------------------------------
1263  if (dAssign_sys[i].res==0)
1264  {
1265  int ri;
1267  BOOLEAN failed=FALSE;
1268  i=0;
1269  while ((dAssign_sys[i].res!=lt)
1270  && (dAssign_sys[i].res!=0)) i++;
1271  while (dAssign_sys[i].res==lt)
1272  {
1273  if ((ri=iiTestConvert(rt,dAssign_sys[i].arg))!=0)
1274  {
1275  failed= ((iiConvert(rt,dAssign_sys[i].arg,ri,r,rn))
1276  || (dAssign_sys[i].p(l,rn)));
1277  // everything done, clean up temp. variables
1278  rn->CleanUp();
1280  if (failed)
1281  {
1282  // leave loop, goto error handling
1283  break;
1284  }
1285  else
1286  {
1287  // everything ok, return
1288  return FALSE;
1289  }
1290  }
1291  i++;
1292  }
1293  // error handling ---------------------------------------------------
1294  if(!errorreported)
1295  {
1296  Werror("`%s` = `%s` is not supported"
1297  ,Tok2Cmdname(lt),Tok2Cmdname(rt));
1298  if (BVERBOSE(V_SHOW_USE))
1299  {
1300  i=0;
1301  while ((dAssign_sys[i].res!=lt)
1302  && (dAssign_sys[i].res!=0)) i++;
1303  while (dAssign_sys[i].res==lt)
1304  {
1305  Werror("expected `%s` = `%s`"
1306  ,Tok2Cmdname(lt),Tok2Cmdname(dAssign_sys[i].arg));
1307  i++;
1308  }
1309  }
1310  }
1311  }
1312  return TRUE;
1313 }
1315 {
1316  /* right side is intvec, left side is list (of int)*/
1317  BOOLEAN nok;
1318  int i=0;
1319  leftv l1=l;
1320  leftv h;
1321  sleftv t;
1322  intvec *iv=(intvec *)r->Data();
1323  memset(&t,0,sizeof(sleftv));
1324  t.rtyp=INT_CMD;
1325  while ((i<iv->length())&&(l!=NULL))
1326  {
1327  t.data=(char *)(long)(*iv)[i];
1328  h=l->next;
1329  l->next=NULL;
1330  nok=jiAssign_1(l,&t,TRUE);
1331  l->next=h;
1332  if (nok) return TRUE;
1333  i++;
1334  l=h;
1335  }
1336  l1->CleanUp();
1337  r->CleanUp();
1338  return FALSE;
1339 }
1341 {
1342  /* right side is vector, left side is list (of poly)*/
1343  BOOLEAN nok;
1344  leftv l1=l;
1345  ideal I=idVec2Ideal((poly)r->Data());
1346  leftv h;
1347  sleftv t;
1348  int i=0;
1349  while (l!=NULL)
1350  {
1351  memset(&t,0,sizeof(sleftv));
1352  t.rtyp=POLY_CMD;
1353  if (i>=IDELEMS(I))
1354  {
1355  t.data=NULL;
1356  }
1357  else
1358  {
1359  t.data=(char *)I->m[i];
1360  I->m[i]=NULL;
1361  }
1362  h=l->next;
1363  l->next=NULL;
1364  nok=jiAssign_1(l,&t,TRUE);
1365  l->next=h;
1366  t.CleanUp();
1367  if (nok)
1368  {
1369  idDelete(&I);
1370  return TRUE;
1371  }
1372  i++;
1373  l=h;
1374  }
1375  idDelete(&I);
1376  l1->CleanUp();
1377  r->CleanUp();
1378  //if (TEST_V_QRING && (currRing->qideal!=NULL)) jjNormalizeQRingP(l);
1379  return FALSE;
1380 }
1382 /* left side: list/def, has to be a "real" variable
1383 * right side: expression list
1384 */
1385 {
1386  int sl = r->listLength();
1388  lists oldL;
1389  leftv h=NULL,o_r=r;
1390  int i;
1391  int rt;
1392 
1393  L->Init(sl);
1394  for (i=0;i<sl;i++)
1395  {
1396  if (h!=NULL) { /* e.g. not in the first step:
1397  * h is the pointer to the old sleftv,
1398  * r is the pointer to the next sleftv
1399  * (in this moment) */
1400  h->next=r;
1401  }
1402  h=r;
1403  r=r->next;
1404  h->next=NULL;
1405  rt=h->Typ();
1406  if ((rt==0)||(rt==NONE)||(rt==DEF_CMD))
1407  {
1408  L->Clean();
1409  Werror("`%s` is undefined",h->Fullname());
1410  //listall();
1411  goto err;
1412  }
1413  //if ((rt==RING_CMD)||(rt==QRING_CMD))
1414  //{
1415  // L->m[i].rtyp=rt;
1416  // L->m[i].data=h->Data();
1417  // ((ring)L->m[i].data)->ref++;
1418  //}
1419  //else
1420  L->m[i].CleanUp();
1421  L->m[i].Copy(h);
1422  if(errorreported)
1423  {
1424  L->Clean();
1425  goto err;
1426  }
1427  }
1428  oldL=(lists)l->Data();
1429  if (oldL!=NULL) oldL->Clean();
1430  if (l->rtyp==IDHDL)
1431  {
1432  IDLIST((idhdl)l->data)=L;
1433  IDTYP((idhdl)l->data)=LIST_CMD; // was possibly DEF_CMD
1434  if (lRingDependend(L)) ipMoveId((idhdl)l->data);
1435  }
1436  else
1437  {
1438  l->LData()->data=L;
1439  if ((l->e!=NULL) && (l->rtyp==DEF_CMD))
1440  l->rtyp=LIST_CMD;
1441  }
1442 err:
1443  o_r->CleanUp();
1444  return errorreported;
1445 }
1447 {
1448  /* left side is intvec/intmat, right side is list (of int,intvec,intmat)*/
1449  leftv hh=r;
1450  int i = 0;
1451  while (hh!=NULL)
1452  {
1453  if (i>=iv->length())
1454  {
1455  if (traceit&TRACE_ASSIGN)
1456  {
1457  Warn("expression list length(%d) does not match intmat size(%d)",
1458  iv->length()+exprlist_length(hh),iv->length());
1459  }
1460  break;
1461  }
1462  if (hh->Typ() == INT_CMD)
1463  {
1464  (*iv)[i++] = (int)((long)(hh->Data()));
1465  }
1466  else if ((hh->Typ() == INTVEC_CMD)
1467  ||(hh->Typ() == INTMAT_CMD))
1468  {
1469  intvec *ivv = (intvec *)(hh->Data());
1470  int ll = 0,l = si_min(ivv->length(),iv->length());
1471  for (; l>0; l--)
1472  {
1473  (*iv)[i++] = (*ivv)[ll++];
1474  }
1475  }
1476  else
1477  {
1478  delete iv;
1479  return TRUE;
1480  }
1481  hh = hh->next;
1482  }
1483  if (l->rtyp==IDHDL)
1484  {
1485  if (IDINTVEC((idhdl)l->data)!=NULL) delete IDINTVEC((idhdl)l->data);
1486  IDINTVEC((idhdl)l->data)=iv;
1487  }
1488  else
1489  {
1490  if (l->data!=NULL) delete ((intvec*)l->data);
1491  l->data=(char*)iv;
1492  }
1493  return FALSE;
1494 }
1496 {
1497  /* left side is bigintmat, right side is list (of int,intvec,intmat)*/
1498  leftv hh=r;
1499  int i = 0;
1500  if (bim->length()==0) { WerrorS("bigintmat is 1x0"); delete bim; return TRUE; }
1501  while (hh!=NULL)
1502  {
1503  if (i>=bim->cols()*bim->rows())
1504  {
1505  if (traceit&TRACE_ASSIGN)
1506  {
1507  Warn("expression list length(%d) does not match bigintmat size(%d x %d)",
1508  exprlist_length(hh),bim->rows(),bim->cols());
1509  }
1510  break;
1511  }
1512  if (hh->Typ() == INT_CMD)
1513  {
1514  number tp = n_Init((int)((long)(hh->Data())), coeffs_BIGINT);
1515  bim->set(i++, tp);
1516  n_Delete(&tp, coeffs_BIGINT);
1517  }
1518  else if (hh->Typ() == BIGINT_CMD)
1519  {
1520  bim->set(i++, (number)(hh->Data()));
1521  }
1522  /*
1523  ((hh->Typ() == INTVEC_CMD)
1524  ||(hh->Typ() == INTMAT_CMD))
1525  {
1526  intvec *ivv = (intvec *)(hh->Data());
1527  int ll = 0,l = si_min(ivv->length(),iv->length());
1528  for (; l>0; l--)
1529  {
1530  (*iv)[i++] = (*ivv)[ll++];
1531  }
1532  }*/
1533  else
1534  {
1535  delete bim;
1536  return TRUE;
1537  }
1538  hh = hh->next;
1539  }
1540  if (IDBIMAT((idhdl)l->data)!=NULL) delete IDBIMAT((idhdl)l->data);
1541  IDBIMAT((idhdl)l->data)=bim;
1542  return FALSE;
1543 }
1545 {
1546  /* left side is string, right side is list of string*/
1547  leftv hh=r;
1548  int sl = 1;
1549  char *s;
1550  char *t;
1551  int tl;
1552  /* find the length */
1553  while (hh!=NULL)
1554  {
1555  if (hh->Typ()!= STRING_CMD)
1556  {
1557  return TRUE;
1558  }
1559  sl += strlen((char *)hh->Data());
1560  hh = hh->next;
1561  }
1562  s = (char * )omAlloc(sl);
1563  sl=0;
1564  hh = r;
1565  while (hh!=NULL)
1566  {
1567  t=(char *)hh->Data();
1568  tl=strlen(t);
1569  memcpy(s+sl,t,tl);
1570  sl+=tl;
1571  hh = hh->next;
1572  }
1573  s[sl]='\0';
1574  omFree((ADDRESS)IDDATA((idhdl)(l->data)));
1575  IDDATA((idhdl)(l->data))=s;
1576  return FALSE;
1577 }
1579 {
1580  /* right side is matrix, left side is list (of poly)*/
1581  BOOLEAN nok=FALSE;
1582  int i;
1584  leftv h;
1585  leftv ol=l;
1586  leftv o_r=r;
1587  sleftv t;
1588  memset(&t,0,sizeof(sleftv));
1589  t.rtyp=POLY_CMD;
1590  int mxn=MATROWS(m)*MATCOLS(m);
1591  loop
1592  {
1593  i=0;
1594  while ((i<mxn /*MATROWS(m)*MATCOLS(m)*/)&&(l!=NULL))
1595  {
1596  t.data=(char *)m->m[i];
1597  m->m[i]=NULL;
1598  h=l->next;
1599  l->next=NULL;
1600  idhdl hh=NULL;
1601  if ((l->rtyp==IDHDL)&&(l->Typ()==DEF_CMD)) hh=(idhdl)l->data;
1602  nok=jiAssign_1(l,&t,TRUE);
1603  if (hh!=NULL) { ipMoveId(hh);hh=NULL;}
1604  l->next=h;
1605  if (nok)
1606  {
1607  idDelete((ideal *)&m);
1608  goto ende;
1609  }
1610  i++;
1611  l=h;
1612  }
1613  idDelete((ideal *)&m);
1614  h=r;
1615  r=r->next;
1616  if (l==NULL)
1617  {
1618  if (r!=NULL)
1619  {
1620  Warn("list length mismatch in assign (l>r)");
1621  nok=TRUE;
1622  }
1623  break;
1624  }
1625  else if (r==NULL)
1626  {
1627  Warn("list length mismatch in assign (l<r)");
1628  nok=TRUE;
1629  break;
1630  }
1631  if ((r->Typ()==IDEAL_CMD)||(r->Typ()==MATRIX_CMD))
1632  {
1633  m=(matrix)r->CopyD(MATRIX_CMD);
1634  mxn=MATROWS(m)*MATCOLS(m);
1635  }
1636  else if (r->Typ()==POLY_CMD)
1637  {
1638  m=mpNew(1,1);
1639  MATELEM(m,1,1)=(poly)r->CopyD(POLY_CMD);
1640  pNormalize(MATELEM(m,1,1));
1641  mxn=1;
1642  }
1643  else
1644  {
1645  nok=TRUE;
1646  break;
1647  }
1648  }
1649 ende:
1650  o_r->CleanUp();
1651  ol->CleanUp();
1652  return nok;
1653 }
1655 {
1656  /*left side are strings, right side is a string*/
1657  /*e.g. s[2..3]="12" */
1658  /*the case s=t[1..4] is handled in iiAssign,
1659  * the case s[2..3]=t[3..4] is handled in iiAssgn_rec*/
1660  BOOLEAN nok=FALSE;
1661  sleftv t;
1662  leftv h,l1=l;
1663  int i=0;
1664  char *ss;
1665  char *s=(char *)r->Data();
1666  int sl=strlen(s);
1667 
1668  memset(&t,0,sizeof(sleftv));
1669  t.rtyp=STRING_CMD;
1670  while ((i<sl)&&(l!=NULL))
1671  {
1672  ss=(char *)omAlloc(2);
1673  ss[1]='\0';
1674  ss[0]=s[i];
1675  t.data=ss;
1676  h=l->next;
1677  l->next=NULL;
1678  nok=jiAssign_1(l,&t,TRUE);
1679  if (nok)
1680  {
1681  break;
1682  }
1683  i++;
1684  l=h;
1685  }
1686  r->CleanUp();
1687  l1->CleanUp();
1688  return nok;
1689 }
1691 {
1692  int i=l->e->start-1;
1693  if (i<0)
1694  {
1695  Werror("index[%d] must be positive",i+1);
1696  return TRUE;
1697  }
1698  if(l->attribute!=NULL)
1699  {
1700  atKillAll((idhdl)l);
1701  l->attribute=NULL;
1702  }
1703  l->flag=0;
1704  lists li;
1705  if (l->rtyp==IDHDL)
1706  {
1707  li=IDLIST((idhdl)l->data);
1708  }
1709  else
1710  {
1711  li=(lists)l->data;
1712  }
1713  if (i>li->nr)
1714  {
1715  if (TEST_V_ALLWARN)
1716  {
1717  Warn("increase list %d -> %d in %s",li->nr,i,my_yylinebuf);
1718  }
1719  li->m=(leftv)omreallocSize(li->m,(li->nr+1)*sizeof(sleftv),(i+1)*sizeof(sleftv));
1720  memset(&(li->m[li->nr+1]),0,(i-li->nr)*sizeof(sleftv));
1721  int j=li->nr+1;
1722  for(;j<=i;j++)
1723  li->m[j].rtyp=DEF_CMD;
1724  li->nr=i;
1725  }
1726  leftv ld=&(li->m[i]);
1727  ld->e=l->e->next;
1728  BOOLEAN b;
1729  if (/*(ld->rtyp!=LIST_CMD)
1730  &&*/(ld->e==NULL)
1731  && (ld->Typ()!=r->Typ()))
1732  {
1733  sleftv tmp;
1734  memset(&tmp,0,sizeof(sleftv));
1735  tmp.rtyp=DEF_CMD;
1736  b=iiAssign(&tmp,r,FALSE);
1737  ld->CleanUp();
1738  memcpy(ld,&tmp,sizeof(sleftv));
1739  }
1740  else if ((ld->e==NULL)
1741  && (ld->Typ()==r->Typ())
1742  && (ld->Typ()<MAX_TOK))
1743  {
1744  sleftv tmp;
1745  memset(&tmp,0,sizeof(sleftv));
1746  tmp.rtyp=r->Typ();
1747  tmp.data=(char*)idrecDataInit(r->Typ());
1748  b=iiAssign(&tmp,r,FALSE);
1749  ld->CleanUp();
1750  memcpy(ld,&tmp,sizeof(sleftv));
1751  }
1752  else
1753  {
1754  b=iiAssign(ld,r,FALSE);
1755  if (l->e!=NULL) l->e->next=ld->e;
1756  ld->e=NULL;
1757  }
1758  return b;
1759 }
1761 {
1762  leftv l1=l;
1763  leftv r1=r;
1764  leftv lrest;
1765  leftv rrest;
1766  BOOLEAN b;
1767  do
1768  {
1769  lrest=l->next;
1770  rrest=r->next;
1771  l->next=NULL;
1772  r->next=NULL;
1773  b=iiAssign(l,r);
1774  l->next=lrest;
1775  r->next=rrest;
1776  l=lrest;
1777  r=rrest;
1778  } while ((!b)&&(l!=NULL));
1779  l1->CleanUp();
1780  r1->CleanUp();
1781  return b;
1782 }
1784 {
1785  if (errorreported) return TRUE;
1786  int ll=l->listLength();
1787  int rl;
1788  int lt=l->Typ();
1789  int rt=NONE;
1790  BOOLEAN b;
1791  if (l->rtyp==ALIAS_CMD)
1792  {
1793  Werror("`%s` is read-only",l->Name());
1794  }
1795 
1796  if (l->rtyp==IDHDL)
1797  {
1798  atKillAll((idhdl)l->data);
1799  IDFLAG((idhdl)l->data)=0;
1800  l->attribute=NULL;
1801  toplevel=FALSE;
1802  }
1803  else if (l->attribute!=NULL)
1804  atKillAll((idhdl)l);
1805  l->flag=0;
1806  if (ll==1)
1807  {
1808  /* l[..] = ... */
1809  if(l->e!=NULL)
1810  {
1811  BOOLEAN like_lists=0;
1812  blackbox *bb=NULL;
1813  int bt;
1814  if (((bt=l->rtyp)>MAX_TOK)
1815  || ((l->rtyp==IDHDL) && ((bt=IDTYP((idhdl)l->data))>MAX_TOK)))
1816  {
1817  bb=getBlackboxStuff(bt);
1818  like_lists=BB_LIKE_LIST(bb); // bb like a list
1819  }
1820  else if (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD))
1821  || (l->rtyp==LIST_CMD))
1822  {
1823  like_lists=2; // bb in a list
1824  }
1825  if(like_lists)
1826  {
1827  if (traceit&TRACE_ASSIGN) PrintS("assign list[..]=...or similar\n");
1828  if (like_lists==1)
1829  {
1830  // check blackbox/newtype type:
1831  if(bb->blackbox_CheckAssign(bb,l,r)) return TRUE;
1832  }
1833  b=jiAssign_list(l,r);
1834  if((!b) && (like_lists==2))
1835  {
1836  //Print("jjA_L_LIST: - 2 \n");
1837  if((l->rtyp==IDHDL) && (l->data!=NULL))
1838  {
1839  ipMoveId((idhdl)l->data);
1840  l->attribute=IDATTR((idhdl)l->data);
1841  l->flag=IDFLAG((idhdl)l->data);
1842  }
1843  }
1844  r->CleanUp();
1845  Subexpr h;
1846  while (l->e!=NULL)
1847  {
1848  h=l->e->next;
1849  omFreeBin((ADDRESS)l->e, sSubexpr_bin);
1850  l->e=h;
1851  }
1852  return b;
1853  }
1854  }
1855  if (lt>MAX_TOK)
1856  {
1857  blackbox *bb=getBlackboxStuff(lt);
1858 #ifdef BLACKBOX_DEVEL
1859  Print("bb-assign: bb=%lx\n",bb);
1860 #endif
1861  return (bb==NULL) || bb->blackbox_Assign(l,r);
1862  }
1863  // end of handling elems of list and similar
1864  rl=r->listLength();
1865  if (rl==1)
1866  {
1867  /* system variables = ... */
1868  if(((l->rtyp>=VECHO)&&(l->rtyp<=VPRINTLEVEL))
1869  ||((l->rtyp>=VALTVARS)&&(l->rtyp<=VMINPOLY)))
1870  {
1871  b=iiAssign_sys(l,r);
1872  r->CleanUp();
1873  //l->CleanUp();
1874  return b;
1875  }
1876  rt=r->Typ();
1877  /* a = ... */
1878  if ((lt!=MATRIX_CMD)
1879  &&(lt!=BIGINTMAT_CMD)
1880  &&(lt!=CMATRIX_CMD)
1881  &&(lt!=INTMAT_CMD)
1882  &&((lt==rt)||(lt!=LIST_CMD)))
1883  {
1884  b=jiAssign_1(l,r,toplevel);
1885  if (l->rtyp==IDHDL)
1886  {
1887  if ((lt==DEF_CMD)||(lt==LIST_CMD))
1888  {
1889  ipMoveId((idhdl)l->data);
1890  }
1891  l->attribute=IDATTR((idhdl)l->data);
1892  l->flag=IDFLAG((idhdl)l->data);
1893  l->CleanUp();
1894  }
1895  r->CleanUp();
1896  return b;
1897  }
1898  if (((lt!=LIST_CMD)
1899  &&((rt==MATRIX_CMD)
1900  ||(rt==BIGINTMAT_CMD)
1901  ||(rt==CMATRIX_CMD)
1902  ||(rt==INTMAT_CMD)
1903  ||(rt==INTVEC_CMD)
1904  ||(rt==MODUL_CMD)))
1905  ||((lt==LIST_CMD)
1906  &&(rt==RESOLUTION_CMD))
1907  )
1908  {
1909  b=jiAssign_1(l,r,toplevel);
1910  if((l->rtyp==IDHDL)&&(l->data!=NULL))
1911  {
1912  if ((lt==DEF_CMD) || (lt==LIST_CMD))
1913  {
1914  //Print("ipAssign - 3.0\n");
1915  ipMoveId((idhdl)l->data);
1916  }
1917  l->attribute=IDATTR((idhdl)l->data);
1918  l->flag=IDFLAG((idhdl)l->data);
1919  }
1920  r->CleanUp();
1921  Subexpr h;
1922  while (l->e!=NULL)
1923  {
1924  h=l->e->next;
1925  omFreeBin((ADDRESS)l->e, sSubexpr_bin);
1926  l->e=h;
1927  }
1928  return b;
1929  }
1930  }
1931  if (rt==NONE) rt=r->Typ();
1932  }
1933  else if (ll==(rl=r->listLength()))
1934  {
1935  b=jiAssign_rec(l,r);
1936  return b;
1937  }
1938  else
1939  {
1940  if (rt==NONE) rt=r->Typ();
1941  if (rt==INTVEC_CMD)
1942  return jiA_INTVEC_L(l,r);
1943  else if (rt==VECTOR_CMD)
1944  return jiA_VECTOR_L(l,r);
1945  else if ((rt==IDEAL_CMD)||(rt==MATRIX_CMD))
1946  return jiA_MATRIX_L(l,r);
1947  else if ((rt==STRING_CMD)&&(rl==1))
1948  return jiA_STRING_L(l,r);
1949  Werror("length of lists in assignment does not match (l:%d,r:%d)",
1950  ll,rl);
1951  return TRUE;
1952  }
1953 
1954  leftv hh=r;
1955  BOOLEAN nok=FALSE;
1956  BOOLEAN map_assign=FALSE;
1957  switch (lt)
1958  {
1959  case INTVEC_CMD:
1960  nok=jjA_L_INTVEC(l,r,new intvec(exprlist_length(r)));
1961  break;
1962  case INTMAT_CMD:
1963  {
1964  nok=jjA_L_INTVEC(l,r,new intvec(IDINTVEC((idhdl)l->data)));
1965  break;
1966  }
1967  case BIGINTMAT_CMD:
1968  {
1969  nok=jjA_L_BIGINTMAT(l, r, new bigintmat(IDBIMAT((idhdl)l->data)));
1970  break;
1971  }
1972  case MAP_CMD:
1973  {
1974  // first element in the list sl (r) must be a ring
1975  if (((rt == RING_CMD)||(rt == QRING_CMD))&&(r->e==NULL))
1976  {
1977  omFree((ADDRESS)IDMAP((idhdl)l->data)->preimage);
1978  IDMAP((idhdl)l->data)->preimage = omStrDup (r->Fullname());
1979  /* advance the expressionlist to get the next element after the ring */
1980  hh = r->next;
1981  //r=hh;
1982  }
1983  else
1984  {
1985  WerrorS("expected ring-name");
1986  nok=TRUE;
1987  break;
1988  }
1989  if (hh==NULL) /* map-assign: map f=r; */
1990  {
1991  WerrorS("expected image ideal");
1992  nok=TRUE;
1993  break;
1994  }
1995  if ((hh->next==NULL)&&(hh->Typ()==IDEAL_CMD))
1996  return jiAssign_1(l,hh,toplevel); /* map-assign: map f=r,i; */
1997  //no break, handle the rest like an ideal:
1998  map_assign=TRUE;
1999  }
2000  case MATRIX_CMD:
2001  case IDEAL_CMD:
2002  case MODUL_CMD:
2003  {
2004  sleftv t;
2005  matrix olm = (matrix)l->Data();
2006  int rk;
2007  char *pr=((map)olm)->preimage;
2008  BOOLEAN module_assign=(/*l->Typ()*/ lt==MODUL_CMD);
2009  matrix lm ;
2010  int num;
2011  int j,k;
2012  int i=0;
2013  int mtyp=MATRIX_CMD; /*Type of left side object*/
2014  int etyp=POLY_CMD; /*Type of elements of left side object*/
2015 
2016  if (lt /*l->Typ()*/==MATRIX_CMD)
2017  {
2018  rk=olm->rows();
2019  num=olm->cols()*rk /*olm->rows()*/;
2020  lm=mpNew(olm->rows(),olm->cols());
2021  int el;
2022  if ((traceit&TRACE_ASSIGN) && (num!=(el=exprlist_length(hh))))
2023  {
2024  Warn("expression list length(%d) does not match matrix size(%d)",el,num);
2025  }
2026  }
2027  else /* IDEAL_CMD or MODUL_CMD */
2028  {
2029  num=exprlist_length(hh);
2030  lm=(matrix)idInit(num,1);
2031  if (module_assign)
2032  {
2033  rk=0;
2034  mtyp=MODUL_CMD;
2035  etyp=VECTOR_CMD;
2036  }
2037  else
2038  rk=1;
2039  }
2040 
2041  int ht;
2042  loop
2043  {
2044  if (hh==NULL)
2045  break;
2046  else
2047  {
2048  matrix rm;
2049  ht=hh->Typ();
2050  if ((j=iiTestConvert(ht,etyp))!=0)
2051  {
2052  nok=iiConvert(ht,etyp,j,hh,&t);
2053  hh->next=t.next;
2054  if (nok) break;
2055  lm->m[i]=(poly)t.CopyD(etyp);
2056  pNormalize(lm->m[i]);
2057  if (module_assign) rk=si_max(rk,(int)pMaxComp(lm->m[i]));
2058  i++;
2059  }
2060  else
2061  if ((j=iiTestConvert(ht,mtyp))!=0)
2062  {
2063  nok=iiConvert(ht,mtyp,j,hh,&t);
2064  hh->next=t.next;
2065  if (nok) break;
2066  rm = (matrix)t.CopyD(mtyp);
2067  if (module_assign)
2068  {
2069  j = si_min(num,rm->cols());
2070  rk=si_max(rk,(int)rm->rank);
2071  }
2072  else
2073  j = si_min(num-i,rm->rows() * rm->cols());
2074  for(k=0;k<j;k++,i++)
2075  {
2076  lm->m[i]=rm->m[k];
2077  pNormalize(lm->m[i]);
2078  rm->m[k]=NULL;
2079  }
2080  idDelete((ideal *)&rm);
2081  }
2082  else
2083  {
2084  nok=TRUE;
2085  break;
2086  }
2087  t.next=NULL;t.CleanUp();
2088  if (i==num) break;
2089  hh=hh->next;
2090  }
2091  }
2092  if (nok)
2093  idDelete((ideal *)&lm);
2094  else
2095  {
2096  idDelete((ideal *)&olm);
2097  if (module_assign) lm->rank=rk;
2098  else if (map_assign) ((map)lm)->preimage=pr;
2099  l=l->LData();
2100  if (l->rtyp==IDHDL)
2101  IDMATRIX((idhdl)l->data)=lm;
2102  else
2103  l->data=(char *)lm;
2104  }
2105  break;
2106  }
2107  case STRING_CMD:
2108  nok=jjA_L_STRING(l,r);
2109  break;
2110  //case DEF_CMD:
2111  case LIST_CMD:
2112  nok=jjA_L_LIST(l,r);
2113  break;
2114  case NONE:
2115  case 0:
2116  Werror("cannot assign to %s",l->Fullname());
2117  nok=TRUE;
2118  break;
2119  default:
2120  WerrorS("assign not impl.");
2121  nok=TRUE;
2122  break;
2123  } /* end switch: typ */
2124  if (nok && (!errorreported)) WerrorS("incompatible type in list assignment");
2125  r->CleanUp();
2126  return nok;
2127 }
2129 {
2130  if ((currRing->qideal!=NULL) && (!hasFlag(I,FLAG_QRING)))
2131  {
2132  if (I->e==NULL)
2133  {
2134  ideal I0=(ideal)I->Data();
2135  switch (I->Typ())
2136  {
2137  case IDEAL_CMD:
2138  case MODUL_CMD:
2139  {
2140  ideal F=idInit(1,1);
2141  ideal II=kNF(F,currRing->qideal,I0);
2142  idDelete(&F);
2143  if (I->rtyp!=IDHDL)
2144  {
2145  idDelete((ideal*)&(I0));
2146  I->data=II;
2147  }
2148  else
2149  {
2150  idhdl h=(idhdl)I->data;
2151  idDelete((ideal*)&IDIDEAL(h));
2152  IDIDEAL(h)=II;
2153  setFlag(h,FLAG_QRING);
2154  }
2155  break;
2156  }
2157  default: break;
2158  }
2159  setFlag(I,FLAG_QRING);
2160  }
2161  }
2162 }
2164 {
2165  if((p!=NULL) && (currRing->qideal!=NULL))
2166  {
2167  ideal F=idInit(1,1);
2168  poly p2=kNF(F,currRing->qideal,p);
2169  pNormalize(p2);
2170  idDelete(&F);
2171  pDelete(&p);
2172  p=p2;
2173  }
2174 }
2176 {
2177  //Print("importfrom %s::%s ->.\n",v->Name(),u->Name() );
2178  assume(u->Typ()==PACKAGE_CMD);
2179  char *vn=(char *)v->Name();
2180  idhdl h=((package)(u->Data()))->idroot->get(vn /*v->Name()*/, myynest);
2181  if (h!=NULL)
2182  {
2183  //check for existence
2184  if (((package)(u->Data()))==basePack)
2185  {
2186  WarnS("source and destination packages are identical");
2187  return FALSE;
2188  }
2189  idhdl t=basePack->idroot->get(vn /*v->Name()*/, myynest);
2190  if (t!=NULL)
2191  {
2192  Warn("redefining `%s`",vn);
2193  killhdl(t);
2194  }
2195  sleftv tmp_expr;
2196  if (iiDeclCommand(&tmp_expr,v,myynest,DEF_CMD,&IDROOT)) return TRUE;
2197  sleftv h_expr;
2198  memset(&h_expr,0,sizeof(h_expr));
2199  h_expr.rtyp=IDHDL;
2200  h_expr.data=h;
2201  h_expr.name=vn;
2202  return iiAssign(&tmp_expr,&h_expr);
2203  }
2204  else
2205  {
2206  Werror("`%s` not found in `%s`",v->Name(), u->Name());
2207  return TRUE;
2208  }
2209  return FALSE;
2210 }
static BOOLEAN jiA_BIGINTMAT(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:800
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:39
int & rows()
Definition: matpol.h:24
void * idrecDataInit(int t)
Definition: ipid.cc:132
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
static BOOLEAN jiA_MAP(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:887
#define IDLIST(a)
Definition: ipid.h:136
ip_package * package
Definition: structs.h:46
static BOOLEAN jiA_INTVEC_L(leftv l, leftv r)
Definition: ipassign.cc:1314
void id_Normalize(ideal I, const ring r)
normialize all polys in id
void ipMoveId(idhdl tomove)
Definition: ipid.cc:604
const CanonicalForm int s
Definition: facAbsFact.cc:55
unsigned si_opt_1
Definition: options.c:5
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:292
BOOLEAN jjIMPORTFROM(leftv, leftv u, leftv v)
Definition: ipassign.cc:2175
void jjNormalizeQRingP(poly &p)
Definition: ipassign.cc:2163
Definition: tok.h:207
sleftv * m
Definition: lists.h:45
static void jiAssignAttr(leftv l, leftv r)
Definition: ipassign.cc:323
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2819
#define TRACE_ASSIGN
Definition: reporter.h:43
static BOOLEAN jjMAXDEG(leftv, leftv a)
Definition: ipassign.cc:89
int yylineno
Definition: febase.cc:45
static BOOLEAN jjA_L_INTVEC(leftv l, leftv r, intvec *iv)
Definition: ipassign.cc:1446
const poly a
Definition: syzextra.cc:212
omBin_t * omBin
Definition: omStructs.h:12
void PrintLn()
Definition: reporter.cc:327
#define Print
Definition: emacs.cc:83
Definition: tok.h:98
ring r
Definition: algext.h:40
Definition: attrib.h:15
Subexpr e
Definition: subexpr.h:106
#define idDelete(H)
delete an ideal
Definition: ideals.h:31
BITSET flag
Definition: subexpr.h:91
static BOOLEAN jiA_QRING(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:912
static BOOLEAN jiA_INT(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:356
Definition: lists.h:22
#define nNormalize(n)
Definition: numbers.h:30
CanonicalForm num(const CanonicalForm &f)
procinfo * iiInitSingularProcinfo(procinfov pi, const char *libname, const char *procname, int line, long pos, BOOLEAN pstatic)
Definition: iplib.cc:968
#define IDINTVEC(a)
Definition: ipid.h:127
#define pMaxComp(p)
Definition: polys.h:270
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
#define IDID(a)
Definition: ipid.h:121
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
#define FALSE
Definition: auxiliary.h:140
Compatiblity layer for legacy polynomial operations (over currRing)
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition: ipconv.cc:358
Definition: tok.h:42
return P p
Definition: myNF.cc:203
int exprlist_length(leftv v)
Definition: ipshell.cc:554
Matrices of numbers.
Definition: bigintmat.h:51
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3097
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231
static BOOLEAN jiAssign_list(leftv l, leftv r)
Definition: ipassign.cc:1690
#define OPT_MULTBOUND
Definition: options.h:84
char * filename
Definition: fevoices.h:62
static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:400
void n2Delete(number2 &d)
Definition: number2.cc:285
Definition: tok.h:217
static BOOLEAN jiAssign_1(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1075
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
Definition: old.gring.cc:3488
static BOOLEAN jjPRINTLEVEL(leftv, leftv a)
Definition: ipassign.cc:65
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:539
#define idSimpleAdd(A, B)
Definition: ideals.h:55
#define IDROOT
Definition: ipid.h:20
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define BB_LIKE_LIST(B)
Definition: blackbox.h:54
static BOOLEAN jjTRACE(leftv, leftv a)
Definition: ipassign.cc:107
int listLength()
Definition: subexpr.cc:61
#define TRUE
Definition: auxiliary.h:144
int length() const
Definition: intvec.h:86
static BOOLEAN jiA_NUMBER2_N(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:508
static BOOLEAN jiA_PACKAGE(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:1046
#define IDIDEAL(a)
Definition: ipid.h:132
static BOOLEAN jiA_1x1MATRIX(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:712
static BOOLEAN jiA_LIST_RES(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:612
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
void * ADDRESS
Definition: auxiliary.h:161
sleftv * leftv
Definition: structs.h:60
int length()
Definition: bigintmat.h:144
#define IDBIMAT(a)
Definition: ipid.h:128
void WerrorS(const char *s)
Definition: feFopen.cc:24
void initRTimer()
Definition: timer.cc:158
int k
Definition: cfEzgcd.cc:93
int min_in()
Definition: intvec.h:113
static BOOLEAN jiA_STRING(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:737
int timerv
Definition: timer.cc:19
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
int traceit
Definition: febase.cc:47
#define WarnS
Definition: emacs.cc:81
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:976
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN piKill(procinfov pi)
Definition: ipid.cc:647
#define Sy_bit(x)
Definition: options.h:30
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:249
static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:832
const char * Name()
Definition: subexpr.h:121
#define pGetComp(p)
Component.
Definition: polys.h:37
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:35
const char * Fullname()
Definition: subexpr.h:126
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
int Kstd1_mu
Definition: kutil.cc:229
static BOOLEAN jjA_L_BIGINTMAT(leftv l, leftv r, bigintmat *bim)
Definition: ipassign.cc:1495
omBin procinfo_bin
Definition: subexpr.cc:51
static BOOLEAN iiAssign_sys(leftv l, leftv r)
Definition: ipassign.cc:1240
void * data
Definition: subexpr.h:89
poly res
Definition: myNF.cc:322
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define V_SHOW_USE
Definition: options.h:50
#define IDTYP(a)
Definition: ipid.h:118
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:403
const struct sValAssign_sys dAssign_sys[]
Definition: table.h:1299
poly * m
Definition: matpol.h:19
Definition: tok.h:59
static number2 n2Init(long i, coeffs c)
Definition: number2.h:17
char my_yylinebuf[80]
Definition: febase.cc:48
static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:777
const ring r
Definition: syzextra.cc:208
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:3937
Coefficient rings, fields and other domains suitable for Singular polynomials.
static BOOLEAN jjTIMER(leftv, leftv a)
Definition: ipassign.cc:75
#define FLAG_TWOSTD
Definition: ipid.h:109
static BOOLEAN jjCOLMAX(leftv, leftv a)
Definition: ipassign.cc:70
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:913
Definition: intvec.h:14
void rKill(ring r)
Definition: ipshell.cc:6057
int j
Definition: myNF.cc:70
Definition: tok.h:61
const char * name
Definition: subexpr.h:88
const struct sValAssign dAssign[]
Definition: table.h:1251
#define pSetCompP(a, i)
Definition: polys.h:274
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:405
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:361
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
#define nMult(n1, n2)
Definition: numbers.h:17
pNormalize(P.p)
#define omfree(addr)
Definition: omAllocDecl.h:237
static BOOLEAN jiA_VECTOR_L(leftv l, leftv r)
Definition: ipassign.cc:1340
omBin sSubexpr_bin
Definition: subexpr.cc:49
ip_smatrix * matrix
idhdl currRingHdl
Definition: ipid.cc:65
static BOOLEAN jjA_L_STRING(leftv l, leftv r)
Definition: ipassign.cc:1544
void Copy(leftv e)
Definition: subexpr.cc:657
#define setFlag(A, F)
Definition: ipid.h:112
static BOOLEAN jjRTIMER(leftv, leftv a)
Definition: ipassign.cc:82
All the auxiliary stuff.
static BOOLEAN jiA_BIGINT(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:572
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:921
idrec * idhdl
Definition: ring.h:18
#define FLAG_QRING
Definition: ipid.h:110
FILE * f
Definition: checklibs.c:7
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1455
omBin sleftv_bin
Definition: subexpr.cc:50
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:901
#define TEST_V_QRING
Definition: options.h:125
idhdl next
Definition: idrec.h:38
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:236
static BOOLEAN jjMINPOLY(leftv, leftv a)
Definition: ipassign.cc:182
#define IDELEMS(i)
Definition: simpleideals.h:24
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
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:722
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDLEV(a)
Definition: ipid.h:120
#define nDelete(n)
Definition: numbers.h:16
#define IDMAP(a)
Definition: ipid.h:134
static BOOLEAN jiA_CRING(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:1058
int cols() const
Definition: bigintmat.h:145
#define FLAG_STD
Definition: ipid.h:108
short errorreported
Definition: feFopen.cc:23
leftv next
Definition: subexpr.h:87
static BOOLEAN jjMAXMULT(leftv, leftv a)
Definition: ipassign.cc:98
static BOOLEAN jiA_RING(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:1015
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
#define BVERBOSE(a)
Definition: options.h:33
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
Definition: tok.h:38
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition: ipshell.cc:1123
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:849
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define pi
Definition: libparse.cc:1143
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
void jjNormalizeQRingId(leftv I)
Definition: ipassign.cc:2128
#define atKillAll(H)
Definition: attrib.h:42
ring rCopy(ring r)
Definition: ring.cc:1618
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:328
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:135
int nr
Definition: lists.h:43
static BOOLEAN jiA_STRING_L(leftv l, leftv r)
Definition: ipassign.cc:1654
int rows() const
Definition: bigintmat.h:146
int & cols()
Definition: matpol.h:25
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define MATCOLS(i)
Definition: matpol.h:28
Definition: tok.h:119
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:434
#define NULL
Definition: omList.c:10
static BOOLEAN jjECHO(leftv, leftv a)
Definition: ipassign.cc:60
static BOOLEAN jiAssign_rec(leftv l, leftv r)
Definition: ipassign.cc:1760
int cols() const
Definition: intvec.h:87
attr attribute
Definition: idrec.h:41
slists * lists
Definition: mpr_numeric.h:146
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3551
struct for passing initialization parameters to naInitChar
Definition: algext.h:40
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static BOOLEAN jiA_LINK(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:863
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:35
int rows() const
Definition: intvec.h:88
Voice * currentVoice
Definition: fevoices.cc:57
void killhdl(idhdl h, package proot)
Definition: ipid.cc:372
static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:759
package basePack
Definition: ipid.cc:64
coeffs basecoeffs() const
Definition: bigintmat.h:147
#define hasFlag(A, F)
Definition: ipid.h:111
static BOOLEAN jiA_MATRIX_L(leftv l, leftv r)
Definition: ipassign.cc:1578
#define IDRING(a)
Definition: ipid.h:126
#define pDelete(p_ptr)
Definition: polys.h:157
static BOOLEAN jjA_L_LIST(leftv l, leftv r)
Definition: ipassign.cc:1381
leftv iiCurrArgs
Definition: ipshell.cc:79
int rtyp
Definition: subexpr.h:92
#define IDFLAG(a)
Definition: ipid.h:119
static bool rIsSCA(const ring r)
Definition: nc.h:206
void CleanUp(ring r=currRing)
Definition: subexpr.cc:321
void Clean(ring r=currRing)
Definition: lists.h:25
#define IDATTR(a)
Definition: ipid.h:122
void * Data()
Definition: subexpr.cc:1118
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:193
int initTimer()
Definition: timer.cc:69
static BOOLEAN jjSHORTOUT(leftv, leftv a)
Definition: ipassign.cc:112
Definition: tok.h:120
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static BOOLEAN jiA_1x1INTMAT(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:690
static BOOLEAN jjNOETHER(leftv, leftv a)
Definition: ipassign.cc:315
attr Copy()
Definition: attrib.cc:41
static BOOLEAN jiA_NUMBER2(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:410
attr attribute
Definition: subexpr.h:90
omBin slists_bin
Definition: lists.cc:23
int printlevel
Definition: febase.cc:42
int idElem(const ideal F)
count non-zero elements
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:849
static BOOLEAN jiA_LIST(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:623
Definition: tok.h:159
static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:807
int rtimerv
Definition: timer.cc:148
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206
#define MATROWS(i)
Definition: matpol.h:27
#define OPT_DEGBOUND
Definition: options.h:85
static BOOLEAN jiA_NUMBER2_I(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:460
static ideal idVec2Ideal(poly vec)
Definition: ideals.h:166
polyrec * poly
Definition: hilb.h:10
#define IDDATA(a)
Definition: ipid.h:125
int Kstd1_deg
Definition: kutil.cc:228
void rSetHdl(idhdl h)
Definition: ipshell.cc:5030
int colmax
Definition: febase.cc:43
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define nInit(i)
Definition: numbers.h:24
int perm[100]
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
#define IMATELEM(M, I, J)
Definition: intvec.h:77
BITSET flag
Definition: idrec.h:42
const poly b
Definition: syzextra.cc:213
static BOOLEAN jiA_POLY(leftv res, leftv a, Subexpr e)
Definition: ipassign.cc:631
#define NONE
Definition: tok.h:220
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
leftv LData()
Definition: subexpr.cc:1387
static BOOLEAN jiA_RESOLUTION(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:825
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static BOOLEAN jiA_MAP_ID(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:900
#define TEST_V_ALLWARN
Definition: options.h:135
void syKillComputation(syStrategy syzstr, ring r=currRing)
Definition: syz1.cc:1497
void * CopyD(int t)
Definition: subexpr.cc:676
static BOOLEAN jiA_IDEAL_M(leftv res, leftv a, Subexpr)
Definition: ipassign.cc:848
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:250
static FORCE_INLINE coeffs n_CoeffRingQuot1(number c, const coeffs r)
Definition: coeffs.h:519
int si_echo
Definition: febase.cc:41
long rank
Definition: matpol.h:20
#define IDMATRIX(a)
Definition: ipid.h:133
static BOOLEAN jiA_DEF(leftv res, leftv, Subexpr)
Definition: ipassign.cc:1052
#define MATELEM(mat, i, j)
Definition: matpol.h:29
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
ssyStrategy * syStrategy
Definition: syz.h:35
utypes data
Definition: idrec.h:40
omBin fractionObjectBin
Definition: transext.cc:93
static void jjMINPOLY_red(idhdl h)
Definition: ipassign.cc:137
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1783
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263