Echelon form of matrix over Zp.
#include <iostream>
#include <linbox/solutions/echelon.h>
#include <fflas-ffpack/ffpack/ffpack.h>
#define COMPARE_FFPACK
using namespace std;
int main (int argc, char **argv)
{
if (argc < 3 || argc > 3) {
cerr << "Usage: echelon <matrix-file-in-SMS-format> <p>" << endl;
return -1;
}
ifstream input (argv[1]);
if (!input) { cerr << "Error opening matrix file " << argv[1] << endl; return -1; }
typedef Givaro::Modular<double> Field;
double q = atof(argv[2]);
Field F(q);
DenseMatrix<Field> A(F);
A.read(input);
DenseMatrix<Field> E(F,A.rowdim(),A.coldim());
cout << "A is " << A.rowdim() << " by " << A.coldim() << endl;
#ifdef COMPARE_FFPACK
DenseMatrix<Field> G(A);
size_t * P = new size_t[G.rowdim()];
size_t * Q = new size_t[G.coldim()];
size_t r= FFPACK::ReducedRowEchelonForm (F, G.rowdim(), G.coldim(), G.getWritePointer(), G.coldim(), P, Q,false);
FFPACK::getReducedEchelonForm (F, FFLAS::FflasUpper, G.rowdim(), G.coldim(), r,
Q, G.getWritePointer(), G.coldim());
if (G.coldim() <20)
G.write(cerr<<"FFPACK::Echelon = "<<endl)<<endl;
delete[] P ;
delete[] Q ;
#endif
if (E.coldim() <20)
E.write(cerr<<"LinBox::Echelon = "<<endl)<<endl;
return 0;
}
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
size_t reducedRowEchelon(Matrix &E, const Matrix &A, const CategoryTag &tag, const Method::Auto &m)
reducedRowEchelon specialisation for Auto.
Definition: echelon-auto.h:123