OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Matrix.hpp
Go to the documentation of this file.
1//
2// Created by Andrew Nazareth on 5/24/24.
3//
4
5#ifndef OASIS_MATRIX_HPP
6#define OASIS_MATRIX_HPP
7#include "Eigen/Dense"
8#include "LeafExpression.hpp"
9
10namespace Oasis {
11typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> MatrixXXD;
12typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Matrix1D;
16class Matrix : public LeafExpression<Matrix> {
17public:
18 Matrix() = default;
19 Matrix(const Matrix& other) = default;
20 Matrix(size_t numRows, size_t numCols);
21 Matrix(size_t numRows, size_t numCols, std::vector<double>& vals);
22
23 explicit Matrix(MatrixXXD other);
24
25 [[nodiscard]] auto Equals(const Expression& other) const -> bool final;
26
29
30
34 [[nodiscard]] auto GetMatrix() const -> MatrixXXD;
35
40 [[nodiscard]] auto GetRows() const -> size_t;
41
46 [[nodiscard]] auto GetCols() const -> size_t;
47
52 [[nodiscard]] auto Transpose() const -> std::unique_ptr<Matrix>;
53
58 [[nodiscard]] auto Inverse() const -> std::unique_ptr<Matrix>;
59
60 [[nodiscard]] auto Integrate(const Expression& integrationVariable) const -> std::unique_ptr<Expression> final;
61
62 [[nodiscard]] auto Identity() const -> std::unique_ptr<Expression>;
63
64 [[nodiscard]] auto Differentiate(const Expression&) const -> std::unique_ptr<Expression> final;
65
66 auto operator=(const Matrix& other) -> Matrix& = default;
67
68private:
69 MatrixXXD matrix {};
70};
71
72} // Oasis
73#endif // OASIS_MATRIX_HPP
#define EXPRESSION_CATEGORY(category)
Definition Expression.hpp:192
#define EXPRESSION_TYPE(type)
Definition Expression.hpp:181
An expression.
Definition Expression.hpp:56
A leaf expression.
Definition LeafExpression.hpp:21
A matrix.
Definition Matrix.hpp:16
auto Equals(const Expression &other) const -> bool final
Compares this expression to another expression for equality.
Definition Matrix.cpp:40
auto GetCols() const -> size_t
Gets the number of columns.
Definition Matrix.cpp:57
auto GetRows() const -> size_t
Gets the number of rows.
Definition Matrix.cpp:52
auto Identity() const -> std::unique_ptr< Expression >
Definition Matrix.cpp:80
auto Differentiate(const Expression &) const -> std::unique_ptr< Expression > final
Tries to differentiate this function.
Definition Matrix.cpp:35
Matrix()=default
auto Transpose() const -> std::unique_ptr< Matrix >
Gets the matrix's transpose.
Definition Matrix.cpp:62
Matrix(const Matrix &other)=default
auto GetMatrix() const -> MatrixXXD
Gets the matrix.
Definition Matrix.cpp:47
auto Integrate(const Expression &integrationVariable) const -> std::unique_ptr< Expression > final
Attempts to integrate this expression using integration rules.
Definition Matrix.cpp:73
auto Inverse() const -> std::unique_ptr< Matrix >
Gets the matrix's inverse.
Definition Matrix.cpp:67
Definition Add.hpp:11
Eigen::Matrix< double, Eigen::Dynamic, 1 > Matrix1D
Definition Linear.hpp:19
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXXD
Definition Linear.hpp:18
@ UnExp
Definition Expression.hpp:46