I have written a sample code testing gbasis on katsura9 (or katsura10 depending on definition) polynomials system.
Code : Tout sélectionner
#include <config.h>
#include <giac.h>
using namespace std;
using namespace giac;
int main()
{
giac::context ct;
vecteur x;
vectpoly ideal;
stringstream sstr;
int n=9;
//variable vector
for (int i=0; i<n+1;++i)
{
stringstream sstr("x"); sstr << i;
x.push_back(identificateur(sstr.str()));
}
// x_0 + 2\sum_{i=1}^n x_i = 1
gen f = x[0];
for (int i=1; i<n+1;++i) f += 2*x[i];
ideal.push_back(polynome(*f._POLYptr));
// \sum_{j=-n}^{n-i} x_{|j|}x_{|j+i|} = x_{i} \qquad i=0,\dots,n-1
for (int i=0; i<n;++i)
{
f=-x[i];
for (int j=-n; j< n-i+1;++j) f += x[abs(j)]*x[abs(j+i)];
f = simplifier(f, &ct);
ideal.push_back(polynome(*f._POLYptr));
}
environment env;
env.modulo = 0;
int rur=0;
gbasis(ideal, x, false, false, rur, &env, &ct, false);
}
This does not compile in Visual Studio because of unresolved external context0 and gbasis (though, this could work if I link statically with respect to the giac library). I will report once I tested this with static links. But in general, can anyone confirm that this compiles in Linux?
Edit: I figured that _gbasis does compile and link properly. Here I do not need to give environment parameter, you basically need the polynomial system and the variables in _gbasis (all enclosed in a vecteur I suppose). But with katsura9 I do not get a proper answer and I think I even get a crash. I am sure I am doing something wrong. Here is the modified code for main():
Code : Tout sélectionner
int main()
{
giac::context ct;
vecteur x;
vecteur ideal;
stringstream sstr;
int n=9;
//variable vector
for (int i=0; i<n+1;++i)
{
stringstream sstr("x"); sstr << i;
x.push_back(identificateur(sstr.str()));
}
// x_0 + 2\sum_{i=1}^n x_i = 1
gen f = x[0];
for (int i=1; i<n+1;++i) f = f+2*x[i];
ideal.push_back(f);
// \sum_{j=-n}^{n-i} x_{|j|}x_{|j+i|} = x_{i} \qquad i=0,\dots,n-1
for (int i=0; i<n;++i)
{
f=-x[i];
for (int j=-n; j< n-i+1;++j) f = f+x[abs(j)]*x[abs(j+i)];
f = simplifier(f, &ct);
ideal.push_back(f);
}
_gbasis(makesequence(ideal,x), &ct);
}
Jose