#ifndef FESA_MATH_MATRIX_H_ #define FESA_MATH_MATRIX_H_ #include #include #include "fesa/math/vector.h" namespace fesa { /// @brief Owns row-major contiguous storage independently of sparse matrices. class Matrix { public: /// @brief Constructs a row-major matrix initialized to one value. Matrix(std::size_t rows, std::size_t columns, double value = 0.0); /// @brief Copies matrix values into independent contiguous storage. Matrix(const Matrix& other); /// @brief Moves matrix storage and resets other to a zero-by-zero shape. Matrix(Matrix&& other) noexcept; /// @brief Copies matrix values into independent contiguous storage. Matrix& operator=(const Matrix& other); /// @brief Moves matrix storage and resets other to a zero-by-zero shape. Matrix& operator=(Matrix&& other) noexcept; /// @brief Returns the row count. std::size_t Rows() const noexcept; /// @brief Returns the column count. std::size_t Columns() const noexcept; /// @brief Returns a bounds-checked mutable entry. /// @throws std::out_of_range if the index is outside the matrix. double& operator()(std::size_t row, std::size_t column); /// @brief Returns a bounds-checked immutable entry. /// @throws std::out_of_range if the index is outside the matrix. const double& operator()(std::size_t row, std::size_t column) const; /// @brief Multiplies this row-major matrix by a dense vector. /// @throws std::invalid_argument if the dimensions are incompatible. Vector Multiply(const Vector& rhs) const; /// @brief Multiplies this row-major matrix by another dense matrix. /// @throws std::invalid_argument if the dimensions are incompatible. Matrix Multiply(const Matrix& rhs) const; private: std::size_t rows_; std::size_t columns_; std::vector values_; }; } // namespace fesa #endif // FESA_MATH_MATRIX_H_