| 1 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
|---|
| 2 | //-------------------------------------------------------------------------- |
|---|
| 3 | // Test for det |
|---|
| 4 | // |
|---|
| 5 | //-------------------------------------------------------------------------- |
|---|
| 6 | // Clement Pernet |
|---|
| 7 | //------------------------------------------------------------------------- |
|---|
| 8 | |
|---|
| 9 | #include <iomanip> |
|---|
| 10 | #include <iostream> |
|---|
| 11 | #include "fflas-ffpack/modular-balanced.h" |
|---|
| 12 | #include "timer.h" |
|---|
| 13 | #include "Matio.h" |
|---|
| 14 | #include "fflas-ffpack/ffpack.h" |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | using namespace std; |
|---|
| 18 | |
|---|
| 19 | typedef ModularBalanced<double> Field; |
|---|
| 20 | |
|---|
| 21 | int main(int argc, char** argv){ |
|---|
| 22 | |
|---|
| 23 | int n; |
|---|
| 24 | int nbit=atoi(argv[3]); // number of times the product is performed |
|---|
| 25 | cerr<<setprecision(10); |
|---|
| 26 | if (argc != 4) { |
|---|
| 27 | cerr<<"Usage : test-det <p> <A> <<i>" |
|---|
| 28 | <<endl |
|---|
| 29 | <<" to compute the determinant of A mod p (i computations)" |
|---|
| 30 | <<endl; |
|---|
| 31 | exit(-1); |
|---|
| 32 | } |
|---|
| 33 | Field F(atof(argv[1])); |
|---|
| 34 | Field::Element * A; |
|---|
| 35 | A = read_field(F,argv[2],&n,&n); |
|---|
| 36 | |
|---|
| 37 | Timer tim,t; t.clear();tim.clear(); |
|---|
| 38 | Field::Element d=0; |
|---|
| 39 | for(int i = 0;i<nbit;++i){ |
|---|
| 40 | t.clear(); |
|---|
| 41 | t.start(); |
|---|
| 42 | d = FFPACK::Det (F, n, n, A, n); |
|---|
| 43 | t.stop(); |
|---|
| 44 | tim+=t; |
|---|
| 45 | if (i+1<nbit){ |
|---|
| 46 | delete[] A; |
|---|
| 47 | A = read_field(F,argv[2],&n,&n); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | double mflops = 2.0/3.0*(n*n/1000000.0)*nbit*n/tim.usertime(); |
|---|
| 52 | F.write (cerr<<"n = "<<n<<" Det (A) = ",d) |
|---|
| 53 | << " mod "<<atoi(argv[1])<<" : t= " |
|---|
| 54 | << tim.usertime()/nbit |
|---|
| 55 | << " s, Mffops = "<<mflops |
|---|
| 56 | << endl; |
|---|
| 57 | |
|---|
| 58 | cout<<n<<" "<<mflops<<" "<<tim.usertime()/nbit<<endl; |
|---|
| 59 | } |
|---|