|
| constexpr | AMatrix ()=default |
| | Default constructor. Assume elements are uninitialized.
|
| constexpr | AMatrix (const Accessor &accessor) |
| | Constructor from a given accessor.
|
| template<typename... Args> |
| constexpr | AMatrix (Args &&... args) |
| | Constructor to initialize all elements explicitly. Requires the number of arguments to be N and the type of each to be T. Only enabled if the Accessor has a N-argument constructor.
|
| constexpr | AMatrix (const std::initializer_list< T > &list) |
| | Constructor to initialize all elements via initializer list.
|
| constexpr | ~AMatrix ()=default |
| | Destructor.
|
| constexpr | AMatrix (const AMatrix< T, N, M, Accessor > &)=default |
| | Default copy constructor.
|
| constexpr | AMatrix (AMatrix< T, N, M, Accessor > &&)=default |
| | Default move constructor.
|
| constexpr AMatrix< T, N, M, Accessor > & | operator= (const AMatrix< T, N, M, Accessor > &)=default |
| | Default copy assignment operator.
|
| constexpr AMatrix< T, N, M, Accessor > & | operator= (AMatrix< T, N, M, Accessor > &&)=default |
| | Default move assignment operator.
|
| template<ValidMatrixType OtherMatrixType> |
| constexpr | AMatrix (const OtherMatrixType &other) &&(OtherMatrixType |
| | Deep copy constructor with different accessor or ownership.
|
| template<ValidMatrixType OtherMatrixType> |
| constexpr | AMatrix (OtherMatrixType &&other) &&(OtherMatrixType |
| | Deep move constructor with different accessor or ownership.
|
| template<ValidMatrixType OtherMatrixType> |
| constexpr AMatrix< T, N, M, Accessor > & | operator= (const OtherMatrixType &other) |
| | Deep copy assignment operator with different accessor or ownership.
|
| template<ValidMatrixType OtherMatrixType> |
| constexpr AMatrix< T, N, M, Accessor > & | operator= (OtherMatrixType &&other) |
| | Deep move assignment operator with different accessor or ownership.
|
| constexpr AMatrix< T, N, M, Accessor > & | operator= (const T value) |
| | Deep copy assignment operator from a single value.
|
| constexpr T & | operator[] (size_t index) |
| | Element access operator via flat index.
|
| constexpr const T & | operator[] (size_t index) const |
| | Const element access operator via flat index.
|
| constexpr T & | operator() (size_t index) |
| | Element access operator via flat index.
|
| constexpr const T & | operator() (size_t index) const |
| | Const element access operator via flat index.
|
| constexpr T & | operator() (size_t row, size_t col) |
| | Element access operator via row and column indices.
|
| constexpr const T & | operator() (size_t row, size_t col) const |
| | Const element access operators.
|
| constexpr decltype(auto) | data () |
| | Get the internal data accessor.
|
| constexpr decltype(auto) | data () const |
| | Get the internal data accessor.
|
| constexpr deep_copy_t | copy () const |
| | Get a deep copy of the matrix.
|
| constexpr Vector< non_const_value_type, N > | copy_column (size_t col) const |
| | Get a copy of a certain column of the matrix.
|
| constexpr Vector< non_const_value_type, M > | copy_row (size_t row) const |
| | Get a copy of a certain row of the matrix.
|
| template<size_t col> |
| constexpr auto | view_column () |
| | Get a view into a certain column of the matrix.
|
| template<size_t col> |
| constexpr auto | view_column () const |
| | Get a view into a certain column of the matrix.
|
| template<size_t row> |
| constexpr auto | view_row () |
| | Get a view into a certain row of the matrix.
|
| template<size_t row> |
| constexpr auto | view_row () const |
| | Get a view into a certain row of the matrix.
|
| constexpr auto | view_diagonal () |
| | Get a view into the diagonal of the matrix.
|
| constexpr auto | view_diagonal () const |
| | Get a view into the diagonal of the matrix.
|
| constexpr auto | view_transpose () |
| | Get a view into the transpose of the matrix.
|
| constexpr auto | view_transpose () const |
| | Get a view into the transpose of the matrix.
|
| template<size_t row_to_exclude, size_t col_to_exclude> |
| constexpr auto | view_minor () |
| | Get a view into the matrix excluding a certain row and column This is known as the minor of the element at that row/column.
|
| template<size_t row_to_exclude, size_t col_to_exclude> |
| constexpr auto | view_minor () const |
| | Get a view into the matrix excluding a certain row and column This is known as the minor of the element at that row/column.
|
| template<typename U> |
| constexpr auto | cast () const |
| | Cast (and copy) the matrix to a different type.
|
| template<typename... Args> |
| constexpr void | set (Args &&... args) |
| | Set all elements of the matrix.
|
| template<ValidAccessor< T > OtherAccessor> |
| constexpr void | set (const OtherAccessor &accessor) |
| | Set all elements of the matrix using an accessor.
|
| template<typename... Args> |
| constexpr void | set_row (const size_t &i, Args &&... args) |
| | Set a certain row of the matrix.
|
| template<typename OtherAccessor> |
| constexpr void | set_row (const size_t &i, const AVector< T, M, OtherAccessor > &row) |
| | Set a certain row of the matrix.
|
| template<typename... Args> |
| constexpr void | set_column (const size_t &j, Args &&... args) |
| | Set a certain column of the matrix.
|
| template<typename OtherAccessor> |
| constexpr void | set_column (const size_t &j, const AVector< T, N, OtherAccessor > &col) |
| | Set a certain column of the matrix.
|
| constexpr void | fill (const T &value) |
| | Fill all elements of the matrix with a single value.
|
| constexpr AMatrix< T, N, M > | operator+ () const |
| | Unary plus operator.
|
| constexpr AMatrix< T, N, M > | operator- () const |
| | Unary minus operator.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator+ (const AMatrix< U, N, M, OtherAccessor > &other) const |
| | AMatrix-matrix addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AMatrix< T, N, M, Accessor > & | operator+= (const AMatrix< U, N, M, OtherAccessor > &other) |
| | Self-matrix addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator- (const AMatrix< U, N, M, OtherAccessor > &other) const |
| | AMatrix-matrix subtraction.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AMatrix< T, N, M, Accessor > & | operator-= (const AMatrix< U, N, M, OtherAccessor > &other) |
| | Self-matrix subtraction.
|
| template<typename U> |
| constexpr auto | operator+ (const U &scalar) const |
| | AMatrix-scalar addition.
|
| template<typename U> |
| constexpr AMatrix< T, N, M, Accessor > & | operator+= (const U &scalar) |
| | Self-scalar addition.
|
| template<typename U> |
| constexpr auto | operator- (const U &scalar) const |
| | AMatrix-scalar subtraction.
|
| template<typename U> |
| constexpr AMatrix< T, N, M, Accessor > & | operator-= (const U &scalar) |
| | Self-scalar subtraction.
|
| template<typename U, typename OtherAccessor, size_t OtherN, size_t OtherM> |
| constexpr auto | operator* (const AMatrix< U, OtherN, OtherM, OtherAccessor > &other) const |
| | AMatrix-matrix multiplication.
|
| template<typename U, typename OtherAccessor, size_t OtherN, size_t OtherM> |
| constexpr AMatrix< T, N, M, Accessor > & | operator*= (const AMatrix< U, OtherN, OtherM, OtherAccessor > &other) |
| | Self-matrix multiplication.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator* (const AVector< U, M, OtherAccessor > &other) const |
| | AMatrix-vector multiplication.
|
| template<typename U> |
| constexpr auto | operator* (const U &scalar) const |
| | AMatrix-scalar multiplication.
|
| template<typename U> |
| constexpr AMatrix< T, N, M, Accessor > & | operator*= (const U &scalar) |
| | Self-scalar multiplication.
|
| template<typename U> |
| constexpr auto | operator/ (const U &scalar) const |
| | AMatrix-scalar division.
|
| template<typename U> |
| constexpr AMatrix< T, N, M, Accessor > & | operator/= (const U &scalar) |
| | Self-scalar division.
|
template<typename T, size_t N, size_t M, ValidAccessor< T > Accessor>
class mundy::AMatrix< T, N, M, Accessor >
- Template Parameters
-
| T | The type of the entries. |
| Accessor | The type of the accessor. |
This class is designed to be used with Kokkos. It is a simple NxM matrix with arithmetic entries implemented without for loops (to provide compile-time optimization for small matrix sizes). It is templated on the type of the entries, Accessor type, and the number of rows and columns. See Accessor.hpp for more details on the Accessor type requirements.
The goal of AMatrix is to be a lightweight class that can be used with Kokkos to perform mathematical operations on matrices in RNxM. It does not own or manage the underlying data, but rather it is templated on an Accessor type that provides access to the underlying data. This allows us to use AMatrix with Kokkos Views, raw pointers, or any other type that meets the ValidAccessor requirements without copying the data. This is especially important for GPU-compatible code.
AMatrices can be constructed by passing an accessor to the constructor. However, if the accessor has a N*M-argument constructor, then the AMatrix can also be constructed by passing the elements directly to the constructor (in row-major order). Similarly, if the accessor has an initializer list constructor, then the AMatrix can be constructed by passing an initializer list to the constructor. This is a convenience feature which makes working with the default accessor (Array<T, N*M>) easier. For example, the following are all valid ways to construct a AMatrix:
AMatrix<int, 3, 3> mat1({1, 2, 3, 4, 5, 6, 7, 8, 9});
AMatrix<int, 3, 3> mat2(1, 2, 3, 4, 5, 6, 7, 8, 9);
AMatrix<int, 3, 3> mat3(
Array<int, 9>{1, 2, 3, 4, 5, 6, 7, 8, 9});
mat4.
set(1, 2, 3, 4, 5, 6, 7, 8, 9);
double data[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
Class for an NxM (num rows x num columns) matrix with arithmetic entries.
Definition Matrix.hpp:120
constexpr decltype(auto) data()
Get the internal data accessor.
Definition Matrix.hpp:314
constexpr void set(Args &&... args)
Set all elements of the matrix.
Definition Matrix.hpp:472
friend class AMatrix
Definition Matrix.hpp:717
A simplistic array type with a fixed size and type.
Definition Array.hpp:44
- Note
- Accessors may be owning or non-owning, that is irrelevant to the AMatrix class; however, these accessors should be lightweight such that they can be copied around without much overhead. Furthermore, the lifetime of the data underlying the accessor should be as long as the AMatrix that use it.