My Project
Macros | Functions
mod_main.cc File Reference
#include "kernel/mod2.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 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 78 of file mod_main.cc.

79{
81
82 const char *usage = "'ClearContent' needs a (non-zero!) poly or vector argument...";
83
84 if( h == NULL )
85 {
86 WarnS(usage);
87 return TRUE;
88 }
89
90 assume( h != NULL );
91
92 if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
93 {
94 WarnS(usage);
95 return TRUE;
96 }
97
98 assume (h->Next() == NULL);
99
100 poly ph = reinterpret_cast<poly>(h->Data());
101
102 if( ph == NULL )
103 {
104 WarnS(usage);
105 return TRUE;
106 }
107
108 const ring r = currRing;
109 assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
110
111 number n;
112
113 // experimentall (recursive enumerator treatment) of alg. ext
114 CPolyCoeffsEnumerator itr(ph);
115 n_ClearContent(itr, n, C);
116
117 res->data = n;
118 res->rtyp = NUMBER_CMD;
119
120 return FALSE;
121}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
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:928
#define WarnS
Definition: emacs.cc:78
CanonicalForm res
Definition: facAbsFact.cc:60
@ VECTOR_CMD
Definition: grammar.cc:292
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
STATIC_VAR Poly * h
Definition: janet.cc:971
#define assume(x)
Definition: mod2.h:387
The main handler for Singular numbers which are suitable for Singular polynomials.
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static void NoReturn(leftv &res)
Definition: mod_main.cc:71

◆ _ClearDenominators()

static BOOLEAN _ClearDenominators ( leftv  res,
leftv  h 
)
static

wrapper around n_ClearDenominators

Definition at line 124 of file mod_main.cc.

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

◆ GetInducedData()

static BOOLEAN GetInducedData ( leftv  res,
leftv  h 
)
static

?

Definition at line 311 of file mod_main.cc.

312{
313 const ring r = currRing;
314
315 int p = 0; // which IS-block? p^th!
316
317 if ((h!=NULL) && (h->Typ()==INT_CMD))
318 {
319 p = (int)((long)(h->Data())); h=h->next;
320 assume(p >= 0);
321 }
322
323 const int pos = rGetISPos(p, r);
324
325 if( /*(*/ -1 == pos /*)*/ )
326 {
327 WerrorS("`GetInducedData([int])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
328 return TRUE;
329 }
330
331
332 const int iLimit = r->typ[pos].data.is.limit;
333 const ideal F = r->typ[pos].data.is.F;
334
335 ideal FF = id_Copy(F, r);
336
338 l->Init(2);
339
340 l->m[0].rtyp = INT_CMD;
341 l->m[0].data = reinterpret_cast<void *>(iLimit);
342
343
344 // l->m[1].rtyp = MODUL_CMD;
345
346 if( id_IsModule(FF, r) ) // ???
347 {
348 l->m[1].rtyp = MODUL_CMD;
349
350 // Print("before: %d\n", FF->nrows);
351 // FF->nrows = id_RankFreeModule(FF, r); // ???
352 // Print("after: %d\n", FF->nrows);
353 }
354 else
355 l->m[1].rtyp = IDEAL_CMD;
356
357 l->m[1].data = reinterpret_cast<void *>(FF);
358
359 res->rtyp = LIST_CMD; // list of int/module
360 res->data = reinterpret_cast<void *>(l);
361
362 return FALSE;
363
364}
int l
Definition: cfEzgcd.cc:100
int p
Definition: cfModGcd.cc:4078
Definition: lists.h:24
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284
@ MODUL_CMD
Definition: grammar.cc:287
ideal id_Copy(ideal h1, const ring r)
copy an ideal
VAR omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
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:5080
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:48
@ LIST_CMD
Definition: tok.h:118
@ INT_CMD
Definition: tok.h:96

◆ 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 172 of file mod_main.cc.

173{
174 if( h!= NULL && h->Typ() == INT_CMD )
175 {
176 int n = (int)(long)(h->Data());
177
178 if( n < 0 )
179 Warn("Negative (%d) optional integer argument", n);
180
181 return (n);
182 }
183
184 return (_n);
185}
#define Warn
Definition: emacs.cc:77

◆ 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 48 of file mod_main.cc.

49{
50 id_Test(id, r);
51
52 if( id->rank != 1 ) return TRUE;
53
54 if (rRing_has_Comp(r))
55 {
56 const int l = IDELEMS(id);
57
58 for (int j=0; j<l; j++)
59 if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0)
60 return TRUE;
61
62 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!
63 }
64
65 return FALSE;
66}
int j
Definition: facHensel.cc:110
#define p_GetComp(p, r)
Definition: monomials.h:64
#define rRing_has_Comp(r)
Definition: monomials.h:266
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ idPrepare()

static BOOLEAN idPrepare ( leftv  res,
leftv  h 
)
static

Get raw syzygies (idPrepare)

Definition at line 415 of file mod_main.cc.

416{
417 // extern int rGetISPos(const int p, const ring r);
418
419 const ring r = currRing;
420
421 const bool isSyz = rIsSyzIndexRing(r);
422 const int posIS = rGetISPos(0, r);
423
424
425 if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD) && (h->Data() != NULL) ) )
426 {
427 WerrorS("`idPrepare(<module>)` expected");
428 return TRUE;
429 }
430
431 const ideal I = reinterpret_cast<ideal>(h->Data());
432
433 assume( I != NULL );
434 idTest(I);
435
436 int iComp = -1;
437
438 h=h->next;
439 if ( (h!=NULL) && (h->Typ()==INT_CMD) )
440 {
441 iComp = (int)((long)(h->Data()));
442 }
443 else
444 {
445 if( (!isSyz) && (-1 == posIS) )
446 {
447 WerrorS("`idPrepare(<...>)` called on incompatible ring (not created by 'MakeSyzCompOrdering' or 'MakeInducedSchreyerOrdering'!)");
448 return TRUE;
449 }
450
451 if( isSyz )
452 iComp = rGetCurrSyzLimit(r);
453 else
454 iComp = id_RankFreeModule(r->typ[posIS].data.is.F, r); // ;
455 }
456
457 assume(iComp >= 0);
458
459
460 intvec* w = reinterpret_cast<intvec *>(atGet(h, "isHomog", INTVEC_CMD));
461 tHomog hom = testHomog;
462
463 // int add_row_shift = 0;
464 //
465 if (w!=NULL)
466 {
467 w = ivCopy(w);
468 // add_row_shift = ww->min_in();
469 //
470 // (*ww) -= add_row_shift;
471 //
472 // if (idTestHomModule(I, currRing->qideal, ww))
473 // {
474 hom = isHomog;
475 // w = ww;
476 // }
477 // else
478 // {
479 // //WarnS("wrong weights");
480 // delete ww;
481 // w = NULL;
482 // hom=testHomog;
483 // }
484 }
485
486
487 // computes syzygies of h1,
488 // works always in a ring with ringorder_s
489 // NOTE: rSetSyzComp(syzcomp) should better be called beforehand
490 // ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w);
491
492 ideal J = // idPrepare( I, hom, iComp, &w);
493 kStd(I, currRing->qideal, hom, &w, NULL, iComp);
494
495 idTest(J);
496
497 if (w!=NULL)
498 atSet(res, omStrDup("isHomog"), w, INTVEC_CMD);
499 // if (w!=NULL) delete w;
500
501 res->rtyp = MODUL_CMD;
502 res->data = reinterpret_cast<void *>(J);
503 return FALSE;
504}
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:132
Definition: intvec.h:23
const CanonicalForm & w
Definition: facAbsFact.cc:51
#define idTest(id)
Definition: ideals.h:47
intvec * ivCopy(const intvec *o)
Definition: intvec.h:135
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:2433
#define omStrDup(s)
Definition: omAllocDecl.h:263
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:724
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:721
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
tHomog
Definition: structs.h:35
@ isHomog
Definition: structs.h:37
@ testHomog
Definition: structs.h:38
@ INTVEC_CMD
Definition: tok.h:101

◆ jjLONG2N()

static number jjLONG2N ( long  d)
inlinestatic

Definition at line 187 of file mod_main.cc.

188{
189 return n_Init(d, coeffs_BIGINT);
190}
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:538
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ leadcomp()

static BOOLEAN leadcomp ( leftv  res,
leftv  h 
)
static

Get leading component.

Definition at line 254 of file mod_main.cc.

255{
256 if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD))
257 {
258 const ring r = currRing;
259
260 const poly p = (poly)(h->Data());
261
262 if (p != NULL )
263 {
264 assume( p != NULL );
265 p_LmTest(p, r);
266
267 const unsigned long iComp = p_GetComp(p, r);
268
269 // assume( iComp > 0 ); // p is a vector
270
271 res->data = reinterpret_cast<void *>(jjLONG2N(iComp));
272 }
273 else
274 res->data = reinterpret_cast<void *>(jjLONG2N(0));
275
276
277 res->rtyp = BIGINT_CMD;
278 return FALSE;
279 }
280
281 WerrorS("`leadcomp(<poly/vector>)` expected");
282 return TRUE;
283}
#define p_LmTest(p, r)
Definition: p_polys.h:163
static number jjLONG2N(long d)
Definition: mod_main.cc:187
@ BIGINT_CMD
Definition: tok.h:38

◆ MakeInducedSchreyerOrdering()

static BOOLEAN MakeInducedSchreyerOrdering ( leftv  res,
leftv  h 
)
static

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

Definition at line 286 of file mod_main.cc.

287{
288 int sign = 1;
289 if ((h!=NULL) && (h->Typ()==INT_CMD))
290 {
291 const int s = (int)((long)(h->Data()));
292
293 if( s != -1 && s != 1 )
294 {
295 WerrorS("`MakeInducedSchreyerOrdering(<int>)` called with wrong integer argument (must be +-1)!");
296 return TRUE;
297 }
298
299 sign = s;
300 }
301
302 assume( sign == 1 || sign == -1 );
303 res->data = reinterpret_cast<void *>(rAssure_InducedSchreyerOrdering(currRing, TRUE, sign));
304 res->rtyp = RING_CMD; // return new ring!
305 // QRING_CMD?
306 return FALSE;
307}
int sign(const CanonicalForm &a)
const CanonicalForm int s
Definition: facAbsFact.cc:51
@ RING_CMD
Definition: grammar.cc:281
ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sgn)
Definition: ring.cc:4930

◆ NoReturn()

static void NoReturn ( leftv res)
inlinestatic

Definition at line 71 of file mod_main.cc.

72{
73 res->rtyp = NONE;
74 res->data = NULL;
75}
#define NONE
Definition: tok.h:221

◆ SetInducedReferrence()

static BOOLEAN SetInducedReferrence ( leftv  res,
leftv  h 
)
static

Returns old SyzCompLimit, can set new limit.

Definition at line 367 of file mod_main.cc.

368{
369 res->Init();
370 NoReturn(res);
371
372 const ring r = currRing;
373
374 if( !( (h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD))) )
375 {
376 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` expected");
377 return TRUE;
378 }
379
380 const ideal F = (ideal)h->Data(); ; // No copy!
381 h=h->next;
382
383 int rank = 0;
384
385 if ((h!=NULL) && (h->Typ()==INT_CMD))
386 {
387 rank = (int)((long)(h->Data())); h=h->next;
388 assume(rank >= 0);
389 } else
390 rank = id_RankFreeModule(F, r); // Starting syz-comp (1st: i+1)
391
392 int p = 0; // which IS-block? p^th!
393
394 if ((h!=NULL) && (h->Typ()==INT_CMD))
395 {
396 p = (int)((long)(h->Data())); h=h->next;
397 assume(p >= 0);
398 }
399
400 const int posIS = rGetISPos(p, r);
401
402 if( /*(*/ -1 == posIS /*)*/ )
403 {
404 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
405 return TRUE;
406 }
407
408 // F & componentWeights belong to that ordering block of currRing now:
409 rSetISReference(r, F, rank, p); // F will be copied!
410 return FALSE;
411}
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:5112

◆ syzextra()

int SI_MOD_INIT() syzextra ( SModulFunctions psModulFunctions)

Definition at line 506 of file mod_main.cc.

507{
508
509#define ADD(C,D,E) \
510 psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
511
512
513 ADD("ClearContent", FALSE, _ClearContent);
514 ADD("ClearDenominators", FALSE, _ClearDenominators);
515
516 ADD("leadcomp", FALSE, leadcomp);
517
518 ADD("SetInducedReferrence", FALSE, SetInducedReferrence);
519 ADD("GetInducedData", FALSE, GetInducedData);
520 ADD("MakeInducedSchreyerOrdering", FALSE, MakeInducedSchreyerOrdering);
521
522 ADD("idPrepare", FALSE, idPrepare);
523
524 ADD("Tail", FALSE, Tail);
525
526#undef ADD
527 return MAX_TOK;
528}
static BOOLEAN GetInducedData(leftv res, leftv h)
?
Definition: mod_main.cc:311
static BOOLEAN idPrepare(leftv res, leftv h)
Get raw syzygies (idPrepare)
Definition: mod_main.cc:415
#define ADD(C, D, E)
static BOOLEAN leadcomp(leftv res, leftv h)
Get leading component.
Definition: mod_main.cc:254
static BOOLEAN _ClearDenominators(leftv res, leftv h)
wrapper around n_ClearDenominators
Definition: mod_main.cc:124
static BOOLEAN SetInducedReferrence(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition: mod_main.cc:367
static BOOLEAN MakeInducedSchreyerOrdering(leftv res, leftv h)
Same for Induced Schreyer ordering (ordering on components is defined by sign!)
Definition: mod_main.cc:286
static BOOLEAN _ClearContent(leftv res, leftv h)
wrapper around n_ClearContent
Definition: mod_main.cc:78
static BOOLEAN Tail(leftv res, leftv h)
wrapper around p_Tail and id_Tail
Definition: mod_main.cc:215
@ MAX_TOK
Definition: tok.h:218

◆ Tail()

static BOOLEAN Tail ( leftv  res,
leftv  h 
)
static

wrapper around p_Tail and id_Tail

Definition at line 215 of file mod_main.cc.

216{
217 NoReturn(res);
218
219 if( h == NULL )
220 {
221 WarnS("Tail needs a poly/vector/ideal/module argument...");
222 return TRUE;
223 }
224
225 assume( h != NULL );
226
227 const ring r = currRing;
228
229 if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
230 {
231 res->data = p_Tail( (const poly)h->Data(), r );
232 res->rtyp = h->Typ();
233
234 h = h->Next(); assume (h == NULL);
235
236 return FALSE;
237 }
238
239 if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
240 {
241 res->data = id_Tail( (const ideal)h->Data(), r );
242 res->rtyp = h->Typ();
243
244 h = h->Next(); assume (h == NULL);
245
246 return FALSE;
247 }
248
249 WarnS("Tail needs a single poly/vector/ideal/module argument...");
250 return TRUE;
251}
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:40
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:48

◆ view()

static void view ( const intvec v)
inlinestatic

Definition at line 192 of file mod_main.cc.

193{
194#ifndef SING_NDEBUG
195 v->view();
196#else
197 // This code duplication is only due to Hannes's #ifndef SING_NDEBUG!
198 Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", v->rows(), v->cols(), v->length());
199
200 for (int i = 0; i < v->rows(); i++)
201 {
202 Print ("Row[%3d]:", i);
203 for (int j = 0; j < v->cols(); j++)
204 Print (" %5d", (*v)[j + i * (v->cols())] );
205 PrintLn ();
206 }
207 PrintS ("}\n");
208#endif
209
210}
int i
Definition: cfEzgcd.cc:132
#define Print
Definition: emacs.cc:80
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310