| 1 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
|---|
| 2 | //-------------------------------------------------------------------------- |
|---|
| 3 | // Test for the krylov-elimination |
|---|
| 4 | //-------------------------------------------------------------------------- |
|---|
| 5 | // usage: test-krylov-elim p A, to compute the rank profile of the (n+m)xn matrix B |
|---|
| 6 | // formed by the n identity vectors and the mxn matrix A over Z/pZ |
|---|
| 7 | //------------------------------------------------------------------------- |
|---|
| 8 | |
|---|
| 9 | //------------------------------------------------------------------------- |
|---|
| 10 | #define DEBUG 0 |
|---|
| 11 | |
|---|
| 12 | #include <iostream> |
|---|
| 13 | #include <iomanip> |
|---|
| 14 | #include <list> |
|---|
| 15 | #include <vector> |
|---|
| 16 | #include "Matio.h" |
|---|
| 17 | #include "timer.h" |
|---|
| 18 | using namespace std; |
|---|
| 19 | #include "fflas-ffpack/modular-positive.h" |
|---|
| 20 | #include "fflas-ffpack/ffpack.h" |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | typedef Modular<double> Field; |
|---|
| 24 | |
|---|
| 25 | template<class T> |
|---|
| 26 | std::ostream& printvect(std::ostream& o, vector<T>& vect){ |
|---|
| 27 | for(size_t i=0; i < vect.size()-1; ++i) |
|---|
| 28 | o << vect[i] << " " ; |
|---|
| 29 | return o << vect[vect.size()-1] << std::endl; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | int main(int argc, char** argv){ |
|---|
| 33 | |
|---|
| 34 | int m,n; |
|---|
| 35 | cout<<setprecision(20); |
|---|
| 36 | |
|---|
| 37 | if (argc!=4){ |
|---|
| 38 | cerr<<"usage : test-frobenius <p> <A> <c>"<<endl |
|---|
| 39 | <<" to compute the frobenius normal form of the matrix A over Z/pZ, with conditonning parameter c" |
|---|
| 40 | <<endl; |
|---|
| 41 | exit(-1); |
|---|
| 42 | } |
|---|
| 43 | Field F( long(atoi(argv[1]))); |
|---|
| 44 | Field::Element one; |
|---|
| 45 | F.init(one, 1UL); |
|---|
| 46 | Field::Element * A = read_field<Field> (F,argv[2],&m,&n); |
|---|
| 47 | size_t c = atoi(argv[3]); |
|---|
| 48 | |
|---|
| 49 | std::list<vector<Field::Element> > frobForm; |
|---|
| 50 | Timer tim; |
|---|
| 51 | tim.clear(); |
|---|
| 52 | tim.start(); |
|---|
| 53 | FFPACK::CharpolyArithProg (F, frobForm, n, A, n, c); |
|---|
| 54 | tim.stop(); |
|---|
| 55 | std::list<vector<Field::Element> >::iterator it = frobForm.begin(); |
|---|
| 56 | while(it != frobForm.end()){ |
|---|
| 57 | printvect (cout, *(it++)); |
|---|
| 58 | } |
|---|
| 59 | cerr<<c<<" "<<tim.usertime()<<" "<<4.55*n*n/1000000.0*n/tim.usertime()<<endl; |
|---|
| 60 | delete[] A; |
|---|
| 61 | return 0; |
|---|
| 62 | } |
|---|