Determinant of sparse matrix over Z or Zp.
Determinant of sparse matrix over Z or Zp.
#include <iostream>
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;
}
ifstream input (argv[1]);
if (!input) {
cerr << "Error opening matrix file " << argv[1] << endl;
return -1;
}
if (argc == 2 ) {
typedef Givaro::ZRing<Integer> Integers;
Integers ZZ;
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) {
typedef Givaro::Modular<double> Field;
double q = atof(argv[2]);
Field F(q);
SparseMatrix<Field> B (F); B.read(input);
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;
}
Dense matrix representation.
Definition: blas-matrix.h:62
size_t rowdim() const
Get the number of rows in the matrix.
Definition: blas-matrix.h:233
size_t coldim() const
Get the number of columns in the matrix.
Definition: blas-matrix.h:238
std::istream & read(std::istream &file)
Read the matrix from an input stream.
Definition: blas-matrix.inl:290
Blackbox::Field::Element & det(typename Blackbox::Field::Element &d, const Blackbox &A, const DomainCategory &tag, const DetMethod &Meth)
Compute the determinant of A.
linbox base configuration file
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> ....