philsupertramp/game-math
|
#include <Matrix.h>
Public Member Functions | |
Matrix (T val, size_t rowCount, size_t colCount, size_t elementDimension=1) | |
Matrix (T *val, size_t colCount) | |
Matrix () | |
Matrix (const std::initializer_list< std::initializer_list< T > > &lst) | |
Matrix (const std::initializer_list< std::initializer_list< std::initializer_list< T > > > &lst) | |
Matrix (Matrix const &other) | |
template<typename V > | |
Matrix (const Matrix< V > &other) | |
~Matrix () | |
size_t | rows () const |
size_t | columns () const |
size_t | elements () const |
size_t | elements_total () const |
T | Determinant () const |
constexpr Matrix< T > | Transpose () const |
Matrix< T > | HorizontalConcat (const Matrix< T > &other) |
bool | operator== (const Matrix< T > &rhs) const |
bool | operator!= (const Matrix< T > &rhs) const |
bool | operator< (const Matrix< T > &rhs) const |
bool | operator> (const Matrix< T > &rhs) const |
bool | IsVector () const |
void | assertSize (const Matrix< T > &other) const |
bool | elementWiseCompare (const Matrix< T > &rhs) const |
Matrix< T > | operator= (const Matrix< T > &other) |
Matrix< T > | Apply (const std::function< T(T)> &fun) const |
Matrix & | HadamardMulti (const Matrix &other) |
Matrix< T > & | KroneckerMulti (const Matrix< T > &other) |
T | sumElements () const |
Matrix< T > | sum (size_t axis) const |
Matrix< T > & | operator*= (T rhs) |
Matrix< T > & | operator+= (const Matrix< T > &rhs) |
Matrix< T > & | operator-= (const Matrix< T > &rhs) |
T & | operator() (size_t row, size_t column, size_t elem=0) |
T & | operator() (size_t row, size_t column, size_t elem=0) const |
Matrix< T > | operator() (size_t row) |
Matrix< T > | operator() (size_t row) const |
T & | operator* () |
T & | operator* () const |
void | SetColumn (size_t index, const Matrix< T > &other) |
void | SetRow (size_t index, const Matrix< T > &other) |
void | Resize (size_t rows, size_t cols, size_t elementSize=1) |
int | GetIndex (size_t row, size_t col, size_t elem=0) const |
Matrix | GetSlice (size_t rowStart) const |
Matrix | GetSlice (size_t rowStart, size_t rowEnd) const |
Matrix | GetSlice (size_t rowStart, size_t rowEnd, size_t colStart) const |
Matrix | GetSlice (size_t rowStart, size_t rowEnd, size_t colStart, size_t colEnd) const |
void | SetSlice (const size_t &row_start, const size_t &row_end, const size_t &col_start, const size_t &col_end, const Matrix< T > &slice) |
void | SetSlice (const size_t &row_start, const Matrix< T > &slice) |
Matrix< T > | GetComponents (const size_t &index) const |
Matrix< T > | GetSlicesByIndex (const Matrix< size_t > &indices) const |
Static Public Member Functions | |
static Matrix | Random (size_t rows, size_t columns, size_t element_size=1, double minValue=0.0, double maxValue=1.0) |
static Matrix | Normal (size_t rows, size_t columns, double mu, double sigma) |
Private Member Functions | |
bool | HasDet () const |
Private Attributes | |
size_t | _rows = 0 |
number rows More... | |
size_t | _columns = 0 |
number columns More... | |
size_t | _element_size = 0 |
number elements More... | |
T * | _data = nullptr |
ongoing array representing data More... | |
size_t | _dataSize = 0 |
total number of elements More... | |
bool | needsFree = false |
Friends | |
std::ostream & | operator<< (std::ostream &ostr, const Matrix &m) |
Represents a multi dimensional Matrix of data with type T
The class is capable of regular matrix operations, including matrix - vector calculation. It also holds several helper methods to calculate data science specific products or other common operations.
T |
Element access using matrix(row, column, element) notation
Accessed elements can be modified!
|
inlineexplicit |
Default constructor
val | default value for all elements |
rowCount | number of rows |
colCount | number of columns |
elementDimension | number of dimensions per element |
Vector-assignment, assigns colCount values of type T
val | pointer representation of array |
colCount | number of elements within val |
|
inline |
Constructor using initializer_list's
lst |
|
inline |
Constructor using multi-dimensional initializer_list's
lst |
Deep copy constructor
other |
|
inline |
Conversion constructor to convert Matrix into other type V
other | the matrix to use |
Default destructor, doesn't do anything
|
inline |
|
inline |
|
inline |
Calculates Determinant
|
inline |
elements getter
|
inline |
getter for total number of elements inside matrix
|
inline |
Element-wise comparison
rhs |
|
inline |
returns 1D-Matrix from given index
index | of elements |
|
inline |
row | \[\in [0, rows() - 1]\] |
col | \[\in [0, columns() - 1]\] |
elem | \[\in [0, elements() - 1]\] |
|
inline |
|
inline |
|
inline |
Returns a slice of given dimension from the matrix
rowStart | row start index |
rowEnd | row end index |
colStart | column start index |
colEnd | column end index |
|
inline |
|
inline |
Hadamard Multiplication Z[i][j] = A[i][j] * B[i][j]
other |
|
inlineprivate |
Helper to test if Matrix can have a determinant
|
inline |
Horizontal matrix concatenation
other | Matrix with same number of rows, dimension n1, m2 |
|
inline |
Helper to determine whether given matrix is a vector.
|
inline |
A form of matrix multiplication For explicit reference please consult https://en.wikipedia.org/wiki/Kronecker_product
other | right hand side with same dimension |
|
inlinestatic |
Generates normal distributed squared matrix
rows | |
columns |
not-equal operator
rhs |
row getter
no in-place editing, creates new object! use SetRow instead
row | index of row to get |
const row-getter
row | index of row |
|
inline |
element access
row | row index |
column | column index |
elem | element index |
|
inline |
const element-access
row | row index |
column | column index |
elem | element index |
|
inline |
pointer operator
|
inline |
const pointer operator
Matrix-Constant-Multiplication
rhs |
|
inline |
Matrix-Addition
rhs |
|
inline |
Matrix-Subtraction
rhs |
|
inline |
Assignment-operator.
careful! actually overrides different sized matrices, just like other languages (python, matlab)
other |
OPERATORS comparison operator
rhs |
|
inlinestatic |
Generates a random matrix
rows | number of rows in target matrix |
columns | number of columns in target matrix |
element_size | |
minValue | |
maxValue |
rows
, columns
initialized with random values from minValue
to maxValue
|
inline |
Resizes a matrix
rows | target number of rows |
cols | target number of columns |
elementSize | target number of elements per cell |
|
inline |
|
inline |
Column setter
index | column index to set |
other | new values |
|
inline |
Row setter
index | row index to set |
other | holds new row elements |
|
inline |
Helper method to automatically resolve dimensions through slice
|
inline |
Calculates element wise sum of sub-elements along given axis
axis | axis index (0: rows, 1: columns) to calculate sum on |
|
inline |
Calculates sum of all elements
|
inlineconstexpr |
Creates transposed matrix of this
|
friend |
ostream operator, beatified representation
ostr | |
m |
|
private |
number columns
|
private |
ongoing array representing data
|
private |
total number of elements
|
private |
number elements
|
private |
number rows
|
private |