CholmodSolver.hh 4.12 KB
Newer Older
Henrik Zimmer's avatar
Henrik Zimmer committed
1 2
/*===========================================================================*\
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
3
 *                               CoMISo                                      *
Henrik Zimmer's avatar
Henrik Zimmer committed
4
 *      Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen      *
Henrik Zimmer's avatar
Henrik Zimmer committed
5
 *                           www.rwth-graphics.de                            *
Henrik Zimmer's avatar
Henrik Zimmer committed
6
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
7 8
 *---------------------------------------------------------------------------* 
 *  This file is part of CoMISo.                                             *
Henrik Zimmer's avatar
Henrik Zimmer committed
9
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
10 11 12 13
 *  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.                                      *
Henrik Zimmer's avatar
Henrik Zimmer committed
14 15 16 17
 *                                                                           *
 *  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            *
Henrik Zimmer's avatar
Henrik Zimmer committed
18
 *  GNU General Public License for more details.                             *
Henrik Zimmer's avatar
Henrik Zimmer committed
19
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
20 21
 *  You should have received a copy of the GNU General Public License        *
 *  along with CoMISo.  If not, see <http://www.gnu.org/licenses/>.          *
Henrik Zimmer's avatar
Henrik Zimmer committed
22
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
23
\*===========================================================================*/ 
Henrik Zimmer's avatar
Henrik Zimmer committed
24 25


26 27 28 29 30 31
//=============================================================================
//
//  CLASS CholmodSolver
//
//=============================================================================

32 33
#ifndef COMISO_CHOLMOD_SOLVER_HH
#define COMISO_CHOLMOD_SOLVER_HH
34 35 36 37 38


//== INCLUDES =================================================================


Henrik Zimmer's avatar
Henrik Zimmer committed
39
#include <CoMISo/Config/CoMISoDefines.hh>
David Bommes's avatar
David Bommes committed
40
#include <CoMISo/Utils/StopWatch.hh>
41 42 43 44

#include <iostream>
#include <vector>

David Bommes's avatar
 
David Bommes committed
45 46 47 48
#include "cholmod.h"

// typedef struct cholmod_common_struct cholmod_common;
// typedef struct cholmod_factor_struct cholmod_factor;
49 50 51 52


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

53
namespace COMISO {
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

//== CLASS DEFINITION =========================================================
class COMISODLLEXPORT CholmodSolver
{
public:

    // _size is maximal size this instance can handle (smaller problems are possible!!!)
    CholmodSolver();
    ~CholmodSolver();
    
    bool calc_system( const std::vector<int>&    _colptr, 
		      const std::vector<int>&    _rowind, 
		      const std::vector<double>& _values );


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


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


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


    bool solve ( double *             _x0, double *             _b);

84
    bool solve ( std::vector<double>& _x0, std::vector<double>& _b);
85

86
    bool& show_timings();
87
    
88
    int dimension();
89
    
90 91 92 93 94 95 96 97 98 99
private:

    cholmod_common * mp_cholmodCommon;

    cholmod_factor * mp_L;

    std::vector<double> values_;
    std::vector<int>    colptr_;
    std::vector<int>    rowind_;

David Bommes's avatar
David Bommes committed
100 101
    bool show_timings_;
    StopWatch sw_;
102 103 104
};

//=============================================================================
105
} // namespace COMISO
106
//=============================================================================
107 108
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_CHOLMOD_SOLVER_TEMPLATES_C)
#define COMISO_CHOLMOD_SOLVER_TEMPLATES
109 110 111
#include "CholmodSolverT.cc"
#endif
//=============================================================================
112
#endif // COMISO_CHOLMOD_SOLVER_HH defined
113
//=============================================================================