// Copyright (c) 2005 INRIA (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org); you may redistribute it under // the terms of the Q Public License version 1.0. // See the file LICENSE.QPL distributed with CGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Laurent Saboret, Pierre Alliez, Bruno Levy #ifndef CGAL_TAUCS_SOLVER_TRAITS #define CGAL_TAUCS_SOLVER_TRAITS #include #include #include #include #include CGAL_BEGIN_NAMESPACE /// The class Taucs_symmetric_solver_traits /// is a traits class for solving SYMMETRIC DEFINITE POSITIVE sparse linear systems /// using TAUCS solvers family. /// The default solver is the Multifrontal Supernodal Cholesky Factorization. /// /// Concept: Model of the SparseLinearAlgebraTraits_d concept. template // Tested with T = taucs_single or taucs_double // May also work with T = taucs_dcomplex and taucs_scomplex class Taucs_symmetric_solver_traits { // Public types public: typedef Taucs_symmetric_matrix Matrix; typedef Taucs_vector Vector; typedef T NT; // Public operations public: /// Create a TAUCS sparse linear solver for SYMMETRIC DEFINITE POSITIVE matrices. /// The default solver is the Multifrontal Supernodal Cholesky Factorization. /// See taucs_linsolve() documentation for the meaning of the /// 'options' and 'arguments' parameters. Taucs_symmetric_solver_traits( const char* options[] = NULL, ///< must be persistent const void* arguments[] = NULL) ///< must be persistent { static const char* MULTIFRONTAL_LLT[] = {"taucs.factor.LLT=true", "taucs.factor.mf=true", "taucs.factor.ordering=metis", NULL}; m_options = (options == NULL) ? MULTIFRONTAL_LLT : options; m_arguments = arguments; } /// Solve the sparse linear system "A*X = B". /// Return true on success. The solution is then (1/D) * X. /// /// Preconditions: /// - A.row_dimension() == B.dimension(). /// - A.column_dimension() == X.dimension(). bool linear_solver (const Matrix& A, const Vector& B, Vector& X, NT& D) { D = 1; // TAUCS does not support homogeneous coordinates #ifdef DEBUG_TRACE // Turn on TAUCS trace std::cerr.flush(); taucs_logfile("stderr"); #endif //#ifdef DEBUG_TRACE // // Debug trace // fprintf(stderr, "\n"); // fprintf(stderr, "linear_solver:\n"); // int n = A.row_dimension(); // if (n < 20) // if small matrix, print it entirely // { // fprintf(stderr, "****************** A: ******************\n"); // for (int i=0; i::min()); } // Fields private: const char** m_options; const void** m_arguments; }; /// The class Taucs_solver_traits /// is a traits class for solving GENERAL (aka unsymmetric) sparse linear systems /// using TAUCS out-of-core LU factorization. /// /// Concept: Model of the SparseLinearAlgebraTraits_d concept. template // Tested with T = taucs_single or taucs_double // May also work with T = taucs_dcomplex and taucs_scomplex class Taucs_solver_traits { // Public types public: typedef Taucs_matrix Matrix; typedef Taucs_vector Vector; typedef T NT; // Public operations public: /// Create a TAUCS sparse linear solver for GENERAL (aka unsymmetric) matrices. Taucs_solver_traits() { } /// Solve the sparse linear system "A*X = B". /// Return true on success. The solution is then (1/D) * X. /// /// Preconditions: /// - A.row_dimension() == B.dimension(). /// - A.column_dimension() == X.dimension(). bool linear_solver (const Matrix& A, const Vector& B, Vector& X, NT& D) { D = 1; // TAUCS does not support homogeneous coordinates #ifdef DEBUG_TRACE // Turn on TAUCS trace std::cerr.flush(); taucs_logfile("stderr"); #endif //#ifdef DEBUG_TRACE // // Debug trace // fprintf(stderr, "\n"); // fprintf(stderr, "linear_solver:\n"); // int n = A.row_dimension(); // if (n < 20) // if small matrix, print it entirely // { // fprintf(stderr, "****************** A: ******************\n"); // for (int i=0; i::min()); } }; CGAL_END_NAMESPACE #endif // CGAL_TAUCS_SOLVER_TRAITS