4ti2gap
package for GAP
Another 4ti2
interface (4ti2Interface
)
Development and test
Provides among other programs:
4ti2[int32, int64, gmp]
, pure executable machine codegroebner, minimize, markov, ...
, wrapper scripts
zsolve
, pure executable machine code
hilbert, graver, ...
, wrapper scriptsProvide an interface groebner
by direct dynamic library link
Separated architecture precision functions from GMP
versions: 4ti2gap.so
and 4ti2gapgmp.so
4ti2[int32, int64, gmp]
are not based in C++ templates4ti2gap.so
groebner
, hilbert
, graver
and zsolve
groebner
GMP
, if present and selected.hilbert
, graver
, zsolve
GAP
to _4ti2_::VectorArray
and _4ti2_zsolve_VectorArrayAPI<T>
lists/matrices are transformed to string streamszsolve.gi | 4ti2zsolve.cc | ZSolve.hpp |
---|---|---|
ZSolve4ti2 |
_4ti2_zsolve_ZSolve4ti2 |
_4ti2_zsolve_::ZSolveAPI<T> |
Interface access:
create_matrix(std::istream& in, const char* name);
set_options(int argc, char** argv);
compute();
get_matrix(const char* name);
ZSolve4ti2(problem);
problem=[type_mat, gap_matrix1, type_mat2, gap_matrix2, ... ]
where
type_mat = "mat" | "lat" | "sign" | "rel" | ....
From 4ti2_manual:
\[ \begin{array}{rrrrl} x & - & y & \leq & 2,\\ -3x & + & y & \leq & 1,\\ x & + & y & \geq & 1,\\ & & y & \geq & 0 \end{array} \]
gap> ZSolve4ti2(["mat",[[1, -1], [-3, 1], [1, 1]],
"rel", ["<", "<", ">"],
"rhs", [[2, 1, 1]],
"sign", [0, 1]]);
rec( zhom := [ [ 1, 3 ], [ 1, 1 ], [ 1, 2 ] ],
zinhom := [ [ 2, 0 ], [ 0, 1 ], [ 1, 0 ], [ 1, 1 ] ] )
So the set of solutions of the above system is
\[\{ (2,0),(0,1), (1,0), (1,1)\} +\langle (1,3),(1,1), (12)\rangle\]
Computing the factorizations of v in terms of the elements in l
FactorizationsVectorWRTList_eje:=function(v,l)
local matrix ,mat, rhs, sign, problem, n;
mat := TransposedMat(Concatenation(l,[-v]));
sign := [List(l,_->1)];
rhs := [v];
problem := ["mat",TransposedMat(l),"sign",sign,"rhs",rhs];
matrix := ZSolve4ti2(problem);
return matrix.zinhom;
end;
gap> FactorizationsVectorWRTList_eje([5,5],[[2,0],[0,2],[1,1]]);
[ [ 2, 2, 1 ], [ 1, 1, 3 ], [ 0, 0, 5 ] ]
graver.gi | 4ti2zsolve.cc | GraverAPI.hpp |
---|---|---|
GraverBasis4ti2 |
_4ti2_zsolve_GraverBasis4ti2 |
_4ti2_zsolve_::GraverAPI<T> |
GraverBasis4ti2(problem);
PrimitiveElementsOfAffineSemigroup_eje:=function(s)
local l, n, facs, mat, trunc;
trunc:=function(ls)
return List(ls, y->Maximum(y,0));
end;
l:=GeneratorsOfAffineSemigroup(s);
n:=Length(l);
mat:=List(TransposedMat(l));
facs:=GraverBasis4ti2(["mat", mat]);
facs:=Set(facs,trunc);
return Set(facs, f->f*l);
end;
gap> a:=AffineSemigroup([[2,0],[0,2],[1,1]]);
<Affine semigroup in 2 dimensional space, with 3 generators>
gap> PrimitiveElementsOfAffineSemigroup(a);
[ [ 2, 2 ] ]
hilbert.gi | 4ti2zsolve.cc | HilbertAPI.hpp |
---|---|---|
HilbertBasis4ti2 |
_4ti2_zsolve_HilbertBasis4ti2 |
_4ti2_zsolve_::HilbertAPI<T> |
HibertBasis4ti2(problem);
with similar syntax for problem
as ZSolve4ti2 and GraverBasis4ti2
groebner.gi | 4ti2groebner.cc | groebner_main.cpp, GroebnerBasis.h/cpp, ... |
---|---|---|
GroebnerBasis4ti2 |
_4ti2_GroebnerBasis4ti2 |
_4ti2_::GroebnerBasis |
GroebnerBasis4ti2(list[,order]);
where
order = "lex" | "grlex" | "grvlex"
ParticularSolutionGB:=function(A)
local zeroAllSameSign, facs, sol;
zeroAllSameSign:=function(bin)
local rv, prv;
rv:=First(bin, x->x<>0);
if rv=fail then return false; fi;
prv:=First([1..Length(bin)],i->bin[i]=rv);
if rv=Length(bin) then return true; fi;
return First(bin{[prv+1 .. Length(bin)]}, x->x * rv<0)=fail;
end;
facs:=GroebnerBasis4ti2(A);
if Length(facs)>0 then
sol:=First(facs, b->zeroAllSameSign(b));
if sol<>fail then return sol; fi;
fi;
return [];
end;
gap> ParticularSolutionGB([[10, 2, -7, 2191],[-4, 280, 1, 7]]);
[ 109, 1, 156, 0 ]