/* * Copyright (C) 2016 FFLAS-FFPACK * Written by Clément Pernet * This file is Free Software and part of FFLAS-FFPACK. * * ========LICENCE======== * This file is part of the library FFLAS-FFPACK. * * FFLAS-FFPACK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ========LICENCE======== *. */ //-------------------------------------------------------------------------- // Test for the computations of the LDLT factorization //-------------------------------------------------------------------------- #include #include #include template std::ostream& operator<<(std::ostream& os, const std::vector &x){ std::ostream_iterator out_it (os,", "); std::copy ( x.begin(), x.end(), out_it ); return os; } #include "fflas-ffpack/fflas-ffpack-config.h" #include "fflas-ffpack/ffpack/ffpack.h" #include "fflas-ffpack/utils/args-parser.h" #include #include #include #include #include "fflas-ffpack/utils/test-utils.h" using namespace std; using namespace FFPACK; using namespace FFLAS; template bool test_RPM_fsytrf (Field& F, FFLAS_UPLO uplo, string file, size_t n, size_t r, RandIter& G, size_t threshold){ typename Field::Element_ptr A; size_t lda; if (!file.empty()){ ReadMatrix (file, F, n, n, A); lda = n; } else { lda = n+(rand() % 13); A = fflas_new (F, n,lda); RandomSymmetricMatrixWithRankandRandomRPM (F, n, r, A, lda, G); } typename Field::Element_ptr B = fflas_new(F, n,lda); fassign (F,n,n,A,lda, B, lda); size_t * P = fflas_new(n); size_t rank = fsytrf_RPM (F, uplo, n, A, lda, P, threshold); typename Field::Element_ptr T = fflas_new(F, n, n); typename Field::Element_ptr U = fflas_new(F, n, n); getTridiagonal(F,n,rank,A,lda, P, T, n); getTriangular(F,FflasUpper, FflasUnit, n,n,rank,A,lda, U, n, false); fgemm(F,FflasTrans,FflasNoTrans, n,n,n,F.one, U,n,T,n,F.zero,A,lda); fgemm(F,FflasNoTrans,FflasNoTrans, n,n,n,F.one,A,lda,U,n,F.zero,T,n); for (size_t i=0; i bool test_generic_fsytrf (Field& F, FFLAS_UPLO uplo, string file, size_t n, RandIter& G, size_t threshold){ typename Field::Element_ptr A; size_t lda; if (!file.empty()){ ReadMatrix (file, F, n, n, A); lda = n; } else { lda = n+(rand() % 13); A = fflas_new (F, n,lda); RandomSymmetricMatrix (F, n, true, A, lda, G); } typename Field::Element_ptr B = fflas_new(F, n,lda); fassign (F,n,n,A,lda, B, lda); bool success=FFPACK::fsytrf (F, uplo, n, A, lda, threshold); if (!success) cerr<<"Non definite matrix"< bool run_with_field(Givaro::Integer q, uint64_t b, size_t n, size_t r, size_t iters, string file, size_t threshold, uint64_t& seed){ bool ok = true ; int nbit=(int)iters; while (ok && nbit){ // choose Field Field* F= chooseField(q,b,seed); if (F==nullptr) return true; typename Field::RandIter G(*F,0,seed++); ostringstream oss; F->write(oss); cout.fill('.'); cout<<"Checking "; cout.width(40); cout<