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