Loading...
Searching...
No Matches
kverify.h File Reference
`#include "polys/simpleideals.h"`

Go to the source code of this file.

## Functions

BOOLEAN | kVerify1 (ideal F, ideal Q)
BOOLEAN | kVerify2 (ideal F, ideal Q)

## Function Documentation

## kVerify1()

BOOLEAN kVerify1 | ( | ideal | F,
|  | ideal | Q )

Definition at line 24 of file kverify.cc.

{
assume (!rIsNCRing(currRing));
kStrategy strat=new skStrategy;
strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
initBuchMoraPos(strat);
initBba(strat);
initBuchMora(F, Q,strat);
/*initBuchMora:*/
strat->tail = pInit();
/*- set s -*/
strat->sl = -1;
/*- set L -*/
strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
strat->Ll = -1;
strat->L = initL(strat->Lmax);
/*- set B -*/
strat->Bmax = setmaxL;
strat->Bl = -1;
strat->B = initL();
/*- set T -*/
strat->tl = -1;
strat->tmax = setmaxT;
strat->T = initT();
strat->R = initR();
strat->sevT = initsevT();
/*- init local data struct.---------------------------------------- -*/
strat->P.ecart=0;
strat->P.length=0;
strat->P.pLength=0;
initS(F, Q,strat); /*sets also S, ecartS, fromQ */
strat->fromT = FALSE;
strat->noTailReduction = FALSE;
/*----------------------------------------------------------------------*/
/* build pairs */
if (strat->fromQ!=NULL)
{
for(int i=1; i<=strat->sl;i++)
{
initenterpairs(strat->S[i],i-1,0,strat->fromQ[i],strat);
}
}
else
{
for(int i=1; i<=strat->sl;i++)
{
initenterpairs(strat->S[i],i-1,0,FALSE,strat);
}
}
if (TEST_OPT_PROT) printf("%d pairs created\n",strat->Ll+1);
if (TEST_OPT_DEBUG) messageSets(strat);
/*---------------------------------------------------------------------*/
BOOLEAN all_okay=TRUE;
for(int i=strat->Ll;i>=0; i--)
{
/* spolys */
int red_result=1;
/* picks the last element from the lazyset L */
strat->P = strat->L[i];
if (pNext(strat->P.p) == strat->tail)
{
// deletes the short spoly
pLmFree(strat->P.p);
strat->P.p = NULL;
poly m1 = NULL, m2 = NULL;
kCheckSpolyCreation(&(strat->P), strat, m1, m2);
ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
strat->tailRing, m1, m2, strat->R);
}
if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
{
red_result = 0;
}
else
{
if (TEST_OPT_DEGBOUND
&& (currRing->pFDeg(strat->P.p,currRing)>Kstd1_deg))
{
/*
* omit pair
* if 24 IN test and the degree of P is bigger then
*a predefined number Kstd1_deg
*/
strat->P.Delete();
red_result=0;
if (TEST_OPT_PROT) { printf("D"); mflush(); }
}
else
{
int sl=strat->sl;
strat->P.GetP();
poly p=redNF(strat->P.p,sl,TRUE,strat);
if (p==NULL) red_result=0;
#ifdef KDEBUG
else
{
if (TEST_OPT_DEBUG)
{
printf("p: ");p_wrp(p,currRing, currRing); printf("\n");
}
}
#endif
}
}
if (red_result!=0)
{
if (TEST_OPT_PROT) printf("fail: %d, result: %d\n",i,red_result);
all_okay=FALSE;
}
}
return all_okay;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
skStrategy
Definition kutil.h:276
skStrategy::kModW
intvec * kModW
Definition kutil.h:334
skStrategy::tailRing
ring tailRing
Definition kutil.h:342
skStrategy::noTailReduction
char noTailReduction
Definition kutil.h:375
skStrategy::Ll
int Ll
Definition kutil.h:350
skStrategy::T
TSet T
Definition kutil.h:325
skStrategy::Bl
int Bl
Definition kutil.h:351
skStrategy::S
polyset S
Definition kutil.h:305
skStrategy::B
LSet B
Definition kutil.h:327
skStrategy::ak
int ak
Definition kutil.h:352
skStrategy::R
TObject ** R
Definition kutil.h:339
skStrategy::tl
int tl
Definition kutil.h:349
skStrategy::sevT
unsigned long * sevT
Definition kutil.h:324
skStrategy::kHomW
intvec * kHomW
Definition kutil.h:335
skStrategy::tail
poly tail
Definition kutil.h:333
skStrategy::tmax
int tmax
Definition kutil.h:349
skStrategy::fromQ
intset fromQ
Definition kutil.h:320
skStrategy::use_buckets
char use_buckets
Definition kutil.h:380
skStrategy::fromT
char fromT
Definition kutil.h:376
skStrategy::P
LObject P
Definition kutil.h:301
skStrategy::Lmax
int Lmax
Definition kutil.h:350
skStrategy::L
LSet L
Definition kutil.h:326
skStrategy::sl
int sl
Definition kutil.h:347
skStrategy::Bmax
int Bmax
Definition kutil.h:351
initT
KINLINE TSet initT()
Definition kInline.h:84
initR
KINLINE TObject ** initR()
Definition kInline.h:95
initsevT
KINLINE unsigned long * initsevT()
Definition kInline.h:100
ksCreateSpoly
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition kspoly.cc:1203
initBba
void initBba(kStrategy strat)
Definition kstd1.cc:1690
kHomW
VAR intvec * kHomW
Definition kstd1.cc:2409
kModW
VAR intvec * kModW
Definition kstd1.cc:2409
Kstd1_deg
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
redNF
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2307
initBuchMora
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9749
initBuchMoraPos
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9580
initenterpairs
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:3809
initS
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7586
kCheckSpolyCreation
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10459
initBuchMoraCrit
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
messageSets
void messageSets(kStrategy strat)
Definition kutil.cc:7536
setmaxL
#define setmaxL
Definition kutil.h:31
initL
static LSet initL(int nr=setmaxL)
Definition kutil.h:417
setmaxT
#define setmaxT
Definition kutil.h:34
setmaxLinc
#define setmaxLinc
Definition kutil.h:32
assume
#define assume(x)
Definition mod2.h:389
pNext
#define pNext(p)
Definition monomials.h:36
NULL
#define NULL
Definition omList.c:12
TEST_OPT_DEGBOUND
#define TEST_OPT_DEGBOUND
Definition options.h:115
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
TEST_OPT_DEBUG
#define TEST_OPT_DEBUG
Definition options.h:110
p_wrp
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pLmFree
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
pInit
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
mflush
#define mflush()
Definition reporter.h:58
rIsNCRing
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
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:992
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
Q
#define Q
Definition sirandom.c:26
kStrategy
skStrategy * kStrategy
Definition structs.h:54

## kVerify2()

BOOLEAN kVerify2 | ( | ideal | F,
|  | ideal | Q )

Definition at line 141 of file kverify.cc.

{
#ifdef HAVE_VSPACE
assume (!rIsNCRing(currRing));
kStrategy strat=new skStrategy;
strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
initBuchMoraPos(strat);
initBba(strat);
initBuchMora(F, Q,strat);
/*initBuchMora:*/
strat->tail = pInit();
/*- set s -*/
strat->sl = -1;
/*- set L -*/
strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
strat->Ll = -1;
strat->L = initL(strat->Lmax);
/*- set B -*/
strat->Bmax = setmaxL;
strat->Bl = -1;
strat->B = initL();
/*- set T -*/
strat->tl = -1;
strat->tmax = setmaxT;
strat->T = initT();
strat->R = initR();
strat->sevT = initsevT();
/*- init local data struct.---------------------------------------- -*/
strat->P.ecart=0;
strat->P.length=0;
strat->P.pLength=0;
initS(F, Q,strat); /*sets also S, ecartS, fromQ */
strat->fromT = FALSE;
strat->noTailReduction = FALSE;
/*----------------------------------------------------------------------*/
/* build pairs */
if (strat->fromQ!=NULL)
{
for(int i=1; i<=strat->sl;i++)
{
initenterpairs(strat->S[i],i-1,0,strat->fromQ[i],strat);
}
}
else
{
for(int i=1; i<=strat->sl;i++)
{
initenterpairs(strat->S[i],i-1,0,FALSE,strat);
}
}
if (TEST_OPT_PROT) printf("%d pairs created\n",strat->Ll+1);
if (TEST_OPT_DEGBOUND)
{
for(int i=strat->Ll; i>=0; i--)
{
if (currRing->pFDeg(strat->L[i].p,currRing)>Kstd1_deg)
{
/*
* omit pairs if 24 IN test and the degree of L[i] is bigger then
*a predefined number Kstd1_deg
*/
deleteInL(strat->L,&strat->Ll,i,strat);
if (TEST_OPT_PROT) { printf("D"); mflush(); }
}
}
}
if (TEST_OPT_DEBUG) messageSets(strat);
/*---------------------------------------------------------------------*/
BOOLEAN all_okay=TRUE;
int cpus=(int)(long)feOptValue(FE_OPT_CPUS);
if (cpus>=vspace::internals::MAX_PROCESS)
cpus=vspace::internals::MAX_PROCESS-1;
/* start no more than MAX_PROCESS-1 children */
if (cpus>strat->Ll+1) cpus=strat->Ll+1;
/* start no more children than elements in L */
int parent_pid=getpid();
using namespace vspace;
vmem_init();
// Create a queue of int
VRef<Queue<int> > queue = vnew<Queue<int> >();
VRef<Queue<int> > rqueue = vnew<Queue<int> >();
for(int i=strat->Ll;i>=0; i--)
{
queue->enqueue(i); // the tasks: process pair L[i]
}
for(int i=cpus*2;i>=0;i--)
{
queue->enqueue(-1); // stop sign, one for each child
}
int pid;
for (int i=0;i<cpus;i++)
{
pid = fork_process();
if (pid==0) break; //child
}
// input queue: queue: <index of L> -1 ...-1
// output queue: rqueue: pid .. pid 0 pid... pid for failure
// pid ... pid for success
if (parent_pid!=getpid()) // child ------------------------------------------
{
si_set_signal(SIGTERM,sig_term_hdl_child);
singular_close_links();
feSetOptValue(FE_OPT_CPUS,0);
si_opt_1&=~OPT_PROT;
loop
{
int ind=queue->dequeue();
if (ind== -1) // negative number as stop sign
{
if (TEST_OPT_PROT) printf("child: end of queue\n");
rqueue->enqueue(getpid()); // report pid of ending child
_exit(0);
}
int red_result=1;
/* picks the element from the lazyset L */
LObject P;
P = strat->L[ind];
if (TEST_OPT_PROT) { printf("."); mflush();}
if (pNext(P.p) == strat->tail)
{
// deletes the short spoly
pLmFree(P.p);
P.p = NULL;
poly m1 = NULL, m2 = NULL;
/* spoly */
kCheckSpolyCreation(&P, strat, m1, m2);
ksCreateSpoly(&P, NULL, strat->use_buckets,
strat->tailRing, m1, m2, strat->R);
}
if ((P.p == NULL) && (P.t_p == NULL))
{
red_result = 0;
}
else
{
/* reduction */
int sl=strat->sl;
P.GetP();
poly p=redNF(P.p,sl,TRUE,strat);
if (p==NULL) red_result=0;
#ifdef KDEBUG
else
{
if (TEST_OPT_DEBUG)
{
printf("p: ");p_wrp(p,currRing, currRing); printf("\n");
}
}
#endif
}
if (red_result!=0)
{
if (TEST_OPT_PROT) printf("fail: result: %d\n",red_result);
rqueue->enqueue(0);
rqueue->enqueue(getpid()); // pid of ending child
_exit(0); // found fail, no need to test further
}
}
// should never be reached:
rqueue->enqueue(getpid()); // stop sign
_exit(0); // all done, quit child
}
else // parent ---------------------------------------------------
{
if (TEST_OPT_PROT) printf("%d children created\n",cpus);
// wait for all process to stop:
// each process sends 0 for failure and its pid at end
// for success only the pid is send the end
int res;
int remaining_children=cpus;
while(remaining_children>0)
{
res=rqueue->dequeue();
if (res>0) // a child finished
{
if (TEST_OPT_PROT) { printf("c");mflush(); }
if (si_waitpid(res,NULL,WNOHANG)==0) // child not finished
{
if (kill(res,0)==0) // child is still running
{
struct timespec t;
struct timespec rem;
// wait till signal or 10s:
t.tv_sec=10;
t.tv_nsec=0;
nanosleep(&t, &rem); // should be interrupted by signal: SIG_CHLD
// child finished ?
if (si_waitpid(res,NULL,WNOHANG) ==0) //child not finished
{
kill(res,SIGTERM);
t.tv_sec=10;
t.tv_nsec=0;
nanosleep(&t, &rem); // should be interrupted by signal: SIG_CHLD
si_waitpid(res,NULL,WNOHANG);
}
}
}
remaining_children--;
}
else if (res==0) // not a GB - clean up and return 0
{
if (TEST_OPT_PROT) { printf("C"); mflush(); }
all_okay=FALSE;
// clean queue:
int dummy;
do
{
dummy=queue->dequeue(); // remove remaining tasks
} while (dummy>=0);
}
}
// removes queues
queue.free();
rqueue.free();
vmem_deinit();
return all_okay;
}
#else
return kVerify1(F,Q);
#endif
}
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
res
CanonicalForm res
Definition facAbsFact.cc:60
feSetOptValue
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition feOpt.cc:154
feOptValue
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
deleteInL
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
LObject
class sLObject LObject
Definition kutil.h:59
kVerify1
BOOLEAN kVerify1(ideal F, ideal Q)
Definition kverify.cc:24
rem
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition minpoly.cc:572
vspace::internals::MAX_PROCESS
static const int MAX_PROCESS
Definition vspace.h:1419
vspace
Definition vspace.cc:615
vspace::vnew
VRef< T > vnew()
Definition vspace.h:1872
vspace::fork_process
pid_t fork_process()
Definition vspace.cc:1081
vspace::vmem_deinit
static void vmem_deinit()
Definition vspace.h:1742
vspace::vmem_init
static Status vmem_init()
Definition vspace.h:1738
si_opt_1
VAR unsigned si_opt_1
Definition options.c:5
OPT_PROT
#define OPT_PROT
Definition options.h:76
singular_close_links
void singular_close_links()
Definition ssiLink.cc:3455
loop
#define loop
Definition structs.h:71
vspace::VRef
Definition vspace.h:1747
vspace::VRef::free
void free()
Definition vspace.h:1805