Ocean
|
This class implements a 2x2 square matrix. More...
Public Types | |
typedef T | Type |
Definition of the used data type. More... | |
Public Member Functions | |
SquareMatrixT2 () | |
Creates a new SquareMatrixT2 object with undefined elements. More... | |
SquareMatrixT2 (const SquareMatrixT2< T > &matrix)=default | |
Copy constructor. More... | |
template<typename U > | |
SquareMatrixT2 (const SquareMatrixT2< U > &matrix) | |
Copy constructor for a matrix with difference element data type than T. More... | |
SquareMatrixT2 (const bool setToIdentity) | |
Creates a new SquareMatrixT2 object. More... | |
SquareMatrixT2 (const VectorT2< T > &diagonal) | |
Creates a new SquareMatrixT2 object by a given diagonal vector. More... | |
template<typename U > | |
SquareMatrixT2 (const U *arrayValues) | |
Creates a new SquareMatrixT2 object by four elements of float type U. More... | |
SquareMatrixT2 (const T *arrayValues) | |
Creates a new SquareMatrixT2 object by four elements. More... | |
template<typename U > | |
SquareMatrixT2 (const U *arrayValues, const bool valuesRowAligned) | |
Creates a new SquareMatrixT2 object by four elements. More... | |
SquareMatrixT2 (const T *arrayValues, const bool valuesRowAligned) | |
Creates a new SquareMatrixT2 object by four elements. More... | |
SquareMatrixT2 (const T &m00, const T &m10, const T &m01, const T &m11) | |
Creates a 2x2 rotation matrix by 4 given matrix elements. More... | |
SquareMatrixT2 (const T eigenValue0, const T eigenValue1, const VectorT2< T > &eigenVector0, const VectorT2< T > &eigenVector1) | |
Creates a covariance matrix by two eigen values and two corresponding eigen vectors. More... | |
SquareMatrixT2< T > | transposed () const |
Returns the transposed of this matrix. More... | |
void | transpose () |
Transposes the matrix. More... | |
SquareMatrixT2< T > | inverted () const |
Returns the inverted matrix of this matrix. More... | |
bool | invert () |
Inverts this matrix in place. More... | |
bool | invert (SquareMatrixT2< T > &invertedMatrix) const |
Inverts the matrix and returns the result as parameter. More... | |
T | determinant () const |
Returns the determinant of the matrix. More... | |
T | trace () const |
Returns the trace of the matrix which is the sum of the diagonal elements. More... | |
bool | solve (const VectorT2< T > &b, VectorT2< T > &x) const |
Solve a simple 2x2 system of linear equations: Ax = b Beware: The system of linear equations is assumed to be fully determined. More... | |
void | toIdentity () |
Sets the matrix to the identity matrix. More... | |
void | toNull () |
Sets the matrix to a zero matrix. More... | |
VectorT2< T > | xAxis () const |
Returns the x axis which is the first column of the matrix. More... | |
VectorT2< T > | yAxis () const |
Returns the y axis which is the middle column of the matrix. More... | |
VectorT2< T > | diagonal () const |
Returns a 2D vector with values of the matrix diagonal. More... | |
T | norm () const |
Returns the norm of this matrix that is the sum of the absolute matrix elements. More... | |
bool | isNull () const |
Returns whether this matrix is a null matrix. More... | |
bool | isIdentity () const |
Returns whether this matrix is the identity matrix. More... | |
bool | isSingular () const |
Returns whether this matrix is singular (and thus cannot be inverted). More... | |
bool | isSymmetric (const T epsilon=NumericT< T >::eps()) const |
Returns whether this matrix is symmetric. More... | |
bool | isEqual (const SquareMatrixT2< T > &matrix, const T eps=NumericT< T >::eps()) const |
Returns whether two matrices are almost identical up to a specified epsilon. More... | |
bool | eigenSystem (T &eigenValue0, T &eigenValue1, VectorT2< T > &eigenVector0, VectorT2< T > &eigenVector1) const |
Performs an eigen value analysis. More... | |
const T * | data () const |
Returns a pointer to the internal values. More... | |
T * | data () |
Returns a pointer to the internal values. More... | |
template<typename U > | |
void | copyElements (U *arrayValues, const bool columnAligned=true) const |
Copies the elements of this matrix to an array with floating point values of type U. More... | |
void | copyElements (T *arrayValues, const bool columnAligned=true) const |
Copies the elements of this matrix to an array with floating point values of type T. More... | |
SquareMatrixT2< T > & | operator= (const SquareMatrixT2< T > &)=default |
Default copy assignment operator. More... | |
bool | operator== (const SquareMatrixT2< T > &matrix) const |
Returns whether two matrices are identical up to a small epsilon. More... | |
bool | operator!= (const SquareMatrixT2< T > &matrix) const |
Returns whether two matrices are not identical up to a small epsilon. More... | |
SquareMatrixT2< T > | operator+ (const SquareMatrixT2< T > &matrix) const |
Adds two matrices. More... | |
SquareMatrixT2< T > & | operator+= (const SquareMatrixT2< T > &matrix) |
Adds and assigns two matrices. More... | |
SquareMatrixT2< T > | operator- (const SquareMatrixT2< T > &matrix) const |
Subtracts two matrices. More... | |
SquareMatrixT2< T > & | operator-= (const SquareMatrixT2< T > &matrix) |
Subtracts and assigns two matrices. More... | |
SquareMatrixT2< T > | operator- () const |
Returns the negative matrix of this matrix (all matrix elements are multiplied by -1). More... | |
SquareMatrixT2< T > | operator* (const SquareMatrixT2< T > &matrix) const |
Multiplies two matrices. More... | |
SquareMatrixT2< T > & | operator*= (const SquareMatrixT2< T > &matrix) |
Multiplies and assigns two matrices. More... | |
VectorT2< T > | operator* (const VectorT2< T > &vector) const |
Multiply operator for a 2D vector. More... | |
SquareMatrixT2< T > | operator* (const T value) const |
Multiplies this matrix with a scalar value. More... | |
SquareMatrixT2< T > & | operator*= (const T value) |
Multiplies and assigns this matrix with a scalar value. More... | |
T | operator[] (const unsigned int index) const |
Element operator. More... | |
T & | operator[] (const unsigned int index) |
Element operator. More... | |
T | operator() (const unsigned int row, const unsigned int column) const |
Element operator. More... | |
T & | operator() (const unsigned int row, const unsigned int column) |
Element operator. More... | |
T | operator() (const unsigned int index) const |
Element operator. More... | |
T & | operator() (const unsigned int index) |
Element operator. More... | |
const T * | operator() () const |
Access operator. More... | |
T * | operator() () |
Access operator. More... | |
size_t | operator() (const SquareMatrixT2< T > &matrix) const |
Hash function. More... | |
std::vector< SquareMatrixT2< float > > | matrices2matrices (const std::vector< SquareMatrixT2< float > > &matrices) |
std::vector< SquareMatrixT2< double > > | matrices2matrices (const std::vector< SquareMatrixT2< double > > &matrices) |
Static Public Member Functions | |
static size_t | elements () |
Returns the number of elements this matrix has. More... | |
template<typename U > | |
static std::vector< SquareMatrixT2< T > > | matrices2matrices (const std::vector< SquareMatrixT2< U > > &matrices) |
Converts matrices with specific data type to matrices with different data type. More... | |
template<typename U > | |
static std::vector< SquareMatrixT2< T > > | matrices2matrices (const SquareMatrixT2< U > *matrices, const size_t size) |
Converts matrices with specific data type to matrices with different data type. More... | |
Protected Attributes | |
T | values [4] |
The four values of the matrix. More... | |
Friends | |
template<typename U > | |
class | SquareMatrixT2 |
This class implements a 2x2 square matrix.
The four values are stored in a column aligned order with indices:
| 0 2 | | 1 3 |
T | Data type of matrix elements |
typedef T Ocean::SquareMatrixT2< T >::Type |
Definition of the used data type.
|
inline |
Creates a new SquareMatrixT2 object with undefined elements.
Beware: This matrix is neither a zero nor an entity matrix!
|
default |
Copy constructor.
matrix | The matrix to copy |
|
inlineexplicit |
Copy constructor for a matrix with difference element data type than T.
matrix | The matrix to copy |
U | The element data type of the second matrix |
|
inlineexplicit |
Creates a new SquareMatrixT2 object.
setToIdentity | Determines whether an identity matrix will be created, otherwise the matrix is initialized with zeros |
|
inlineexplicit |
Creates a new SquareMatrixT2 object by a given diagonal vector.
diagonal | Diagonal vector for the new matrix |
|
explicit |
Creates a new SquareMatrixT2 object by four elements of float type U.
arrayValues | The four matrix elements defining the new matrix, must be valid |
U | The floating point type of the given elements |
|
explicit |
Creates a new SquareMatrixT2 object by four elements.
arrayValues | The four matrix elements defining the new matrix, must be valid |
Ocean::SquareMatrixT2< T >::SquareMatrixT2 | ( | const U * | arrayValues, |
const bool | valuesRowAligned | ||
) |
Creates a new SquareMatrixT2 object by four elements.
arrayValues | The four matrix elements defining the new matrix, must be valid |
valuesRowAligned | True, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order (which is the default case for this matrix) |
U | The floating point type of the given elements |
Ocean::SquareMatrixT2< T >::SquareMatrixT2 | ( | const T * | arrayValues, |
const bool | valuesRowAligned | ||
) |
Creates a new SquareMatrixT2 object by four elements.
arrayValues | The four matrix elements defining the new matrix, must be valid |
valuesRowAligned | True, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order (which is the default case for this matrix) |
|
inline |
Creates a 2x2 rotation matrix by 4 given matrix elements.
m00 | Element of the first row and first column |
m10 | Element of the second row and first column |
m01 | Element of the first row and second column |
m11 | Element of the second row and second column |
Ocean::SquareMatrixT2< T >::SquareMatrixT2 | ( | const T | eigenValue0, |
const T | eigenValue1, | ||
const VectorT2< T > & | eigenVector0, | ||
const VectorT2< T > & | eigenVector1 | ||
) |
Creates a covariance matrix by two eigen values and two corresponding eigen vectors.
eigenValue0 | First eigen value |
eigenValue1 | Second eigen value |
eigenVector0 | First eigen vector |
eigenVector1 | Second eigen vector |
|
inline |
Copies the elements of this matrix to an array with floating point values of type T.
arrayValues | Array with 4 floating point values of type T receiving the elements of this matrix |
columnAligned | True, if the target elements are column aligned, false to target row aligned elements |
|
inline |
Copies the elements of this matrix to an array with floating point values of type U.
arrayValues | Array with 4 floating point values of type U receiving the elements of this matrix |
columnAligned | True, if the target elements are column aligned, false to target row aligned elements |
U | Floating point type |
|
inline |
Returns a pointer to the internal values.
|
inline |
Returns a pointer to the internal values.
|
inline |
Returns the determinant of the matrix.
|
inline |
Returns a 2D vector with values of the matrix diagonal.
bool Ocean::SquareMatrixT2< T >::eigenSystem | ( | T & | eigenValue0, |
T & | eigenValue1, | ||
VectorT2< T > & | eigenVector0, | ||
VectorT2< T > & | eigenVector1 | ||
) | const |
Performs an eigen value analysis.
eigenValue0 | First eigen value |
eigenValue1 | Second eigen value |
eigenVector0 | First eigen vector |
eigenVector1 | Second eigen vector |
|
inlinestatic |
Returns the number of elements this matrix has.
|
inline |
Inverts this matrix in place.
|
inline |
Inverts the matrix and returns the result as parameter.
invertedMatrix | The resulting inverted matrix |
|
inline |
Returns the inverted matrix of this matrix.
This matrix must not be singular.
Beware: This function does not throw an exception if the matrix cannot be inverted.
Thus, ensure that the matrix is invertible before calling this function.
Even better: avoid the usage of this function and call invert() instead.
In case, this matrix is not invertible, this matrix will be returned instead.
|
inline |
Returns whether two matrices are almost identical up to a specified epsilon.
matrix | Second matrix that will be checked |
eps | The epsilon threshold to be used, with range [0, infinity) |
|
inline |
Returns whether this matrix is the identity matrix.
|
inline |
Returns whether this matrix is a null matrix.
|
inline |
Returns whether this matrix is singular (and thus cannot be inverted).
A matrix is singular if the determinant of a matrix is 0.
|
inline |
Returns whether this matrix is symmetric.
epsilon | The epsilon threshold to be used, with range [0, infinity) |
|
inlinestatic |
Converts matrices with specific data type to matrices with different data type.
matrices | The matrices to convert |
size | The number of matrices to convert |
U | The element data type of the matrices to convert |
|
inline |
|
inline |
|
inlinestatic |
Converts matrices with specific data type to matrices with different data type.
matrices | The matrices to convert |
U | The element data type of the matrices to convert |
|
inline |
Returns the norm of this matrix that is the sum of the absolute matrix elements.
|
inline |
Returns whether two matrices are not identical up to a small epsilon.
matrix | Right operand |
|
inline |
Access operator.
|
inline |
Access operator.
|
inline |
Hash function.
matrix | The matrix for which the hash value will be determined |
|
inline |
Element operator.
Beware: No range check will be done!
index | Index of the element to return [0, 8] |
|
inline |
Element operator.
Beware: No range check will be done!
index | Index of the element to return [0, 8] |
|
inline |
Element operator.
Beware: No range check will be done!
row | Row of the element to return [0, 1] |
column | Column of the element to return [0, 1] |
|
inline |
Element operator.
Beware: No range check will be done!
row | Row of the element to return [0, 1] |
column | Column of the element to return [0, 1] |
|
inline |
Multiplies two matrices.
matrix | Right operand |
|
inline |
Multiplies this matrix with a scalar value.
value | Right operand |
|
inline |
Multiply operator for a 2D vector.
vector | Right operand |
|
inline |
Multiplies and assigns two matrices.
matrix | Right operand |
|
inline |
Multiplies and assigns this matrix with a scalar value.
value | right operand |
|
inline |
Adds two matrices.
matrix | Right operand |
|
inline |
Adds and assigns two matrices.
matrix | Right operand |
|
inline |
Returns the negative matrix of this matrix (all matrix elements are multiplied by -1).
|
inline |
Subtracts two matrices.
matrix | Right operand |
|
inline |
Subtracts and assigns two matrices.
matrix | Right operand |
|
default |
Default copy assignment operator.
|
inline |
Returns whether two matrices are identical up to a small epsilon.
matrix | Right operand |
|
inline |
Element operator.
Beware: No range check will be done!
index | Index of the element to return [0, 4] |
|
inline |
Element operator.
Beware: No range check will be done!
index | Index of the element to return [0, 4] |
|
inline |
Solve a simple 2x2 system of linear equations: Ax = b Beware: The system of linear equations is assumed to be fully determined.
b | The right-hand side vector |
x | The resulting solution vector |
|
inline |
Sets the matrix to the identity matrix.
|
inline |
Sets the matrix to a zero matrix.
|
inline |
Returns the trace of the matrix which is the sum of the diagonal elements.
|
inline |
Transposes the matrix.
|
inline |
Returns the transposed of this matrix.
|
inline |
Returns the x axis which is the first column of the matrix.
|
inline |
Returns the y axis which is the middle column of the matrix.
|
protected |
The four values of the matrix.