philsupertramp/game-math
|
Go to the source code of this file.
Macros | |
#define | EPS 1e-8 |
accuracy of calculated results More... | |
Functions | |
Matrix< double > | linspace (double start, double end, unsigned long num_elements) |
Matrix< double > | zeros (size_t rows, size_t columns, size_t elements=1) |
Matrix< double > | zerosV (size_t rows) |
Matrix< double > | ones (size_t rows, size_t columns=1, size_t elements=1) |
Matrix< double > | eye (size_t rows, size_t columns=0) |
Matrix< double > | tridiag (size_t rows, size_t columns, double left, double center, double right) |
double | norm (const Matrix< double > &in) |
Matrix< double > | norm (const Matrix< double > &in, int axis) |
Matrix< size_t > | argsort (const Matrix< double > &in) |
Matrix< size_t > | nonzero (const std::function< bool(const double &)> &validation, const Matrix< double > &x) |
template<typename T > | |
Matrix< T > | diag (const Matrix< T > &in) |
Requires:
Numerical helper methods.
This header includes numerical methods used to simplify computation of numerical algorithms. It mostly contains generator like functions to generate a specific kind of Matrix
#define EPS 1e-8 |
accuracy of calculated results
Computes indices of ordered vector. Orders vector, than builds resulting vector by selecting indices.
in | given matrix to sort |
Method to extract diagonal elements of given matrix into dedicated vector
in | given matrix to extract diagonal elements from |
Matrix< double > eye | ( | size_t | rows, |
size_t | columns = 0 |
||
) |
creates unit matrix of dimension rows, columns
rows | |
columns | if 0, then columns = rows |
Matrix< double > linspace | ( | double | start, |
double | end, | ||
unsigned long | num_elements | ||
) |
generates a vector with equidistant values, [start:(end-start)/num_elements:end]
start | start value |
end | end value |
num_elements | number of elements within the resulting vector |
Matrix< size_t > nonzero | ( | const std::function< bool(const double &)> & | validation, |
const Matrix< double > & | x | ||
) |
Index-Getter for validated values
Examples: validation function x<=0 returns indices of values <= 0
validation | validation function, this method validates your data |
x | vector to test |
double norm | ( | const Matrix< double > & | in | ) |
Calculates the p=2-Norm for a given matrix
\[ \sqrt{\sum x_i^2} \]
In 2D this is equal to the pythagorean theorem.
in | input matrix to calculate norm of |
Helper method to calculate 2-Norm on given axis
in | input matrix to calculate norm(s) of |
axis | along which to calculate norm on (options: 0 (row-wise), 1 (column-wise)) @returnss norm on given axis |
Matrix< double > ones | ( | size_t | rows, |
size_t | columns = 1 , |
||
size_t | elements = 1 |
||
) |
Generates a matrix with each element = 1 for given size
rows | number rows for resulting matrix |
columns | number columns for resulting matrix |
elements | number of elements per cell |
Matrix< double > tridiag | ( | size_t | rows, |
size_t | columns, | ||
double | left, | ||
double | center, | ||
double | right | ||
) |
creates tri-diagonal-matrix with given values and dimensions
rows | row dimension |
columns | column dimension |
left | left/lower diagonal element value |
center | diagonal element value |
right | right/upper diagonal element value |
Matrix< double > zeros | ( | size_t | rows, |
size_t | columns, | ||
size_t | elements = 1 |
||
) |
Generates a matrix with each element = 0 for given size
rows | number rows for resulting matrix |
columns | number columns for resulting matrix |
elements | number of elements per cell |
Matrix< double > zerosV | ( | size_t | rows | ) |
Generates a matrix with each element = 0 for given size
rows | number of rows in resulting vetor |