My Project
freealgebra.cc
Go to the documentation of this file.
3#include <vector>
4
5#if !defined(__CYGWIN__) || defined(STATIC_VERSION)
6// acces from a module to routines from the main program
7// does not work on windows (restrict of the dynamic linker),
8// a static version is required:
9// ./configure --with-builtinmodules=freealgebra,...
10
11#ifdef HAVE_SHIFTBBA
13{
14 const short t1[]={2,RING_CMD,INT_CMD};
15 const short t2[]={3,RING_CMD,INT_CMD,INT_CMD};
16 if (iiCheckTypes(args, t2, 0) || iiCheckTypes(args, t1, 1))
17 {
18 ring r=(ring)args->Data();
19 int d=(int)(long)args->next->Data();
20 if (d<2)
21 {
22 WerrorS("degree must be >=2");
23 return TRUE;
24 }
25 int i=0;
26 while(r->order[i]!=0)
27 {
28 if ((r->order[i]==ringorder_c) ||(r->order[i]==ringorder_C)) i++;
29 else if ((r->block0[i]==1)&&(r->block1[i]==r->N)) i++;
30 else
31 {
32 WerrorS("only for rings with a global ordering of one block");
33 return TRUE;
34 }
35 }
36 if ((r->order[i]!=0)
38 {
39 WerrorS("only for rings with a global ordering of one block");
40 //Werror("only for rings with a global ordering of one block,i=%d, o=%d",i,r->order[i]);
41 return TRUE;
42 }
43 int ncGenCount = 0;
44 if (iiCheckTypes(args,t2,0))
45 ncGenCount = (int)(long) args->next->next->Data();
46 ring R=freeAlgebra(r,d,ncGenCount);
47 res->rtyp=RING_CMD;
48 res->data=R;
49 return R==NULL;
50 }
51 return TRUE;
52}
53
55{
56 const short t[]={2,POLY_CMD,INT_CMD};
57 if (iiCheckTypes(args,t,1))
58 {
59 poly p=(poly)args->CopyD();
60 args=args->next;
61 int sh=(int)((long)(args->Data()));
62 if (sh<0)
63 {
64 WerrorS("negative shift for pLPshift");
65 return TRUE;
66 }
67 int L = pLastVblock(p);
68 if (L+sh > currRing->N/currRing->isLPring)
69 {
70 WerrorS("pLPshift: too big shift requested\n");
71 return TRUE;
72 }
74 res->data = p;
75 res->rtyp = POLY_CMD;
76 return FALSE;
77 }
78 else return TRUE;
79}
80
82{
83 const short t[]={1,POLY_CMD};
84 if (iiCheckTypes(h,t,1))
85 {
86 poly p=(poly)h->Data();
87 res->rtyp = INT_CMD;
88 res->data = (void*)(long)pLastVblock(p);
89 return FALSE;
90 }
91 else return TRUE;
92}
93
95{
96 const short t1[]={2,POLY_CMD,POLY_CMD};
97 const short t2[]={2,IDEAL_CMD,POLY_CMD};
98 if (iiCheckTypes(h,t1,0))
99 {
100 poly p=(poly)h->Data();
101 poly q=(poly)h->next->Data();
102 res->rtyp = INT_CMD;
103 res->data = (void*)(long)p_LPDivisibleBy(p, q, currRing);
104 return FALSE;
105 }
106 else if (iiCheckTypes(h,t2,1))
107 {
108 ideal I=(ideal)h->Data();
109 poly q=(poly)h->next->Data();
110 res->rtyp = INT_CMD;
111 res->data=(void*)(long) p_LPDivisibleBy(I, q, currRing);
112 return FALSE;
113 }
114 else return TRUE;
115}
116
118{
119 const short t[]={2,POLY_CMD,INT_CMD};
120 if (iiCheckTypes(h,t,1))
121 {
122 poly p=(poly)h->Data();
123 int pos=(int)((long)(h->next->Data()));
124 res->rtyp = POLY_CMD;
125 res->data = p_LPVarAt(p, pos, currRing);
126 return FALSE;
127 }
128 else return TRUE;
129}
130
132{
133 const short t[]={1,IDEAL_CMD};
134 if (iiCheckTypes(h,t,1))
135 {
136 ideal I = (ideal) h->Data();
137 res->rtyp = LIST_CMD;
138
139 ideal standardWords;
140 intvec* graph = lp_ufnarovskiGraph(I, standardWords);
141
143 li->Init(2);
144 li->m[0].rtyp=INTMAT_CMD;
145 li->m[1].rtyp=IDEAL_CMD;
146 li->m[0].data=graph;
147 li->m[1].data=standardWords;
148
149 res->data = li;
150
151 if (errorreported) return TRUE;
152 return FALSE;
153 }
154 else return TRUE;
155}
156#endif
157
158//------------------------------------------------------------------------
159// initialisation of the module
160extern "C" int SI_MOD_INIT(freealgebra)(SModulFunctions* p)
161{
162#ifdef HAVE_SHIFTBBA
163 p->iiAddCproc("freealgebra.so","freeAlgebra",FALSE,freeAlgebra);
164 p->iiAddCproc("freealgebra.so","lpLmDivides",FALSE,lpLmDivides);
165 p->iiAddCproc("freealgebra.so","lpVarAt",FALSE,lpVarAt);
166 p->iiAddCproc("freealgebra.so","lpUfnarovskiGraph",FALSE,lpUfnarovskiGraph);
167
168 p->iiAddCproc("freealgebra.so","stest",TRUE,stest);
169 p->iiAddCproc("freealgebra.so","btest",TRUE,btest);
170#endif
171 return (MAX_TOK);
172}
173#endif
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
Definition: intvec.h:23
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void * CopyD(int t)
Definition: subexpr.cc:710
int rtyp
Definition: subexpr.h:91
void * Data()
Definition: subexpr.cc:1154
leftv next
Definition: subexpr.h:86
void * data
Definition: subexpr.h:88
Definition: lists.h:24
sleftv * m
Definition: lists.h:46
INLINE_THIS void Init(int l=0)
CanonicalForm res
Definition: facAbsFact.cc:60
VAR short errorreported
Definition: feFopen.cc:23
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN lpUfnarovskiGraph(leftv res, leftv h)
Definition: freealgebra.cc:131
static BOOLEAN freeAlgebra(leftv res, leftv args)
Definition: freealgebra.cc:12
static BOOLEAN lpVarAt(leftv res, leftv h)
Definition: freealgebra.cc:117
static BOOLEAN btest(leftv res, leftv h)
Definition: freealgebra.cc:81
int SI_MOD_INIT() freealgebra(SModulFunctions *p)
Definition: freealgebra.cc:160
static BOOLEAN lpLmDivides(leftv res, leftv h)
Definition: freealgebra.cc:94
static BOOLEAN stest(leftv res, leftv args)
Definition: freealgebra.cc:54
@ IDEAL_CMD
Definition: grammar.cc:284
@ INTMAT_CMD
Definition: grammar.cc:279
@ POLY_CMD
Definition: grammar.cc:289
@ RING_CMD
Definition: grammar.cc:281
intvec * lp_ufnarovskiGraph(ideal G, ideal &standardWords)
Definition: hdegree.cc:1801
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition: ipshell.cc:6572
STATIC_VAR Poly * h
Definition: janet.cc:971
VAR omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#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
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:760
void p_LPshift(poly p, int sh, const ring ri)
Definition: shiftop.cc:392
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition: shiftop.cc:776
poly p_LPVarAt(poly p, int pos, const ring r)
Definition: shiftop.cc:845
#define pLastVblock(p)
Definition: shiftop.h:32
#define R
Definition: sirandom.c:27
@ LIST_CMD
Definition: tok.h:118
@ INT_CMD
Definition: tok.h:96
@ MAX_TOK
Definition: tok.h:218