SuiteSparseSolver
The GeMA Suite Sparse Numeric Solver Plugin
Loading...
Searching...
No Matches
cholmodSolver.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_CHOLMOD_SOLVER_H_
25#define _GEMA_CHOLMOD_SOLVER_H_
26
27#include "suiteSparseSolver.h"
28
29#include <cholmod.h>
30
31
32// Returns the int_32 version of a cholmod method (cholmod_analyze, for example)
33#define CALL_CHOLMOD_I32(name) cholmod_ ## name
34
35// Returns the int_64 version of a cholmod method (cholmod_l_analyze, for example)
36#define CALL_CHOLMOD_I64(name) cholmod_l_ ## name
37
38// Returns the int_32 or int_64 version of a cholmod method, depending on the SuiteSparseSolver::_i64 object attribute
39// Should only be called from inside a CholmodSolver class method
40#define CALL_CHOLMOD(name) (_i64 ? CALL_CHOLMOD_I64(name) : CALL_CHOLMOD_I32(name))
41
42
45{
46public:
47
55
57 virtual ~CholmodSolver();
58
59 // Comments on the base class
60 virtual const char* pluginType() const { return "cholmod"; }
61
62 virtual bool loadPrivateData(LuaTable& table);
63
64 virtual bool solveImpl(GmSolverMatrix* A, const GmVector& b, GmVector& x, bool xIsGuess = false) const;
65
66 virtual void printParameters(const GmLogCategory& logger);
67
68 static QString errorStr(int status);
69
70private:
71 QString errorStr() const { return errorStr(_context.status); }
73
74 mutable cholmod_common _context;
75
76 bool _gpu;
77 bool _refine;
80 bool _LDL;
81 double _symRelTol;
82 double _symAbsTol;
84
85 static int _numSolvers;
86 int _trackSolveRefineItem = -1;
87};
88
89#endif
A class for creating a GeMA solver based on the CHOLMOD solver from the SuiteSparse library.
Definition cholmodSolver.h:45
CholmodSolver(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition cholmodSolver.cpp:99
static QString errorStr(int status)
Translates _context.status error indices.
Definition cholmodSolver.cpp:476
bool _gpu
Are we using the GPU?
Definition cholmodSolver.h:76
static int _numSolvers
The number of instanced solvers.
Definition cholmodSolver.h:85
cholmod_common _context
The Cholmod library context.
Definition cholmodSolver.h:74
double _symRelTol
The relative tolerance when testing a matrix for symmetry.
Definition cholmodSolver.h:81
QString selectedOrderMethod() const
Translates the value of _context.selected into a ordering name.
Definition cholmodSolver.cpp:497
double _symAbsTol
The absolute tolerance when testeing a matrix for symmetry.
Definition cholmodSolver.h:82
bool _refine
Should we perform a refinement step after solving the system?
Definition cholmodSolver.h:77
SymOptions _symmetric
The configured option on matrix symmetry. Default = AUTO.
Definition cholmodSolver.h:79
QString _ordering
The requested ordering option.
Definition cholmodSolver.h:78
virtual ~CholmodSolver()
Destructor.
Definition cholmodSolver.cpp:133
QMap< GmSolverMatrix *, bool > _matrixSymOptions
A map storing whether a matrix is symmetric or not for the _symmetric == FIRST option.
Definition cholmodSolver.h:83
bool _LDL
If true, forces an LDL' factorization. Slow but useful (is it?) for indefinite (non positive definite...
Definition cholmodSolver.h:80
SymOptions
The possible options for the Symmetric flag.
Definition cholmodSolver.h:49
@ SYMPD_TRUE
The matrix is symmetric.
Definition cholmodSolver.h:51
@ SYMPD_FIRST
The symmetry of the matrix will be tested at the first time that the matrix is used.
Definition cholmodSolver.h:53
@ SYMPD_FALSE
The matrix is NOT symmetric.
Definition cholmodSolver.h:52
@ SYMPD_AUTO
The symmetry of the matrix will be tested each time the system is solved.
Definition cholmodSolver.h:50
virtual const GmLogCategory & logger() const
QString description() const
A base class with the common behavior for creating a GeMA solver based on one of the following SuiteS...
Definition suiteSparseSolver.h:44
arma::vec GmVector
Declaration of the SuiteSparseSolver base class.