My Project
Loading...
Searching...
No Matches
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)
 

Functions

static void NoReturn (leftv &res)
 
static BOOLEAN _ClearContent (leftv res, leftv h)
 wrapper around n_ClearContent
 
static BOOLEAN _ClearDenominators (leftv res, leftv h)
 wrapper around n_ClearDenominators
 
static number jjLONG2N (long d)
 
static void view (const intvec *v)
 
static BOOLEAN leadcomp (leftv res, leftv h)
 Get leading component.
 
static BOOLEAN MakeInducedSchreyerOrdering (leftv res, leftv h)
 Same for Induced Schreyer ordering (ordering on components is defined by sign!)
 
static BOOLEAN GetInducedData (leftv res, leftv h)
 ?
 
static BOOLEAN SetInducedReferrence (leftv res, leftv h)
 Returns old SyzCompLimit, can set new limit.
 
static BOOLEAN idPrepare (leftv res, leftv h)
 Get raw syzygies (idPrepare)
 
int SI_MOD_INIT syzextra (SModulFunctions *psModulFunctions)
 

Macro Definition Documentation

◆ ADD

#define ADD ( C,
D,
E )
Value:
psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
REvaluation E(1, terms.length(), IntRandom(25))
#define D(A)
Definition gentable.cc:128
VAR package currPack
Definition ipid.cc:55

Function Documentation

◆ _ClearContent()

static BOOLEAN _ClearContent ( leftv res,
leftv h )
static

wrapper around n_ClearContent

Definition at line 49 of file mod_main.cc.

50{
52
53 const char *usage = "'ClearContent' needs a (non-zero!) poly or vector argument...";
54
55 if( h == NULL )
56 {
57 WarnS(usage);
58 return TRUE;
59 }
60
61 assume( h != NULL );
62
63 if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
64 {
65 WarnS(usage);
66 return TRUE;
67 }
68
69 assume (h->Next() == NULL);
70
71 poly ph = reinterpret_cast<poly>(h->Data());
72
73 if( ph == NULL )
74 {
75 WarnS(usage);
76 return TRUE;
77 }
78
79 const ring r = currRing;
80 assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
81
82 number n;
83
84 // experimentall (recursive enumerator treatment) of alg. ext
86 n_ClearContent(itr, n, C);
87
88 res->data = n;
89 res->rtyp = NUMBER_CMD;
90
91 return FALSE;
92}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
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:293
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
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:42

◆ _ClearDenominators()

static BOOLEAN _ClearDenominators ( leftv res,
leftv h )
static

wrapper around n_ClearDenominators

Definition at line 95 of file mod_main.cc.

96{
98
99 const char *usage = "'ClearDenominators' needs a (non-zero!) poly or vector argument...";
100
101 if( h == NULL )
102 {
103 WarnS(usage);
104 return TRUE;
105 }
106
107 assume( h != NULL );
108
109 if( !( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD) )
110 {
111 WarnS(usage);
112 return TRUE;
113 }
114
115 assume (h->Next() == NULL);
116
117 poly ph = reinterpret_cast<poly>(h->Data());
118
119 if( ph == NULL )
120 {
121 WarnS(usage);
122 return TRUE;
123 }
124
125 const ring r = currRing;
126 assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
127
128 number n;
129
130 // experimentall (recursive enumerator treatment) of alg. ext.
131 CPolyCoeffsEnumerator itr(ph);
132 n_ClearDenominators(itr, n, C);
133
134 res->data = n;
135 res->rtyp = NUMBER_CMD;
136
137 return FALSE;
138}
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 244 of file mod_main.cc.

245{
246 const ring r = currRing;
247
248 int p = 0; // which IS-block? p^th!
249
250 if ((h!=NULL) && (h->Typ()==INT_CMD))
251 {
252 p = (int)((long)(h->Data())); h=h->next;
253 assume(p >= 0);
254 }
255
256 const int pos = rGetISPos(p, r);
257
258 if( /*(*/ -1 == pos /*)*/ )
259 {
260 WerrorS("`GetInducedData([int])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
261 return TRUE;
262 }
263
264
265 const int iLimit = r->typ[pos].data.is.limit;
266 const ideal F = r->typ[pos].data.is.F;
267
268 ideal FF = id_Copy(F, r);
269
271 l->Init(2);
272
273 l->m[0].rtyp = INT_CMD;
274 l->m[0].data = reinterpret_cast<void *>(iLimit);
275
276
277 // l->m[1].rtyp = MODUL_CMD;
278
279 if( id_IsModule(FF, r) ) // ???
280 {
281 l->m[1].rtyp = MODUL_CMD;
282
283 // Print("before: %d\n", FF->nrows);
284 // FF->nrows = id_RankFreeModule(FF, r); // ???
285 // Print("after: %d\n", FF->nrows);
286 }
287 else
288 l->m[1].rtyp = IDEAL_CMD;
289
290 l->m[1].data = reinterpret_cast<void *>(FF);
291
292 res->rtyp = LIST_CMD; // list of int/module
293 res->data = reinterpret_cast<void *>(l);
294
295 return FALSE;
296
297}
int l
Definition cfEzgcd.cc:100
int p
Definition cfModGcd.cc:4086
void WerrorS(const char *s)
Definition feFopen.cc:24
@ IDEAL_CMD
Definition grammar.cc:285
@ MODUL_CMD
Definition grammar.cc:288
ideal id_Copy(ideal h1, const ring r)
copy an ideal
VAR omBin slists_bin
Definition lists.cc:23
slists * lists
#define omAllocBin(bin)
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:5144
BOOLEAN id_IsModule(ideal A, const ring src)
@ LIST_CMD
Definition tok.h:118
@ INT_CMD
Definition tok.h:96

◆ idPrepare()

static BOOLEAN idPrepare ( leftv res,
leftv h )
static

Get raw syzygies (idPrepare)

Definition at line 348 of file mod_main.cc.

349{
350 // extern int rGetISPos(const int p, const ring r);
351
352 const ring r = currRing;
353
354 const bool isSyz = rIsSyzIndexRing(r);
355 const int posIS = rGetISPos(0, r);
356
357
358 if ( !( (h!=NULL) && (h->Typ()==MODUL_CMD) && (h->Data() != NULL) ) )
359 {
360 WerrorS("`idPrepare(<module>)` expected");
361 return TRUE;
362 }
363
364 const ideal I = reinterpret_cast<ideal>(h->Data());
365
366 assume( I != NULL );
367 idTest(I);
368
369 int iComp = -1;
370
371 h=h->next;
372 if ( (h!=NULL) && (h->Typ()==INT_CMD) )
373 {
374 iComp = (int)((long)(h->Data()));
375 }
376 else
377 {
378 if( (!isSyz) && (-1 == posIS) )
379 {
380 WerrorS("`idPrepare(<...>)` called on incompatible ring (not created by 'MakeSyzCompOrdering' or 'MakeInducedSchreyerOrdering'!)");
381 return TRUE;
382 }
383
384 if( isSyz )
385 iComp = rGetCurrSyzLimit(r);
386 else
387 iComp = id_RankFreeModule(r->typ[posIS].data.is.F, r); // ;
388 }
389
390 assume(iComp >= 0);
391
392
393 intvec* w = reinterpret_cast<intvec *>(atGet(h, "isHomog", INTVEC_CMD));
394 tHomog hom = testHomog;
395
396 // int add_row_shift = 0;
397 //
398 if (w!=NULL)
399 {
400 w = ivCopy(w);
401 // add_row_shift = ww->min_in();
402 //
403 // (*ww) -= add_row_shift;
404 //
405 // if (idTestHomModule(I, currRing->qideal, ww))
406 // {
407 hom = isHomog;
408 // w = ww;
409 // }
410 // else
411 // {
412 // //WarnS("wrong weights");
413 // delete ww;
414 // w = NULL;
415 // hom=testHomog;
416 // }
417 }
418
419
420 // computes syzygies of h1,
421 // works always in a ring with ringorder_s
422 // NOTE: rSetSyzComp(syzcomp) should better be called beforehand
423 // ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w);
424
425 ideal J = // idPrepare( I, hom, iComp, &w);
426 kStd2(I, currRing->qideal, hom, &w, (bigintmat*)NULL, iComp);
427
428 idTest(J);
429
430 if (w!=NULL)
431 atSet(res, omStrDup("isHomog"), w, INTVEC_CMD);
432 // if (w!=NULL) delete w;
433
434 res->rtyp = MODUL_CMD;
435 res->data = reinterpret_cast<void *>(J);
436 return FALSE;
437}
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
Matrices of numbers.
Definition bigintmat.h:51
const CanonicalForm & w
Definition facAbsFact.cc:51
#define idTest(id)
Definition ideals.h:47
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2602
#define omStrDup(s)
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:729
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition ring.h:726
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
tHomog
Definition structs.h:31
@ isHomog
Definition structs.h:33
@ testHomog
Definition structs.h:34
@ INTVEC_CMD
Definition tok.h:101

◆ jjLONG2N()

static number jjLONG2N ( long d)
inlinestatic

Definition at line 159 of file mod_main.cc.

160{
161 return n_Init(d, coeffs_BIGINT);
162}
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
VAR coeffs coeffs_BIGINT
Definition polys.cc:14

◆ leadcomp()

static BOOLEAN leadcomp ( leftv res,
leftv h )
static

Get leading component.

Definition at line 187 of file mod_main.cc.

188{
189 if ((h!=NULL) && (h->Typ()==VECTOR_CMD || h->Typ()==POLY_CMD))
190 {
191 const ring r = currRing;
192
193 const poly p = (poly)(h->Data());
194
195 if (p != NULL )
196 {
197 assume( p != NULL );
198 p_LmTest(p, r);
199
200 const unsigned long iComp = p_GetComp(p, r);
201
202 // assume( iComp > 0 ); // p is a vector
203
204 res->data = reinterpret_cast<void *>(jjLONG2N(iComp));
205 }
206 else
207 res->data = reinterpret_cast<void *>(jjLONG2N(0));
208
209
210 res->rtyp = BIGINT_CMD;
211 return FALSE;
212 }
213
214 WerrorS("`leadcomp(<poly/vector>)` expected");
215 return TRUE;
216}
#define p_GetComp(p, r)
Definition monomials.h:64
#define p_LmTest(p, r)
Definition p_polys.h:162
static number jjLONG2N(long d)
Definition mod_main.cc:159
@ 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 219 of file mod_main.cc.

220{
221 int sign = 1;
222 if ((h!=NULL) && (h->Typ()==INT_CMD))
223 {
224 const int s = (int)((long)(h->Data()));
225
226 if( s != -1 && s != 1 )
227 {
228 WerrorS("`MakeInducedSchreyerOrdering(<int>)` called with wrong integer argument (must be +-1)!");
229 return TRUE;
230 }
231
232 sign = s;
233 }
234
235 assume( sign == 1 || sign == -1 );
236 res->data = reinterpret_cast<void *>(rAssure_InducedSchreyerOrdering(currRing, TRUE, sign));
237 res->rtyp = RING_CMD; // return new ring!
238 // QRING_CMD?
239 return FALSE;
240}
const CanonicalForm int s
Definition facAbsFact.cc:51
@ RING_CMD
Definition grammar.cc:282
ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sgn)
Definition ring.cc:4989
static int sign(int x)
Definition ring.cc:3503

◆ NoReturn()

static void NoReturn ( leftv & res)
inlinestatic

Definition at line 42 of file mod_main.cc.

43{
44 res->rtyp = NONE;
45 res->data = NULL;
46}
#define NONE
Definition tok.h:223

◆ SetInducedReferrence()

static BOOLEAN SetInducedReferrence ( leftv res,
leftv h )
static

Returns old SyzCompLimit, can set new limit.

Definition at line 300 of file mod_main.cc.

301{
302 res->Init();
303 NoReturn(res);
304
305 const ring r = currRing;
306
307 if( !( (h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD))) )
308 {
309 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` expected");
310 return TRUE;
311 }
312
313 const ideal F = (ideal)h->Data(); ; // No copy!
314 h=h->next;
315
316 int rank = 0;
317
318 if ((h!=NULL) && (h->Typ()==INT_CMD))
319 {
320 rank = (int)((long)(h->Data())); h=h->next;
321 assume(rank >= 0);
322 } else
323 rank = id_RankFreeModule(F, r); // Starting syz-comp (1st: i+1)
324
325 int p = 0; // which IS-block? p^th!
326
327 if ((h!=NULL) && (h->Typ()==INT_CMD))
328 {
329 p = (int)((long)(h->Data())); h=h->next;
330 assume(p >= 0);
331 }
332
333 const int posIS = rGetISPos(p, r);
334
335 if( /*(*/ -1 == posIS /*)*/ )
336 {
337 WerrorS("`SetInducedReferrence(<ideal/module>, [int[, int]])` called on incompatible ring (not created by 'MakeInducedSchreyerOrdering'!)");
338 return TRUE;
339 }
340
341 // F & componentWeights belong to that ordering block of currRing now:
342 rSetISReference(r, F, rank, p); // F will be copied!
343 return FALSE;
344}
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:5176

◆ syzextra()

int SI_MOD_INIT syzextra ( SModulFunctions * psModulFunctions)

Definition at line 439 of file mod_main.cc.

440{
441
442#define ADD(C,D,E) \
443 psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""), (char*)C, D, E);
444
445
446 ADD("ClearContent", FALSE, _ClearContent);
447 ADD("ClearDenominators", FALSE, _ClearDenominators);
448
449 ADD("leadcomp", FALSE, leadcomp);
450
451 ADD("SetInducedReferrence", FALSE, SetInducedReferrence);
452 ADD("GetInducedData", FALSE, GetInducedData);
453 ADD("MakeInducedSchreyerOrdering", FALSE, MakeInducedSchreyerOrdering);
454
455 ADD("idPrepare", FALSE, idPrepare);
456
457#undef ADD
458 return MAX_TOK;
459}
static ideal idPrepare(ideal h1, ideal h11, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition ideals.cc:613
static BOOLEAN GetInducedData(leftv res, leftv h)
?
Definition mod_main.cc:244
#define ADD(C, D, E)
static BOOLEAN leadcomp(leftv res, leftv h)
Get leading component.
Definition mod_main.cc:187
static BOOLEAN _ClearDenominators(leftv res, leftv h)
wrapper around n_ClearDenominators
Definition mod_main.cc:95
static BOOLEAN SetInducedReferrence(leftv res, leftv h)
Returns old SyzCompLimit, can set new limit.
Definition mod_main.cc:300
static BOOLEAN MakeInducedSchreyerOrdering(leftv res, leftv h)
Same for Induced Schreyer ordering (ordering on components is defined by sign!)
Definition mod_main.cc:219
static BOOLEAN _ClearContent(leftv res, leftv h)
wrapper around n_ClearContent
Definition mod_main.cc:49
@ MAX_TOK
Definition tok.h:220

◆ view()

static void view ( const intvec * v)
inlinestatic

Definition at line 164 of file mod_main.cc.

165{
166#ifndef SING_NDEBUG
167 v->view();
168#else
169 // This code duplication is only due to Hannes's #ifndef SING_NDEBUG!
170 Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", v->rows(), v->cols(), v->length());
171
172 for (int i = 0; i < v->rows(); i++)
173 {
174 Print ("Row[%3d]:", i);
175 for (int j = 0; j < v->cols(); j++)
176 Print (" %5d", (*v)[j + i * (v->cols())] );
177 PrintLn ();
178 }
179 PrintS ("}\n");
180#endif
181
182}
int i
Definition cfEzgcd.cc:132
#define Print
Definition emacs.cc:80
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
int j
Definition facHensel.cc:110
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310