// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Global variables for input parameters int MaximumIters; // Maximum number of iterations double RelErr; // Relative error of the computed solution double best_time_val; // Current best time overall solvers int best_time_id; // id of the best solver for the current system
void printStatheader(std::ofstream& out)
{ // Print XML header // NOTE It would have been much easier to write these XML documents using external libraries like tinyXML or Xerces-C++.
out << "<?xml version='1.0' encoding='UTF-8'?> \n";
out << "<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
out << "<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
out << "\n\n<!-- Generated by the Eigen library -->\n";
out << "\n<BENCH> \n" ; //root XML element // Print the xsl style section
printBenchStyle(out); // List all available solvers
out << " <AVAILSOLVER> \n"; #ifdef EIGEN_UMFPACK_SUPPORT
out <<" <SOLVER ID='" << EIGEN_UMFPACK << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> UMFPACK </PACKAGE> \n";
out << " </SOLVER> \n"; #endif #ifdef EIGEN_KLU_SUPPORT
out <<" <SOLVER ID='" << EIGEN_KLU << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> KLU </PACKAGE> \n";
out << " </SOLVER> \n"; #endif #ifdef EIGEN_SUPERLU_SUPPORT
out <<" <SOLVER ID='" << EIGEN_SUPERLU << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> SUPERLU </PACKAGE> \n";
out << " </SOLVER> \n"; #endif #ifdef EIGEN_CHOLMOD_SUPPORT
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_SIMPLICIAL_LLT << "'>\n";
out << " <TYPE> LLT SP</TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_SUPERNODAL_LLT << "'>\n";
out << " <TYPE> LLT</TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n"; #endif #ifdef EIGEN_PARDISO_SUPPORT
out <<" <SOLVER ID='" << EIGEN_PARDISO << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PARDISO_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PARDISO_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n"; #endif #ifdef EIGEN_PASTIX_SUPPORT
out <<" <SOLVER ID='" << EIGEN_PASTIX << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PASTIX_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PASTIX_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n"; #endif
out <<" <SOLVER ID='" << EIGEN_BICGSTAB << "'>\n";
out << " <TYPE> BICGSTAB </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_BICGSTAB_ILUT << "'>\n";
out << " <TYPE> BICGSTAB_ILUT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_GMRES_ILUT << "'>\n";
out << " <TYPE> GMRES_ILUT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SIMPLICIAL_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SIMPLICIAL_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CG << "'>\n";
out << " <TYPE> CG </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SPARSELU_COLAMD << "'>\n";
out << " <TYPE> LU_COLAMD </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
#ifdef EIGEN_METIS_SUPPORT
out <<" <SOLVER ID='" << EIGEN_SPARSELU_METIS << "'>\n";
out << " <TYPE> LU_METIS </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n"; #endif
out << " </AVAILSOLVER> \n";
// Internal CG
{
cout << "\nSolving with CG ... \n";
ConjugateGradient<SpMat, Lower> solver;
call_itersolver(solver,EIGEN_CG, A, b, refX,statFile);
} //CG+IdentityPreconditioner // { // cout << "\nSolving with CG and IdentityPreconditioner ... \n"; // ConjugateGradient<SpMat, Lower, IdentityPreconditioner> solver; // call_itersolver(solver,EIGEN_CG_PRECOND, A, b, refX,statFile); // }
} // End SPD matrices
}
/* Browse all the matrices available in the specified folder * and solve the associated linear system. * The results of each solve are printed in the standard output * and optionally in the provided html file
*/ template <typename Scalar> void Browse_Matrices(const string folder, bool statFileExists, std::string& statFile, int maxiters, double tol)
{
MaximumIters = maxiters; // Maximum number of iterations, global variable
RelErr = tol; //Relative residual error as stopping criterion for iterative solvers
MatrixMarketIterator<Scalar> it(folder); for ( ; it; ++it)
{ //print the infos for this linear system if(statFileExists)
{
std::ofstream statbuf(statFile.c_str(), std::ios::app);
statbuf << "<LINEARSYSTEM> \n";
statbuf << " <MATRIX> \n";
statbuf << " <NAME> " << it.matname() << " </NAME>\n";
statbuf << " <SIZE> " << it.matrix().rows() << " </SIZE>\n";
statbuf << " <ENTRIES> " << it.matrix().nonZeros() << "</ENTRIES>\n"; if (it.sym()!=NonSymmetric)
{
statbuf << " <SYMMETRY> Symmetric </SYMMETRY>\n" ; if (it.sym() == SPD)
statbuf << " <POSDEF> YES </POSDEF>\n"; else
statbuf << " <POSDEF> NO </POSDEF>\n";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.