philsupertramp/game-math
|
#include <Matrix.h>
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 | |
size_t | _columns = 0 |
number columns | |
size_t | _element_size = 0 |
number elements | |
T * | _data = nullptr |
ongoing array representing data | |
size_t | _dataSize = 0 |
total number of elements | |
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 |
overwritten default constructor
Constructor using initializer_list's
lst |
|
inline |
Constructor using multi-dimensional initializer_list's
lst |
Deep copy constructor
other |
Conversion constructor to convert Matrix into other type V
other | the matrix to use |
Default destructor, doesn't do anything
Apply given function to Matrix
fun | element-wise function to apply |
getter for total number of elements inside matrix
Element-wise comparison
rhs |
row | \[\in [0, rows() - 1]\] |
col | \[\in [0, columns() - 1]\] |
elem | \[\in [0, elements() - 1]\] |
|
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 |
Hadamard Multiplication Z[i][j] = A[i][j] * B[i][j]
other |
Helper to test if Matrix can have a determinant
Horizontal matrix concatenation
other | Matrix with same number of rows, dimension n1, m2 |
Helper to determine whether given matrix is a vector.
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 |
element access
row | row index |
column | column index |
elem | element index |
const element-access
row | row index |
column | column index |
elem | element index |
const pointer operator
Matrix-Constant-Multiplication
rhs |
Matrix-Addition
rhs |
Matrix-Subtraction
rhs |
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
Resizes a matrix
rows | target number of rows |
cols | target number of columns |
elementSize | target number of elements per cell |
Column setter
index | column index to set |
other | new values |
Row setter
index | row index to set |
other | holds new row elements |
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 |
Calculates sum of all elements
Creates transposed matrix of this
ostream operator, beatified representation
ostr | |
m |
ongoing array representing data