My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
freealgebra
freealgebra.cc
Go to the documentation of this file.
1
#include "
Singular/libsingular.h
"
2
#include "
kernel/combinatorics/stairc.h
"
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
12
static
BOOLEAN
freeAlgebra
(
leftv
res
,
leftv
args)
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)
37
|| (
rHasLocalOrMixedOrdering
(r)))
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
54
static
BOOLEAN
stest
(
leftv
res
,
leftv
args)
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
}
73
p_LPshift
(
p
,sh,
currRing
);
74
res
->data =
p
;
75
res
->rtyp =
POLY_CMD
;
76
return
FALSE
;
77
}
78
else
return
TRUE
;
79
}
80
81
static
BOOLEAN
btest
(
leftv
res
,
leftv
h
)
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
94
static
BOOLEAN
lpLmDivides
(
leftv
res
,
leftv
h
)
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
117
static
BOOLEAN
lpVarAt
(
leftv
res
,
leftv
h
)
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
131
static
BOOLEAN
lpUfnarovskiGraph
(
leftv
res
,
leftv
h
)
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
142
lists
li=(
lists
)
omAllocBin
(
slists_bin
);
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
160
extern
"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
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
intvec
Definition
intvec.h:24
sleftv::CopyD
void * CopyD(int t)
Definition
subexpr.cc:714
sleftv::rtyp
int rtyp
Definition
subexpr.h:91
sleftv::Data
void * Data()
Definition
subexpr.cc:1192
sleftv::next
leftv next
Definition
subexpr.h:86
sleftv::data
void * data
Definition
subexpr.h:88
slists::m
sleftv * m
Definition
lists.h:46
slists::Init
INLINE_THIS void Init(int l=0)
res
CanonicalForm res
Definition
facAbsFact.cc:60
errorreported
VAR short errorreported
Definition
feFopen.cc:23
WerrorS
void WerrorS(const char *s)
Definition
feFopen.cc:24
lpUfnarovskiGraph
static BOOLEAN lpUfnarovskiGraph(leftv res, leftv h)
Definition
freealgebra.cc:131
freeAlgebra
static BOOLEAN freeAlgebra(leftv res, leftv args)
Definition
freealgebra.cc:12
lpVarAt
static BOOLEAN lpVarAt(leftv res, leftv h)
Definition
freealgebra.cc:117
freealgebra
int SI_MOD_INIT freealgebra(SModulFunctions *p)
Definition
freealgebra.cc:160
btest
static BOOLEAN btest(leftv res, leftv h)
Definition
freealgebra.cc:81
lpLmDivides
static BOOLEAN lpLmDivides(leftv res, leftv h)
Definition
freealgebra.cc:94
stest
static BOOLEAN stest(leftv res, leftv args)
Definition
freealgebra.cc:54
IDEAL_CMD
@ IDEAL_CMD
Definition
grammar.cc:285
INTMAT_CMD
@ INTMAT_CMD
Definition
grammar.cc:280
POLY_CMD
@ POLY_CMD
Definition
grammar.cc:290
RING_CMD
@ RING_CMD
Definition
grammar.cc:282
lp_ufnarovskiGraph
intvec * lp_ufnarovskiGraph(ideal G, ideal &standardWords)
Definition
hdegree.cc:1766
iiCheckTypes
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:6576
h
STATIC_VAR Poly * h
Definition
janet.cc:971
libsingular.h
slists_bin
VAR omBin slists_bin
Definition
lists.cc:23
lists
slists * lists
Definition
mpr_numeric.h:146
omAllocBin
#define omAllocBin(bin)
Definition
omAllocDecl.h:205
NULL
#define NULL
Definition
omList.c:12
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
rHasLocalOrMixedOrdering
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition
ring.h:774
ringorder_C
@ ringorder_C
Definition
ring.h:74
ringorder_c
@ ringorder_c
Definition
ring.h:73
p_LPshift
void p_LPshift(poly p, int sh, const ring ri)
Definition
shiftop.cc:392
p_LPDivisibleBy
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition
shiftop.cc:776
freeAlgebra
ring freeAlgebra(ring r, int d, int ncGenCount)
create the letterplace ring corresponding to r up to degree d
Definition
shiftop.cc:942
p_LPVarAt
poly p_LPVarAt(poly p, int pos, const ring r)
Definition
shiftop.cc:845
pLastVblock
#define pLastVblock(p)
Definition
shiftop.h:32
R
#define R
Definition
sirandom.c:27
stairc.h
SModulFunctions
Definition
ipid.h:69
leftv
sleftv * leftv
Definition
structs.h:53
LIST_CMD
@ LIST_CMD
Definition
tok.h:118
INT_CMD
@ INT_CMD
Definition
tok.h:96
MAX_TOK
@ MAX_TOK
Definition
tok.h:220
Generated on
for My Project by
doxygen 1.17.0
for
Singular