My Project  debian-1:4.1.1-p2+ds-4build2
Macros | Functions
mod_main.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/intvec.h"
#include "misc/options.h"
#include "coeffs/coeffs.h"
#include "polys/PolyEnumerator.h"
#include "polys/monomials/p_polys.h"
#include "polys/monomials/ring.h"
#include "polys/simpleideals.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/syz.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "Singular/lists.h"
#include "Singular/attrib.h"
#include "Singular/ipshell.h"
#include "singularxx_defs.h"
#include "syzextra.h"
#include "Singular/mod_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define ADD(C, D, E)   psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
 

Functions

static BOOLEAN id_IsModule (ideal id, ring r)
 test whether this input has vectors among entries or no enties result must be FALSE for only 0-entries More...
 
static void NoReturn (leftv &res)
 
static BOOLEAN _ClearContent (leftv res, leftv h)
 wrapper around n_ClearContent More...
 
static BOOLEAN _ClearDenominators (leftv res, leftv h)
 wrapper around n_ClearDenominators More...
 
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 More...
 
static number jjLONG2N (long d)
 
static void view (const intvec *v)
 
static BOOLEAN Tail (leftv res, leftv h)
 wrapper around p_Tail and id_Tail More...
 
static BOOLEAN _SchreyerSyzygyNF (leftv res, leftv h)
 
static BOOLEAN _ReduceTerm (leftv res, leftv h)
 proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #) More...
 
static BOOLEAN _TraverseTail (leftv res, leftv h)
 
static BOOLEAN _ComputeResolution (leftv res, leftv h)
 
static BOOLEAN _ComputeSyzygy (leftv res, leftv h)
 module (LL, TT) = SSComputeSyzygy(L, T); Compute Syz(L ++ T) = N = LL ++ TT More...
 
static BOOLEAN leadcomp (leftv res, leftv h)
 Get leading component. More...
 
static BOOLEAN MakeInducedSchreyerOrdering (leftv res, leftv h)
 Same for Induced Schreyer ordering (ordering on components is defined by sign!) More...
 
static BOOLEAN GetInducedData (leftv res, leftv h)
 ? More...
 
static BOOLEAN SetInducedReferrence (leftv res, leftv h)
 Returns old SyzCompLimit, can set new limit. More...
 
static BOOLEAN idPrepare (leftv res, leftv h)
 Get raw syzygies (idPrepare) More...
 
int SI_MOD_INIT() syzextra (SModulFunctions *psModulFunctions)
 

Macro Definition Documentation

◆ ADD

#define ADD (   C,
  D,
  E 
)    psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);

Function Documentation

◆ _ClearContent()

static BOOLEAN _ClearContent ( leftv  res,
leftv  h 
)
static

wrapper around n_ClearContent

Definition at line 85 of file mod_main.cc.

86 {
87  NoReturn(res);
88 
89  const char *usage = "'ClearContent' needs a (non-zero!) poly or vector argument...";
90 
91  if( h == NULL )
92  {
93  WarnS(usage);
94  return TRUE;
95  }
96 
97  assume( h != NULL );
98 
99  if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
100  {
101  WarnS(usage);
102  return TRUE;
103  }
104 
105  assume (h->Next() == NULL);
106 
107  poly ph = reinterpret_cast<poly>(h->Data());
108 
109  if( ph == NULL )
110  {
111  WarnS(usage);
112  return TRUE;
113  }
114 
115  const ring r = currRing;
116  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
117 
118  number n;
119 
120  // experimentall (recursive enumerator treatment) of alg. ext
121  CPolyCoeffsEnumerator itr(ph);
122  n_ClearContent(itr, n, C);
123 
124  res->data = n;
125  res->rtyp = NUMBER_CMD;
126 
127  return FALSE;
128 }

◆ _ClearDenominators()

static BOOLEAN _ClearDenominators ( leftv  res,
leftv  h 
)
static

wrapper around n_ClearDenominators

Definition at line 131 of file mod_main.cc.

132 {
133  NoReturn(res);
134 
135  const char *usage = "'ClearDenominators' needs a (non-zero!) poly or vector argument...";
136 
137  if( h == NULL )
138  {
139  WarnS(usage);
140  return TRUE;
141  }
142 
143  assume( h != NULL );
144 
145  if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
146  {
147  WarnS(usage);
148  return TRUE;
149  }
150 
151  assume (h->Next() == NULL);
152 
153  poly ph = reinterpret_cast<poly>(h->Data());
154 
155  if( ph == NULL )
156  {
157  WarnS(usage);
158  return TRUE;
159  }
160 
161  const ring r = currRing;
162  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
163 
164  number n;
165 
166  // experimentall (recursive enumerator treatment) of alg. ext.
167  CPolyCoeffsEnumerator itr(ph);
168  n_ClearDenominators(itr, n, C);
169 
170  res->data = n;
171  res->rtyp = NUMBER_CMD;
172 
173  return FALSE;
174 }

◆ _ComputeResolution()

static BOOLEAN _ComputeResolution ( leftv  res,
leftv  h 
)
static

Definition at line 513 of file mod_main.cc.

514 {
516 
517  const char* usage = "`ComputeResolution(<ideal/module>, <same as before>, <same as before>[,int])` expected";
518  const ring r = attributes.m_rBaseRing;
519 
520  NoReturn(res);
521 
522  // input
523  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
524  {
525  WerrorS(usage);
526  return TRUE;
527  }
528 
529  const int type = h->Typ();
530  ideal M = (ideal)(h->CopyD()); // copy for resolution...!???
531  int size = IDELEMS(M);
532 
533  assume( size >= 0 );
534 
535  h = h->Next();
536 
537  // lead
538  if ((h==NULL) || (h->Typ()!=type) || (h->Data() == NULL))
539  {
540  WerrorS(usage);
541  return TRUE;
542  }
543 
544  ideal L = (ideal)(h->CopyD()); // no copy!
545  assume( IDELEMS(L) == size );
546 
547  h = h->Next();
548  if ((h==NULL) || (h->Typ()!=type) || (h->Data() == NULL))
549  {
550  WerrorS(usage);
551  return TRUE;
552  }
553 
554  ideal T = (ideal)(h->CopyD()); // no copy!
555  assume( IDELEMS(T) == size );
556 
557  h = h->Next();
558 
559  // length..?
560  long length = 0;
561 
562  if ((h!=NULL) && (h->Typ()==INT_CMD))
563  {
564  length = (long)(h->Data());
565  h = h->Next();
566  }
567 
568  assume( h == NULL );
569 
570  if( length <= 0 )
571  length = 1 + rVar(r);
572 
573  syStrategy _res=(syStrategy)omAlloc0(sizeof(ssyStrategy));
574 
575 // class ssyStrategy; typedef ssyStrategy * syStrategy;
576 // typedef ideal * resolvente;
577 
578  _res->length = length + 1; // index + 1;
579  _res->fullres = (resolvente)omAlloc0((_res->length+1)*sizeof(ideal));
580  int index = 0;
581  _res->fullres[index++] = M;
582 
583 // if (UNLIKELY(attributes.OPT__TREEOUTPUT))
584 // Print("{ \"RESOLUTION: HYBRIDNF:%d, TAILREDSYZ: %d, LEAD2SYZ: %d, IGNORETAILS: %d\": [\n", attributes.OPT__HYBRIDNF, attributes.OPT__TAILREDSYZ, attributes.OPT__LEAD2SYZ, attributes.OPT__IGNORETAILS);
585 
586  while( (!idIs0(L)) && (index < length))
587  {
588  attributes.nextSyzygyLayer();
589  ideal LL, TT;
590 
591  ComputeSyzygy(L, T, LL, TT, attributes);
592 
593  size = IDELEMS(LL);
594 
595  assume( size == IDELEMS(TT) );
596 
597  id_Delete(&L, r); id_Delete(&T, r);
598 
599  L = LL; T = TT;
600 
601  // id_Add(T, L, r);
602  M = idInit(size, 0);
603  for( int i = size-1; i >= 0; i-- )
604  {
605  M->m[i] = p_Add_q(p_Copy(T->m[i], r), p_Copy(L->m[i], r), r); // TODO: :(((
606  }
607  M->rank = id_RankFreeModule(M, r);
608 
609  _res->fullres[index++] = M; // ???
610  }
611 // if ( UNLIKELY(attributes.OPT__TREEOUTPUT) )
612 // PrintS("] }\n");
613 
614  id_Delete(&L, r); id_Delete(&T, r);
615 
616  res->data = _res;
617  res->rtyp = RESOLUTION_CMD;
618 
619 // omFreeSize(_res, sizeof(ssyStrategy));
620 
621  return FALSE;
622 
623 }

◆ _ComputeSyzygy()

static BOOLEAN _ComputeSyzygy ( leftv  res,
leftv  h 
)
static

module (LL, TT) = SSComputeSyzygy(L, T); Compute Syz(L ++ T) = N = LL ++ TT

Definition at line 629 of file mod_main.cc.

630 {
632 
633 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
634 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
635 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
636 // const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
637 
638  const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>)` expected";
639  const ring r = attributes.m_rBaseRing;
640 
641  NoReturn(res);
642 
643  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
644  {
645  WerrorS(usage);
646  return TRUE;
647  }
648 
649  const ideal L = (ideal) h->Data();
650 
651  assume( IDELEMS(L) > 0 );
652 
653  h = h->Next();
654  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
655  {
656  WerrorS(usage);
657  return TRUE;
658  }
659 
660  const ideal T = (ideal) h->Data();
661  assume( IDELEMS(L) == IDELEMS(T) );
662 
663 
664  h = h->Next(); assume( h == NULL );
665 
666  ideal LL, TT;
667 
668  ComputeSyzygy(L, T, LL, TT, attributes);
669 
670  lists l = (lists)omAllocBin(slists_bin); l->Init(2);
671 
672  l->m[0].rtyp = MODUL_CMD; l->m[0].data = reinterpret_cast<void *>(LL);
673 
674  l->m[1].rtyp = MODUL_CMD; l->m[1].data = reinterpret_cast<void *>(TT);
675 
676  res->data = l; res->rtyp = LIST_CMD;
677 
678  return FALSE;
679 
680 }

◆ _ReduceTerm()

static BOOLEAN _ReduceTerm ( leftv  res,
leftv  h 
)
static

proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)

Definition at line 342 of file mod_main.cc.

343 {
345 
346 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
347 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
348 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
349  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
350 
351  const char* usage = "`ReduceTerm(<poly>, <poly/vector>, <vector/0>, <ideal/module>, <ideal/module>[,<module>])` expected";
352  const ring r = attributes.m_rBaseRing;
353 
354  NoReturn(res);
355 
356  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
357  {
358  WerrorS(usage);
359  return TRUE;
360  }
361 
362  const poly multiplier = (poly) h->Data(); assume (multiplier != NULL);
363 
364 
365  h = h->Next();
366  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD) || (h->Data() == NULL))
367  {
368  WerrorS(usage);
369  return TRUE;
370  }
371 
372  const poly term4reduction = (poly) h->Data(); assume( term4reduction != NULL );
373 
374 
375  poly syztermCheck = NULL;
376 
377  h = h->Next();
378  if ((h==NULL) || !((h->Typ()==VECTOR_CMD) || (h->Data() == NULL)) )
379  {
380  WerrorS(usage);
381  return TRUE;
382  }
383 
384  if(h->Typ()==VECTOR_CMD)
385  syztermCheck = (poly) h->Data();
386 
387 
388  h = h->Next();
389  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
390  {
391  WerrorS(usage);
392  return TRUE;
393  }
394 
395  const ideal L = (ideal) h->Data(); assume( IDELEMS(L) > 0 );
396 
397 
398  h = h->Next();
399  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
400  {
401  WerrorS(usage);
402  return TRUE;
403  }
404 
405  const ideal T = (ideal) h->Data();
406 
407  assume( IDELEMS(L) == IDELEMS(T) );
408 
409  ideal LS = NULL;
410 
411  h = h->Next();
412  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
413  {
414  LS = (ideal)h->Data();
415  h = h->Next();
416  }
417 
418 #ifndef SING_NDEBUG
419  if( LIKELY( OPT__TAILREDSYZ) )
420  assume (LS != NULL);
421 #endif
422 
423  assume( h == NULL );
424 
425  res->rtyp = VECTOR_CMD;
426  res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, attributes);
427 
428  return FALSE;
429 }

◆ _SchreyerSyzygyNF()

static BOOLEAN _SchreyerSyzygyNF ( leftv  res,
leftv  h 
)
static

Definition at line 261 of file mod_main.cc.

262 {
264 
265 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
266 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
267  const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
268  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
269 
270  const char* usage = "`SchreyerSyzygyNF(<vector>, <vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
271  const ring r = attributes.m_rBaseRing;
272 
273  NoReturn(res);
274 
275  assume( OPT__HYBRIDNF ); // ???
276 
277  if ((h==NULL) || (h->Typ() != VECTOR_CMD) || (h->Data() == NULL))
278  {
279  WerrorS(usage);
280  return TRUE;
281  }
282 
283  const poly syz_lead = (poly) h->Data(); assume (syz_lead != NULL);
284 
285 
286  h = h->Next();
287  if ((h==NULL) || (h->Typ() != VECTOR_CMD) || (h->Data() == NULL))
288  {
289  WerrorS(usage);
290  return TRUE;
291  }
292 
293  const poly syz_2 = (poly) h->Data(); assume (syz_2 != NULL);
294 
295  h = h->Next();
296  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
297  {
298  WerrorS(usage);
299  return TRUE;
300  }
301 
302  const ideal L = (ideal) h->Data(); assume( IDELEMS(L) > 0 );
303 
304 
305  h = h->Next();
306  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
307  {
308  WerrorS(usage);
309  return TRUE;
310  }
311 
312  const ideal T = (ideal) h->Data();
313 
314  assume( IDELEMS(L) == IDELEMS(T) );
315 
316  ideal LS = NULL;
317 
318  h = h->Next();
319  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
320  {
321  LS = (ideal)h->Data();
322  h = h->Next();
323  }
324 
325 #ifndef SING_NDEBUG
326  if( LIKELY( OPT__TAILREDSYZ) )
327  assume (LS != NULL);
328 #endif
329 
330  assume( h == NULL );
331 
332  res->rtyp = VECTOR_CMD;
333  res->data = SchreyerSyzygyNF(syz_lead,
334  (syz_2!=NULL)? p_Copy(syz_2, r): syz_2, L, T, LS, attributes);
335 
336  return FALSE;
337 }

◆ _TraverseTail()

static BOOLEAN _TraverseTail ( leftv  res,
leftv  h 
)
static

Definition at line 435 of file mod_main.cc.

436 {
438 
439 // const BOOLEAN OPT__SYZCHECK = attributes.OPT__SYZCHECK;
440 // const BOOLEAN OPT__LEAD2SYZ = attributes.OPT__LEAD2SYZ;
441 // const BOOLEAN OPT__HYBRIDNF = attributes.OPT__HYBRIDNF;
442  const BOOLEAN OPT__TAILREDSYZ = attributes.OPT__TAILREDSYZ;
443 
444  const char* usage = "`TraverseTail(<poly>, <poly/vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
445  const ring r = attributes.m_rBaseRing;
446 
447  NoReturn(res);
448 
449  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
450  {
451  WerrorS(usage);
452  return TRUE;
453  }
454 
455  const poly multiplier = (poly) h->Data(); assume (multiplier != NULL);
456 
457  h = h->Next();
458  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD))
459  {
460  WerrorS(usage);
461  return TRUE;
462  }
463 
464  const poly tail = (poly) h->Data();
465 
466  h = h->Next();
467 
468  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
469  {
470  WerrorS(usage);
471  return TRUE;
472  }
473 
474  const ideal L = (ideal) h->Data();
475 
476  assume( IDELEMS(L) > 0 );
477 
478  h = h->Next();
479  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
480  {
481  WerrorS(usage);
482  return TRUE;
483  }
484 
485  const ideal T = (ideal) h->Data();
486 
487  assume( IDELEMS(L) == IDELEMS(T) );
488 
489  h = h->Next();
490 
491  ideal LS = NULL;
492 
493  if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL))
494  {
495  LS = (ideal)h->Data();
496  h = h->Next();
497  }
498 
499 #ifndef SING_NDEBUG
500  if( LIKELY( OPT__TAILREDSYZ) )
501  assume (LS != NULL);
502 #endif
503 
504  assume( h == NULL );
505 
506  res->rtyp = VECTOR_CMD;
507  res->data = TraverseTail(multiplier, tail, L, T, LS, attributes);
508 
509  return FALSE;
510 }

◆ GetInducedData()

static BOOLEAN GetInducedData ( leftv  res,
leftv  h 
)
static

?

Definition at line 744 of file mod_main.cc.

745 {
746  NoReturn(res);
747 
748  const ring r = currRing;
749 
750  int p = 0; // which IS-block? p^th!
751 
752  if ((h!=NULL) && (h->Typ()==INT_CMD))
753  {
754  p = (int)((long)(h->Data())); h=h->next;
755  assume(p >= 0);
756  }
757 
758  const int pos = rGetISPos(p, r);
759 
760  if( /*(*/ -1 == pos /*)*/ )
761  {
762  WerrorS("`GetInducedData([int])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
763  return TRUE;
764  }
765 
766 
767  const int iLimit = r->typ[pos].data.is.limit;
768  const ideal F = r->typ[pos].data.is.F;
769 
770  ideal FF = id_Copy(F, r);
771 
773  l->Init(2);
774 
775  l->m[0].rtyp = INT_CMD;
776  l->m[0].data = reinterpret_cast<void *>(iLimit);
777 
778 
779  // l->m[1].rtyp = MODUL_CMD;
780 
781  if( id_IsModule(FF, r) ) // ???
782  {
783  l->m[1].rtyp = MODUL_CMD;
784 
785  // Print("before: %d\n", FF->nrows);
786  // FF->nrows = id_RankFreeModule(FF, r); // ???
787  // Print("after: %d\n", FF->nrows);
788  }
789  else
790  l->m[1].rtyp = IDEAL_CMD;
791 
792  l->m[1].data = reinterpret_cast<void *>(FF);
793 
794  res->rtyp = LIST_CMD; // list of int/module
795  res->data = reinterpret_cast<void *>(l);
796 
797  return FALSE;
798 
799 }

◆ getOptionalInteger()

static int getOptionalInteger ( const leftv h,
const int  _n 
)
static

try to get an optional (simple) integer argument out of h or return the default value

Definition at line 179 of file mod_main.cc.

180 {
181  if( h!= NULL && h->Typ() == INT_CMD )
182  {
183  int n = (int)(long)(h->Data());
184 
185  if( n < 0 )
186  Warn("Negative (%d) optional integer argument", n);
187 
188  return (n);
189  }
190 
191  return (_n);
192 }

◆ id_IsModule()

static BOOLEAN id_IsModule ( ideal  id,
ring  r 
)
static

test whether this input has vectors among entries or no enties result must be FALSE for only 0-entries

Definition at line 55 of file mod_main.cc.

56 {
57  id_Test(id, r);
58 
59  if( id->rank != 1 ) return TRUE;
60 
61  if (rRing_has_Comp(r))
62  {
63  const int l = IDELEMS(id);
64 
65  for (int j=0; j<l; j++)
66  if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0)
67  return TRUE;
68 
69  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!
70  }
71 
72  return FALSE;
73 }

◆ idPrepare()

static BOOLEAN idPrepare ( leftv  res,
leftv  h 
)
static

Get raw syzygies (idPrepare)

Definition at line 851 of file mod_main.cc.

852 {
853  // extern int rGetISPos(const int p, const ring r);
854 
855  const ring r = currRing;
856 
857  const bool isSyz = rIsSyzIndexRing(r);
858  const int posIS = rGetISPos(0, r);
859 
860 
861  if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD) && (h->Data() != NULL) ) )
862  {
863  WerrorS("`idPrepare(<module>)` expected");
864  return TRUE;
865  }
866 
867  const ideal I = reinterpret_cast<ideal>(h->Data());
868 
869  assume( I != NULL );
870  idTest(I);
871 
872  int iComp = -1;
873 
874  h=h->next;
875  if ( (h!=NULL) && (h->Typ()==INT_CMD) )
876  {
877  iComp = (int)((long)(h->Data()));
878  }
879  else
880  {
881  if( (!isSyz) && (-1 == posIS) )
882  {
883  WerrorS("`idPrepare(<...>)` called on incompatible ring (not created by 'MakeSyzCompOrdering' or 'MakeInducedSchreyerOrdering'!)");
884  return TRUE;
885  }
886 
887  if( isSyz )
888  iComp = rGetCurrSyzLimit(r);
889  else
890  iComp = id_RankFreeModule(r->typ[posIS].data.is.F, r); // ;
891  }
892 
893  assume(iComp >= 0);
894 
895 
896  intvec* w = reinterpret_cast<intvec *>(atGet(h, "isHomog", INTVEC_CMD));
897  tHomog hom = testHomog;
898 
899  // int add_row_shift = 0;
900  //
901  if (w!=NULL)
902  {
903  w = ivCopy(w);
904  // add_row_shift = ww->min_in();
905  //
906  // (*ww) -= add_row_shift;
907  //
908  // if (idTestHomModule(I, currRing->qideal, ww))
909  // {
910  hom = isHomog;
911  // w = ww;
912  // }
913  // else
914  // {
915  // //WarnS("wrong weights");
916  // delete ww;
917  // w = NULL;
918  // hom=testHomog;
919  // }
920  }
921 
922 
923  // computes syzygies of h1,
924  // works always in a ring with ringorder_s
925  // NOTE: rSetSyzComp(syzcomp) should better be called beforehand
926  // ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w);
927 
928  ideal J = // idPrepare( I, hom, iComp, &w);
929  kStd(I, currRing->qideal, hom, &w, NULL, iComp);
930 
931  idTest(J);
932 
933  if (w!=NULL)
934  atSet(res, omStrDup("isHomog"), w, INTVEC_CMD);
935  // if (w!=NULL) delete w;
936 
937  res->rtyp = MODUL_CMD;
938  res->data = reinterpret_cast<void *>(J);
939  return FALSE;
940 }

◆ jjLONG2N()

static number jjLONG2N ( long  d)
inlinestatic

Definition at line 194 of file mod_main.cc.

195 {
196  return n_Init(d, coeffs_BIGINT);
197 }

◆ leadcomp()

static BOOLEAN leadcomp ( leftv  res,
leftv  h 
)
static

Get leading component.

Definition at line 683 of file mod_main.cc.

684 {
685  NoReturn(res);
686 
687  if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD))
688  {
689  const ring r = currRing;
690 
691  const poly p = (poly)(h->Data());
692 
693  if (p != NULL )
694  {
695  assume( p != NULL );
696  p_LmTest(p, r);
697 
698  const unsigned long iComp = p_GetComp(p, r);
699 
700  // assume( iComp > 0 ); // p is a vector
701 
702  res->data = reinterpret_cast<void *>(jjLONG2N(iComp));
703  } else
704  res->data = reinterpret_cast<void *>(jjLONG2N(0));
705 
706 
707  res->rtyp = BIGINT_CMD;
708  return FALSE;
709  }
710 
711  WerrorS("`leadcomp(<poly/vector>)` expected");
712  return TRUE;
713 }

◆ MakeInducedSchreyerOrdering()

static BOOLEAN MakeInducedSchreyerOrdering ( leftv  res,
leftv  h 
)
static

Same for Induced Schreyer ordering (ordering on components is defined by sign!)

Definition at line 716 of file mod_main.cc.

717 {
718 
719  NoReturn(res);
720 
721  int sign = 1;
722  if ((h!=NULL) && (h->Typ()==INT_CMD))
723  {
724  const int s = (int)((long)(h->Data()));
725 
726  if( s != -1 && s != 1 )
727  {
728  WerrorS("`MakeInducedSchreyerOrdering(<int>)` called with wrong integer argument (must be +-1)!");
729  return TRUE;
730  }
731 
732  sign = s;
733  }
734 
735  assume( sign == 1 || sign == -1 );
736  res->data = reinterpret_cast<void *>(rAssure_InducedSchreyerOrdering(currRing, TRUE, sign));
737  res->rtyp = RING_CMD; // return new ring!
738  // QRING_CMD?
739  return FALSE;
740 }

◆ NoReturn()

static void NoReturn ( leftv res)
inlinestatic

Definition at line 78 of file mod_main.cc.

79 {
80  res->rtyp = NONE;
81  res->data = NULL;
82 }

◆ SetInducedReferrence()

static BOOLEAN SetInducedReferrence ( leftv  res,
leftv  h 
)
static

Returns old SyzCompLimit, can set new limit.

Definition at line 802 of file mod_main.cc.

803 {
804  NoReturn(res);
805 
806  const ring r = currRing;
807 
808  if( !( (h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD))) )
809  {
810  WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` expected");
811  return TRUE;
812  }
813 
814  const ideal F = (ideal)h->Data(); ; // No copy!
815  h=h->next;
816 
817  int rank = 0;
818 
819  if ((h!=NULL) && (h->Typ()==INT_CMD))
820  {
821  rank = (int)((long)(h->Data())); h=h->next;
822  assume(rank >= 0);
823  } else
824  rank = id_RankFreeModule(F, r); // Starting syz-comp (1st: i+1)
825 
826  int p = 0; // which IS-block? p^th!
827 
828  if ((h!=NULL) && (h->Typ()==INT_CMD))
829  {
830  p = (int)((long)(h->Data())); h=h->next;
831  assume(p >= 0);
832  }
833 
834  const int posIS = rGetISPos(p, r);
835 
836  if( /*(*/ -1 == posIS /*)*/ )
837  {
838  WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
839  return TRUE;
840  }
841 
842 
843 
844  // F & componentWeights belong to that ordering block of currRing now:
845  rSetISReference(r, F, rank, p); // F will be copied!
846  return FALSE;
847 }

◆ syzextra()

int SI_MOD_INIT() syzextra ( SModulFunctions psModulFunctions)

Definition at line 942 of file mod_main.cc.

943 {
944 
945 #define ADD(C,D,E) \
946  psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
947 
948 
949 // #define ADD(A,B,C,D,E) ADD0(iiAddCproc, "", C, D, E)
950 
951 //#define ADD0(A,B,C,D,E) A(B, (char*)C, D, E)
952 // #define ADD(A,B,C,D,E) ADD0(A->iiAddCproc, B, C, D, E)
953  ADD("ClearContent", FALSE, _ClearContent);
954  ADD("ClearDenominators", FALSE, _ClearDenominators);
955 
956  ADD("leadcomp", FALSE, leadcomp);
957 
958  ADD("SetInducedReferrence", FALSE, SetInducedReferrence);
959  ADD("GetInducedData", FALSE, GetInducedData);
960  ADD("MakeInducedSchreyerOrdering", FALSE, MakeInducedSchreyerOrdering);
961 
962  ADD("idPrepare", FALSE, idPrepare);
963 
964  ADD("Tail", FALSE, Tail);
965 
966  ADD("ReduceTerm", FALSE, _ReduceTerm);
967  ADD("TraverseTail", FALSE, _TraverseTail);
968 
969 
970  ADD("SchreyerSyzygyNF", FALSE, _SchreyerSyzygyNF);
971  ADD("ComputeSyzygy", FALSE, _ComputeSyzygy);
972 
973  ADD("ComputeResolution", FALSE, _ComputeResolution);
974 
975  // ADD("", FALSE, );
976 
977 #undef ADD
978  return MAX_TOK;
979 }

◆ Tail()

static BOOLEAN Tail ( leftv  res,
leftv  h 
)
static

wrapper around p_Tail and id_Tail

Definition at line 222 of file mod_main.cc.

223 {
224  NoReturn(res);
225 
226  if( h == NULL )
227  {
228  WarnS("Tail needs a poly/vector/ideal/module argument...");
229  return TRUE;
230  }
231 
232  assume( h != NULL );
233 
234  const ring r = currRing;
235 
236  if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
237  {
238  res->data = p_Tail( (const poly)h->Data(), r );
239  res->rtyp = h->Typ();
240 
241  h = h->Next(); assume (h == NULL);
242 
243  return FALSE;
244  }
245 
246  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
247  {
248  res->data = id_Tail( (const ideal)h->Data(), r );
249  res->rtyp = h->Typ();
250 
251  h = h->Next(); assume (h == NULL);
252 
253  return FALSE;
254  }
255 
256  WarnS("Tail needs a single poly/vector/ideal/module argument...");
257  return TRUE;
258 }

◆ view()

static void view ( const intvec v)
inlinestatic

Definition at line 199 of file mod_main.cc.

200 {
201 #ifndef SING_NDEBUG
202  v->view();
203 #else
204  // This code duplication is only due to Hannes's #ifndef SING_NDEBUG!
205  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", v->rows(), v->cols(), v->length());
206 
207  for (int i = 0; i < v->rows(); i++)
208  {
209  Print ("Row[%3d]:", i);
210  for (int j = 0; j < v->cols(); j++)
211  Print (" %5d", (*v)[j + i * (v->cols())] );
212  PrintLn ();
213  }
214  PrintS ("}\n");
215 #endif
216 
217 }
NoReturn
static void NoReturn(leftv &res)
Definition: mod_main.cc:78
FALSE
#define FALSE
Definition: auxiliary.h:94
SetInducedReferrence
static BOOLEAN SetInducedReferrence(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition: mod_main.cc:802
MakeInducedSchreyerOrdering
static BOOLEAN MakeInducedSchreyerOrdering(leftv res, leftv h)
Same for Induced Schreyer ordering (ordering on components is defined by sign!)
Definition: mod_main.cc:716
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:71
j
int j
Definition: facHensel.cc:105
leadcomp
static BOOLEAN leadcomp(leftv res, leftv h)
Get leading component.
Definition: mod_main.cc:683
NUMBER_CMD
@ NUMBER_CMD
Definition: grammar.cc:287
BIGINT_CMD
@ BIGINT_CMD
Definition: tok.h:38
LIST_CMD
@ LIST_CMD
Definition: tok.h:118
syStrategy
ssyStrategy * syStrategy
Definition: syz.h:35
MODUL_CMD
@ MODUL_CMD
Definition: grammar.cc:286
ssyStrategy::fullres
resolvente fullres
Definition: syz.h:57
_ComputeResolution
static BOOLEAN _ComputeResolution(leftv res, leftv h)
Definition: mod_main.cc:513
_TraverseTail
static BOOLEAN _TraverseTail(leftv res, leftv h)
Definition: mod_main.cc:435
NONE
#define NONE
Definition: tok.h:218
MAX_TOK
@ MAX_TOK
Definition: tok.h:215
length
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
sign
static int sign(int x)
Definition: ring.cc:3328
LIKELY
#define LIKELY
Definition: auxiliary.h:421
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
idTest
#define idTest(id)
Definition: ideals.h:47
ComputeSyzygy
static void ComputeSyzygy(const ideal L, const ideal T, ideal &LL, ideal &TT, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:502
testHomog
@ testHomog
Definition: structs.h:41
idPrepare
static BOOLEAN idPrepare(leftv res, leftv h)
Get raw syzygies (idPrepare)
Definition: mod_main.cc:851
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:768
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
RING_CMD
@ RING_CMD
Definition: grammar.cc:281
_ComputeSyzygy
static BOOLEAN _ComputeSyzygy(leftv res, leftv h)
module (LL, TT) = SSComputeSyzygy(L, T); Compute Syz(L ++ T) = N = LL ++ TT
Definition: mod_main.cc:629
_SchreyerSyzygyNF
static BOOLEAN _SchreyerSyzygyNF(leftv res, leftv h)
Definition: mod_main.cc:261
currRingHdl
idhdl currRingHdl
Definition: ipid.cc:61
slists_bin
omBin slists_bin
Definition: lists.cc:23
rSetISReference
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:4919
Tail
static BOOLEAN Tail(leftv res, leftv h)
wrapper around p_Tail and id_Tail
Definition: mod_main.cc:222
CPolyCoeffsEnumerator
Definition: PolyEnumerator.h:129
tHomog
tHomog
Definition: structs.h:37
rGetCurrSyzLimit
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:714
TraverseTail
static poly TraverseTail(poly multiplier, poly tail, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:534
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
ivCopy
intvec * ivCopy(const intvec *o)
Definition: intvec.h:133
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
res
CanonicalForm res
Definition: facAbsFact.cc:64
INT_CMD
@ INT_CMD
Definition: tok.h:96
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition: simpleideals.cc:782
SchreyerSyzygyNF
static poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:549
M
#define M
Definition: sirandom.c:24
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
GetInducedData
static BOOLEAN GetInducedData(leftv res, leftv h)
?
Definition: mod_main.cc:744
T
static jList * T
Definition: janet.cc:31
id_Tail
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:325
p_Tail
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:316
resolvente
ideal * resolvente
Definition: ideals.h:18
IDEAL_CMD
@ IDEAL_CMD
Definition: grammar.cc:283
h
static Poly * h
Definition: janet.cc:972
ReduceTerm
static poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A)
Definition: syzextra.h:541
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
coeffs
atSet
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:152
intvec
Definition: intvec.h:17
isHomog
@ isHomog
Definition: structs.h:40
jjLONG2N
static number jjLONG2N(long d)
Definition: mod_main.cc:194
ssyStrategy::length
int length
Definition: syz.h:60
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
VECTOR_CMD
@ VECTOR_CMD
Definition: grammar.cc:290
SchreyerSyzygyComputationFlags
Computation attribute storage.
Definition: syzextra.h:162
rAssure_InducedSchreyerOrdering
ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sgn)
Definition: ring.cc:4751
_ReduceTerm
static BOOLEAN _ReduceTerm(leftv res, leftv h)
proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)
Definition: mod_main.cc:342
ADD
#define ADD(C, D, E)
p_LmTest
#define p_LmTest(p, r)
Definition: p_polys.h:164
slists
Definition: lists.h:22
INTVEC_CMD
@ INTVEC_CMD
Definition: tok.h:101
_ClearDenominators
static BOOLEAN _ClearDenominators(leftv res, leftv h)
wrapper around n_ClearDenominators
Definition: mod_main.cc:131
coeffs_BIGINT
coeffs coeffs_BIGINT
Definition: ipid.cc:52
id_IsModule
static BOOLEAN id_IsModule(ideal id, ring r)
test whether this input has vectors among entries or no enties result must be FALSE for only 0-entrie...
Definition: mod_main.cc:55
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
_ClearContent
static BOOLEAN _ClearContent(leftv res, leftv h)
wrapper around n_ClearContent
Definition: mod_main.cc:85
n_ClearContent
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
n_ClearDenominators
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
rRing_has_Comp
#define rRing_has_Comp(r)
Definition: monomials.h:273
Print
#define Print
Definition: emacs.cc:80
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:131
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
WarnS
#define WarnS
Definition: emacs.cc:78
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
lists
slists * lists
Definition: mpr_numeric.h:146
l
int l
Definition: cfEzgcd.cc:93
Warn
#define Warn
Definition: emacs.cc:77
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
RESOLUTION_CMD
@ RESOLUTION_CMD
Definition: grammar.cc:289
POLY_CMD
@ POLY_CMD
Definition: grammar.cc:288
rIsSyzIndexRing
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:711
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:26
kStd
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:2096
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition: simpleideals.cc:404
PrintLn
void PrintLn()
Definition: reporter.cc:310
id_Test
#define id_Test(A, lR)
Definition: simpleideals.h:80
index
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
rGetISPos
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!...
Definition: ring.cc:4887
ssyStrategy
Definition: syz.h:37