Changeset 57

Show
Ignore:
Timestamp:
03/02/08 16:50:38 (10 months ago)
Author:
pernet
Message:

Add MatCopy? in fflas
Add rank profile routines and fullranksubmatrix routines.
Minor fixes

Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • TODO

    r47 r57  
    3131 
    3232 
     33Verifier la validite avec modular<int> (sage révele des det faux) 
     34 
     35Revoir la structure des bornes dans winograd: trop de reductions 
     36   modulaires quand il y a des etapes de wino dans le corps fini. 
  • include/fflas-ffpack/fflas.h

    r44 r57  
    3232         
    3333#ifndef __LINBOX_STRASSEN_OPTIMIZATION 
    34 #define WINOTHRESHOLD 1100 
     34#define WINOTHRESHOLD 428 
    3535#else 
    3636#define WINOTHRESHOLD __LINBOX_WINOTHRESHOLD 
     
    240240                 
    241241                FFLAS_BASE base = BaseCompute<typename Field::Element> ()(F, w); 
    242  
     242                size_t d = DotProdBound (F, w, beta, base); 
     243                //std::cerr<<"d = "<<d<<std::endl; 
    243244                WinoMain (F, ta, tb, m, n, k, alpha, A, lda, B, ldb, beta, 
    244                                  C, ldc, DotProdBound (F, w, beta, base), w, base); 
     245                                 C, ldc, d, w, base); 
    245246                return C; 
    246247                }; 
     
    298299                                                 typename Field::Element* C,  
    299300                                                 const size_t ldc); 
     301        /** 
     302         * MatCopy 
     303         * Makes a copy of the matrix M into a new allocated space. 
     304         */ 
     305        template<class Field> 
     306        static typename Field::Element* MatCopy (const Field& F, 
     307                                                 const size_t M, const size_t N, 
     308                                                 const typename Field::Element * A, 
     309                                                 const size_t lda){ 
     310 
     311                typename Field::Element * C = new typename Field::Element[M*N]; 
     312                for (size_t i = 0; i < N; ++i) 
     313                        for (size_t j = 0; j < N; ++j) 
     314                                F.assign(*(C + i*N + j),*(A + i*lda + j)); 
     315                return C; 
     316        } 
     317         
    300318protected: 
    301319 
  • include/fflas-ffpack/fflas_fgemm.inl

    r36 r57  
    531531                } 
    532532 
     533                // S3 = A11 - A21 in X1 
    533534                typename Field::Element* X1 = new typename Field::Element[mr*x1rd];             // S3 = A11 - A21 in X1 
    534535                d11 = A11; d21 = A21; dx1 = X1; 
  • include/fflas-ffpack/ffpack.h

    r55 r57  
    684684        } 
    685685 
     686        /** RowRankProfile 
     687         * Computes the row rank profile of A. 
     688         * 
     689         * @param A: input matrix of dimension  
     690         * @param rklprofile: return the rank profile as an array of row indexes, of dimension r=rank(A) 
     691         * 
     692         * rkprofile is allocated during the computation. 
     693         * Returns R 
     694         */ 
     695        template <class Field> 
     696        static size_t RowRankProfile (const Field& F, const size_t M, const size_t N, 
     697                                      typename Field::Element* A, const size_t lda, size_t* rkprofile){ 
     698                size_t *P = new size_t[N]; 
     699                size_t *Q = new size_t[M]; 
     700                size_t R; 
     701 
     702                R = LUdivine (F, FflasNonUnit, FflasNoTrans, M, N, A, lda, P, Q); 
     703                rkprofile = new size_t[R]; 
     704 
     705                for (size_t i=0; i<R; ++i) 
     706                        rkprofile[i] = Q[i]; 
     707                delete[] P; 
     708                delete[] Q; 
     709                return R; 
     710        } 
     711 
     712        /** ColumnRankProfile 
     713         * Computes the column rank profile of A. 
     714         * 
     715         * @param A: input matrix of dimension  
     716         * @param rklprofile: return the rank profile as an array of row indexes, of dimension r=rank(A) 
     717         * 
     718         * A is modified  
     719         * rkprofile is allocated during the computation. 
     720         * Returns R 
     721         */ 
     722        template <class Field> 
     723        static size_t ColumnRankProfile (const Field& F, const size_t M, const size_t N, 
     724                                         typename Field::Element* A, const size_t lda, size_t* rkprofile){ 
     725                size_t *P = new size_t[N]; 
     726                size_t *Q = new size_t[M]; 
     727                size_t R; 
     728 
     729                R = LUdivine (F, FflasNonUnit, FflasTrans, M, N, A, lda, P, Q); 
     730                rkprofile = new size_t[R]; 
     731 
     732                for (size_t i=0; i<R; ++i) 
     733                        rkprofile[i] = Q[i]; 
     734                delete[] P; 
     735                delete[] Q; 
     736                return R; 
     737        } 
     738 
     739        /** RowRankProfileSubmatrixIndices 
     740         * Computes the indices of the submatrix r*r X of A whose rows correspond to 
     741         * the row rank profile of A. 
     742         * 
     743         * @param A: input matrix of dimension  
     744         * @param rowindices: array of the row indices of X in A 
     745         * @param colindices: array of the col indices of X in A 
     746         * 
     747         * rowindices and colindices are allocated during the computation.  
     748         * A is modified  
     749         * Returns R 
     750         */ 
     751        template <class Field> 
     752        static size_t RowRankProfileSubmatrixIndices (const Field& F, 
     753                                                      const size_t M, const size_t N, 
     754                                                      typename Field::Element* A, 
     755                                                      const size_t lda, 
     756                                                      size_t*& rowindices, 
     757                                                      size_t*& colindices, 
     758                                                      size_t& R){ 
     759                size_t *P = new size_t[N]; 
     760                size_t *Q = new size_t[M]; 
     761 
     762                R = LUdivine (F, FflasNonUnit, FflasNoTrans, M, N, A, lda, P, Q); 
     763                rowindices = new size_t[M]; 
     764                colindices = new size_t[N]; 
     765                for (size_t i=0; i<R; ++i){ 
     766                        rowindices [i] = Q [i]; 
     767                } 
     768                for (size_t i=0; i<N; ++i) 
     769                        colindices [i] = i; 
     770                size_t tmp; 
     771                for (size_t i=0; i<R; ++i){ 
     772                        if (i != P[i]){ 
     773                                tmp = colindices[i]; 
     774                                colindices[i] = colindices[P[i]]; 
     775                                colindices[P[i]] = tmp; 
     776                        } 
     777                } 
     778                                 
     779                delete[] P; 
     780                delete[] Q; 
     781 
     782                return R; 
     783        } 
     784 
     785        /** ColRankProfileSubmatrixIndices 
     786         * Computes the indices of the submatrix r*r X of A whose columns correspond to 
     787         * the column rank profile of A. 
     788         * 
     789         * @param A: input matrix of dimension  
     790         * @param rowindices: array of the row indices of X in A 
     791         * @param colindices: array of the col indices of X in A 
     792         * 
     793         * rowindices and colindices are allocated during the computation.  
     794         * A is modified  
     795         * Returns R 
     796         */ 
     797        template <class Field> 
     798        static size_t ColRankProfileSubmatrixIndices (const Field& F, 
     799                                                      const size_t M, const size_t N, 
     800                                                      typename Field::Element* A, 
     801                                                      const size_t lda, 
     802                                                      size_t*& rowindices, 
     803                                                      size_t*& colindices, 
     804                                                      size_t& R){ 
     805                size_t *P = new size_t[M]; 
     806                size_t *Q = new size_t[N]; 
     807 
     808                R = LUdivine (F, FflasNonUnit, FflasTrans, M, N, A, lda, P, Q); 
     809                rowindices = new size_t[M]; 
     810                colindices = new size_t[N]; 
     811                for (size_t i=0; i<R; ++i) 
     812                        colindices [i] = Q [i]; 
     813 
     814                for (size_t i=0; i<N; ++i) 
     815                        rowindices [i] = i; 
     816 
     817                size_t tmp; 
     818                for (size_t i=0; i<R; ++i){ 
     819                        if (i != P[i]){ 
     820                                tmp = rowindices[i]; 
     821                                rowindices[i] = rowindices[P[i]]; 
     822                                rowindices[P[i]] = tmp; 
     823                        } 
     824                } 
     825                delete[] P; 
     826                delete[] Q; 
     827 
     828                return R; 
     829        } 
     830 
     831        /** RowRankProfileSubmatrix 
     832         * Compute the r*r submatrix X of A, by picking the row rank profile rows of A 
     833         *  
     834         * @param A: input matrix of dimension M x N 
     835         * @param X: the output matrix 
     836         * 
     837         * A is not modified 
     838         * X is allocated during the computation. 
     839         * Returns R 
     840         */ 
     841        template <class Field> 
     842        static size_t RowRankProfileSubmatrix (const Field& F, 
     843                                               const size_t M, const size_t N, 
     844                                               typename Field::Element* A, 
     845                                               const size_t lda, 
     846                                               typename Field::Element*& X, size_t& R){ 
     847                 
     848                size_t * rowindices, * colindices; 
     849 
     850                typename Field::Element * A2 = MatCopy (F, M, N, A, lda); 
     851                 
     852                RowRankProfileSubmatrixIndices (F, M, N, A2, N, rowindices, colindices, R); 
     853 
     854                X = new typename Field::Element[R*R]; 
     855                for (size_t i=0; i<R; ++i) 
     856                        for (size_t j=0; j<R; ++j) 
     857                                F.assign (*(X + i*R + j), *(A + rowindices[i]*lda + colindices[j])); 
     858                delete[] A2; 
     859                delete[] rowindices; 
     860                delete[] colindices; 
     861                return R; 
     862        } 
     863 
     864 
     865        /** ColRankProfileSubmatrix 
     866         * Compute the r*r submatrix X of A, by picking the row rank profile rows of A 
     867         *  
     868         * @param A: input matrix of dimension M x N 
     869         * @param X: the output matrix 
     870         * 
     871         * A is not modified 
     872         * X is allocated during the computation. 
     873         * Returns R 
     874         */ 
     875         
     876        template <class Field> 
     877        static size_t ColRankProfileSubmatrix (const Field& F, const size_t M, const size_t N, 
     878                                               typename Field::Element* A, const size_t lda, 
     879                                               typename Field::Element*& X, size_t& R){ 
     880                 
     881                size_t * rowindices, * colindices; 
     882                 
     883                typename Field::Element * A2 = MatCopy (F, M, N, A, lda); 
     884                 
     885                ColRankProfileSubmatrixIndices (F, M, N, A2, N, rowindices, colindices, R); 
     886                 
     887                X = new typename Field::Element[R*R]; 
     888                for (size_t i=0; i<R; ++i) 
     889                        for (size_t j=0; j<R; ++j) 
     890                                F.assign (*(X + i*R + j), *(A + rowindices[i]*lda + colindices[j])); 
     891                delete[] A2; 
     892                delete[] colindices; 
     893                delete[] rowindices; 
     894                return R; 
     895        } 
     896 
     897         
    686898        /**  
    687899         * LQUPtoInverseOfFullRankMinor 
     
    777989 
    778990        template <class Field> 
    779         static size_t  
     991        static size_t 
    780992        LUdivine_gauss (const Field& F, const FFLAS_DIAG Diag, 
    781993                        const size_t M, const size_t N, 
     
    12241436        template <class Field> 
    12251437        static size_t  SpecRankProfile (const Field& F, const size_t M, const size_t N, 
    1226                                          typename Field::Element * A, const size_t lda, const size_t deg, size_t *rankProfile); 
     1438                                        typename Field::Element * A, const size_t lda, const size_t deg, size_t *rankProfile); 
    12271439        template <class Field, class Polynomial> 
    12281440        static std::list<Polynomial>&