-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.lib
More file actions
97 lines (78 loc) · 2.64 KB
/
example.lib
File metadata and controls
97 lines (78 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
LIB "buchbergergspc.lib";
option("redSB"); // if option redSB is set: gspc_buchberger will calculate a unique reduced basis
configToken gc = configure_gspc();
gc.options.tmpdir = "tempdir";
gc.options.nodefile = "nodefile";
gc.options.procspernode = 6;
gc.options.loghostfile = "loghostfile";
gc.options.deleteoutputfiles = 1; // if true the final output file will also be deleted after reading the result into SINGULAR
gc.options.logport = 9876;
proc comp(def I, def J) // compare-function for indexed types
{
string t = typeof(I);
int i,n;
if(t!=typeof(J)) {return(0);}
if(t=="ideal" || t=="list" || t=="intvec" || t=="module")
{
n = size(I);
if(n != size(J)) {return(0);}
else {
for(i=1; i<=n; i++) {if(!comp(I[i],J[i])) {return(0);}}
return(1);
}
}
else {return (I==J);}
}
// minimal example:
/*
ring R = 0,(x,y),dp;
ideal I = x5, y7+x4, x2y-xy;
I = I;
ideal GB, F, M;
intmat A;
intvec indices;
GB, A, F, M, indices = gspc_buchberger(I, gc);
if(size(string(I))<2000) {printf("%nI (%s elements): %n%p",size(I),I);}
else {printf("%nI (%s elements): ...",size(I));}
if(size(string(GB))<2000) {printf("%nGB (%s elements): %n%p",size(GB),GB);}
else {printf("%nGB (%s elements): ...",size(GB));}
if(comp(std(I), GB)) {printf("%nEQUAL to std(I) !!!",0);}
else {printf("%nNOT equal to std(I) !!!",0);}
printf("%nbookkeeping matrix A (%s elements): %n%p%n%n%n",nrows(A),A,0);
*/
// bigger example:
ring R = 0,(x,y),dp;
ideal I = x5, y7+x4, x2y-xy;
I = I^2;
//I = ideal(I)*I;
//I = ideal(I)*gen(2)+I;
//def I = katsura(7);
proc testBB(def I, int nworkers)
{
def GB;
intmat A,D;
int cd;
def F;
def M;
intvec indices;
list runtimes, runtimes_raw;
GB, A, D, cd, F, M, indices, runtimes, runtimes_raw = gspc_buchberger(I, gc, nworkers);
if(size(string(I))<2000) {printf("%nI (%s elements): %n%p",size(I),I);}
else {printf("%nI (%s elements): ...",size(I));}
if(size(string(GB))<2000) {printf("%nGB (%s elements): %n%p",size(GB),GB);}
else {printf("%nGB (%s elements): ...",size(GB));}
if(comp(std(I), GB)) {printf("%nEQUAL to std(I) !!!",0);}
else {printf("%nNOT equal to std(I) !!!",0);}
intmat AA = A; int i,j;
for(i=1;i<=nrows(AA);i++) {for(j=1;j<=nrows(AA);j++) { if(AA[i,j]<2) {AA[i,j]=0;}}} AA[1,1] = 1;
if(size(string(A))<2000) {
printf("%nbookkeeping matrix A (%s elements): %n%p%n",nrows(A),A,0);
printf("%nsyzygies responsible for new GB elements (%s elements): %n%p",nrows(AA),AA);
}
else {
printf("%nbookkeeping matrix A (%s elements): %n...%n",nrows(A), 0);
}
export(GB,A,D,cd,F,M,indices,AA, runtimes, runtimes_raw);
}
def I = katsura(7);
testBB(I, 2);