linbox
examples/det.C

Determinant of dense matrix over Z or sparse matrix over Zp.

/*
* examples/det.C
*
* Copyright (C) 2005, 2010 D. Saunders, J-G. Dumas
* ========LICENCE========
* This file is part of the library LinBox.
*
* LinBox is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*/
#include <iostream>
using namespace LinBox;
using namespace std;
template<class MatRep> void handleDet( istream & matData, long p = 0);
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 matData (argv[1]);
if (!matData) {
cerr << "Error opening matrix file " << argv[1] << endl;
return -1;
}
// Example 1: dense matrix over integers.
if (argc == 2 )
handleDet< DenseMatrix< Givaro::ZRing< Integer > > >
(matData);
// Example 2: sparse matrix over modular field.
if (argc == 3 )
handleDet< SparseMatrix< Givaro::Modular< double > > >
(matData, atoi(argv[2]));
}
template<class MatRep>
void handleDet(istream & matData, long p) {
typedef typename MatRep::Field Ring;
Ring R(p);
MatRep A(R);
A.read(matData);
cout << "Matrix is " << A.rowdim() << " by " << A.coldim() << endl;
typename Ring::Element det_A;
det (det_A, A);
cout << "Determinant is ";
R.write(cout, det_A) << endl;
}
// Local Variables:
// mode: C++
// tab-width: 4
// indent-tabs-mode: nil
// c-basic-offset: 4
// End:
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
LinBox::det
Blackbox::Field::Element & det(typename Blackbox::Field::Element &d, const Blackbox &A, const DomainCategory &tag, const DetMethod &Meth)
Compute the determinant of A.
modular.h
A Givaro::Modular ring is a representations of Z/mZ. This file groups many implementations/specialisa...
det.h
NO DOC.
LinBox
Namespace in which all linbox code resides.
Definition: alt-blackbox-block-container.h:4
sparse-matrix.h
linbox-config.h
linbox base configuration file