Determinant of sparse matrix over Z or Zp.
#define __LINBOX_HAVE_KAAPI
#include <iostream>
#include <string>
#include <linbox/ring/gmp-integers.h>
#include <linbox/util/matrix-stream.h>
using namespace std;
typedef Givaro::ZRing<Integer> Integers;
struct cra_det_task {
void operator()(int argc, char **argv) {
ifstream input (argv[1]);
if (!input) {
cerr << "Error opening matrix file '" << argv[1] << "'" << endl;
return ;
}
Util::logfile() << "creating matrix" << std::endl;
Integers ZZ;
SparseMatrix<Integers> sparseMatrix (ZZ);
sparseMatrix.read(input);
Util::logfile() << "matrix created" << std::endl;
Givaro::ZRing<Integer>::Element det_A;
try {
cra_det(det_A, sparseMatrix, RingCategories::IntegerTag(), Method::Auto() );
}
std::cerr << err << std::endl;
}
cout << "Determinant is ";
ZZ.write(cout, det_A) << endl;
}
};
int main (int argc, char **argv)
{
if(argc<2) {
cerr << "not enough args : usage = athadet file" << endl;
return 1;
}
a1::Community com = a1::System::join_community(argc,argv);
Util::logfile() << "starting job" << std::endl;
a1::ForkMain<cra_det_task>()(argc,argv);
com.leave();
a1::System::terminate();
return 0;
}
base class for execption handling in LinBox
Definition: error.h:37
A Givaro::Modular ring is a representations of Z/mZ.
Namespace in which all linbox code resides.
Definition: alt-blackbox-block-container.h:4
A SparseMatrix<_Field, _Storage> ....