Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_MatrixBase.hpp
1
23#ifndef MORPHEUS_MATRIXBASE_HPP
24#define MORPHEUS_MATRIXBASE_HPP
25
26#include <Morpheus_MatrixOptions.hpp>
27#include <Morpheus_ContainerTraits.hpp>
28
29namespace Morpheus {
30
68template <template <class, class...> class Container, class ValueType,
69 class... Properties>
70class MatrixBase : public ContainerTraits<Container, ValueType, Properties...> {
71 public:
73 using type = MatrixBase<Container, ValueType, Properties...>;
75 using traits = ContainerTraits<Container, ValueType, Properties...>;
77 using size_type = typename traits::size_type;
83 : _m(0), _n(0), _nnz(0), _structure(MATSTR_NONE), _options(MATOPT_NONE) {}
84
93 MatrixBase(size_type rows, size_type cols, size_type entries = 0)
94 : _m(rows),
95 _n(cols),
96 _nnz(entries),
97 _structure(MATSTR_NONE),
98 _options(MATOPT_NONE) {}
99
108 void resize(size_type rows, size_type cols, size_type entries) {
109 _m = rows;
110 _n = cols;
111 _nnz = entries;
112 }
113
119 inline size_type nrows() const { return _m; }
120
126 inline size_type ncols() const { return _n; }
127
133 inline size_type nnnz() const { return _nnz; }
134
140 inline void set_nrows(const size_type rows) { _m = rows; }
141
147 inline void set_ncols(const size_type cols) { _n = cols; }
148
154 inline void set_nnnz(const size_type nnz) { _nnz = nnz; }
155
161 inline MatrixStructure structure() const { return _structure; }
168 inline MatrixOptions options() const { return _options; }
169
175 inline void set_structure(MatrixStructure op) { _structure = op; }
176
182 inline void set_options(MatrixOptions op) { _options = op; }
183
184 private:
185 size_type _m, _n, _nnz;
186 MatrixStructure _structure;
187 MatrixOptions _options;
188};
191} // namespace Morpheus
192
193#endif // MORPHEUS_MATRIXBASE_HPP
Base class used to derive new matrices.
Definition: Morpheus_MatrixBase.hpp:70
void set_options(MatrixOptions op)
Set the characteristics of the matrix.
Definition: Morpheus_MatrixBase.hpp:182
void set_ncols(const size_type cols)
Set the number of columns of the matrix.
Definition: Morpheus_MatrixBase.hpp:147
MatrixBase(size_type rows, size_type cols, size_type entries=0)
Construct a MatrixBase object with shape (num_rows, num_cols) and number of non-zeros equal to num_en...
Definition: Morpheus_MatrixBase.hpp:93
void set_structure(MatrixStructure op)
Set the structure of the matrix.
Definition: Morpheus_MatrixBase.hpp:175
void resize(size_type rows, size_type cols, size_type entries)
Resizes MatrixBase with shape of (num_rows, num_cols) and sets number of non-zero entries to num_entr...
Definition: Morpheus_MatrixBase.hpp:108
size_type nnnz() const
Number of non-zeros of the matrix.
Definition: Morpheus_MatrixBase.hpp:133
void set_nrows(const size_type rows)
Set the number of rows of the matrix.
Definition: Morpheus_MatrixBase.hpp:140
size_type nrows() const
Number of rows of the matrix.
Definition: Morpheus_MatrixBase.hpp:119
size_type ncols() const
Number of columns of the matrix.
Definition: Morpheus_MatrixBase.hpp:126
void set_nnnz(const size_type nnz)
Set the number of non-zeros of the matrix.
Definition: Morpheus_MatrixBase.hpp:154
MatrixStructure structure() const
The specialized structure of the matrix e.g Symmetric.
Definition: Morpheus_MatrixBase.hpp:161
MatrixOptions options() const
Information about specific characteristics of the matrix e.g has short rows.
Definition: Morpheus_MatrixBase.hpp:168
MatrixBase()
Default constructor.
Definition: Morpheus_MatrixBase.hpp:82
Generic Morpheus interfaces.
Definition: dummy.cpp:24
Traits class for accessing attributes of a Container (Matrix or Vector)
Definition: Morpheus_ContainerTraits.hpp:54
size_t size_type
The size type of the container.
Definition: Morpheus_ContainerTraits.hpp:103
A wrapper that checks if the provided type is a scalar type.
Definition: Morpheus_TypeTraits.hpp:85