SuiteSparseSolver
The GeMA Suite Sparse Numeric Solver Plugin
Loading...
Searching...
No Matches
suiteSparseMatrix.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_SUITESPARSE_MATRIX_H_
25#define _GEMA_SUITESPARSE_MATRIX_H_
26
27#include <gmSparseMatrix.h>
28
29#include <cholmod.h> // For cholmod_sparse
30
32template<class IndexType>
33class SuiteSparseMatrix : public GmSparseMatrix<IndexType, GM_CSC_SPARSE_FORMAT>
34{
35public:
36
38 virtual ~SuiteSparseMatrix();
39
41 cholmod_sparse* cholmodMatrix() { return &_cholMatrix; }
42
43 static cholmod_sparse* newCholmodMatrix(int nlin, int ncol, IndexType nnz, double* values, IndexType* ptrs, IndexType* indices);
44
45 virtual void clear(bool keepSparseLayout);
46 virtual void clearLineAndColumnSet(const QVector<int>& indexList, bool setDiagonal, bool keepSparseLayout);
47 virtual void ensureDiagonal();
48
49protected:
50 virtual void matrixLayoutReady();
52
53private:
54 void updateCholMatrix();
55 void clearCholMatrix();
56
57 static void initCholMatrix(cholmod_sparse* m, int nlin, int ncol);
58 static void initCholMatrixData(cholmod_sparse* m, IndexType nnz, double* values, IndexType* ptrs, IndexType* indices);
59
60 cholmod_sparse _cholMatrix;
61};
62
63void SuiteSparseFillCholmodVector(cholmod_dense* v, int nlin, double* values);
64
65
66#endif
A class for wrapping up a suite sparse matrix as a cholmod_sparse structure.
Definition suiteSparseMatrix.h:34
cholmod_sparse * cholmodMatrix()
Returns the "SuiteSparse"Cholmod" matrix wrapped by this class.
Definition suiteSparseMatrix.h:41
SuiteSparseMatrix(int nlin, int ncol, const SuiteSparseMatrix< IndexType > *sharedLayout, GmSparseMatrixOptions options)
Constructor for the square matrix used by the SuiteSparse set of solvers. If sharedLayout is differen...
Definition suiteSparseMatrix.cpp:38
void updateCholMatrix()
Updates the number of non - zero values + value and index pointers in the CHOLMOD matrix from the spa...
Definition suiteSparseMatrix.cpp:197
virtual ~SuiteSparseMatrix()
Destructor.
Definition suiteSparseMatrix.cpp:62
static void initCholMatrix(cholmod_sparse *m, int nlin, int ncol)
Initializes the given matrix with the number of lines / columns & other constant values.
Definition suiteSparseMatrix.cpp:151
virtual void matrixLayoutReady()
Allocates space for matrix values and build the LIS wrapper over matrix vectors.
Definition suiteSparseMatrix.cpp:69
static void initCholMatrixData(cholmod_sparse *m, IndexType nnz, double *values, IndexType *ptrs, IndexType *indices)
Initializes the given matrix with the layout + data values.
Definition suiteSparseMatrix.cpp:181
void clearCholMatrix()
Clears the information stored in the SuperLU matrix.
Definition suiteSparseMatrix.cpp:209
static cholmod_sparse * newCholmodMatrix(int nlin, int ncol, IndexType nnz, double *values, IndexType *ptrs, IndexType *indices)
Creates a new cholmod_sparse structure filled with the given data. No space is allocated....
Definition suiteSparseMatrix.cpp:138
void SuiteSparseFillCholmodVector(cholmod_dense *v, int nlin, double *values)
Fills the given dense matrix with data from the given vector. No space is allocated....
Definition suiteSparseMatrix.cpp:223