guanaqo 1.0.0-alpha.26
Utilities for scientific software
Loading...
Searching...
No Matches
matrix-view.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @ingroup linalg_views
5/// Non-owning view over values plus sparsity description.
6
9
10namespace guanaqo::linalg {
11
12/// Non-owning view of dense and various formats of sparse matrix.
13/// @ingroup linalg_views
14template <class T>
15struct MatrixView {
16 /// Description of sparsity format.
18
19 /// Constructs an empty 0×0 dense matrix.
20 MatrixView() : sparsity{sparsity::Dense{0, 0}} {}
21 /// General constructor from flattened values and view of the sparsity
22 /// pattern.
23 /// @param values View of flattened array of (column-major) values.
24 /// @param sparsity View of the sparsity pattern (dense, CSC or COO).
27 /// Dense matrix constructor (column-major).
28 /// @param values View of flattened array of (column-major) values.
29 /// @param rows Number of rows.
30 /// @param cols Number of cols.
31 /// @param symmetry Symmetry of the matrix.
32 MatrixView(std::span<const T> values, length_t rows, length_t cols,
34 : MatrixView{values, sparsity::Dense{rows, cols, symmetry}} {}
35
36 /// Non-owning view of the flattened array of (column-major) values.
37 std::span<const T> values;
38 /// Non-owning view of the sparsity pattern of the matrix.
40};
41
42} // namespace guanaqo::linalg
Common linear algebra index types.
Symmetry
Describes the symmetry of matrices.
Definition sparsity.hpp:20
std::ptrdiff_t length_t
Definition config.hpp:14
Sparse and dense sparsity descriptors.
sparsity::Sparsity Sparsity
Description of sparsity format.
MatrixView(std::span< const T > values, length_t rows, length_t cols, sparsity::Symmetry symmetry=sparsity::Symmetry::Unsymmetric)
Dense matrix constructor (column-major).
MatrixView()
Constructs an empty 0×0 dense matrix.
std::span< const T > values
Non-owning view of the flattened array of (column-major) values.
Sparsity sparsity
Non-owning view of the sparsity pattern of the matrix.
MatrixView(std::span< const T > values, Sparsity sparsity)
General constructor from flattened values and view of the sparsity pattern.
Stores any of the supported sparsity patterns.
Definition sparsity.hpp:118