mod_main.cc
Go to the documentation of this file.
1 #include <kernel/mod2.h>
2 
3 #include <omalloc/omalloc.h>
4 
5 #include <misc/intvec.h>
6 #include <misc/options.h>
7 
8 #include <coeffs/coeffs.h>
9 
10 #include <polys/PolyEnumerator.h>
11 
13 #include <polys/monomials/ring.h>
14 #include <polys/simpleideals.h>
15 
16 // #include <kernel/longrat.h>
17 #include <kernel/GBEngine/kstd1.h>
18 
19 #include <kernel/polys.h>
20 
21 #include <kernel/GBEngine/syz.h>
22 
23 #include <Singular/tok.h>
24 #include <Singular/ipid.h>
25 #include <Singular/lists.h>
26 #include <Singular/attrib.h>
27 
28 #include <Singular/ipid.h>
29 #include <Singular/ipshell.h> // For iiAddCproc
30 
31 // extern coeffs coeffs_BIGINT
32 
33 #include "singularxx_defs.h"
34 
35 #include "DebugPrint.h"
36 #include "myNF.h"
37 #include "syzextra.h"
38 
39 
40 #include <Singular/mod_lib.h>
41 
42 
43 #if GOOGLE_PROFILE_ENABLED
44 #include <google/profiler.h>
45 #endif // #if GOOGLE_PROFILE_ENABLED
46 
47 
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <string.h>
51 
52 
53 
54 
55 extern void pISUpdateComponents(ideal F, const intvec *const V, const int MIN, const ring r);
56 // extern ring rCurrRingAssure_SyzComp();
57 extern ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sign);
58 extern int rGetISPos(const int p, const ring r);
59 
60 // USING_NAMESPACE_SINGULARXX;
61 
62 USING_NAMESPACE( SINGULARXXNAME :: DEBUG )
64 USING_NAMESPACE( SINGULARXXNAME :: SYZEXTRA )
65 
66 
68 
69 // returns TRUE, if idRankFreeModule(m) > 0 ???
70 /// test whether this input has vectors among entries or no enties
71 /// result must be FALSE for only 0-entries
72 static BOOLEAN id_IsModule(ideal id, ring r)
73 {
74  id_Test(id, r);
75 
76  if( id->rank != 1 ) return TRUE;
77 
78  if (rRing_has_Comp(r))
79  {
80  const int l = IDELEMS(id);
81 
82  for (int j=0; j<l; j++)
83  if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0)
84  return TRUE;
85 
86  return FALSE; // rank: 1, only zero or no entries? can be an ideal OR module... BUT in the use-case should better be an ideal!
87  }
88 
89  return FALSE;
90 }
91 
92 
93 
94 
95 static inline void NoReturn(leftv& res)
96 {
97  res->rtyp = NONE;
98  res->data = NULL;
99 }
100 
101 /// wrapper around n_ClearContent
103 {
104  NoReturn(res);
105 
106  const char *usage = "'ClearContent' needs a (non-zero!) poly or vector argument...";
107 
108  if( h == NULL )
109  {
110  WarnS(usage);
111  return TRUE;
112  }
113 
114  assume( h != NULL );
115 
116  if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
117  {
118  WarnS(usage);
119  return TRUE;
120  }
121 
122  assume (h->Next() == NULL);
123 
124  poly ph = reinterpret_cast<poly>(h->Data());
125 
126  if( ph == NULL )
127  {
128  WarnS(usage);
129  return TRUE;
130  }
131 
132  const ring r = currRing;
133  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
134 
135  number n;
136 
137  // experimentall (recursive enumerator treatment) of alg. ext
138  CPolyCoeffsEnumerator itr(ph);
139  n_ClearContent(itr, n, C);
140 
141  res->data = n;
142  res->rtyp = NUMBER_CMD;
143 
144  return FALSE;
145 }
146 
147 /// wrapper around n_ClearDenominators
149 {
150  NoReturn(res);
151 
152  const char *usage = "'ClearDenominators' needs a (non-zero!) poly or vector argument...";
153 
154  if( h == NULL )
155  {
156  WarnS(usage);
157  return TRUE;
158  }
159 
160  assume( h != NULL );
161 
162  if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
163  {
164  WarnS(usage);
165  return TRUE;
166  }
167 
168  assume (h->Next() == NULL);
169 
170  poly ph = reinterpret_cast<poly>(h->Data());
171 
172  if( ph == NULL )
173  {
174  WarnS(usage);
175  return TRUE;
176  }
177 
178  const ring r = currRing;
179  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
180 
181  number n;
182 
183  // experimentall (recursive enumerator treatment) of alg. ext.
184  CPolyCoeffsEnumerator itr(ph);
185  n_ClearDenominators(itr, n, C);
186 
187  res->data = n;
188  res->rtyp = NUMBER_CMD;
189 
190  return FALSE;
191 }
192 
193 
194 /// try to get an optional (simple) integer argument out of h
195 /// or return the default value
196 static int getOptionalInteger(const leftv& h, const int _n)
197 {
198  if( h!= NULL && h->Typ() == INT_CMD )
199  {
200  int n = (int)(long)(h->Data());
201 
202  if( n < 0 )
203  Warn("Negative (%d) optional integer argument", n);
204 
205  return (n);
206  }
207 
208  return (_n);
209 }
210 
211 static BOOLEAN noop(leftv __res, leftv /*__v*/)
212 {
213  NoReturn(__res);
214  return FALSE;
215 }
216 
218 {
219  NoReturn(__res);
220 #if GOOGLE_PROFILE_ENABLED
221  if( h!= NULL && h->Typ() == STRING_CMD )
222  {
223  const char* name = (char*)(h->Data());
224  assume( name != NULL );
225  ProfilerStart(name);
226  } else
227  WerrorS("ProfilerStart requires a string [name] argument");
228 #else
229  WarnS("Sorry no google profiler support (GOOGLE_PROFILE_ENABLE!=1)...");
230 // return TRUE; // ?
231 #endif // #if GOOGLE_PROFILE_ENABLED
232  return FALSE;
233  (void)h;
234 }
235 static BOOLEAN _ProfilerStop(leftv __res, leftv /*__v*/)
236 {
237  NoReturn(__res);
238 #if GOOGLE_PROFILE_ENABLED
239  ProfilerStop();
240 #else
241  WarnS("Sorry no google profiler support (GOOGLE_PROFILE_ENABLED!=1)...");
242 // return TRUE; // ?
243 #endif // #if GOOGLE_PROFILE_ENABLED
244  return FALSE;
245 }
246 
247 static inline number jjLONG2N(long d)
248 {
249  return n_Init(d, coeffs_BIGINT);
250 }
251 
252 static inline void view(const intvec* v)
253 {
254 #ifndef SING_NDEBUG
255  v->view();
256 #else
257  // This code duplication is only due to Hannes's #ifndef SING_NDEBUG!
258  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", v->rows(), v->cols(), v->length());
259 
260  for (int i = 0; i < v->rows(); i++)
261  {
262  Print ("Row[%3d]:", i);
263  for (int j = 0; j < v->cols(); j++)
264  Print (" %5d", (*v)[j + i * (v->cols())] );
265  PrintLn ();
266  }
267  PrintS ("}\n");
268 #endif
269 
270 }
271 
272 
273 
275 {
276  NoReturn(__res);
277 
278  if( h == NULL )
279  {
280  WarnS("DetailedPrint needs an argument...");
281  return TRUE;
282  }
283 
284  if( h->Typ() == NUMBER_CMD)
285  {
286  number n = (number)h->Data();
287 
288  const ring r = currRing;
289 
290  n_Test(n, r->cf);
291 
292  StringSetS("");
293  n_Write(n, r->cf);
294  PrintS(StringEndS());
295  PrintLn();
296 
297  return FALSE;
298  }
299 
300  if( h->Typ() == RING_CMD)
301  {
302  const ring r = (const ring)h->Data();
303  rWrite(r, TRUE);
304  PrintLn();
305 #ifdef RDEBUG
306  //rDebugPrint(r);
307 #endif
308  return FALSE;
309  }
310 
311  if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
312  {
313  const poly p = (const poly)h->Data(); h = h->Next();
314 
316 
317  return FALSE;
318  }
319 
320  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
321  {
322  const ideal id = (const ideal)h->Data(); h = h->Next();
323 
325 
326  return FALSE;
327  }
328 
329  if( h->Typ() == RESOLUTION_CMD )
330  {
331  const syStrategy syzstr = reinterpret_cast<const syStrategy>(h->Data());
332 
333  h = h->Next();
334 
335  int nTerms = getOptionalInteger(h, 1);
336 
337 
338  Print("RESOLUTION_CMD(%p): ", reinterpret_cast<const void*>(syzstr)); PrintLn();
339 
340  const ring save = currRing;
341  const ring r = syzstr->syRing;
342 // const ring rr = (r != NULL) ? r: save;
343 
344 
345  const int iLength = syzstr->length;
346 
347  Print("int 'length': %d", iLength); PrintLn();
348  Print("int 'regularity': %d", syzstr->regularity); PrintLn();
349  Print("short 'list_length': %hd", syzstr->list_length); PrintLn();
350  Print("short 'references': %hd", syzstr->references); PrintLn();
351 
352 
353 #define PRINT_pINTVECTOR(s, v) Print("intvec '%10s'(%p)", #v, reinterpret_cast<const void*>((s)->v)); \
354 if( (s)->v != NULL ){ PrintS(": "); view((s)->v); }; \
355 PrintLn();
356 
357  PRINT_pINTVECTOR(syzstr, resolution);
358  PRINT_pINTVECTOR(syzstr, betti);
359  PRINT_pINTVECTOR(syzstr, Tl);
360  PRINT_pINTVECTOR(syzstr, cw);
361 #undef PRINT_pINTVECTOR
362 
363  if (r == NULL)
364  Print("ring '%10s': NULL", "syRing");
365  else
366  if (r == currRing)
367  Print("ring '%10s': currRing", "syRing");
368  else
369  if (r != NULL && r != save)
370  {
371  Print("ring '%10s': ", "syRing");
372  rWrite(r);
373 #ifdef RDEBUG
374  // rDebugPrint(r);
375 #endif
376  // rChangeCurrRing(r);
377  }
378  PrintLn();
379 
380  const SRes rP = syzstr->resPairs;
381  Print("SRes 'resPairs': %p", reinterpret_cast<const void*>(rP)); PrintLn();
382 
383  if (rP != NULL)
384  for (int iLevel = 0; (iLevel < iLength) && (rP[iLevel] != NULL) && ((*syzstr->Tl)[iLevel] >= 0); iLevel++)
385  {
386  int n = 0;
387  const int iTl = (*syzstr->Tl)[iLevel];
388  for (int j = 0; (j < iTl) && ((rP[iLevel][j].lcm!=NULL) || (rP[iLevel][j].syz!=NULL)); j++)
389  {
390  if (rP[iLevel][j].isNotMinimal==NULL)
391  n++;
392  }
393  Print("minimal-resPairs-Size[1+%d]: %d", iLevel, n); PrintLn();
394  }
395 
396 
397  // const ring rrr = (iLevel > 0) ? rr : save; ?
398 #define PRINT_RESOLUTION(s, v) Print("resolution '%12s': %p", #v, reinterpret_cast<const void*>((s)->v)); PrintLn(); \
399 if ((s)->v != NULL) \
400  for (int iLevel = 0; (iLevel < iLength) && ( ((s)->v)[iLevel] != NULL ); iLevel++) \
401  { \
402  /* const ring rrr = (iLevel > 0) ? save : save; */ \
403  Print("id '%10s'[%d]: (%p) ncols = %d / size: %d; nrows = %d, rank = %ld / rk: %ld", #v, iLevel, reinterpret_cast<const void*>(((s)->v)[iLevel]), ((s)->v)[iLevel]->ncols, IDELEMS(((s)->v)[iLevel]), ((s)->v)[iLevel]->nrows, ((s)->v)[iLevel]->rank, -1L/*id_RankFreeModule(((s)->v)[iLevel], rrr)*/ ); \
404  PrintLn(); \
405  } \
406  PrintLn();
407 
408  // resolvente:
409  PRINT_RESOLUTION(syzstr, minres);
410  PRINT_RESOLUTION(syzstr, fullres);
411 
412 // assume (id_RankFreeModule (syzstr->res[1], rr) == syzstr->res[1]->rank);
413 
414  PRINT_RESOLUTION(syzstr, res);
415  PRINT_RESOLUTION(syzstr, orderedRes);
416 #undef PRINT_RESOLUTION
417 
418 #define PRINT_POINTER(s, v) Print("pointer '%17s': %p", #v, reinterpret_cast<const void*>((s)->v)); PrintLn();
419  // 2d arrays:
420  PRINT_POINTER(syzstr, truecomponents);
421  PRINT_POINTER(syzstr, ShiftedComponents);
422  PRINT_POINTER(syzstr, backcomponents);
423  PRINT_POINTER(syzstr, Howmuch);
424  PRINT_POINTER(syzstr, Firstelem);
425  PRINT_POINTER(syzstr, elemLength);
426  PRINT_POINTER(syzstr, sev);
427 
428  // arrays of intvects:
429  PRINT_POINTER(syzstr, weights);
430  PRINT_POINTER(syzstr, hilb_coeffs);
431 #undef PRINT_POINTER
432 
433 
434  if (syzstr->fullres==NULL)
435  {
436  PrintS("resolution 'fullres': (NULL) => resolution not computed yet");
437  PrintLn();
438  } else
439  {
440  Print("resolution 'fullres': (%p) => resolution seems to be computed already", reinterpret_cast<const void*>(syzstr->fullres));
441  PrintLn();
442  dPrint(*syzstr->fullres, save, save, nTerms);
443  }
444 
445 
446 
447 
448  if (syzstr->minres==NULL)
449  {
450  PrintS("resolution 'minres': (NULL) => resolution not minimized yet");
451  PrintLn();
452  } else
453  {
454  Print("resolution 'minres': (%p) => resolution seems to be minimized already", reinterpret_cast<const void*>(syzstr->minres));
455  PrintLn();
456  dPrint(*syzstr->minres, save, save, nTerms);
457  }
458 
459 
460 
461 
462  /*
463  int ** truecomponents;
464  long** ShiftedComponents;
465  int ** backcomponents;
466  int ** Howmuch;
467  int ** Firstelem;
468  int ** elemLength;
469  unsigned long ** sev;
470 
471  intvec ** weights;
472  intvec ** hilb_coeffs;
473 
474  SRes resPairs; //polynomial data for internal use only
475 
476  resolvente fullres;
477  resolvente minres;
478  resolvente res; //polynomial data for internal use only
479  resolvente orderedRes; //polynomial data for internal use only
480 */
481 
482  // if( currRing != save ) rChangeCurrRing(save);
483  }
484 
485 
486  return FALSE;
487 }
488 
489 /// wrapper around p_Tail and id_Tail
491 {
492  NoReturn(res);
493 
494  if( h == NULL )
495  {
496  WarnS("Tail needs a poly/vector/ideal/module argument...");
497  return TRUE;
498  }
499 
500  assume( h != NULL );
501 
502  const ring r = currRing;
503 
504  if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
505  {
506  res->data = p_Tail( (const poly)h->Data(), r );
507  res->rtyp = h->Typ();
508 
509  h = h->Next(); assume (h == NULL);
510 
511  return FALSE;
512  }
513 
514  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
515  {
516  res->data = id_Tail( (const ideal)h->Data(), r );
517  res->rtyp = h->Typ();
518 
519  h = h->Next(); assume (h == NULL);
520 
521  return FALSE;
522  }
523 
524  WarnS("Tail needs a single poly/vector/ideal/module argument...");
525  return TRUE;
526 }
527 
528 
529 
531 {
533 
534  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
535 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
536  const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
537 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
538 // const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
539 
540  const ring r = attributes.m_rBaseRing;
541  NoReturn(res);
542 
543  if( h == NULL )
544  {
545  WarnS("ComputeLeadingSyzygyTerms needs an argument...");
546  return TRUE;
547  }
548 
549  assume( h != NULL );
550 
551  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
552  {
553  const ideal id = (const ideal)h->Data();
554 
555  assume(id != NULL);
556 
557  if( UNLIKELY( OPT__DEBUG ) )
558  {
559  PrintS("ComputeLeadingSyzygyTerms::Input: \n");
560  dPrint(id, r, r, 0);
561  }
562 
563  assume( !OPT__LEAD2SYZ );
564 
565  h = h->Next(); assume (h == NULL);
566 
567  const ideal newid = ComputeLeadingSyzygyTerms(id, attributes);
568 
569  res->data = newid; res->rtyp = MODUL_CMD;
570  return FALSE;
571  }
572 
573  WarnS("ComputeLeadingSyzygyTerms needs a single ideal/module argument...");
574  return TRUE;
575 }
576 
577 /// sorting wrt <c,ds> & reversing...
578 /// change the input inplace!!!
579 // TODO: use a ring with >_{c, ds}!???
581 {
583 
584  const BOOLEAN OPT__DEBUG = FALSE; // attributes.OPT__DEBUG;
585 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
586 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
587 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
588 // const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
589 
590  NoReturn(res);
591 
592  const ring r = attributes.m_rBaseRing;
593  NoReturn(res);
594 
595  if( h == NULL )
596  {
597  WarnS("Sort_c_ds needs an argument...");
598  return TRUE;
599  }
600 
601  assume( h != NULL );
602 
603  if( (h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
604  && (h->rtyp == IDHDL) // must be a variable!
605  && (h->e == NULL) // not a list element
606  )
607  {
608  const ideal id = (const ideal)h->Data();
609 
610  assume(id != NULL);
611 
612  if( UNLIKELY( OPT__DEBUG ) )
613  {
614  PrintS("Sort_c_ds::Input: \n");
615  dPrint(id, r, r, 0);
616  }
617 
618  assume (h->Next() == NULL);
619 
620  id_Test(id, r);
621 
622  Sort_c_ds(id, r); // NOT A COPY! inplace sorting!!!
623 
624 // res->data = id;
625 // res->rtyp = h->Typ();
626 
627  if( UNLIKELY( OPT__DEBUG ) )
628  {
629  PrintS("Sort_c_ds::Output: \n");
630  dPrint(id, r, r, 0);
631  }
632 
633  // NOTE: nothing is to be returned!!!
634  return FALSE;
635  }
636 
637  WarnS("ComputeLeadingSyzygyTerms needs a single ideal/module argument (must be a variable!)...");
638  return TRUE;
639 }
640 
641 
643 {
645 
646  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
647 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
648  const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
649 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
650 // const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
651 
652  const ring r = attributes.m_rBaseRing;
653  NoReturn(res);
654 
655  if( h == NULL )
656  {
657  WarnS("Compute2LeadingSyzygyTerms needs an argument...");
658  return TRUE;
659  }
660 
661  assume( h != NULL );
662 
663  assume( OPT__LEAD2SYZ ); // ???
664 
665  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
666  {
667  const ideal id = (const ideal)h->Data();
668 
669  assume(id != NULL);
670 
671  if( UNLIKELY( OPT__DEBUG ) )
672  {
673  PrintS("Compute2LeadingSyzygyTerms::Input: \n");
674  dPrint(id, r, r, 0);
675  }
676 
677  h = h->Next(); assume (h == NULL);
678 
679  res->data = Compute2LeadingSyzygyTerms(id, attributes);
680  res->rtyp = MODUL_CMD;
681 
682  return FALSE;
683  }
684 
685  WarnS("Compute2LeadingSyzygyTerms needs a single ideal/module argument...");
686  return TRUE;
687 }
688 
689 
690 
691 /// proc SSFindReducer(def product, def syzterm, def L, def T, list #)
693 {
695 
696  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
697 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
698 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
699 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
700  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
701 
702  const char* usage = "`FindReducer(<poly/vector>, <vector/0>, <ideal/module>[,<module>])` expected";
703  const ring r = attributes.m_rBaseRing;
704 
705  NoReturn(res);
706 
707 
708  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD) || (h->Data() == NULL))
709  {
710  WerrorS(usage);
711  return TRUE;
712  }
713 
714  const poly product = (poly) h->Data(); assume (product != NULL);
715 
716 
717  h = h->Next();
718  if ((h==NULL) || !((h->Typ()==VECTOR_CMD) || (h->Data() == NULL)) )
719  {
720  WerrorS(usage);
721  return TRUE;
722  }
723 
724  poly syzterm = NULL;
725 
726  if(h->Typ()==VECTOR_CMD)
727  syzterm = (poly) h->Data();
728 
729 
730 
731  h = h->Next();
732  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
733  {
734  WerrorS(usage);
735  return TRUE;
736  }
737 
738  const ideal L = (ideal) h->Data(); h = h->Next();
739 
740  assume( IDELEMS(L) > 0 );
741 
742  ideal LS = NULL;
743 
744  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
745  {
746  LS = (ideal)h->Data();
747  h = h->Next();
748  }
749 
750 #ifndef SING_NDEBUG
751  if( LIKELY( OPT__TAILREDSYZ) )
752  assume (LS != NULL);
753 #endif
754 
755  assume( h == NULL );
756 
757  if( UNLIKELY(OPT__DEBUG) )
758  {
759  PrintS("FindReducer(product, syzterm, L, T, #)::Input: \n");
760 
761  PrintS("product: "); dPrint(product, r, r, 0);
762  PrintS("syzterm: "); dPrint(syzterm, r, r, 0);
763 // PrintS("L: "); dPrint(L, r, r, 0);
764 // PrintS("T: "); dPrint(T, r, r, 0);
765 
766  if( LS == NULL )
767 // PrintS("LS: NULL\n");
768  ;
769  else
770  {
771 // PrintS("LS: "); dPrint(LS, r, r, 0);
772  }
773  }
774 
775  res->rtyp = VECTOR_CMD;
776  res->data = FindReducer(product, syzterm, L, LS, attributes);
777 
778  if( UNLIKELY( OPT__DEBUG ) )
779  {
780  PrintS("FindReducer::Output: \n");
781  dPrint((poly)res->data, r, r, 0);
782  }
783 
784  return FALSE;
785 
786 }
787 
788 // proc SchreyerSyzygyNF(vector syz_lead, vector syz_2, def L, def T, list #)
790 {
792 
793  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
794 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
795 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
796  const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
797  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
798 
799  const char* usage = "`SchreyerSyzygyNF(<vector>, <vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
800  const ring r = attributes.m_rBaseRing;
801 
802  NoReturn(res);
803 
804  assume( OPT__HYBRIDNF ); // ???
805 
806  if ((h==NULL) || (h->Typ() != VECTOR_CMD) || (h->Data() == NULL))
807  {
808  WerrorS(usage);
809  return TRUE;
810  }
811 
812  const poly syz_lead = (poly) h->Data(); assume (syz_lead != NULL);
813 
814 
815  h = h->Next();
816  if ((h==NULL) || (h->Typ() != VECTOR_CMD) || (h->Data() == NULL))
817  {
818  WerrorS(usage);
819  return TRUE;
820  }
821 
822  const poly syz_2 = (poly) h->Data(); assume (syz_2 != NULL);
823 
824  h = h->Next();
825  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
826  {
827  WerrorS(usage);
828  return TRUE;
829  }
830 
831  const ideal L = (ideal) h->Data(); assume( IDELEMS(L) > 0 );
832 
833 
834  h = h->Next();
835  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
836  {
837  WerrorS(usage);
838  return TRUE;
839  }
840 
841  const ideal T = (ideal) h->Data();
842 
843  assume( IDELEMS(L) == IDELEMS(T) );
844 
845  ideal LS = NULL;
846 
847  h = h->Next();
848  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
849  {
850  LS = (ideal)h->Data();
851  h = h->Next();
852  }
853 
854 #ifndef SING_NDEBUG
855  if( LIKELY( OPT__TAILREDSYZ) )
856  assume (LS != NULL);
857 #endif
858 
859  assume( h == NULL );
860 
861  if( UNLIKELY( OPT__DEBUG ) )
862  {
863  PrintS("SchreyerSyzygyNF(syz_lead, syz_2, L, T, #)::Input: \n");
864 
865  PrintS("syz_lead: "); dPrint(syz_lead, r, r, 0);
866  PrintS("syz_2: "); dPrint(syz_2, r, r, 0);
867 
868 // PrintS("L: "); dPrint(L, r, r, 0);
869 // PrintS("T: "); dPrint(T, r, r, 0);
870 
871  if( LS == NULL )
872 // PrintS("LS: NULL\n")
873  ;
874  else
875  {
876 // PrintS("LS: "); dPrint(LS, r, r, 0);
877  }
878  }
879 
880  res->rtyp = VECTOR_CMD;
881  res->data = SchreyerSyzygyNF(syz_lead,
882  (syz_2!=NULL)? p_Copy(syz_2, r): syz_2, L, T, LS, attributes);
883 
884  if( UNLIKELY( OPT__DEBUG ) )
885  {
886  PrintS("SchreyerSyzygyNF::Output: ");
887 
888  dPrint((poly)res->data, r, r, 0);
889  }
890 
891 
892  return FALSE;
893 }
894 
895 
896 
897 /// proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)
899 {
901 
902  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
903 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
904 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
905 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
906  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
907 
908  const char* usage = "`ReduceTerm(<poly>, <poly/vector>, <vector/0>, <ideal/module>, <ideal/module>[,<module>])` expected";
909  const ring r = attributes.m_rBaseRing;
910 
911  NoReturn(res);
912 
913  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
914  {
915  WerrorS(usage);
916  return TRUE;
917  }
918 
919  const poly multiplier = (poly) h->Data(); assume (multiplier != NULL);
920 
921 
922  h = h->Next();
923  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD) || (h->Data() == NULL))
924  {
925  WerrorS(usage);
926  return TRUE;
927  }
928 
929  const poly term4reduction = (poly) h->Data(); assume( term4reduction != NULL );
930 
931 
932  poly syztermCheck = NULL;
933 
934  h = h->Next();
935  if ((h==NULL) || !((h->Typ()==VECTOR_CMD) || (h->Data() == NULL)) )
936  {
937  WerrorS(usage);
938  return TRUE;
939  }
940 
941  if(h->Typ()==VECTOR_CMD)
942  syztermCheck = (poly) h->Data();
943 
944 
945  h = h->Next();
946  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
947  {
948  WerrorS(usage);
949  return TRUE;
950  }
951 
952  const ideal L = (ideal) h->Data(); assume( IDELEMS(L) > 0 );
953 
954 
955  h = h->Next();
956  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
957  {
958  WerrorS(usage);
959  return TRUE;
960  }
961 
962  const ideal T = (ideal) h->Data();
963 
964  assume( IDELEMS(L) == IDELEMS(T) );
965 
966  ideal LS = NULL;
967 
968  h = h->Next();
969  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
970  {
971  LS = (ideal)h->Data();
972  h = h->Next();
973  }
974 
975 #ifndef SING_NDEBUG
976  if( LIKELY( OPT__TAILREDSYZ) )
977  assume (LS != NULL);
978 #endif
979 
980  assume( h == NULL );
981 
982  if( UNLIKELY( OPT__DEBUG ) )
983  {
984  PrintS("ReduceTerm(m, t, syzterm, L, T, #)::Input: \n");
985 
986  PrintS("m: "); dPrint(multiplier, r, r, 0);
987  PrintS("t: "); dPrint(term4reduction, r, r, 0);
988  PrintS("syzterm: "); dPrint(syztermCheck, r, r, 0);
989 
990 // PrintS("L: "); dPrint(L, r, r, 0);
991 // PrintS("T: "); dPrint(T, r, r, 0);
992 
993  if( LS == NULL )
994 // PrintS("LS: NULL\n")
995  ;
996  else
997  {
998 // PrintS("LS: "); dPrint(LS, r, r, 0);
999  }
1000  }
1001 
1002 
1003  if ( UNLIKELY( OPT__DEBUG && syztermCheck != NULL) )
1004  {
1005  const int c = p_GetComp(syztermCheck, r) - 1;
1006  assume( c >= 0 && c < IDELEMS(L) );
1007 
1008  const poly p = L->m[c];
1009  assume( p != NULL ); assume( pNext(p) == NULL );
1010 
1011  assume( p_EqualPolys(term4reduction, p, r) ); // assume? TODO
1012 
1013 
1014  poly m = leadmonom(syztermCheck, r);
1015  assume( m != NULL ); assume( pNext(m) == NULL );
1016 
1017  assume( p_EqualPolys(multiplier, m, r) ); // assume? TODO
1018 
1019  p_Delete(&m, r);
1020 
1021 // NOTE: leadmonomial(syzterm) == m && L[leadcomp(syzterm)] == t
1022  }
1023 
1024  res->rtyp = VECTOR_CMD;
1025  res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, attributes);
1026 
1027 
1028  if( UNLIKELY( OPT__DEBUG ) )
1029  {
1030  PrintS("ReduceTerm::Output: ");
1031 
1032  dPrint((poly)res->data, r, r, 0);
1033  }
1034 
1035 
1036  return FALSE;
1037 }
1038 
1039 
1040 
1041 
1042 // proc SSTraverseTail(poly m, def @tail, def L, def T, list #)
1044 {
1045  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
1046 
1047  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
1048 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
1049 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
1050 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
1051  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
1052 
1053  const char* usage = "`TraverseTail(<poly>, <poly/vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
1054  const ring r = attributes.m_rBaseRing;
1055 
1056  NoReturn(res);
1057 
1058  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
1059  {
1060  WerrorS(usage);
1061  return TRUE;
1062  }
1063 
1064  const poly multiplier = (poly) h->Data(); assume (multiplier != NULL);
1065 
1066  h = h->Next();
1067  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD))
1068  {
1069  WerrorS(usage);
1070  return TRUE;
1071  }
1072 
1073  const poly tail = (poly) h->Data();
1074 
1075  h = h->Next();
1076 
1077  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
1078  {
1079  WerrorS(usage);
1080  return TRUE;
1081  }
1082 
1083  const ideal L = (ideal) h->Data();
1084 
1085  assume( IDELEMS(L) > 0 );
1086 
1087  h = h->Next();
1088  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
1089  {
1090  WerrorS(usage);
1091  return TRUE;
1092  }
1093 
1094  const ideal T = (ideal) h->Data();
1095 
1096  assume( IDELEMS(L) == IDELEMS(T) );
1097 
1098  h = h->Next();
1099 
1100  ideal LS = NULL;
1101 
1102  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
1103  {
1104  LS = (ideal)h->Data();
1105  h = h->Next();
1106  }
1107 
1108 #ifndef SING_NDEBUG
1109  if( LIKELY( OPT__TAILREDSYZ) )
1110  assume (LS != NULL);
1111 #endif
1112 
1113  assume( h == NULL );
1114 
1115  if( UNLIKELY( OPT__DEBUG ) )
1116  {
1117  PrintS("TraverseTail(m, t, L, T, #)::Input: \n");
1118 
1119  PrintS("m: "); dPrint(multiplier, r, r, 0);
1120  PrintS("t: "); dPrint(tail, r, r, 0);
1121 
1122 // PrintS("L: "); dPrint(L, r, r, 0);
1123 // PrintS("T: "); dPrint(T, r, r, 0);
1124 
1125  if( LS == NULL )
1126 // PrintS("LS: NULL\n")
1127  ;
1128  else
1129  {
1130 // PrintS("LS: "); dPrint(LS, r, r, 0);
1131  }
1132  }
1133 
1134  res->rtyp = VECTOR_CMD;
1135  res->data = TraverseTail(multiplier, tail, L, T, LS, attributes);
1136 
1137 
1138  if( UNLIKELY( OPT__DEBUG ) )
1139  {
1140  PrintS("TraverseTail::Output: ");
1141  dPrint((poly)res->data, r, r, 0);
1142  }
1143 
1144  return FALSE;
1145 }
1146 
1147 
1149 {
1150  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
1151 
1152  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
1153 
1154  const char* usage = "`ComputeResolution(<ideal/module>, <same as before>, <same as before>[,int])` expected";
1155  const ring r = attributes.m_rBaseRing;
1156 
1157  NoReturn(res);
1158 
1159  // input
1160  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
1161  {
1162  WerrorS(usage);
1163  return TRUE;
1164  }
1165 
1166  const int type = h->Typ();
1167  ideal M = (ideal)(h->CopyD()); // copy for resolution...!???
1168  int size = IDELEMS(M);
1169 
1170  assume( size >= 0 );
1171 
1172  h = h->Next();
1173 
1174  // lead
1175  if ((h==NULL) || (h->Typ()!=type) || (h->Data() == NULL))
1176  {
1177  WerrorS(usage);
1178  return TRUE;
1179  }
1180 
1181  ideal L = (ideal)(h->CopyD()); // no copy!
1182  assume( IDELEMS(L) == size );
1183 
1184  h = h->Next();
1185  if ((h==NULL) || (h->Typ()!=type) || (h->Data() == NULL))
1186  {
1187  WerrorS(usage);
1188  return TRUE;
1189  }
1190 
1191  ideal T = (ideal)(h->CopyD()); // no copy!
1192  assume( IDELEMS(T) == size );
1193 
1194  h = h->Next();
1195 
1196  // length..?
1197  long length = 0;
1198 
1199  if ((h!=NULL) && (h->Typ()==INT_CMD))
1200  {
1201  length = (long)(h->Data());
1202  h = h->Next();
1203  }
1204 
1205  assume( h == NULL );
1206 
1207  if( length <= 0 )
1208  length = 1 + rVar(r);
1209 
1210  if( UNLIKELY( OPT__DEBUG ) )
1211  {
1212  PrintS("ComputeResolution(M, length)::Input: \n");
1213  Print( "starting length: %ld\n", length);
1214  PrintS("M: \n"); dPrint(M, r, r, 0);
1215  PrintS("L=LEAD(M): \n"); dPrint(L, r, r, 0);
1216  PrintS("T=TAIL(M): \n"); dPrint(T, r, r, 0);
1217  }
1218 
1219 
1220  syStrategy _res=(syStrategy)omAlloc0(sizeof(ssyStrategy));
1221 
1222 // class ssyStrategy; typedef ssyStrategy * syStrategy;
1223 // typedef ideal * resolvente;
1224 
1225  _res->length = length + 1; // index + 1;
1226  _res->fullres = (resolvente)omAlloc0((_res->length+1)*sizeof(ideal));
1227  int index = 0;
1228  _res->fullres[index++] = M;
1229 
1230 // if (UNLIKELY(attributes.OPT__TREEOUTPUT))
1231 // Print("{ \"RESOLUTION: HYBRIDNF:%d, TAILREDSYZ: %d, LEAD2SYZ: %d, IGNORETAILS: %d\": [\n", attributes.OPT__HYBRIDNF, attributes.OPT__TAILREDSYZ, attributes.OPT__LEAD2SYZ, attributes.OPT__IGNORETAILS);
1232 
1233  while( (!idIs0(L)) && (index < length))
1234  {
1235  attributes.nextSyzygyLayer();
1236  ideal LL, TT;
1237 
1238  ComputeSyzygy(L, T, LL, TT, attributes);
1239 
1240  if( UNLIKELY( OPT__DEBUG ) )
1241  {
1242  Print("ComputeResolution()::Separated Syzygy[%d]: \n", index);
1243 // PrintS("LL: \n"); dPrint(LL, r, r, 0);
1244 // PrintS("TT: \n"); dPrint(TT, r, r, 0);
1245  }
1246  size = IDELEMS(LL);
1247 
1248  assume( size == IDELEMS(TT) );
1249 
1250  id_Delete(&L, r); id_Delete(&T, r);
1251 
1252  L = LL; T = TT;
1253 
1254  // id_Add(T, L, r);
1255  M = idInit(size, 0);
1256  for( int i = size-1; i >= 0; i-- )
1257  {
1258  M->m[i] = p_Add_q(p_Copy(T->m[i], r), p_Copy(L->m[i], r), r); // TODO: :(((
1259  }
1260  M->rank = id_RankFreeModule(M, r);
1261 
1262  if( UNLIKELY( OPT__DEBUG ) )
1263  {
1264  Print("ComputeResolution()::Restored Syzygy[%d]: \n", index);
1265  PrintS("M = LL + TT: \n"); dPrint(M, r, r, 0);
1266  }
1267 
1268  _res->fullres[index++] = M; // ???
1269  }
1270 // if ( UNLIKELY(attributes.OPT__TREEOUTPUT) )
1271 // PrintS("] }\n");
1272 
1273  id_Delete(&L, r); id_Delete(&T, r);
1274 
1275  res->data = _res;
1276  res->rtyp = RESOLUTION_CMD;
1277 
1278  if( UNLIKELY(OPT__DEBUG) )
1279  {
1280  Print("ComputeResolution::Output (index: %d): ", index);
1281 // class sleftv; typedef sleftv * leftv;
1282  sleftv _h;
1283  DetailedPrint(&_h, res);
1284  }
1285 
1286 // omFreeSize(_res, sizeof(ssyStrategy));
1287 
1288  return FALSE;
1289 
1290 }
1291 
1292 
1293 /// module (LL, TT) = SSComputeSyzygy(L, T);
1294 /// Compute Syz(L ++ T) = N = LL ++ TT
1295 // proc SSComputeSyzygy(def L, def T)
1297 {
1298  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
1299 
1300  const BOOLEAN OPT__DEBUG = attributes.OPT__DEBUG;
1301 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
1302 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
1303 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
1304 // const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
1305 
1306  const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>)` expected";
1307  const ring r = attributes.m_rBaseRing;
1308 
1309  NoReturn(res);
1310 
1311  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
1312  {
1313  WerrorS(usage);
1314  return TRUE;
1315  }
1316 
1317  const ideal L = (ideal) h->Data();
1318 
1319  assume( IDELEMS(L) > 0 );
1320 
1321  h = h->Next();
1322  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
1323  {
1324  WerrorS(usage);
1325  return TRUE;
1326  }
1327 
1328  const ideal T = (ideal) h->Data();
1329  assume( IDELEMS(L) == IDELEMS(T) );
1330 
1331 
1332  h = h->Next(); assume( h == NULL );
1333 
1334  if( UNLIKELY( OPT__DEBUG ) )
1335  {
1336  PrintS("ComputeSyzygy(L, T)::Input: \n");
1337 // PrintS("L: "); dPrint(L, r, r, 0);
1338 // PrintS("T: "); dPrint(T, r, r, 0);
1339  }
1340 
1341  ideal LL, TT;
1342 
1343  ComputeSyzygy(L, T, LL, TT, attributes);
1344 
1345  lists l = (lists)omAllocBin(slists_bin); l->Init(2);
1346 
1347  l->m[0].rtyp = MODUL_CMD; l->m[0].data = reinterpret_cast<void *>(LL);
1348 
1349  l->m[1].rtyp = MODUL_CMD; l->m[1].data = reinterpret_cast<void *>(TT);
1350 
1351  res->data = l; res->rtyp = LIST_CMD;
1352 
1353  if( UNLIKELY( OPT__DEBUG ) )
1354  {
1355  PrintS("ComputeSyzygy::Output: \nLL: \n");
1356  dPrint(LL, r, r, 0);
1357  PrintS("\nTT: \n");
1358  dPrint(TT, r, r, 0);
1359  }
1360 
1361  return FALSE;
1362 
1363 }
1364 
1365 /// Get leading term without a module component
1367 {
1368  NoReturn(res);
1369 
1370  if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD) && (h->Data() != NULL))
1371  {
1372  const ring r = currRing;
1373  const poly p = (poly)(h->Data());
1374 
1375  res->data = reinterpret_cast<void *>( leadmonom(p, r) );
1376  res->rtyp = POLY_CMD;
1377 
1378  return FALSE;
1379  }
1380 
1381  WerrorS("`leadmonom(<poly/vector>)` expected");
1382  return TRUE;
1383 }
1384 
1385 /// Get leading component
1387 {
1388  NoReturn(res);
1389 
1390  if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD))
1391  {
1392  const ring r = currRing;
1393 
1394  const poly p = (poly)(h->Data());
1395 
1396  if (p != NULL )
1397  {
1398  assume( p != NULL );
1399  p_LmTest(p, r);
1400 
1401  const unsigned long iComp = p_GetComp(p, r);
1402 
1403  // assume( iComp > 0 ); // p is a vector
1404 
1405  res->data = reinterpret_cast<void *>(jjLONG2N(iComp));
1406  } else
1407  res->data = reinterpret_cast<void *>(jjLONG2N(0));
1408 
1409 
1410  res->rtyp = BIGINT_CMD;
1411  return FALSE;
1412  }
1413 
1414  WerrorS("`leadcomp(<poly/vector>)` expected");
1415  return TRUE;
1416 }
1417 
1418 
1419 
1420 
1421 /// Get raw leading exponent vector
1423 {
1424  NoReturn(res);
1425 
1426  if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD) && (h->Data() != NULL))
1427  {
1428  const ring r = currRing;
1429  const poly p = (poly)(h->Data());
1430 
1431  assume( p != NULL );
1432  p_LmTest(p, r);
1433 
1434  const int iExpSize = r->ExpL_Size;
1435 
1436 // intvec *iv = new intvec(iExpSize);
1437 
1439  l->Init(iExpSize);
1440 
1441  for(int i = iExpSize-1; i >= 0; i--)
1442  {
1443  l->m[i].rtyp = BIGINT_CMD;
1444  l->m[i].data = reinterpret_cast<void *>(jjLONG2N(p->exp[i])); // longs...
1445  }
1446 
1447  res->rtyp = LIST_CMD; // list of bigints
1448  res->data = reinterpret_cast<void *>(l);
1449  return FALSE;
1450  }
1451 
1452  WerrorS("`leadrawexp(<poly/vector>)` expected");
1453  return TRUE;
1454 }
1455 
1456 
1457 /// Endowe the current ring with additional (leading) Syz-component ordering
1459 {
1460 
1461  NoReturn(res);
1462 
1463  // res->data = rCurrRingAssure_SyzComp(); // changes current ring! :(
1464  res->data = reinterpret_cast<void *>(rAssure_SyzComp(currRing, TRUE));
1465  res->rtyp = RING_CMD; // return new ring!
1466  // QRING_CMD?
1467 
1468  return FALSE;
1469 }
1470 
1471 
1472 /// Same for Induced Schreyer ordering (ordering on components is defined by sign!)
1474 {
1475 
1476  NoReturn(res);
1477 
1478  int sign = 1;
1479  if ((h!=NULL) && (h->Typ()==INT_CMD))
1480  {
1481  const int s = (int)((long)(h->Data()));
1482 
1483  if( s != -1 && s != 1 )
1484  {
1485  WerrorS("`MakeInducedSchreyerOrdering(<int>)` called with wrong integer argument (must be +-1)!");
1486  return TRUE;
1487  }
1488 
1489  sign = s;
1490  }
1491 
1492  assume( sign == 1 || sign == -1 );
1493  res->data = reinterpret_cast<void *>(rAssure_InducedSchreyerOrdering(currRing, TRUE, sign));
1494  res->rtyp = RING_CMD; // return new ring!
1495  // QRING_CMD?
1496  return FALSE;
1497 }
1498 
1499 
1500 /// Returns old SyzCompLimit, can set new limit
1502 {
1503  NoReturn(res);
1504 
1505  const ring r = currRing;
1506 
1507  if( !rIsSyzIndexRing(r) )
1508  {
1509  WerrorS("`SetSyzComp(<int>)` called on incompatible ring (not created by 'MakeSyzCompOrdering'!)");
1510  return TRUE;
1511  }
1512 
1513  res->rtyp = INT_CMD;
1514  res->data = reinterpret_cast<void *>(rGetCurrSyzLimit(r)); // return old syz limit
1515 
1516  if ((h!=NULL) && (h->Typ()==INT_CMD))
1517  {
1518  const int iSyzComp = (int)reinterpret_cast<long>(h->Data());
1519  assume( iSyzComp > 0 );
1520  rSetSyzComp(iSyzComp, currRing);
1521  }
1522 
1523  return FALSE;
1524 }
1525 
1526 /// ?
1528 {
1529  NoReturn(res);
1530 
1531  const ring r = currRing;
1532 
1533  int p = 0; // which IS-block? p^th!
1534 
1535  if ((h!=NULL) && (h->Typ()==INT_CMD))
1536  {
1537  p = (int)((long)(h->Data())); h=h->next;
1538  assume(p >= 0);
1539  }
1540 
1541  const int pos = rGetISPos(p, r);
1542 
1543  if( /*(*/ -1 == pos /*)*/ )
1544  {
1545  WerrorS("`GetInducedData([int])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
1546  return TRUE;
1547  }
1548 
1549 
1550  const int iLimit = r->typ[pos].data.is.limit;
1551  const ideal F = r->typ[pos].data.is.F;
1552 
1553  ideal FF = id_Copy(F, r);
1554 
1556  l->Init(2);
1557 
1558  l->m[0].rtyp = INT_CMD;
1559  l->m[0].data = reinterpret_cast<void *>(iLimit);
1560 
1561 
1562  // l->m[1].rtyp = MODUL_CMD;
1563 
1564  if( id_IsModule(FF, r) ) // ???
1565  {
1566  l->m[1].rtyp = MODUL_CMD;
1567 
1568  // Print("before: %d\n", FF->nrows);
1569  // FF->nrows = id_RankFreeModule(FF, r); // ???
1570  // Print("after: %d\n", FF->nrows);
1571  }
1572  else
1573  l->m[1].rtyp = IDEAL_CMD;
1574 
1575  l->m[1].data = reinterpret_cast<void *>(FF);
1576 
1577  res->rtyp = LIST_CMD; // list of int/module
1578  res->data = reinterpret_cast<void *>(l);
1579 
1580  return FALSE;
1581 
1582 }
1583 
1584 
1585 /* // the following turned out to be unnecessary...
1586 /// Finds p^th AM ordering, and returns its position in r->typ[] AND
1587 /// corresponding &r->wvhdl[]
1588 /// returns FALSE if something went wrong!
1589 /// p - starts with 0!
1590 BOOLEAN rGetAMPos(const ring r, const int p, int &typ_pos, int &wvhdl_pos, const BOOLEAN bSearchWvhdl = FALSE)
1591 {
1592 #if MYTEST
1593  Print("rGetAMPos(p: %d...)\nF:", p);
1594  PrintLn();
1595 #endif
1596  typ_pos = -1;
1597  wvhdl_pos = -1;
1598 
1599  if (r->typ==NULL)
1600  return FALSE;
1601 
1602 
1603  int j = p; // Which IS record to use...
1604  for( int pos = 0; pos < r->OrdSize; pos++ )
1605  if( r->typ[pos].ord_typ == ro_am)
1606  if( j-- == 0 )
1607  {
1608  typ_pos = pos;
1609 
1610  if( bSearchWvhdl )
1611  {
1612  const int nblocks = rBlocks(r) - 1;
1613  const int* w = r->typ[pos].data.am.weights; // ?
1614 
1615  for( pos = 0; pos <= nblocks; pos ++ )
1616  if (r->order[pos] == ringorder_am)
1617  if( r->wvhdl[pos] == w )
1618  {
1619  wvhdl_pos = pos;
1620  break;
1621  }
1622  if (wvhdl_pos < 0)
1623  return FALSE;
1624 
1625  assume(wvhdl_pos >= 0);
1626  }
1627  assume(typ_pos >= 0);
1628  return TRUE;
1629  }
1630 
1631  return FALSE;
1632 }
1633 
1634 // // ?
1635 // static BOOLEAN GetAMData(leftv res, leftv h)
1636 // {
1637 // NoReturn(res);
1638 //
1639 // const ring r = currRing;
1640 //
1641 // int p = 0; // which IS-block? p^th!
1642 //
1643 // if ((h!=NULL) && (h->Typ()==INT_CMD))
1644 // p = (int)((long)(h->Data())); h=h->next;
1645 //
1646 // assume(p >= 0);
1647 //
1648 // int d, w;
1649 //
1650 // if( !rGetAMPos(r, p, d, w, TRUE) )
1651 // {
1652 // Werror("`GetAMData([int])`: no %d^th _am block-ordering!", p);
1653 // return TRUE;
1654 // }
1655 //
1656 // assume( r->typ[d].ord_typ == ro_am );
1657 // assume( r->order[w] == ringorder_am );
1658 //
1659 //
1660 // const short start = r->typ[d].data.am.start; // bounds of ordering (in E)
1661 // const short end = r->typ[d].data.am.end;
1662 // const short len_gen = r->typ[d].data.am.len_gen; // i>len_gen: weight(gen(i)):=0
1663 // const int *weights = r->typ[d].data.am.weights; // pointers into wvhdl field of length (end-start+1) + len_gen
1664 // // contents w_1,... w_n, len, mod_w_1, .. mod_w_len, 0
1665 //
1666 // assume( weights == r->wvhdl[w] );
1667 //
1668 //
1669 // lists l=(lists)omAllocBin(slists_bin);
1670 // l->Init(2);
1671 //
1672 // const short V = end-start+1;
1673 // intvec* ww_vars = new intvec(V);
1674 // intvec* ww_gens = new intvec(len_gen);
1675 //
1676 // for (int i = 0; i < V; i++ )
1677 // (*ww_vars)[i] = weights[i];
1678 //
1679 // assume( weights[V] == len_gen );
1680 //
1681 // for (int i = 0; i < len_gen; i++ )
1682 // (*ww_gens)[i] = weights[i - V - 1];
1683 //
1684 //
1685 // l->m[0].rtyp = INTVEC_CMD;
1686 // l->m[0].data = reinterpret_cast<void *>(ww_vars);
1687 //
1688 // l->m[1].rtyp = INTVEC_CMD;
1689 // l->m[1].data = reinterpret_cast<void *>(ww_gens);
1690 //
1691 //
1692 // return FALSE;
1693 //
1694 // }
1695 */
1696 
1697 /// Returns old SyzCompLimit, can set new limit
1699 {
1700  NoReturn(res);
1701 
1702  const ring r = currRing;
1703 
1704  if( !( (h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD))) )
1705  {
1706  WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` expected");
1707  return TRUE;
1708  }
1709 
1710  const ideal F = (ideal)h->Data(); ; // No copy!
1711  h=h->next;
1712 
1713  int rank = 0;
1714 
1715  if ((h!=NULL) && (h->Typ()==INT_CMD))
1716  {
1717  rank = (int)((long)(h->Data())); h=h->next;
1718  assume(rank >= 0);
1719  } else
1720  rank = id_RankFreeModule(F, r); // Starting syz-comp (1st: i+1)
1721 
1722  int p = 0; // which IS-block? p^th!
1723 
1724  if ((h!=NULL) && (h->Typ()==INT_CMD))
1725  {
1726  p = (int)((long)(h->Data())); h=h->next;
1727  assume(p >= 0);
1728  }
1729 
1730  const int posIS = rGetISPos(p, r);
1731 
1732  if( /*(*/ -1 == posIS /*)*/ )
1733  {
1734  WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
1735  return TRUE;
1736  }
1737 
1738 
1739 
1740  // F & componentWeights belong to that ordering block of currRing now:
1741  rSetISReference(r, F, rank, p); // F will be copied!
1742  return FALSE;
1743 }
1744 
1745 
1746 // F = ISUpdateComponents( F, V, MIN );
1747 // // replace gen(i) -> gen(MIN + V[i-MIN]) for all i > MIN in all terms from F!
1749 {
1750  NoReturn(res);
1751 
1752  PrintS("ISUpdateComponents:.... \n");
1753 
1754  if ((h!=NULL) && (h->Typ()==MODUL_CMD))
1755  {
1756  ideal F = (ideal)h->Data(); ; // No copy!
1757  h=h->next;
1758 
1759  if ((h!=NULL) && (h->Typ()==INTVEC_CMD))
1760  {
1761  const intvec* const V = (const intvec* const) h->Data();
1762  h=h->next;
1763 
1764  if ((h!=NULL) && (h->Typ()==INT_CMD))
1765  {
1766  const int MIN = (int)((long)(h->Data()));
1767 
1768  pISUpdateComponents(F, V, MIN, currRing);
1769  return FALSE;
1770  }
1771  }
1772  }
1773 
1774  WerrorS("`ISUpdateComponents(<module>, intvec, int)` expected");
1775  return TRUE;
1776 }
1777 
1778 
1779 /// NF using length
1781 {
1782  // const ring r = currRing;
1783 
1784  if ( !( (h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD) ) )
1785  {
1786  WerrorS("`reduce_syz(<poly/vector>!, <ideal/module>, <int>, [int])` expected");
1787  return TRUE;
1788  }
1789 
1790  res->rtyp = h->Typ();
1791  const poly v = reinterpret_cast<poly>(h->Data());
1792  h=h->next;
1793 
1794  if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD || h->Typ()==IDEAL_CMD ) ) )
1795  {
1796  WerrorS("`reduce_syz(<poly/vector>, <ideal/module>!, <int>, [int])` expected");
1797  return TRUE;
1798  }
1799 
1800  assumeStdFlag(h);
1801  const ideal M = reinterpret_cast<ideal>(h->Data()); h=h->next;
1802 
1803 
1804  if ( !( (h!=NULL) && (h->Typ()== INT_CMD) ) )
1805  {
1806  WerrorS("`reduce_syz(<poly/vector>, <ideal/module>, <int>!, [int])` expected");
1807  return TRUE;
1808  }
1809 
1810  const int iSyzComp = (int)((long)(h->Data())); h=h->next;
1811 
1812  int iLazyReduce = 0;
1813 
1814  if ( ( (h!=NULL) && (h->Typ()== INT_CMD) ) )
1815  iLazyReduce = (int)((long)(h->Data()));
1816 
1817  res->data = (void *)kNFLength(M, currRing->qideal, v, iSyzComp, iLazyReduce); // NOTE: currRing :(
1818  return FALSE;
1819 }
1820 
1821 
1822 /// Get raw syzygies (idPrepare)
1824 {
1825  // extern int rGetISPos(const int p, const ring r);
1826 
1827  const ring r = currRing;
1828 
1829  const bool isSyz = rIsSyzIndexRing(r);
1830  const int posIS = rGetISPos(0, r);
1831 
1832 
1833  if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD) && (h->Data() != NULL) ) )
1834  {
1835  WerrorS("`idPrepare(<module>)` expected");
1836  return TRUE;
1837  }
1838 
1839  const ideal I = reinterpret_cast<ideal>(h->Data());
1840 
1841  assume( I != NULL );
1842  idTest(I);
1843 
1844  int iComp = -1;
1845 
1846  h=h->next;
1847  if ( (h!=NULL) && (h->Typ()==INT_CMD) )
1848  {
1849  iComp = (int)((long)(h->Data()));
1850  }
1851  else
1852  {
1853  if( (!isSyz) && (-1 == posIS) )
1854  {
1855  WerrorS("`idPrepare(<...>)` called on incompatible ring (not created by 'MakeSyzCompOrdering' or 'MakeInducedSchreyerOrdering'!)");
1856  return TRUE;
1857  }
1858 
1859  if( isSyz )
1860  iComp = rGetCurrSyzLimit(r);
1861  else
1862  iComp = id_RankFreeModule(r->typ[posIS].data.is.F, r); // ;
1863  }
1864 
1865  assume(iComp >= 0);
1866 
1867 
1868  intvec* w = reinterpret_cast<intvec *>(atGet(h, "isHomog", INTVEC_CMD));
1869  tHomog hom = testHomog;
1870 
1871  // int add_row_shift = 0;
1872  //
1873  if (w!=NULL)
1874  {
1875  w = ivCopy(w);
1876  // add_row_shift = ww->min_in();
1877  //
1878  // (*ww) -= add_row_shift;
1879  //
1880  // if (idTestHomModule(I, currRing->qideal, ww))
1881  // {
1882  hom = isHomog;
1883  // w = ww;
1884  // }
1885  // else
1886  // {
1887  // //WarnS("wrong weights");
1888  // delete ww;
1889  // w = NULL;
1890  // hom=testHomog;
1891  // }
1892  }
1893 
1894 
1895  // computes syzygies of h1,
1896  // works always in a ring with ringorder_s
1897  // NOTE: rSetSyzComp(syzcomp) should better be called beforehand
1898  // ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w);
1899 
1900  ideal J = // idPrepare( I, hom, iComp, &w);
1901  kStd(I, currRing->qideal, hom, &w, NULL, iComp);
1902 
1903  idTest(J);
1904 
1905  if (w!=NULL)
1906  atSet(res, omStrDup("isHomog"), w, INTVEC_CMD);
1907  // if (w!=NULL) delete w;
1908 
1909  res->rtyp = MODUL_CMD;
1910  res->data = reinterpret_cast<void *>(J);
1911  return FALSE;
1912 }
1913 
1914 /// Get raw syzygies (idPrepare)
1916 {
1917  if ( !( (h!=NULL) && (h->Typ()==POLY_CMD) && (h->Data() != NULL) ) )
1918  {
1919  WerrorS("`p_Content(<poly-var>)` expected");
1920  return TRUE;
1921  }
1922 
1923 
1924  const poly p = reinterpret_cast<poly>(h->Data());
1925 
1926 
1927  pTest(p); pWrite(p); PrintLn();
1928 
1929 
1930  p_Content( p, currRing);
1931 
1932  pTest(p);
1933  pWrite(p); PrintLn();
1934 
1935  NoReturn(res);
1936  return FALSE;
1937 }
1938 
1940 {
1941  int ret = 0;
1942 
1943  if ( (h!=NULL) && (h->Typ()!=INT_CMD) )
1944  {
1945  WerrorS("`m2_end([<int>])` expected");
1946  return TRUE;
1947  }
1948  ret = (int)(long)(h->Data());
1949 
1950  m2_end( ret );
1951 
1952  NoReturn(res);
1953  return FALSE;
1954 }
1955 
1956 // no args.
1957 // init num stats
1959 {
1960  if ( (h!=NULL) && (h->Typ()!=INT_CMD) )
1961  {
1962  WerrorS("`NumberStatsInit([<int>])` expected");
1963  return TRUE;
1964  }
1965 
1966  unsigned long v = 0;
1967 
1968  if( h != NULL )
1969  v = (unsigned long)(h->Data());
1970 
1971  number_stats_Init(v);
1972 
1973  NoReturn(res);
1974  return FALSE;
1975 }
1976 
1977 // maybe one arg.
1978 // print num stats
1980 {
1981  if ( (h!=NULL) && (h->Typ()!=STRING_CMD) )
1982  {
1983  WerrorS("`NumberStatsPrint([<string>])` expected");
1984  return TRUE;
1985  }
1986 
1987  const char* msg = NULL;
1988 
1989  if( h != NULL )
1990  msg = (const char*)(h->Data());
1991 
1992  number_stats_Print(msg);
1993 
1994  NoReturn(res);
1995  return FALSE;
1996 }
1997 
1999 
2000 extern "C" int SI_MOD_INIT(syzextra)(SModulFunctions* psModulFunctions)
2001 {
2002 
2003 #define ADD(C,D,E) \
2004  psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
2005 
2006 
2007 // #define ADD(A,B,C,D,E) ADD0(iiAddCproc, "", C, D, E)
2008 
2009 //#define ADD0(A,B,C,D,E) A(B, (char*)C, D, E)
2010 // #define ADD(A,B,C,D,E) ADD0(A->iiAddCproc, B, C, D, E)
2011  ADD("ClearContent", FALSE, _ClearContent);
2012  ADD("ClearDenominators", FALSE, _ClearDenominators);
2013 
2014  ADD("m2_end", FALSE, _m2_end);
2015 
2016  ADD("DetailedPrint", FALSE, DetailedPrint);
2017  ADD("leadmonomial", FALSE, _leadmonom);
2018  ADD("leadcomp", FALSE, leadcomp);
2019  ADD("leadrawexp", FALSE, leadrawexp);
2020 
2021  ADD("ISUpdateComponents", FALSE, ISUpdateComponents);
2022  ADD("SetInducedReferrence", FALSE, SetInducedReferrence);
2023  ADD("GetInducedData", FALSE, GetInducedData);
2024  ADD("SetSyzComp", FALSE, SetSyzComp);
2025  ADD("MakeInducedSchreyerOrdering", FALSE, MakeInducedSchreyerOrdering);
2026  ADD("MakeSyzCompOrdering", FALSE, MakeSyzCompOrdering);
2027 
2028  ADD("ProfilerStart", FALSE, _ProfilerStart);
2029  ADD("ProfilerStop", FALSE, _ProfilerStop );
2030 
2031  ADD("noop", FALSE, noop);
2032  ADD("idPrepare", FALSE, idPrepare);
2033  ADD("reduce_syz", FALSE, reduce_syz);
2034 
2035  ADD("p_Content", FALSE, _p_Content);
2036 
2037  ADD("Tail", FALSE, Tail);
2038 
2039  ADD("ComputeLeadingSyzygyTerms", FALSE, _ComputeLeadingSyzygyTerms);
2040  ADD("Compute2LeadingSyzygyTerms", FALSE, _Compute2LeadingSyzygyTerms);
2041 
2042  ADD("Sort_c_ds", FALSE, _Sort_c_ds);
2043  ADD("FindReducer", FALSE, _FindReducer);
2044 
2045 
2046  ADD("ReduceTerm", FALSE, _ReduceTerm);
2047  ADD("TraverseTail", FALSE, _TraverseTail);
2048 
2049 
2050  ADD("SchreyerSyzygyNF", FALSE, _SchreyerSyzygyNF);
2051  ADD("ComputeSyzygy", FALSE, _ComputeSyzygy);
2052 
2053  ADD("ComputeResolution", FALSE, _ComputeResolution);
2054 // ADD("GetAMData", FALSE, GetAMData);
2055 
2056  ADD("NumberStatsInit", FALSE, _NumberStatsInit);
2057  ADD("NumberStatsPrint", FALSE, _NumberStatsPrint);
2058 
2059  // ADD("", FALSE, );
2060 
2061 #undef ADD
2062  return MAX_TOK;
2063 }
int length
Definition: syz.h:60
Computation attribute storage.
Definition: syzextra.h:189
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static ideal Compute2LeadingSyzygyTerms(const ideal &L, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:592
USING_NAMESPACE(SINGULARXXNAME ::DEBUG) USING_NAMESPACE(SINGULARXXNAME
Definition: mod_main.cc:62
#define PRINT_pINTVECTOR(s, v)
const CanonicalForm int s
Definition: facAbsFact.cc:55
sleftv * m
Definition: lists.h:45
static void view(const intvec *v)
Definition: mod_main.cc:252
static poly TraverseTail(poly multiplier, poly tail, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:608
void Sort_c_ds(const ideal id, const ring r)
inplace sorting of the module (ideal) id wrt <_(c,ds)
Definition: syzextra.cc:527
void atSet(idhdl root, const char *name, void *data, int typ)
Definition: attrib.cc:156
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
static BOOLEAN idPrepare(leftv res, leftv h)
Get raw syzygies (idPrepare)
Definition: mod_main.cc:1823
static number jjLONG2N(long d)
Definition: mod_main.cc:247
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:711
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
Definition: tok.h:95
static void number_stats_Print(const char *const msg=NULL)
print out all counters
Definition: numstats.h:136
static void ComputeSyzygy(const ideal L, const ideal T, ideal &LL, ideal &TT, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:576
static void NoReturn(leftv &res)
Definition: mod_main.cc:95
Subexpr e
Definition: subexpr.h:106
Definition: lists.h:22
poly leadmonom(const poly p, const ring r, const bool bSetZeroComp)
return a new term: leading coeff * leading monomial of p with 0 leading component! ...
Definition: syzextra.cc:473
const int OPT__HYBRIDNF
Use the usual NF&#39;s S-poly reduction while dropping lower order terms 2 means - smart selection! ...
Definition: syzextra.h:214
#define SINGULARXXNAME
static BOOLEAN noop(leftv __res, leftv)
Definition: mod_main.cc:211
#define FALSE
Definition: auxiliary.h:95
Compatiblity layer for legacy polynomial operations (over currRing)
void view() const
Definition: intvec.cc:135
Definition: tok.h:38
return P p
Definition: myNF.cc:203
ideal id_Copy(ideal h1, const ring r)
copy an ideal
short references
Definition: syz.h:63
#define id_Test(A, lR)
Definition: simpleideals.h:80
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:708
Detailed print for debugging.
#define p_GetComp(p, r)
Definition: monomials.h:72
#define pTest(p)
Definition: polys.h:399
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:711
Definition: tok.h:215
static BOOLEAN _ClearContent(leftv res, leftv h)
wrapper around n_ClearContent
Definition: mod_main.cc:102
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:542
int rows() const
Definition: intvec.h:88
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static BOOLEAN Tail(leftv res, leftv h)
wrapper around p_Tail and id_Tail
Definition: mod_main.cc:490
intvec * ivCopy(const intvec *o)
Definition: intvec.h:126
void m2_end(int i)
Definition: misc_ip.cc:1072
static BOOLEAN SetSyzComp(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition: mod_main.cc:1501
static BOOLEAN MakeSyzCompOrdering(leftv res, leftv)
Endowe the current ring with additional (leading) Syz-component ordering.
Definition: mod_main.cc:1458
#define TRUE
Definition: auxiliary.h:99
static poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:623
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2231
static int getOptionalInteger(const leftv &h, const int _n)
try to get an optional (simple) integer argument out of h or return the default value ...
Definition: mod_main.cc:196
END_NAMESPACE int SI_MOD_INIT() syzextra(SModulFunctions *psModulFunctions)
Definition: mod_main.cc:2000
#define MIN(a, b)
Definition: omDebug.c:102
static BOOLEAN DetailedPrint(leftv __res, leftv h)
Definition: mod_main.cc:274
void pWrite(poly p)
Definition: polys.h:291
static BOOLEAN leadrawexp(leftv res, leftv h)
Get raw leading exponent vector.
Definition: mod_main.cc:1422
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define UNLIKELY(expression)
Definition: tgb_internal.h:838
char * StringEndS()
Definition: reporter.cc:151
#define LIKELY(expression)
Definition: tgb_internal.h:837
static BOOLEAN _ComputeResolution(leftv res, leftv h)
Definition: mod_main.cc:1148
NF which uses pLength instead of pSize!
poly p_Tail(const poly p, const ring r)
return the tail of a given polynomial or vector returns NULL if input is NULL, otherwise the result i...
Definition: syzextra.cc:501
const int OPT__DEBUG
output all the intermediate states
Definition: syzextra.h:204
#define WarnS
Definition: emacs.cc:81
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:1004
static BOOLEAN GetInducedData(leftv res, leftv h)
?
Definition: mod_main.cc:1527
static BOOLEAN _ProfilerStop(leftv __res, leftv)
Definition: mod_main.cc:235
static BOOLEAN leadcomp(leftv res, leftv h)
Get leading component.
Definition: mod_main.cc:1386
ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sign)
Definition: ring.cc:4732
#define IDHDL
Definition: tok.h:31
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
Computation of Syzygies.
const int OPT__TAILREDSYZ
Reduce syzygy tails wrt the leading syzygy terms.
Definition: syzextra.h:210
void pISUpdateComponents(ideal F, const intvec *const V, const int MIN, const ring r)
Definition: ring.cc:4240
void * data
Definition: subexpr.h:89
int regularity
Definition: syz.h:61
intvec * Tl
Definition: syz.h:50
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define ADD(C, D, E)
static BOOLEAN _SchreyerSyzygyNF(leftv res, leftv h)
Definition: mod_main.cc:789
#define PRINT_RESOLUTION(s, v)
static BOOLEAN _p_Content(leftv res, leftv h)
Get raw syzygies (idPrepare)
Definition: mod_main.cc:1915
static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Computes the content and (inplace) divides it out on a collection of numbers number c is the content ...
Definition: coeffs.h:942
static poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:615
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
Definition: intvec.h:14
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Concrete implementation of enumerators over polynomials.
static BOOLEAN _TraverseTail(leftv res, leftv h)
Definition: mod_main.cc:1043
leftv Next()
Definition: subexpr.h:137
tHomog
Definition: structs.h:37
int j
Definition: myNF.cc:70
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
#define assume(x)
Definition: mod2.h:403
The main handler for Singular numbers which are suitable for Singular polynomials.
static BOOLEAN SetInducedReferrence(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition: mod_main.cc:1698
void StringSetS(const char *st)
Definition: reporter.cc:128
static BOOLEAN MakeInducedSchreyerOrdering(leftv res, leftv h)
Same for Induced Schreyer ordering (ordering on components is defined by sign!)
Definition: mod_main.cc:1473
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4349
#define BEGIN_NAMESPACE_NONAME
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
BEGIN_NAMESPACE_SINGULARXX const ring const ring const int nTerms
Definition: DebugPrint.h:30
static BOOLEAN _ProfilerStart(leftv __res, leftv h)
Definition: mod_main.cc:217
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:742
idhdl currRingHdl
Definition: ipid.cc:65
static BOOLEAN _NumberStatsInit(leftv res, leftv h)
Definition: mod_main.cc:1958
int m
Definition: cfEzgcd.cc:119
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1483
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
char name(const Variable &v)
Definition: factory.h:178
static poly FindReducer(poly product, poly syzterm, ideal L, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:601
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:236
void p_Content(poly ph, const ring r)
Definition: p_polys.cc:2215
#define IDELEMS(i)
Definition: simpleideals.h:24
#define p_LmTest(p, r)
Definition: p_polys.h:161
resolvente fullres
Definition: syz.h:57
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4320
leftv next
Definition: subexpr.h:87
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:4954
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
resolvente minres
Definition: syz.h:58
INLINE_THIS void Init(int l=0)
#define rRing_has_Comp(r)
Definition: monomials.h:274
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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 * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:135
static BOOLEAN _ComputeLeadingSyzygyTerms(leftv res, leftv h)
Definition: mod_main.cc:530
static void number_stats_Init(const unsigned long defaultvalue=0)
set all counters to zero
Definition: numstats.h:124
#define NULL
Definition: omList.c:10
static BOOLEAN _FindReducer(leftv res, leftv h)
proc SSFindReducer(def product, def syzterm, def L, def T, list #)
Definition: mod_main.cc:692
slists * lists
Definition: mpr_numeric.h:146
ring syRing
Definition: syz.h:56
SRes resPairs
Definition: syz.h:49
int length() const
Definition: intvec.h:86
static BOOLEAN reduce_syz(leftv res, leftv h)
NF using length.
Definition: mod_main.cc:1780
static BOOLEAN _Compute2LeadingSyzygyTerms(leftv res, leftv h)
Definition: mod_main.cc:642
static BOOLEAN _NumberStatsPrint(leftv res, leftv h)
Definition: mod_main.cc:1979
static BOOLEAN _ClearDenominators(leftv res, leftv h)
wrapper around n_ClearDenominators
Definition: mod_main.cc:148
static BOOLEAN _ReduceTerm(leftv res, leftv h)
proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)
Definition: mod_main.cc:898
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define END_NAMESPACE
int cols() const
Definition: intvec.h:87
BOOLEAN rSetISReference(const ring r, const ideal F, const int i, const int p)
Changes r by setting induced ordering parameters: limit and reference leading terms F belong to r...
Definition: ring.cc:4900
int rtyp
Definition: subexpr.h:92
const ring m_rBaseRing
global base ring
Definition: syzextra.h:241
static BOOLEAN _ComputeSyzygy(leftv res, leftv h)
module (LL, TT) = SSComputeSyzygy(L, T); Compute Syz(L ++ T) = N = LL ++ TT
Definition: mod_main.cc:1296
#define pNext(p)
Definition: monomials.h:43
void * Data()
Definition: subexpr.cc:1146
SSet * SRes
Definition: syz.h:33
short list_length
Definition: syz.h:62
Definition: tok.h:117
ideal * resolvente
Definition: ideals.h:18
static BOOLEAN _Sort_c_ds(leftv res, leftv h)
sorting wrt <c,ds> & reversing... change the input inplace!!!
Definition: mod_main.cc:580
ideal id_Tail(const ideal id, const ring r)
return the tail of a given ideal or module returns NULL if input is NULL, otherwise the result is a n...
Definition: syzextra.cc:510
omBin slists_bin
Definition: lists.cc:23
int rGetISPos(const int p, const ring r)
Finds p^th IS ordering, and returns its position in r->typ[] returns -1 if something went wrong! p - ...
Definition: ring.cc:4868
static BOOLEAN _m2_end(leftv res, leftv h)
Definition: mod_main.cc:1939
static jList * T
Definition: janet.cc:37
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
void dPrint(const ideal id, const ring lmRing=currRing, const ring tailRing=currRing, const int nTerms=0)
prints an ideal, optionally with details
static Poly * h
Definition: janet.cc:978
static BOOLEAN _leadmonom(leftv res, leftv h)
Get leading term without a module component.
Definition: mod_main.cc:1366
int BOOLEAN
Definition: auxiliary.h:86
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define NONE
Definition: tok.h:218
static int sign(int x)
Definition: ring.cc:3328
void * CopyD(int t)
Definition: subexpr.cc:714
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition: coeffs.h:949
static ideal ComputeLeadingSyzygyTerms(const ideal &L, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:583
#define PRINT_POINTER(s, v)
#define idTest(id)
Definition: ideals.h:47
ssyStrategy * syStrategy
Definition: syz.h:35
static BOOLEAN ISUpdateComponents(leftv res, leftv h)
Definition: mod_main.cc:1748
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263