Loading...
Searching...
No Matches
kstdhelper.cc File Reference
`#include "kernel/mod2.h"`
`#include "coeffs/bigintmat.h"`
`#include "coeffs/longrat.h"`
`#include "misc/options.h"`
`#include "misc/intvec.h"`
`#include "reporter/si_signals.h"`
`#include "kernel/polys.h"`
`#include "polys/ext_fields/transext.h"`
`#include "kernel/GBEngine/kutil.h"`
`#include "kernel/GBEngine/kstd1.h"`
`#include "kernel/GBEngine/khstd.h"`
`#include "kernel/ideals.h"`
`#include "kernel/combinatorics/hilb.h"`
`#include "kernel/combinatorics/stairc.h"`
`#include "Singular/ipid.h"`
`#include "Singular/cntrlc.h"`
`#include "Singular/links/ssiLink.h"`
`#include "Singular/feOpt.h"`

Go to the source code of this file.

## Macros

#define | TRANSEXT_PRIVATES

## Functions

static int | kFindLuckyPrime (ideal F, ideal Q)
poly | kTryHC (ideal F, ideal Q)
static number | nMapQa2Zp (number a, const coeffs src, const coeffs dst)
static number | nMapZpa2Zp (number a, const coeffs src, const coeffs dst)
static ideal | kTryHilbstd_homog (ideal F, ideal Q)
static ideal | kTryHilbstd_nonhomog (ideal F, ideal Q)
ideal | kTryHilbstd (ideal F, ideal Q)
ideal | kTryHilbstd_par (ideal F, ideal Q, tHomog h, intvec **mw)

## Macro Definition Documentation

## TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES

Definition at line 17 of file kstdhelper.cc.

## Function Documentation

## kFindLuckyPrime()

int kFindLuckyPrime | ( | ideal | F,
|  | ideal | Q )

static

Definition at line 31 of file kstdhelper.cc.

{
int prim=32003;
// assume coeff are in Q
return prim;
}

## kTryHC()

poly kTryHC | ( | ideal | F,
|  | ideal | Q )

Definition at line 38 of file kstdhelper.cc.

{
if (Q!=NULL)
return NULL;
int prim=kFindLuckyPrime(F,Q);
if (TEST_OPT_PROT) Print("try HC in ring over ZZ/%d\n",prim);
// create Zp_ring
ring save_ring=currRing;
ring Zp_ring=rCopy0(save_ring);
nKillChar(Zp_ring->cf);
Zp_ring->cf=nInitChar(n_Zp, (void*)(long)prim);
rComplete(Zp_ring);
// map data
rChangeCurrRing(Zp_ring);
nMapFunc nMap=n_SetMap(save_ring->cf,Zp_ring->cf);
if (nMap==NULL) return NULL;
ideal FF=id_PermIdeal(F,1,IDELEMS(F),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
ideal QQ=NULL;
if (Q!=NULL) QQ=id_PermIdeal(Q,1,IDELEMS(Q),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
// call std
kStrategy strat=new skStrategy;
strat->LazyPass=20;
strat->LazyDegree = 1;
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
strat->homog = (tHomog)idHomIdeal(F,Q);
ideal res=mora(FF,QQ,NULL,NULL,strat);
// clean
idDelete(&FF);
poly HC=NULL;
if (strat->kNoether!=NULL) scComputeHC(res,QQ,0,HC);
delete strat;
if (QQ!=NULL) idDelete(&QQ);
idDelete(&res);
// map back
rChangeCurrRing(save_ring);
if (HC!=NULL)
{
//p_IncrExp(HC,Zp_ring->N,Zp_ring);
for (int i=rVar(Zp_ring)-1; i>0; i--)
{
int e;
if ((e=pGetExp(HC, i)) > 0) pSetExp(HC,i,e-1);
}
p_Setm(HC,Zp_ring);
if (TEST_OPT_PROT) Print("HC(%ld) found\n",pTotaldegree(HC));
pSetCoeff0(HC,nInit(1));
}
else
{
if (TEST_OPT_PROT) PrintS("HC not found\n");
}
rDelete(Zp_ring);
return HC;
}
i
int i
Definition cfEzgcd.cc:132
skStrategy
Definition kutil.h:276
skStrategy::kModW
intvec * kModW
Definition kutil.h:334
skStrategy::kNoether
poly kNoether
Definition kutil.h:328
skStrategy::kHomW
intvec * kHomW
Definition kutil.h:335
skStrategy::LazyPass
int LazyPass
Definition kutil.h:352
skStrategy::LazyDegree
int LazyDegree
Definition kutil.h:352
skStrategy::homog
char homog
Definition kutil.h:369
n_Zp
@ n_Zp
\F{p < 2^31}
Definition coeffs.h:29
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
nKillChar
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:563
Print
#define Print
Definition emacs.cc:80
res
CanonicalForm res
Definition facAbsFact.cc:60
scComputeHC
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition hdegree.cc:1074
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
idHomIdeal
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
mora
ideal mora(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd1.cc:1887
kHomW
VAR intvec * kHomW
Definition kstd1.cc:2409
kModW
VAR intvec * kModW
Definition kstd1.cc:2409
kFindLuckyPrime
static int kFindLuckyPrime(ideal F, ideal Q)
Definition kstdhelper.cc:31
pSetCoeff0
#define pSetCoeff0(p, n)
Definition monomials.h:59
nInit
#define nInit(i)
Definition numbers.h:24
NULL
#define NULL
Definition omList.c:12
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pTotaldegree
static long pTotaldegree(poly p)
Definition polys.h:283
pGetExp
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
pSetExp
#define pSetExp(p, i, v)
Definition polys.h:43
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
rComplete
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3527
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
id_PermIdeal
ideal id_PermIdeal(ideal I, int R, int C, const int *perm, const ring src, const ring dst, nMapFunc nMap, const int *par_perm, int P, BOOLEAN use_mult)
mapping ideals/matrices to other rings
Definition simpleideals.cc:2219
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
Q
#define Q
Definition sirandom.c:26
tHomog
tHomog
Definition structs.h:31
kStrategy
skStrategy * kStrategy
Definition structs.h:54

## kTryHilbstd()

ideal kTryHilbstd | ( | ideal | F,
|  | ideal | Q )

Definition at line 323 of file kstdhelper.cc.

{
if (rField_is_Ring(currRing)) return NULL;
if(!TEST_V_PURE_GB)
{
tHomog h = (tHomog)id_HomIdealDP(F,Q,currRing);
if (h==(tHomog)TRUE) return kTryHilbstd_homog(F,Q);
if((!rField_is_Q(currRing))
&&(!rField_is_Zp(currRing))
) return NULL;
if (h==(tHomog)FALSE) return kTryHilbstd_nonhomog(F,Q);
}
return NULL;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
h
STATIC_VAR Poly * h
Definition janet.cc:971
kTryHilbstd_nonhomog
static ideal kTryHilbstd_nonhomog(ideal F, ideal Q)
Definition kstdhelper.cc:175
kTryHilbstd_homog
static ideal kTryHilbstd_homog(ideal F, ideal Q)
Definition kstdhelper.cc:113
TEST_V_PURE_GB
#define TEST_V_PURE_GB
Definition options.h:137
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
id_HomIdealDP
BOOLEAN id_HomIdealDP(ideal id, ideal Q, const ring r)
Definition simpleideals.cc:1059

## kTryHilbstd_homog()

ideal kTryHilbstd_homog | ( | ideal | F,
|  | ideal | Q )

static

Definition at line 113 of file kstdhelper.cc.

{
// create Zp_ring
ring save_ring=currRing;
BITSET save_opt;SI_SAVE_OPT1(save_opt);
int prim=kFindLuckyPrime(F,Q);
//if(nCoeff_is_transExt(save_ring->cf)
//&&(nCoeff_is_Zp(save_ring->cf->extRing->cf)))
// prim=save_ring->cf->extRing->cf->ch;
if(nCoeff_is_Zp(save_ring->cf))
prim=save_ring->cf->ch;
coeffs cf=nInitChar(n_Zp, (void*)(long)prim);
ring Zp_ring=rDefault(cf,save_ring->N,save_ring->names,ringorder_dp);
// map data
nMapFunc nMap=n_SetMap(save_ring->cf,Zp_ring->cf);
if (nMap==NULL)
{
if (nCoeff_is_transExt(save_ring->cf))
{
if (nCoeff_is_Q(save_ring->cf->extRing->cf))
nMap=nMapQa2Zp;
else if (nCoeff_is_Zp(save_ring->cf->extRing->cf))
nMap=nMapZpa2Zp;
else
{
SI_RESTORE_OPT1(save_opt);
return NULL;
}
}
else
{
SI_RESTORE_OPT1(save_opt);
return NULL;
}
}
rChangeCurrRing(Zp_ring);
ideal FF=id_PermIdeal(F,1,IDELEMS(F),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
ideal QQ=NULL;
if (Q!=NULL) QQ=id_PermIdeal(Q,1,IDELEMS(Q),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
// compute GB in Zp_ring
si_opt_1&= ~Sy_bit(OPT_REDSB);
si_opt_1&= ~Sy_bit(OPT_REDTAIL);
if(TEST_OPT_PROT) Print("std in char. %d ------------------\n",prim);
ideal GB=kStd_internal(FF,QQ,(tHomog)TRUE,NULL,NULL,0,0,NULL,NULL);
// compute hilb
bigintmat* hilb=hFirstSeries0b(GB,QQ,NULL,NULL,Zp_ring,coeffs_BIGINT);
// clean up Zp_ring
rChangeCurrRing(save_ring);
id_Delete(&GB,Zp_ring);
id_Delete(&FF,Zp_ring);
if (QQ!=NULL) id_Delete(&QQ,Zp_ring);
rDelete(Zp_ring);
// std with hilb
intvec *w=NULL;
if(TEST_OPT_PROT) PrintS("stdhilb in basering ------------------\n");
SI_RESTORE_OPT1(save_opt);
ideal result=kStd_internal(F,Q,(tHomog)TRUE,&w,hilb);
if (w!=NULL) delete w;
delete hilb;
return result;
}
BITSET
#define BITSET
Definition auxiliary.h:85
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
intvec
Definition intvec.h:24
nCoeff_is_Q
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition coeffs.h:801
nCoeff_is_Zp
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:795
nCoeff_is_transExt
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:913
result
return result
Definition facAbsBiFact.cc:76
w
const CanonicalForm & w
Definition facAbsFact.cc:51
hFirstSeries0b
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2019
kStd_internal
ideal kStd_internal(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
pure GB/SB computations
Definition kstd1.cc:2434
nMapQa2Zp
static number nMapQa2Zp(number a, const coeffs src, const coeffs dst)
Definition kstdhelper.cc:95
nMapZpa2Zp
static number nMapZpa2Zp(number a, const coeffs src, const coeffs dst)
Definition kstdhelper.cc:104
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
si_opt_1
VAR unsigned si_opt_1
Definition options.c:5
OPT_REDTAIL
#define OPT_REDTAIL
Definition options.h:92
SI_SAVE_OPT1
#define SI_SAVE_OPT1(A)
Definition options.h:21
SI_RESTORE_OPT1
#define SI_RESTORE_OPT1(A)
Definition options.h:24
OPT_REDSB
#define OPT_REDSB
Definition options.h:77
Sy_bit
#define Sy_bit(x)
Definition options.h:31
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
rDefault
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
ringorder_dp
@ ringorder_dp
Definition ring.h:79
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123

## kTryHilbstd_nonhomog()

ideal kTryHilbstd_nonhomog | ( | ideal | F,
|  | ideal | Q )

static

Definition at line 175 of file kstdhelper.cc.

{
int prim=kFindLuckyPrime(F,Q);
//if(nCoeff_is_transExt(save_ring->cf)
//&&(nCoeff_is_Zp(save_ring->cf->extRing->cf)))
// prim=save_ring->cf->extRing->cf->ch;
if(nCoeff_is_Zp(currRing->cf))
prim=currRing->cf->ch;
if(TEST_OPT_PROT) Print("std in char. %d, homogenized ------------------\n",prim);
// create Zp_ring, need 1 more variable
ring save_ring=currRing;
BITSET save_opt;SI_SAVE_OPT1(save_opt);
coeffs cf=nInitChar(n_Zp, (void*)(long)prim);
char **names=(char**)omAlloc0((currRing->N+1) * sizeof(char *));
for(int i=0;i<currRing->N;i++)
{
names[i]=omStrDup(currRing->names[i]);
}
names[currRing->N]=omStrDup("@");
ring Zp_ring=rDefault(cf,save_ring->N+1,names,ringorder_dp);
// map data
nMapFunc nMap=n_SetMap(save_ring->cf,Zp_ring->cf);
if (nMap==NULL) return NULL;
rChangeCurrRing(Zp_ring);
ideal FF=id_PermIdeal(F,1,IDELEMS(F),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
ideal QQ=NULL;
if (Q!=NULL) QQ=id_PermIdeal(Q,1,IDELEMS(Q),NULL,save_ring,Zp_ring,nMap,NULL,0,0);
// homogenize
ideal tmp=id_HomogenDP(FF,Zp_ring->N,Zp_ring);
id_Delete(&FF,Zp_ring);
FF=tmp;
if (QQ!=NULL)
{
tmp=id_HomogenDP(QQ,Zp_ring->N,Zp_ring);
id_Delete(&QQ,Zp_ring);
QQ=tmp;
}
// compute GB in Zp_ring
si_opt_1&= ~Sy_bit(OPT_REDSB);
si_opt_1&= ~Sy_bit(OPT_REDTAIL);
ideal GB=kStd_internal(FF,QQ,(tHomog)TRUE,NULL,NULL,0,0,NULL,NULL);
// compute hilb
bigintmat* hilb=hFirstSeries0b(GB,QQ,NULL,NULL,Zp_ring,coeffs_BIGINT);
// clean up Zp_ring
id_Delete(&GB,Zp_ring);
id_Delete(&FF,Zp_ring);
if (QQ!=NULL) id_Delete(&QQ,Zp_ring);
rChangeCurrRing(save_ring);
rDelete(Zp_ring);
//omFreeBin(Zp_ring,sip_sring_bin);
// create Q_ring
cf=nCopyCoeff(save_ring->cf);
int nblocks=rBlocks(save_ring)+1;
names=(char**)omAlloc0((save_ring->N+1) * sizeof(char *));
for(int i=0;i<save_ring->N;i++)
{
names[i]=omStrDup(save_ring->names[i]);
}
names[save_ring->N]=omStrDup("@");
rRingOrder_t *order = (rRingOrder_t *) omAlloc(nblocks* sizeof(rRingOrder_t));
int *block0 = (int *)omAlloc0(nblocks * sizeof(int));
int *block1 = (int *)omAlloc0(nblocks * sizeof(int));
int **wvhdl=(int**)omAlloc0(nblocks * sizeof(int *));
for (int j=0; j<nblocks-1; j++)
{
if (save_ring->wvhdl[j]!=NULL)
{
#ifdef HAVE_OMALLOC
wvhdl[j] = (int*) omMemDup(save_ring->wvhdl[j]);
#else
{
int l=save_ring->block1[j]-save_ring->block0[j]+1;
if (save_ring->order[j]==ringorder_a64) l*=2;
else if (save_ring->order[j]==ringorder_M) l=l*l;
else if (save_ring->order[j]==ringorder_am)
{
l+=save_ring->wvhdl[j][save_ring->block1[j]-save_ring->block0[j]+1]+1;
}
wvhdl[j]=(int*)omalloc(l*sizeof(int));
memcpy(wvhdl[j],save_ring->wvhdl[j],l*sizeof(int));
}
#endif
}
}
memcpy(order,save_ring->order,(nblocks-1) * sizeof(rRingOrder_t));
memcpy(block0,save_ring->block0,(nblocks-1) * sizeof(int));
memcpy(block1,save_ring->block1,(nblocks-1) * sizeof(int));
order[nblocks-1]=ringorder_lp;
block0[nblocks-1]=save_ring->N+1;
block1[nblocks-1]=save_ring->N+1;
ring Q_ring=rDefault(cf,save_ring->N+1,names,nblocks,order,block0,block1,wvhdl,save_ring->wanted_maxExp);
// map data
nMap=n_SetMap(save_ring->cf,Q_ring->cf);
if (nMap==NULL) return NULL;
rChangeCurrRing(Q_ring);
FF=id_PermIdeal(F,1,IDELEMS(F),NULL,save_ring,Q_ring,nMap,NULL,0,0);
QQ=NULL;
if (Q!=NULL) QQ=id_PermIdeal(Q,1,IDELEMS(Q),NULL,save_ring,Q_ring,nMap,NULL,0,0);
// homogenize
if(TEST_OPT_PROT) PrintS("stdhilb in basering, homogenized ------------------\n");
tmp=id_HomogenDP(FF,Q_ring->N,Q_ring);
id_Delete(&FF,Q_ring);
FF=tmp;
if (QQ!=NULL)
{
tmp=id_HomogenDP(QQ,Q_ring->N,Q_ring);
id_Delete(&QQ,Q_ring);
QQ=tmp;
}
// std with hilb
intvec *w=NULL;
tmp=kStd_internal(FF,QQ,testHomog,&w,hilb);
if (w!=NULL) delete w;
delete hilb;
// dehomogenize
if(TEST_OPT_PROT) PrintS("de-homogenize, interred ------------------\n");
poly one=pOne();
tmp=id_Subst(tmp,Q_ring->N,one,Q_ring);
p_Delete(&one,Q_ring);
// map back to save_ring
rChangeCurrRing(save_ring);
nMap=n_SetMap(Q_ring->cf,save_ring->cf);
GB=id_PermIdeal(tmp,1,IDELEMS(tmp),NULL,Q_ring,save_ring,nMap,NULL,0,0);
// clean up Q_ring
id_Delete(&FF,Q_ring);
if (QQ!=NULL) id_Delete(&QQ,Q_ring);
id_Delete(&tmp,Q_ring);
rDelete(Q_ring);
//omFreeBin(Q_ring,sip_sring_bin);
SI_RESTORE_OPT1(save_opt);
int dummy;
if (TEST_OPT_REDSB)
{
id_DelDiv(GB,currRing);
idSkipZeroes(GB);
ideal GB2=kInterRedBba(GB,currRing->qideal,dummy);
idDelete(&GB);
return GB2;
}
else
{
id_DelDiv(GB,currRing);
idSkipZeroes(GB);
return GB;
}
}
l
int l
Definition cfEzgcd.cc:100
nCopyCoeff
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition coeffs.h:439
j
int j
Definition facHensel.cc:110
kInterRedBba
ideal kInterRedBba(ideal F, ideal Q, int &need_retry)
Definition kstd1.cc:3551
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omalloc
#define omalloc(size)
Definition omAllocDecl.h:228
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
omMemDup
#define omMemDup(s)
Definition omAllocDecl.h:264
TEST_OPT_REDSB
#define TEST_OPT_REDSB
Definition options.h:106
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
pOne
#define pOne()
Definition polys.h:316
rBlocks
static int rBlocks(const ring r)
Definition ring.h:574
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_lp
@ ringorder_lp
Definition ring.h:78
ringorder_am
@ ringorder_am
Definition ring.h:90
ringorder_a64
@ ringorder_a64
for int64 weights
Definition ring.h:72
ringorder_M
@ ringorder_M
Definition ring.h:75
id_DelDiv
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
Definition simpleideals.cc:463
id_HomogenDP
ideal id_HomogenDP(ideal h, int varnum, const ring r)
Definition simpleideals.cc:1515
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201
id_Subst
ideal id_Subst(ideal id, int n, poly e, const ring r)
Definition simpleideals.cc:1709
testHomog
@ testHomog
Definition structs.h:34

## kTryHilbstd_par()

ideal kTryHilbstd_par | ( | ideal | F,
|  | ideal | Q,
|  | tHomog | h,
|  | intvec ** | mw )

Definition at line 338 of file kstdhelper.cc.

{
int cpus = (long) feOptValue(FE_OPT_CPUS);
if (cpus<1)
{
//WerrorS("no sub-processes allowed");
return NULL;
}
#if 0
if(!TEST_V_PURE_GB)
{
int cp_std[2];
int cp_hstd[2];
int err1=pipe(cp_std);// [0] is read , [1] is write
int err2=pipe(cp_hstd);
if (err1||err2)
{
Werror("pipe failed with %d\n",errno);
si_close(cp_std[0]);
si_close(cp_std[1]);
si_close(cp_hstd[0]);
si_close(cp_hstd[1]);
return NULL;
}
pid_t pid_std=fork();
if (pid_std==0) /*child std*/
{
si_set_signal(SIGTERM,sig_term_hdl_child);
si_close(cp_std[0]);
si_close(cp_hstd[0]);
si_close(cp_hstd[1]);
ssiInfo d;
memset(&d,0,sizeof(d));
d.f_write=fdopen(cp_std[1],"w");
d.fd_write=cp_std[1];
d.r=currRing;
si_opt_2|=Sy_bit(V_PURE_GB);
ideal res=kStd_internal(F,Q,h,mw);
ssiWriteIdeal(&d,IDEAL_CMD,res);
fclose(d.f_write);
_exit(0);
}
pid_t pid_hstd=fork();
if (pid_hstd==0) /*child hstd*/
{
si_set_signal(SIGTERM,sig_term_hdl_child);
si_close(cp_hstd[0]);
si_close(cp_std[0]);
si_close(cp_std[1]);
ssiInfo d;
memset(&d,0,sizeof(d));
d.f_write=fdopen(cp_hstd[1],"w");
d.fd_write=cp_hstd[1];
d.r=currRing;
si_opt_2|=Sy_bit(V_PURE_GB);
ideal res=kTryHilbstd(F,Q);
if (res!=NULL)
{
ssiWriteIdeal(&d,IDEAL_CMD,res);
}
fclose(d.f_write);
_exit(0);
}
/*parent*/
si_close(cp_std[1]);
si_close(cp_hstd[1]);
#ifdef HAVE_POLL
pollfd pfd[2];
pfd[0].fd=cp_std[0];
pfd[0].events=POLLIN;
pfd[1].fd=cp_hstd[0];
pfd[1].events=POLLIN;
int s=si_poll(pfd,2,-1); // wait infinite
ideal res;
ssiInfo d;
memset(&d,0,sizeof(d));
d.r=currRing;
if (s==1) //std
{
d.f_read=s_open(cp_std[0]);
d.fd_read=cp_std[0];
res=ssiReadIdeal(&d);
si_close(cp_hstd[0]);
s_close(d.f_read);
si_close(cp_std[0]);
kill(pid_hstd,SIGTERM);
si_waitpid(pid_std,NULL,0);
si_waitpid(pid_hstd,NULL,0);
}
else if(s==2)
{
d.f_read=s_open(cp_hstd[0]);
d.fd_read=cp_hstd[0];
res=ssiReadIdeal(&d);
si_close(cp_std[0]);
s_close(d.f_read);
si_close(cp_hstd[0]);
kill(pid_std,SIGTERM);
si_waitpid(pid_hstd,NULL,0);
si_waitpid(pid_std,NULL,0);
}
return res;
#endif
}
#endif
return NULL;
}
si_set_signal
si_hdl_typ si_set_signal(int sig, si_hdl_typ signal_handler)
meta function for binding a signal to an handler
Definition cntrlc.cc:121
sig_term_hdl_child
void sig_term_hdl_child(int)
Definition cntrlc.cc:86
s
const CanonicalForm int s
Definition facAbsFact.cc:51
feOptValue
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
kTryHilbstd
ideal kTryHilbstd(ideal F, ideal Q)
Definition kstdhelper.cc:323
si_opt_2
VAR unsigned si_opt_2
Definition options.c:6
V_PURE_GB
#define V_PURE_GB
Definition options.h:71
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
s_open
s_buff s_open(int fd)
Definition s_buff.cc:32
s_close
int s_close(s_buff &F)
Definition s_buff.cc:46
ssiInfo::fd_write
int fd_write
Definition s_buff.h:26
ssiInfo::f_read
s_buff f_read
Definition s_buff.h:22
ssiInfo::f_write
FILE * f_write
Definition s_buff.h:23
ssiInfo::r
ring r
Definition s_buff.h:24
ssiInfo::fd_read
int fd_read
Definition s_buff.h:26
ssiInfo
Definition s_buff.h:21
ssiReadIdeal
ideal ssiReadIdeal(ssiInfo *d)
Definition ssiLink.cc:1319
ssiWriteIdeal
void ssiWriteIdeal(const ssiInfo *d, int typ, const ideal I)
Definition ssiLink.cc:612

## nMapQa2Zp()

number nMapQa2Zp | ( | number | a,
|  | const coeffs | src,
|  | const coeffs | dst )

static

Definition at line 95 of file kstdhelper.cc.

{
if (a==NULL) return a;
fraction f=(fraction)a;
poly p=NUM(f);
while(pNext(p)!=NULL) pIter(p);
return nlModP(pGetCoeff(p),src->extRing->cf,dst);
}
p
int p
Definition cfModGcd.cc:4086
f
FILE * f
Definition checklibs.c:9
nlModP
number nlModP(number q, const coeffs, const coeffs Zp)
Definition longrat.cc:1572
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
NUM
#define NUM
Definition readcf.cc:180

## nMapZpa2Zp()

number nMapZpa2Zp | ( | number | a,
|  | const coeffs | src,
|  | const coeffs | dst )

static

Definition at line 104 of file kstdhelper.cc.

{
if (a==NULL) return a;
fraction f=(fraction)a;
poly p=NUM(f);
while(pNext(p)!=NULL) pIter(p);
return pGetCoeff(p);
}