Changeset 62 for tests

Show
Ignore:
Timestamp:
06/03/08 21:24:57 (7 months ago)
Author:
pernet
Message:

* Change the design of fflas-bounds
* Modular<double> -> ModularBalanced?<double>
* Fix the winograd recursion issue (when some steps are done over the field)
* Fix a bunch of bugs
* Remove the template specialization by the Element (incompatible with the soon coming compressed representations over small fields)
* Create a randiter file, generic wrt the modular field

Location:
tests
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • tests

    • Property svn:ignore set to
      test-invert
      test-det
      dense_generator
      test-frobenius
      Makefile
      test-charpoly
      test-lqup
      test-fgemm
      test-fgemv
      test-ftrsm
      test-rank
  • tests/Matio.h

    r16 r62  
    88// Reading a matrice from a (eventually zipped) file 
    99double * read_dbl(char * mat_file,int* tni,int* tnj) { 
    10   char *UT, *File_Name; 
     10  char *UT; 
    1111  int is_gzipped = 0; 
    1212  size_t s = strlen(mat_file); 
    1313  double* X=NULL; 
    14   if ((mat_file[--s] == 'z') &&  
    15       (mat_file[--s] == 'g') &&  
    16       (mat_file[--s] == '.')) { 
    17     is_gzipped = 1; 
    18     File_Name = "/tmp/bbXXXXXX_"; 
    19     mkstemp(File_Name); 
    20     UT = new char[s+34+strlen(File_Name)]; 
    21     sprintf(UT,"gunzip -c %s > %s", mat_file, File_Name); 
    22     system(UT); 
    23     sprintf(UT,"\\rm %s", File_Name); 
    24   } else 
    25     File_Name = mat_file; 
     14  const char * File_Name = mat_file; 
    2615   
    2716  FILE* FileDes = fopen(File_Name, "r"); 
     
    6554typename Field::Element * read_field(const Field& F,char * mat_file,int* tni,int* tnj) 
    6655{ 
    67   char *UT, *File_Name; 
     56  char *UT; 
    6857  int is_gzipped = 0; 
    6958  size_t s = strlen(mat_file); 
     
    7160  F.init(zero,0.0); 
    7261  typename Field::Element * X=NULL; 
    73   if ((mat_file[--s] == 'z') &&  
    74       (mat_file[--s] == 'g') &&  
    75       (mat_file[--s] == '.')) { 
    76     is_gzipped = 1; 
    77     File_Name = "/tmp/bbXXXXXX_"; 
    78     mkstemp(File_Name); 
    79     UT = new char[s+34+strlen(File_Name)]; 
    80     sprintf(UT,"gunzip -c %s > %s", mat_file, File_Name); 
    81     system(UT); 
    82     sprintf(UT,"\\rm %s", File_Name); 
    83   } else 
    84     File_Name = mat_file; 
     62  const char * File_Name = mat_file; 
    8563  FILE* FileDes = fopen(File_Name, "r"); 
    8664  if (FileDes != NULL) { 
  • tests/test-charpoly.C

    r4 r62  
    99#include <iomanip> 
    1010#include <iostream> 
    11 #include "fflas-ffpack/modular-positive.h" 
     11#include "fflas-ffpack/modular-balanced.h" 
    1212#include "timer.h" 
    1313#include "Matio.h" 
     
    1919using namespace std; 
    2020 
    21 typedef Modular<double> Field; 
     21typedef ModularBalanced<double> Field; 
    2222typedef vector<Field::Element> Polynomial; 
    2323 
  • tests/test-det.C

    r46 r62  
    1717using namespace std; 
    1818 
    19 typedef Modular<double> Field; 
     19typedef ModularBalanced<double> Field; 
    2020 
    2121int main(int argc, char** argv){ 
     
    3131                exit(-1); 
    3232        } 
    33         Field F(atoi(argv[1])); 
     33        Field F(atof(argv[1])); 
    3434        Field::Element * A; 
    3535        A = read_field(F,argv[2],&n,&n); 
  • tests/test-fgemm.C

    r46 r62  
    77//------------------------------------------------------------------------- 
    88 
    9 #define DEBUG 1 
     9#define DEBUG 1  
    1010#define NEWWINO 
    1111#define TIME 1 
     
    1515using namespace std; 
    1616 
    17 #include "fflas-ffpack/modular-balanced.h" 
     17#include "fflas-ffpack/modular-positive.h" 
    1818#include "timer.h" 
    1919#include "Matio.h" 
     
    2525typedef Modular<double> Field; 
    2626//typedef Modular<float> Field; 
     27//typedef ModularBalanced<double> Field; 
     28//typedef ModularBalanced<float> Field; 
    2729//typedef Modular<int> Field; 
    2830 
     
    109111                        F.assign (*(Cd+i), zero); 
    110112        } 
    111         Field::Element aij, bij, beta_alpha; 
    112         F.div (beta_alpha, beta, alpha); 
     113        Field::Element aij, bij, beta_alpha, tmp; 
     114        //F.div (beta_alpha, beta, alpha); 
    113115        for (int i = 0; i < m; ++i) 
    114116                for (int j = 0; j < n; ++j){ 
    115                         F.mulin(*(Cd+i*n+j),beta_alpha); 
     117                        F.mulin(*(Cd+i*n+j),beta); 
     118                        F.assign (tmp, zero); 
    116119                        for ( int l = 0; l < k ; ++l ){ 
    117120                                if ( ta == FFLAS::FflasNoTrans ) 
     
    123126                                else 
    124127                                        bij = *(B+j*ldb+l); 
    125                                 F.axpyin( *(Cd+i*n+j), aij, bij ); 
     128                                //F.mul (tmp, aij, bij); 
     129                                //F.axpyin( *(Cd+i*n+j), alpha, tmp ); 
     130                                F.axpyin (tmp, aij, bij);  
    126131                        } 
    127                         F.mulin( *(Cd+i*n+j),alpha ); 
     132                        F.axpyin (*(Cd+i*n+j), alpha, tmp); 
     133                        //F.mulin( *(Cd+i*n+j),alpha ); 
    128134                        if ( !F.areEqual( *(Cd+i*n+j), *(C+i*n+j) ) ) { 
    129135                                wrong = true; 
  • tests/test-ftrsm.C

    r43 r62  
    11/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 
    22//-------------------------------------------------------------------------- 
    3 //                        Test for ftrtri : 1 computation 
     3//                        Test for ftrsm : 1 computation 
    44//                   
    55//-------------------------------------------------------------------------- 
     
    2020using namespace std; 
    2121 
    22 typedef Modular<double> Field; 
     22//typedef ModularBalanced<double> Field; 
     23typedef ModularBalanced<float> Field; 
    2324 
    2425int main(int argc, char** argv){ 
     
    3435        } 
    3536        int nbit=atoi(argv[4]); // number of times the product is performed 
    36         Field F(atoi(argv[1])); 
     37        Field F(atof(argv[1])); 
    3738        F.init(zero,0.0); 
    3839        F.init(one,1.0); 
     
    9798                //write_field (F,cerr<<"B2="<<endl,B2,m,n,n); 
    9899                //write_field (F,cerr<<"B="<<endl,B,m,n,n); 
    99         }else{ 
    100          
     100        } else   
    101101                cerr<<"PASS"<<endl; 
    102         } 
    103  
    104         Field::Element * C = read_field (F, argv[2], &k, &k); 
    105         wrong = false; 
    106  
    107         for (int i=0;i<k;++i) 
    108                 for (int j=0;j<k;++j) 
    109                         if ( !F.areEqual(*(A+i*k+j), *(C+i*k+j))){ 
    110                                 cerr<<"A ["<<i<<", "<<j<<"] = "<<(*(A+i*k+j)) 
    111                                     <<" ; C ["<<i<<", "<<j<<"] = "<<(*(C+i*k+j)) 
    112                                     <<endl; 
    113                                 wrong = true; 
    114                         } 
    115          
    116         delete[] C; 
    117                  
    118         if ( wrong ){ 
    119                 cerr<<"FAIL A modifed"<<endl; 
    120                 //write_field (F,cerr<<"B2="<<endl,B2,m,n,n); 
    121                 //write_field (F,cerr<<"B="<<endl,B,m,n,n); 
    122         }else{ 
    123          
    124                 cerr<<"PASS"<<endl; 
    125         } 
    126          
    127102#endif 
    128103 
     
    130105        delete[] B; 
    131106        delete[] B2; 
     107 
    132108#if TIME 
    133109        double mflops = m*n/1000000.0*nbit*n/time; 
  • tests/test-invert.C

    r25 r62  
    1919 
    2020 
    21  
    22  
    23 typedef Modular<double> Field; 
     21typedef ModularBalanced<float> Field; 
    2422 
    2523int main(int argc, char** argv){ 
     
    3735                exit(-1); 
    3836        } 
    39         Field F(atoi(argv[1])); 
     37        Field F(atof(argv[1])); 
    4038        F.init(zero,0.0); 
    4139        F.init(one,1.0); 
  • tests/test-lqup.C

    r37 r62  
    2020#include "Matio.h" 
    2121#include "timer.h" 
    22 //#include "fflas-ffpack/modular-balanced.h" 
    23 #include "fflas-ffpack/modular-positive.h" 
     22#include "fflas-ffpack/modular-balanced.h" 
    2423#include "fflas-ffpack/ffpack.h" 
    2524 
    26 typedef Modular<double> Field; 
     25//typedef ModularBalanced<double> Field; 
     26typedef ModularBalanced<float> Field; 
    2727 
    2828int main(int argc, char** argv){ 
     
    3737                exit(-1); 
    3838        } 
    39         Field F((unsigned long)atoi(argv[1])); 
     39        Field F(atof(argv[1])); 
    4040        Field::Element * A; 
    4141         
     
    5151 
    5252        enum FFLAS::FFLAS_DIAG diag = FFLAS::FflasUnit; 
    53         enum FFLAS::FFLAS_TRANSPOSE trans = FFLAS::FflasTrans; 
     53        enum FFLAS::FFLAS_TRANSPOSE trans = FFLAS::FflasNoTrans; 
    5454        if (trans == FFLAS::FflasTrans){ 
    5555                maxP = m; 
     
    122122                        F.assign(*(L+i*(m+1)), one); 
    123123 
    124 //              write_field(F,cerr<<"L = "<<endl,L,m,m,m); 
    125 //              write_field(F,cerr<<"U = "<<endl,U,m,n,n); 
     124                //write_field(F,cerr<<"L = "<<endl,L,m,m,m); 
     125                //write_field(F,cerr<<"U = "<<endl,U,m,n,n); 
    126126                if (diag == FFLAS::FflasNonUnit) 
    127127                        for ( int i=0; i<R; ++i ) 
     
    196196        for (int i=0; i<m; ++i) 
    197197                for (int j=0; j<n; ++j) 
    198                         if (!F.areEqual (*(B+i*n+j), *(X+i*n+j))) 
     198                        if (!F.areEqual (*(B+i*n+j), *(X+i*n+j))){ 
     199                                std::cerr << " B["<<i<<","<<j<<"] = " << (*(B+i*n+j)) 
     200                                          << " X["<<i<<","<<j<<"] = " << (*(X+i*n+j)) 
     201                                          << endl; 
    199202                                fail=true; 
    200          
     203                        } 
    201204//      write_field(F,cerr<<"X = "<<endl,X,m,n,n); 
    202205//      write_field(F,cerr<<"B = "<<endl,B,m,n,n); 
     
    218221        double numops = m*m/1000.0*(n-m/3.0); 
    219222         
    220         cerr<<m<<"x"<< n  
     223        cerr<<m<<"x"<< n 
     224            << " Trans = "<<trans 
     225            << " Diag = "<<diag 
    221226            << " : rank = " << R << "  [" 
    222227            << ((double)nbf/1000.0*(double)numops / t)  
  • tests/test-rank.C

    r12 r62  
    1818using namespace std; 
    1919 
    20 typedef Modular<double> Field; 
     20typedef ModularBalanced<double> Field; 
    2121 
    2222int main(int argc, char** argv){ 
     
    3232                exit(-1); 
    3333        } 
    34         Field F(atoi(argv[1])); 
     34        Field F(atof(argv[1])); 
    3535        Field::Element * A; 
    3636        A = read_field(F,argv[2],&m ,&n); 
  • tests/testeur_fgemm.C

    r25 r62  
    1212#include <iomanip> 
    1313using namespace std; 
    14 //#include "fflas-ffpack/modular-int.h" 
    15 #include "fflas-ffpack/modular-balanced.h" 
     14#include "fflas-ffpack/modular-int.h" 
     15//#include "fflas-ffpack/modular-balanced.h" 
    1616#include "timer.h" 
    1717#include "Matio.h" 
     
    2121 
    2222 
    23 typedef Modular<double> Field; 
     23//typedef ModularBalanced<float> Field; 
     24typedef ModularBalanced<double> Field; 
     25//typedef Modular<double> Field; 
     26//typedef Modular<float> Field; 
    2427//typedef Modular<int> Field; 
    25 //typedef Modular<float> Field; 
    2628//typedef GivaroZpz<Std32> Field; 
    2729//typedef GivaroGfq Field; 
     
    3133        IntPrimeDom IPD; 
    3234        Field::Element alpha, beta; 
    33         int p; 
     35        long p; 
    3436        size_t M, K, N, Wino; 
    3537        bool keepon = true; 
     
    126128//                                      keepon = false; 
    127129//              } 
    128                 Field::Element aij, bij, boa; 
    129                 F.div(boa, beta, alpha); 
     130                Field::Element aij, bij, boa, temp; 
     131                //F.div(boa, beta, alpha); 
    130132                for (int i = 0; i < M; ++i ) 
    131133                        for ( int j = 0; j < N; ++j ){ 
    132                                 F.mulin(*(Cbis+i*N+j),boa); 
     134                                //                              F.mulin(*(Cbis+i*N+j),boa); 
     135                                F.mulin(*(Cbis+i*N+j),beta); 
    133136                                for ( int l = 0; l < K ; ++l ){ 
    134137                                        if ( ta == FFLAS::FflasNoTrans ) 
     
    140143                                        else 
    141144                                                bij = *(B+j*ldb+l); 
    142                                          
    143                                         F.axpyin( *(Cbis+i*N+j), aij, bij ); 
     145                                        F.mul(temp,aij,bij); 
     146                                        F.axpyin( *(Cbis+i*N+j), alpha, temp); 
     147                                        //F.axpyin( *(Cbis+i*N+j), aij, bij ); 
    144148                                } 
    145                                 F.mulin( *(Cbis+i*N+j),alpha ); 
     149                                //F.mulin( *(Cbis+i*N+j),alpha ); 
    146150                                if ( !F.areEqual( *(Cbis+i*N+j), *(C+i*N+j) ) ) { 
    147151                                        cerr<<"error for i,j="<<i<<" "<<j<<" "<<*(C+i*N+j)<<" "<<*(Cbis+i*N+j)<<endl; 
     
    160164                } 
    161165                else{ 
    162                         cerr<<"C="<<endl; 
    163                         write_field( F, cerr, C, M, N, N ); 
    164                         cerr<<"Cbis="<<endl; 
    165                         write_field( F, cerr, Cbis, M, N, N ); 
     166                        // cerr<<"C="<<endl; 
     167//                      write_field( F, cerr, C, M, N, N ); 
     168//                      cerr<<"Cbis="<<endl; 
     169//                      write_field( F, cerr, Cbis, M, N, N ); 
    166170                } 
    167171        } 
  • tests/testeur_lqup.C

    r26 r62  
    2121 
    2222 
    23 typedef Modular<double> Field; 
     23//typedef Modular<double> Field; 
     24typedef ModularBalanced<double> Field; 
     25//typedef Modular<float> Field; 
     26//typedef ModularBalanced<float> Field; 
    2427//typedef Modular<int> Field; 
    25 //typedef Modular<float> Field; 
    2628//typedef GivaroZpz<Std32> Field; 
    2729//typedef GivaroGfq Field; 
     
    265267        for (size_t i=0; i<M; ++i) 
    266268                for (size_t j=0; j<N; ++j) 
    267                         if (!(*(Abis+i*lda+j))) 
    268                                 cerr<<i+1<<" "<<j+1<<" "<<((size_t) *(Abis+i*lda+j) )<<endl; 
     269                        if (*(Abis+i*lda+j)) 
     270                                cerr<<i+1<<" "<<j+1<<" "<<((int) *(Abis+i*lda+j) )<<endl; 
    269271        cerr<<"0 0 0"<<endl<<endl; 
    270272