Show
Ignore:
Timestamp:
03/11/07 15:11:02 (2 years ago)
Author:
pernet
Message:

New algorithm for charpoly: CharpolyArithProg?

- Complete the unfinished preconditionning phase (using complementary subspace comp. and rec. call)
- Exception management for the Las Vegas failure
- set as default for charpoly

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • include/fflas-ffpack/ffpack.h

    r1 r3  
    4848                                   FfpackKGFast=4, 
    4949                                   FfpackDanilevski=5, 
    50                                    FfpackKGFastG=6 
     50                                   FfpackArithProg=6, 
     51                                   FfpackKGFastG=7 
    5152        }; 
     53         
     54        class CharpolyFailed{}; 
    5255         
    5356        enum FFPACK_MINPOLY_TAG { FfpackDense=1, 
     
    451454        CharPoly( const Field& F, std::list<Polynomial>& charp, const size_t N, 
    452455                  typename Field::Element * A, const size_t lda, 
    453                   const enum FFPACK_CHARPOLY_TAG CharpTag= FfpackLUK); 
     456                  const enum FFPACK_CHARPOLY_TAG CharpTag= FfpackArithProg); 
    454457         
    455458        //--------------------------------------------------------------------- 
     
    469472 
    470473        // Solve L X = B or X L = B in place 
    471         // L is M*M if Side == FflasLeft and N*N if Side == FflasRigt, B is M*N. 
     474        // L is M*M if Side == FflasLeft and N*N if Side == FflasRight, B is M*N. 
    472475        // Only the R non trivial column of L are stored in the M*R matrix L 
    473476        // Requirement :  so that L could  be expanded in-place 
     
    483486                F.init(one, 1.0); 
    484487                F.init(zero, 0.0); 
     488                size_t LM = (Side == FflasRight)?N:M; 
    485489                for (int i=R-1; i>=0; --i){ 
    486490                        if (  Q[i] > (size_t) i){ 
    487491                                //for (size_t j=0; j<=Q[i]; ++j) 
    488492                                //F.init( *(L+Q[i]+j*ldl), 0 ); 
    489                                 fcopy( F, M-Q[i]-1, L+Q[i]*(ldl+1)+ldl,ldl, L+(Q[i]+1)*ldl+i, ldl ); 
    490                                 for ( size_t j=Q[i]*ldl; j<M*ldl; j+=ldl) 
     493                                //cerr<<"1 deplacement "<<i<<"<-->"<<Q[i]<<endl; 
     494                                fcopy( F, LM-Q[i]-1, L+Q[i]*(ldl+1)+ldl,ldl, L+(Q[i]+1)*ldl+i, ldl ); 
     495                                for ( size_t j=Q[i]*ldl; j<LM*ldl; j+=ldl) 
    491496                                        F.assign( *(L+i+j), zero ); 
    492497                        } 
    493498                } 
    494499                ftrsm( F, Side, FflasLower, FflasNoTrans, FflasUnit, M, N, one, L, ldl , B, ldb); 
    495                  
     500                //write_field(F,cerr<<"dans solveLB "<<endl,L,N,N,ldl); 
    496501                // Undo the permutation of L 
    497502                for (size_t i=0; i<R; ++i){ 
     
    499504                                //for (size_t j=0; j<=Q[i]; ++j) 
    500505                                //F.init( *(L+Q[i]+j*ldl), 0 ); 
    501                                 fcopy( F, M-Q[i]-1, L+(Q[i]+1)*ldl+i, ldl, L+Q[i]*(ldl+1)+ldl,ldl ); 
    502                                 for ( size_t j=Q[i]*ldl; j<M*ldl; j+=ldl) 
     506                                fcopy( F, LM-Q[i]-1, L+(Q[i]+1)*ldl+i, ldl, L+Q[i]*(ldl+1)+ldl,ldl ); 
     507                                for ( size_t j=Q[i]*ldl; j<LM*ldl; j+=ldl) 
    503508                                        F.assign( *(L+Q[i]+j), zero ); 
    504509                        } 
     
    547552                        int j=R-1; 
    548553                        while ( j >=0 ) { 
     554                                //cerr<<"j="<<j<<endl; 
    549555                                k = ib = Q[j]; 
    550556                                while ( (j>=0) &&  (Q[j] == k)  ) {--k;--j;} 
    551557                                Ldim = ib-k; 
     558                                //cerr<<"Ldim, ib, k, N = "<<Ldim<<" "<<ib<<" "<<k<<" "<<N<<endl; 
    552559                                Lcurr = L + j+1 + (k+1)*ldl; 
    553560                                Bcurr = B + ib; 
    554561                                Rcurr = Lcurr + Ldim*ldl; 
    555                                 fgemm( F, FflasNoTrans, FflasNoTrans, M, N-ib-1, Ldim, Mone, Bcurr, ldb, Rcurr, ldl,  one, Bcurr-Ldim, ldb); 
     562                                fgemm (F, FflasNoTrans, FflasNoTrans, M,  Ldim, N-ib-1, Mone, Bcurr, ldb, Rcurr, ldl,  one, Bcurr-Ldim, ldb); 
    556563                                //cerr<<"j avant="<<j<<endl; 
    557564                                //cerr<<"k, ib, j, R "<<k<<" "<<ib<<" "<<j<<" "<<R<<endl; 
    558565                                //cerr<<"M,k="<<M<<" "<<k<<endl; 
    559566                                //cerr<<" ftrsm with M, N="<<Ldim<<" "<<N<<endl; 
    560                                 ftrsm( F, Side, FflasLower, FflasNoTrans, FflasUnit, M, Ldim, one, Lcurr, ldl , Bcurr-Ldim, ldb ); 
     567                                ftrsm (F, Side, FflasLower, FflasNoTrans, FflasUnit, M, Ldim, one, Lcurr, ldl , Bcurr-Ldim, ldb ); 
    561568                                //cerr<<"M,k="<<M<<" "<<k<<endl; 
    562569                                //cerr<<" fgemm with M, N, K="<<M-k<<" "<<N<<" "<<Ldim<<endl; 
     
    581588        template <class Field, class Polynomial> 
    582589        static std::list<Polynomial>& 
    583         Frobenius (const Field& F, std::list<Polynomial>& frobeniusForm,  
    584                    const size_t N, typename Field::Element * A, const size_t lda, const size_t c); 
     590        CharpolyArithProg (const Field& F, std::list<Polynomial>& frobeniusForm,  
     591                           const size_t N, typename Field::Element * A, const size_t lda, const size_t c); 
    585592        template <class Field> 
    586593        static void CompressRows (Field& F, const size_t M,