32#include "steppable/number.hpp"
34#include "types/point.hpp"
46 template<
typename NumberT>
47 using MatVec2D = std::vector<std::vector<NumberT>>;
59 namespace __internals::symbols
135 template<concepts::Numeric ValueT>
140 for (
size_t i = 0; i <
_rows; i++)
141 for (
size_t j = 0; j <
_cols; j++)
169 [[nodiscard]] std::string
present(
int endRows = 0)
const;
204 template<concepts::Numeric NumberT>
205 static Matrix diag(
const size_t colsRows,
const NumberT& fill = 0)
Represents a mathematical matrix.
Definition mat2d.hpp:74
bool operator==(const Matrix &rhs) const
Test for equal matrices.
Definition mat2d.cpp:550
static Matrix zeros(size_t rows, size_t cols)
Creates a matrix filled with zeros.
Definition mat2d.cpp:504
auto begin()
Alias for the data begin() method to allow iterating over the matrix rows,.
Definition mat2d.hpp:214
Matrix operator+() const
Unary plus operator.
Definition mat2d.cpp:346
Matrix rref() const
Converts the matrix to its reduced row echelon form.
Definition mat2d.cpp:176
Matrix transpose() const
Transposes a matrix.
Definition mat2d.cpp:541
size_t _rows
The number of rows in the matrix.
Definition mat2d.hpp:76
Number rank() const
Calculates the rank of a matrix.
Definition mat2d.cpp:518
size_t prec
Precision of numbers in the matrix.
Definition mat2d.hpp:77
Matrix(const MatVec2D< ValueT > &data, const size_t prec)
Constructs a matrix from a 2D vector of C++ numbers.
Definition mat2d.hpp:136
Matrix operator+=(const Matrix &rhs)
Adds the other matrix to current matrix and assigns result to this matrix.
Definition mat2d.cpp:348
std::string present(int endRows=0) const
Presents the matrix as a string.
Definition mat2d.cpp:496
Matrix operator>>(const Matrix &rhs) const
Join a matrix to the left of the current matrix.
Definition mat2d.cpp:424
void _checkIdxSanity(const YXPoint *point) const
Checks whether a point is inside the matrix. Errors and exits the program if not.
Definition mat2d.cpp:133
static Matrix ones(size_t rows, size_t cols)
Creates a matrix filled with ones.
Definition mat2d.cpp:498
static Matrix diag(size_t colsRows, const Number &fill=1)
Creates a diagnal matrix.
Definition mat2d.cpp:510
bool operator!=(const Matrix &rhs) const
Test for unequal matrices.
Definition mat2d.cpp:552
Number & operator[](const YXPoint &point)
Gets the element at a point in the matrix.
Definition mat2d.cpp:554
size_t _cols
The number of columns in the matrix.
Definition mat2d.hpp:75
Matrix operator^=(const Number ×)
Raises the current matrix to a certain power, and assigns result to the current matrix.
static void _checkDataSanity(const MatVec2D< Number > &data)
Checks whether the matrix data is correct in format.
Definition mat2d.cpp:101
Matrix operator-=(const Matrix &rhs)
Subtracts the other matrix from current matrix and assigns result to this matrix.
Definition mat2d.cpp:365
size_t getRows() const
Get the number of rows in the matrix.
Definition mat2d.hpp:446
static Matrix diag(const size_t colsRows, const NumberT &fill=0)
Creates a diagnal matrix.
Definition mat2d.hpp:205
Matrix operator>>=(const Matrix &rhs)
Join a matrix to the left of the current matrix, then assign the result to the current one.
Definition mat2d.cpp:455
Matrix operator<<=(const Matrix &rhs)
Join a matrix to the right of the current matrix, then assign the result to the current one.
Definition mat2d.cpp:449
Matrix operator^(const Number ×) const
Raises the current matrix to a certain power.
Definition mat2d.cpp:473
Matrix operator<<(const Matrix &rhs) const
Join a matrix to the right of the current matrix.
Definition mat2d.cpp:399
Matrix ref() const
Converts a matrix to row echelon form.
Definition mat2d.cpp:239
Matrix operator-() const
Unary minus operator.
Definition mat2d.cpp:356
auto end()
Alias for the data end() method to allow iterating over the matrix rows,.
Definition mat2d.hpp:220
MatVec2D< Number > data
The data of the matrix.
Definition mat2d.hpp:78
size_t getCols() const
Get the number of columns in the matrix.
Definition mat2d.hpp:452
static MatVec2D< Number > roundOffValues(const MatVec2D< Number > &data, size_t prec)
Rounds off all data inside a vector to a specified precision.
Definition mat2d.cpp:154
Number det() const
Find the determinant of a matrix.
Definition mat2d.cpp:273
Matrix()
Default constructor for the Matrix class.
Definition mat2d.cpp:116
Matrix operator*(const Number &rhs) const
Scalar multiplication.
Definition mat2d.cpp:371
Matrix operator*=(const Number &rhs)
Multiplies the current matrix by a scalar value and assigns the result to this matrix.
Definition mat2d.cpp:461
MatVec2D< Number > getData() const
Get the data std::vector object from the matrix.
Definition mat2d.hpp:458
Represents a number with arbitrary precision. It basically stores the value as a string.
Definition number.hpp:80
constexpr std::string_view MATRIX_LEFT_BOTTOM
Definition mat2d.hpp:63
constexpr std::string_view MATRIX_RIGHT_BOTTOM
Definition mat2d.hpp:66
constexpr std::string_view MATRIX_RIGHT_TOP
Definition mat2d.hpp:64
constexpr std::string_view MATRIX_LEFT_MIDDLE
Definition mat2d.hpp:62
constexpr std::string_view MATRIX_LEFT_TOP
Definition mat2d.hpp:61
constexpr std::string_view MATRIX_RIGHT_MIDDLE
Definition mat2d.hpp:65
The custom-implemented printer engines for outputting expressions.
Definition baseConvert.cpp:50
std::string ppMatrix(const MatVec2D< Number > &matrix, const int endRows)
Pretty prints a matrix.
Definition mat2d.cpp:53
The public namespace for the Steppable library.
Definition argParse.cpp:40
std::vector< std::vector< NumberT > > MatVec2D
Alias for a 2D matrix represented as a vector of vectors.
Definition mat2d.hpp:47
A points object that represents two points.
Definition point.hpp:55
A point object.
Definition point.hpp:44