Determinant of sparse matrix over Z or Zp.
#include <iostream>
#include "linbox/blackbox/sparse.h"
#include "linbox/util/matrix-stream.h"
int main (int argc, char **argv)
{
commentator().
setMaxDetailLevel (-1);
commentator().
setMaxDepth (-1);
commentator().
setReportStream (std::cerr);
if (argc <= 1 || argc > 3) {
cerr << "Usage: det <matrix-file-in-supported-format> [<p>]" << endl;
return -1;
}
if (argc == 2 ) {
Integers ZZ;
ifstream input (argv[1]);
if (!input)
{ cerr << "Error opening matrix file " << argv[1] << endl;
return -1;
}
cout <<
"Matrix is " << A.
rowdim() <<
" by " << A.
coldim() << endl;
Integers::Element det_A;
cout << "Determinant is ";
ZZ.write(cout, det_A) << endl;
}
if (argc == 3) {
double q = atof(argv[2]);
Field F(q);
ifstream input (argv[1]);
if (!input)
{ cerr << "Error opening matrix file " << argv[1] << endl;
return -1;
}
cout <<
"Matrix is " << B.
rowdim() <<
" by " << B.
coldim() << endl;
Field::Element det_B;
cout << "Determinant is ";
F.write(cout, det_B) << " mod " << q << endl;
}
return 0;
}