My Project
Loading...
Searching...
No Matches
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 "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 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 75 of file mod_main.cc.

76{
78
79 const char *usage = "'ClearContent' needs a (non-zero!) poly or vector argument...";
80
81 if( h == NULL )
82 {
83 WarnS(usage);
84 return TRUE;
85 }
86
87 assume( h != NULL );
88
89 if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
90 {
91 WarnS(usage);
92 return TRUE;
93 }
94
95 assume (h->Next() == NULL);
96
97 poly ph = reinterpret_cast<poly>(h->Data());
98
99 if( ph == NULL )
100 {
101 WarnS(usage);
102 return TRUE;
103 }
104
105 const ring r = currRing;
106 assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
107
108 number n;
109
110 // experimentall (recursive enumerator treatment) of alg. ext
111 CPolyCoeffsEnumerator itr(ph);
112 n_ClearContent(itr, n, C);
113
114 res->data = n;
115 res->rtyp = NUMBER_CMD;
116
117 return FALSE;
118}
#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:925
#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:389
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:68

◆ _ClearDenominators()

static BOOLEAN _ClearDenominators ( leftv  res,
leftv  h 
)
static

wrapper around n_ClearDenominators

Definition at line 121 of file mod_main.cc.

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

◆ GetInducedData()

static BOOLEAN GetInducedData ( leftv  res,
leftv  h 
)
static

?

Definition at line 269 of file mod_main.cc.

270{
271 const ring r = currRing;
272
273 int p = 0; // which IS-block? p^th!
274
275 if ((h!=NULL) && (h->Typ()==INT_CMD))
276 {
277 p = (int)((long)(h->Data())); h=h->next;
278 assume(p >= 0);
279 }
280
281 const int pos = rGetISPos(p, r);
282
283 if( /*(*/ -1 == pos /*)*/ )
284 {
285 WerrorS("`GetInducedData([int])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
286 return TRUE;
287 }
288
289
290 const int iLimit = r->typ[pos].data.is.limit;
291 const ideal F = r->typ[pos].data.is.F;
292
293 ideal FF = id_Copy(F, r);
294
296 l->Init(2);
297
298 l->m[0].rtyp = INT_CMD;
299 l->m[0].data = reinterpret_cast<void *>(iLimit);
300
301
302 // l->m[1].rtyp = MODUL_CMD;
303
304 if( id_IsModule(FF, r) ) // ???
305 {
306 l->m[1].rtyp = MODUL_CMD;
307
308 // Print("before: %d\n", FF->nrows);
309 // FF->nrows = id_RankFreeModule(FF, r); // ???
310 // Print("after: %d\n", FF->nrows);
311 }
312 else
313 l->m[1].rtyp = IDEAL_CMD;
314
315 l->m[1].data = reinterpret_cast<void *>(FF);
316
317 res->rtyp = LIST_CMD; // list of int/module
318 res->data = reinterpret_cast<void *>(l);
319
320 return FALSE;
321
322}
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:5000
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:45
@ 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 169 of file mod_main.cc.

170{
171 if( h!= NULL && h->Typ() == INT_CMD )
172 {
173 int n = (int)(long)(h->Data());
174
175 if( n < 0 )
176 Warn("Negative (%d) optional integer argument", n);
177
178 return (n);
179 }
180
181 return (_n);
182}
#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 45 of file mod_main.cc.

46{
47 id_Test(id, r);
48
49 if( id->rank != 1 ) return TRUE;
50
51 if (rRing_has_Comp(r))
52 {
53 const int l = IDELEMS(id);
54
55 for (int j=0; j<l; j++)
56 if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0)
57 return TRUE;
58
59 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!
60 }
61
62 return FALSE;
63}
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:87

◆ idPrepare()

static BOOLEAN idPrepare ( leftv  res,
leftv  h 
)
static

Get raw syzygies (idPrepare)

Definition at line 373 of file mod_main.cc.

374{
375 // extern int rGetISPos(const int p, const ring r);
376
377 const ring r = currRing;
378
379 const bool isSyz = rIsSyzIndexRing(r);
380 const int posIS = rGetISPos(0, r);
381
382
383 if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD) && (h->Data() != NULL) ) )
384 {
385 WerrorS("`idPrepare(<module>)` expected");
386 return TRUE;
387 }
388
389 const ideal I = reinterpret_cast<ideal>(h->Data());
390
391 assume( I != NULL );
392 idTest(I);
393
394 int iComp = -1;
395
396 h=h->next;
397 if ( (h!=NULL) && (h->Typ()==INT_CMD) )
398 {
399 iComp = (int)((long)(h->Data()));
400 }
401 else
402 {
403 if( (!isSyz) && (-1 == posIS) )
404 {
405 WerrorS("`idPrepare(<...>)` called on incompatible ring (not created by 'MakeSyzCompOrdering' or 'MakeInducedSchreyerOrdering'!)");
406 return TRUE;
407 }
408
409 if( isSyz )
410 iComp = rGetCurrSyzLimit(r);
411 else
412 iComp = id_RankFreeModule(r->typ[posIS].data.is.F, r); // ;
413 }
414
415 assume(iComp >= 0);
416
417
418 intvec* w = reinterpret_cast<intvec *>(atGet(h, "isHomog", INTVEC_CMD));
419 tHomog hom = testHomog;
420
421 // int add_row_shift = 0;
422 //
423 if (w!=NULL)
424 {
425 w = ivCopy(w);
426 // add_row_shift = ww->min_in();
427 //
428 // (*ww) -= add_row_shift;
429 //
430 // if (idTestHomModule(I, currRing->qideal, ww))
431 // {
432 hom = isHomog;
433 // w = ww;
434 // }
435 // else
436 // {
437 // //WarnS("wrong weights");
438 // delete ww;
439 // w = NULL;
440 // hom=testHomog;
441 // }
442 }
443
444
445 // computes syzygies of h1,
446 // works always in a ring with ringorder_s
447 // NOTE: rSetSyzComp(syzcomp) should better be called beforehand
448 // ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w);
449
450 ideal J = // idPrepare( I, hom, iComp, &w);
451 kStd(I, currRing->qideal, hom, &w, NULL, iComp);
452
453 idTest(J);
454
455 if (w!=NULL)
456 atSet(res, omStrDup("isHomog"), w, INTVEC_CMD);
457 // if (w!=NULL) delete w;
458
459 res->rtyp = MODUL_CMD;
460 res->data = reinterpret_cast<void *>(J);
461 return FALSE;
462}
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:145
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:2447
#define omStrDup(s)
Definition: omAllocDecl.h:263
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:723
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:720
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 184 of file mod_main.cc.

185{
186 return n_Init(d, coeffs_BIGINT);
187}
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:535
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ leadcomp()

static BOOLEAN leadcomp ( leftv  res,
leftv  h 
)
static

Get leading component.

Definition at line 212 of file mod_main.cc.

213{
214 if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD))
215 {
216 const ring r = currRing;
217
218 const poly p = (poly)(h->Data());
219
220 if (p != NULL )
221 {
222 assume( p != NULL );
223 p_LmTest(p, r);
224
225 const unsigned long iComp = p_GetComp(p, r);
226
227 // assume( iComp > 0 ); // p is a vector
228
229 res->data = reinterpret_cast<void *>(jjLONG2N(iComp));
230 }
231 else
232 res->data = reinterpret_cast<void *>(jjLONG2N(0));
233
234
235 res->rtyp = BIGINT_CMD;
236 return FALSE;
237 }
238
239 WerrorS("`leadcomp(<poly/vector>)` expected");
240 return TRUE;
241}
#define p_LmTest(p, r)
Definition: p_polys.h:160
static number jjLONG2N(long d)
Definition: mod_main.cc:184
@ 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 244 of file mod_main.cc.

245{
246 int sign = 1;
247 if ((h!=NULL) && (h->Typ()==INT_CMD))
248 {
249 const int s = (int)((long)(h->Data()));
250
251 if( s != -1 && s != 1 )
252 {
253 WerrorS("`MakeInducedSchreyerOrdering(<int>)` called with wrong integer argument (must be +-1)!");
254 return TRUE;
255 }
256
257 sign = s;
258 }
259
260 assume( sign == 1 || sign == -1 );
261 res->data = reinterpret_cast<void *>(rAssure_InducedSchreyerOrdering(currRing, TRUE, sign));
262 res->rtyp = RING_CMD; // return new ring!
263 // QRING_CMD?
264 return FALSE;
265}
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:4850
static int sign(int x)
Definition: ring.cc:3427

◆ NoReturn()

static void NoReturn ( leftv res)
inlinestatic

Definition at line 68 of file mod_main.cc.

69{
70 res->rtyp = NONE;
71 res->data = NULL;
72}
#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 325 of file mod_main.cc.

326{
327 res->Init();
328 NoReturn(res);
329
330 const ring r = currRing;
331
332 if( !( (h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD))) )
333 {
334 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` expected");
335 return TRUE;
336 }
337
338 const ideal F = (ideal)h->Data(); ; // No copy!
339 h=h->next;
340
341 int rank = 0;
342
343 if ((h!=NULL) && (h->Typ()==INT_CMD))
344 {
345 rank = (int)((long)(h->Data())); h=h->next;
346 assume(rank >= 0);
347 } else
348 rank = id_RankFreeModule(F, r); // Starting syz-comp (1st: i+1)
349
350 int p = 0; // which IS-block? p^th!
351
352 if ((h!=NULL) && (h->Typ()==INT_CMD))
353 {
354 p = (int)((long)(h->Data())); h=h->next;
355 assume(p >= 0);
356 }
357
358 const int posIS = rGetISPos(p, r);
359
360 if( /*(*/ -1 == posIS /*)*/ )
361 {
362 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
363 return TRUE;
364 }
365
366 // F & componentWeights belong to that ordering block of currRing now:
367 rSetISReference(r, F, rank, p); // F will be copied!
368 return FALSE;
369}
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:5032

◆ syzextra()

int SI_MOD_INIT() syzextra ( SModulFunctions psModulFunctions)

Definition at line 464 of file mod_main.cc.

465{
466
467#define ADD(C,D,E) \
468 psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
469
470
471 ADD("ClearContent", FALSE, _ClearContent);
472 ADD("ClearDenominators", FALSE, _ClearDenominators);
473
474 ADD("leadcomp", FALSE, leadcomp);
475
476 ADD("SetInducedReferrence", FALSE, SetInducedReferrence);
477 ADD("GetInducedData", FALSE, GetInducedData);
478 ADD("MakeInducedSchreyerOrdering", FALSE, MakeInducedSchreyerOrdering);
479
480 ADD("idPrepare", FALSE, idPrepare);
481
482#undef ADD
483 return MAX_TOK;
484}
static BOOLEAN GetInducedData(leftv res, leftv h)
?
Definition: mod_main.cc:269
static BOOLEAN idPrepare(leftv res, leftv h)
Get raw syzygies (idPrepare)
Definition: mod_main.cc:373
#define ADD(C, D, E)
static BOOLEAN leadcomp(leftv res, leftv h)
Get leading component.
Definition: mod_main.cc:212
static BOOLEAN _ClearDenominators(leftv res, leftv h)
wrapper around n_ClearDenominators
Definition: mod_main.cc:121
static BOOLEAN SetInducedReferrence(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition: mod_main.cc:325
static BOOLEAN MakeInducedSchreyerOrdering(leftv res, leftv h)
Same for Induced Schreyer ordering (ordering on components is defined by sign!)
Definition: mod_main.cc:244
static BOOLEAN _ClearContent(leftv res, leftv h)
wrapper around n_ClearContent
Definition: mod_main.cc:75
@ MAX_TOK
Definition: tok.h:218

◆ view()

static void view ( const intvec v)
inlinestatic

Definition at line 189 of file mod_main.cc.

190{
191#ifndef SING_NDEBUG
192 v->view();
193#else
194 // This code duplication is only due to Hannes's #ifndef SING_NDEBUG!
195 Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", v->rows(), v->cols(), v->length());
196
197 for (int i = 0; i < v->rows(); i++)
198 {
199 Print ("Row[%3d]:", i);
200 for (int j = 0; j < v->cols(); j++)
201 Print (" %5d", (*v)[j + i * (v->cols())] );
202 PrintLn ();
203 }
204 PrintS ("}\n");
205#endif
206
207}
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