Thea
SparseMatVec.hpp
1 //============================================================================
2 //
3 // This file is part of the Thea toolkit.
4 //
5 // This software is distributed under the BSD license, as detailed in the
6 // accompanying LICENSE.txt file. Portions are derived from other works:
7 // their respective licenses and copyright information are reproduced in
8 // LICENSE.txt and/or in the relevant source files.
9 //
10 // Author: Siddhartha Chaudhuri
11 // First version: 2019
12 //
13 //============================================================================
14 
15 #ifndef __Thea_SparseMatVec_hpp__
16 #define __Thea_SparseMatVec_hpp__
17 
18 #include "Common.hpp"
19 #include "MatrixFormat.hpp"
20 #include <Eigen/SparseCore>
21 
22 namespace Thea {
23 
24 #ifdef THEA_SPARSE_ROW_MAJOR
25  int const DEFAULT_SPARSE_MATRIX_LAYOUT = MatrixLayout::ROW_MAJOR;
26 #else // nothing provided or THEA_SPARSE_COLUMN_MAJOR defined
27  int const DEFAULT_SPARSE_MATRIX_LAYOUT = MatrixLayout::COLUMN_MAJOR;
28 #endif
29 
34 template <typename T = Real,
35  int Options = DEFAULT_SPARSE_MATRIX_LAYOUT,
36  typename StorageIndex = int>
37 using SparseMatrix = Eigen::SparseMatrix<T, Options, StorageIndex>;
38 
40 template <typename T = Real,
41  typename StorageIndex = int>
42 using SparseColumnMatrix = Eigen::SparseMatrix<T, MatrixLayout::COLUMN_MAJOR, StorageIndex>;
43 
45 template <typename T = Real,
46  typename StorageIndex = int>
47 using SparseRowMatrix = Eigen::SparseMatrix<T, MatrixLayout::ROW_MAJOR, StorageIndex>;
48 
53 template <typename T = Real,
54  int Options = DEFAULT_SPARSE_MATRIX_LAYOUT,
55  typename StorageIndex = int>
56 using SparseVector = Eigen::SparseVector<T, Options, StorageIndex>;
57 
59 template <typename T = Real,
60  typename StorageIndex = int>
61 using SparseColumnVector = Eigen::SparseVector<T, MatrixLayout::COLUMN_MAJOR, StorageIndex>;
62 
64 template <typename T = Real,
65  typename StorageIndex = int>
66 using SparseRowVector = Eigen::SparseVector<T, MatrixLayout::ROW_MAJOR, StorageIndex>;
67 
68 } // namespace Thea
69 
70 #include "MatrixUtil.hpp"
71 
72 #endif
Root namespace for the Thea library.
Eigen::SparseMatrix< T, Options, StorageIndex > SparseMatrix
General 2D sparse matrix template, alias for Eigen::SparseMatrix with a custom default layout (row or...
Eigen::SparseMatrix< T, MatrixLayout::ROW_MAJOR, StorageIndex > SparseRowMatrix
2D sparse row matrix template, alias for Eigen::SparseMatrix with Eigen::RowMajor.
Eigen::SparseVector< T, MatrixLayout::COLUMN_MAJOR, StorageIndex > SparseColumnVector
1D sparse column vector template, alias for Eigen::SparseVector with Eigen::ColMajor.
Eigen::SparseMatrix< T, MatrixLayout::COLUMN_MAJOR, StorageIndex > SparseColumnMatrix
2D sparse column matrix template, alias for Eigen::SparseMatrix with Eigen::ColMajor.
Eigen::SparseVector< T, MatrixLayout::ROW_MAJOR, StorageIndex > SparseRowVector
1D sparse row vector template, alias for Eigen::SparseVector with Eigen::RowMajor.
Eigen::SparseVector< T, Options, StorageIndex > SparseVector
General 1D sparse vector template, alias for Eigen::SparseVector with a custom default layout (row or...