EigenLDLTSolver.hh 4.33 KB
Newer Older
1 2 3 4 5 6
/*===========================================================================*\
 *                                                                           *
 *                               CoMISo                                      *
 *      Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.rwth-graphics.de                            *
 *                                                                           *
7
 *---------------------------------------------------------------------------*
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *  This file is part of CoMISo.                                             *
 *                                                                           *
 *  CoMISo is free software: you can redistribute it and/or modify           *
 *  it under the terms of the GNU General Public License as published by     *
 *  the Free Software Foundation, either version 3 of the License, or        *
 *  (at your option) any later version.                                      *
 *                                                                           *
 *  CoMISo 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 General Public License for more details.                             *
 *                                                                           *
 *  You should have received a copy of the GNU General Public License        *
 *  along with CoMISo.  If not, see <http://www.gnu.org/licenses/>.          *
 *                                                                           *
23
\*===========================================================================*/
24 25 26 27 28 29 30 31 32 33 34 35


//=============================================================================
//
//  CLASS CholmodSolver
//
//=============================================================================

#ifndef COMISO_EIGEN_LDLT_SOLVER_HH
#define COMISO_EIGEN_LDLT_SOLVER_HH


36 37
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
David Bommes's avatar
David Bommes committed
38
#if (COMISO_EIGEN3_AVAILABLE)
39 40 41 42 43 44 45 46
//== INCLUDES =================================================================


#include <CoMISo/Config/CoMISoDefines.hh>

#include <iostream>
#include <vector>

47

Max Lyon's avatar
Max Lyon committed
48 49
#include <Base/Code/Quality.hh>
LOW_CODE_QUALITY_SECTION_BEGIN
50 51 52
#include <Eigen/Eigen>
#include <Eigen/Sparse>
#include <Eigen/SparseCholesky>
Max Lyon's avatar
Max Lyon committed
53
LOW_CODE_QUALITY_SECTION_END
54 55 56 57 58 59 60


//== NAMESPACES ===============================================================

namespace COMISO {

//== CLASS DEFINITION =========================================================
61
class COMISODLLEXPORT EigenLDLTSolver
62 63
{
public:
64
  EigenLDLTSolver() : n_(0) {}
65

66 67 68
  bool calc_system(const std::vector<int>&    _colptr,
    const std::vector<int>&    _rowind,
    const std::vector<double>& _values);
Andreas Fabri's avatar
Andreas Fabri committed
69

70 71
  template< class GMM_MatrixT>
  bool calc_system_gmm(const GMM_MatrixT& _mat);
72

73 74
  template< class Eigen_MatrixT>
  bool calc_system_eigen(const Eigen_MatrixT& _mat);
75

76 77 78
  bool update_system(const std::vector<int>&    _colptr,
    const std::vector<int>&    _rowind,
    const std::vector<double>& _values);
79

80 81
  template< class GMM_MatrixT>
  bool update_system_gmm(const GMM_MatrixT& _mat);
82

83 84
  template< class Eigen_MatrixT>
  bool update_system_eigen(const Eigen_MatrixT& _mat);
85 86


87
  bool solve(double *             _x0, double *             _b);
88 89


90 91 92 93 94 95 96 97
  bool solve(std::vector<double>& _x0, std::vector<double>& _b);


  bool& show_timings();


  int dimension();

98 99
private:

100 101
  // dimension n_
  unsigned int n_;
102

103
  Eigen::SimplicialLDLT<Eigen::SparseMatrix<double> > ldlt_;
104

105
  bool show_timings_;
106 107
};

108
  //=============================================================================
109 110 111 112 113 114 115
} // namespace COMISO
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_EIGEN_LDLT_SOLVER_TEMPLATES_C)
#define COMISO_EIGEN_LDLT_SOLVER_TEMPLATES
#include "EigenLDLTSolverT.cc"
#endif
//=============================================================================
David Bommes's avatar
David Bommes committed
116
#endif // COMISO_EIGEN3_AVAILABLE
117
//=============================================================================
118 119
#endif // COMISO_EIGEN_LDLT_SOLVER_HH defined
//=============================================================================