/* * Copyright (C) 2016 FFLAS-FFPACK group. * * Written by Clément Pernet * Philippe LEDENT * * ========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======== * */ #include "fflas-ffpack/fflas-ffpack-config.h" #include #include #include "fflas-ffpack/utils/timer.h" #include "fflas-ffpack/ffpack/ffpack.h" #include "fflas-ffpack/utils/fflas_randommatrix.h" #ifdef __GIVARO_USE_OPENMP typedef Givaro::OMPTimer TTimer; #else typedef Givaro::Timer TTimer; #endif #include #define CUBE(x) ((x)*(x)*(x)) #define GFOPS(n,t) (CUBE(double(n)/1000.0)/(3.0*t)) int main () { using namespace std; typedef Givaro::ModularBalanced Field; Field F(131071); size_t n=1000, nmax=5000, k=1000, kmax=5000, prec=1000, nbest=0, count=0; TTimer chrono,tim; bool bound=false; time_t result = std::time(NULL); // Let C be a random symmetric n by n matrix Field::Element_ptr C = FFLAS::fflas_new (F, nmax, nmax); size_t ldc = nmax; typename Field::RandIter G(F); FFPACK::RandomSymmetricMatrix (F, n, true, C, ldc,G); // Let B be a copy of C Field::Element_ptr B = FFLAS::fflas_new (F, nmax, nmax); size_t ldb = ldc; FFLAS::fassign (F, n, n, C, ldc, B, ldb); // Let A be a random n by k matrix Field::Element_ptr A = FFLAS::fflas_new (F, nmax, kmax); size_t lda = kmax; FFPACK::RandomMatrix(F,n,k,A,lda); // Let D be a random n dimensional diagonal Field::Element_ptr D = FFLAS::fflas_new (F, nmax); FFPACK::RandomMatrix(F,1,n,D,n); // let alpha and beta be scalars in F Field::Element alpha = F.mOne, beta = F.one; cerr << std::endl << "---------------------------------------------------------------------" << std::endl << std::asctime(std::localtime(&result)) << std::endl << "Threshold for fsyrk base case" ; F.write(cerr << " (using ") << ')' << endl << endl; cerr << "fsyrk: n Base case Recursive 1 level" << std::endl; cerr << " seconds Gfops seconds Gfops" << std::endl; double BCTime, RecTime; int iter; do{ iter=3; //warm up computation FFLAS::fsyrk(F,FFLAS::FflasUpper,FFLAS::FflasNoTrans,n,k,alpha,A,lda,D,1,beta,C,ldc,n); FFLAS::fassign (F, n, n, B, ldb, C, ldc); // base case chrono.clear();tim.clear(); for (int i=0;i RecTime){ count++; if (count > 2){ nbest = n; bound = true; prec = prec >> 1; n -= prec; } } else{ count=0; if (bound) prec=prec>>1; n+=prec; } } while ((prec > 1 ) && (n < nmax)); cerr<s,f0,{0,g0,(0,\:0,t0,+0,=s