// This is to demonstrate the use of the JSCL API from a java shell interpreter

import jscl.math.Debug;
import jscl.math.Generic;
import jscl.math.Variable;
import jscl.math.polynomial.Basis;
import jscl.math.polynomial.Monomial;
static import jscl.math.Predef.*;

Debug.setOutputStream(System.out);

int n=4;
v=new Variable[n];
a=new Generic[n];
for(i=0;i<n;i++) v[i]=variable(new Character((char)('a'+i)).toString()).variableValue();
for(i=0;i<n;i++) {
        a[i]=integer("0");
        for(j=0;j<(i<n-1?n:1);j++) {
                s=integer("1");
                for(k=0;k<=i;k++) s=s.multiply(v[(j+k)%n].expressionValue());
                a[i]=a[i].add(s);
        }
        if(i==n-1) a[i]=a[i].subtract(variable("t").pow(0));
}
t=System.currentTimeMillis();
b=Basis.compute(a,Basis.augmentUnknown(v,a),Monomial.degreeReverseLexicographic,0);
t=System.currentTimeMillis()-t;
print(b);
print(t);