![]() |
TrinityCore
|
#include <Matrix.h>
Classes | |
| class | Impl |
| class | SortRank |
Public Types | |
| typedef float | T |
Static Public Member Functions | |
| template<class S > | |
| static Matrix | fromDiagonal (const Array< S > &d) |
| static Matrix | fromDiagonal (const Matrix &d) |
| static Matrix | zero (int R, int C) |
| static Matrix | one (int R, int C) |
| static Matrix | identity (int N) |
| static Matrix | random (int R, int C) |
| static const char * | svdCore (float **U, int rows, int cols, float *D, float **V) |
Static Public Attributes | |
| static int | debugNumCopyOps = 0 |
| static int | debugNumAllocOps = 0 |
Private Types | |
| typedef shared_ptr< Impl > | ImplRef |
Private Member Functions | |
| Matrix (ImplRef i) | |
| Matrix (Impl *i) | |
| Matrix | vectorPseudoInverse () const |
| Matrix | partitionPseudoInverse () const |
| Matrix | colPartPseudoInverse () const |
| Matrix | rowPartPseudoInverse () const |
| Matrix | col2PseudoInverse (const Matrix &B) const |
| Matrix | col3PseudoInverse (const Matrix &B) const |
| Matrix | col4PseudoInverse (const Matrix &B) const |
| Matrix | row2PseudoInverse (const Matrix &B) const |
| Matrix | row3PseudoInverse (const Matrix &B) const |
| Matrix | row4PseudoInverse (const Matrix &B) const |
Private Attributes | |
| ImplRef | impl |
N x M matrix.
The actual data is tracked internally by a reference counted pointer; it is efficient to pass and assign Matrix objects because no data is actually copied. This avoids the headache of pointers and allows natural math notation:
Matrix A, B, C; // ...
C = A * f(B); C = C.inverse();
A = Matrix::identity(4); C = A; C.set(0, 0, 2.0); // Triggers a copy of the data so that A remains unchanged.
// etc.
The Matrix::debugNumCopyOps and Matrix::debugNumAllocOps counters increment every time an operation forces the copy and allocation of matrices. You can use these to detect slow operations when efficiency is a major concern.
Some methods accept an output argument instead of returning a value. For example, A = B.transpose() can also be invoked as B.transpose(A). The latter may be more efficient, since Matrix may be able to re-use the storage of A (if it has approximatly the right size and isn't currently shared with another matrix).
|
private |
| typedef float G3D::Matrix::T |
Internal precision. Currently float, but this may become a templated class in the future to allow operations like Matrix<double> and Matrix<ComplexFloat>.
Not necessarily a plain-old-data type (e.g., could ComplexFloat), but must be something with no constructor, that can be safely memcpyd, and that has a bit pattern of all zeros when zero.
|
inlineprivate |
|
inlineprivate |
|
inline |
Here is the caller graph for this function:
|
inline |
Returns a new matrix that is all zero.
|
inline |
Here is the call graph for this function:
Here is the caller graph for this function:| bool G3D::Matrix::allNonZero | ( | ) | const |
Returns true if all elements are non-zero
Here is the caller graph for this function:
|
inline |
Here is the call graph for this function:| bool G3D::Matrix::anyNonZero | ( | ) | const |
Returns true if any element is non-zero
Here is the caller graph for this function:
|
inline |
Here is the call graph for this function:
Here is the caller graph for this function:Mutates this
Here is the call graph for this function:| Matrix G3D::Matrix::col | ( | int | c | ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Number of columns
Here is the caller graph for this function:
|
inline |
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the call graph for this function:
|
inline |
(ATA)-1AT) computed using Gauss-Jordan elimination.
Here is the call graph for this function:| Matrix::T G3D::Matrix::get | ( | int | r, |
| int | c | ||
| ) | const |
Here is the caller graph for this function:
|
static |
Returns a new identity matrix
Here is the call graph for this function:
|
inline |
A-1 computed using the Gauss-Jordan algorithm, for square matrices. Run time is O(R3), where R is the number of rows.
Here is the call graph for this function:scalar B - this
Here is the caller graph for this function:| double G3D::Matrix::norm | ( | ) | const |
2-norm (sqrt(sum(squares))
Here is the call graph for this function:| double G3D::Matrix::normSquared | ( | ) | const |
2-norm squared: sum(squares). (i.e., dot product with itself)
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns a new matrix that is all one.
Here is the call graph for this function:Matrix multiplication. To perform element-by-element multiplication, see arrayMul.
See also A *= B, which is more efficient in many cases
See also A += B, which is more efficient in many cases
See also A += B, which is more efficient in many cases
See also A -= B, which is more efficient in many cases
See also A -= B, which is more efficient in many cases
|
inline |
|
private |
Here is the call graph for this function:
Here is the caller graph for this function:| Matrix G3D::Matrix::pseudoInverse | ( | float | tolerance = -1 | ) | const |
Computes the Moore-Penrose pseudo inverse, equivalent to (ATA)-1AT). The SVD method is used for performance when the matrix has more than four rows or columns.
[http://en.wikipedia.org/wiki/Moore]E2%80%93Penrose_pseudoinverse
| tolerance | Use -1 for automatic tolerance. |
Here is the call graph for this function:
|
static |
Uniformly distributed values between zero and one.
Here is the call graph for this function:| Matrix G3D::Matrix::row | ( | int | r | ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
The number of rows
Here is the caller graph for this function:| void G3D::Matrix::serialize | ( | TextOutput & | t | ) | const |
Serializes in Matlab source format
Here is the call graph for this function:| void G3D::Matrix::set | ( | int | r, |
| int | c, | ||
| T | v | ||
| ) |
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
|
inline |
Here is the call graph for this function:
Here is the caller graph for this function:| Matrix G3D::Matrix::subMatrix | ( | int | r1, |
| int | r2, | ||
| int | c1, | ||
| int | c2 | ||
| ) | const |
Returns a new matrix that is a subset of this one, from r1:r2 to c1:c2, inclusive.
Here is the call graph for this function:Singular value decomposition. Factors into three matrices such that this = U * fromDiagonal(d) * V.transpose().
The matrix must have at least as many rows as columns.
Run time is O(C2*R).
| sort | If true (default), the singular values are arranged so that D is sorted from largest to smallest. |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Low-level SVD functionality. Useful for applications that do not want to construct a Matrix but need to perform the SVD operation.
this = U * D * V'
Assumes that rows >= cols
| U | rows x cols matrix to be decomposed, gets overwritten with U, a rows x cols matrix with orthogonal columns. |
| D | vector of singular values of a (diagonal of the D matrix). Length cols. |
| V | returns the right orthonormal transformation matrix, size cols x cols |
[Based] on Dianne Cook's implementation, which is adapted from svdecomp.c in XLISP-STAT 2.1, which is code from Numerical Recipes adapted by Luke Tierney and David Betz. The Numerical Recipes code is adapted from Forsythe et al, who based their code on Golub and Reinsch's original implementation.
Here is the call graph for this function:
Here is the caller graph for this function:| Matrix G3D::Matrix::svdPseudoInverse | ( | float | tolerance = -1 | ) | const |
Called from pseudoInverse when the matrix has size > 4 along some dimension.
Here is the call graph for this function:
Here is the caller graph for this function:| void G3D::Matrix::swapAndNegateCols | ( | int | c0, |
| int | c1 | ||
| ) |
Swaps columns c0 and c1 and negates both
Here is the call graph for this function:| void G3D::Matrix::swapRows | ( | int | r0, |
| int | r1 | ||
| ) |
Here is the call graph for this function:| Matrix3 G3D::Matrix::toMatrix3 | ( | ) | const |
Here is the caller graph for this function:| Matrix4 G3D::Matrix::toMatrix4 | ( | ) | const |
Here is the caller graph for this function:| std::string G3D::Matrix::toString | ( | const std::string & | name | ) | const |
Here is the call graph for this function:
|
inline |
| Vector2 G3D::Matrix::toVector2 | ( | ) | const |
| Vector3 G3D::Matrix::toVector3 | ( | ) | const |
| Vector4 G3D::Matrix::toVector4 | ( | ) | const |
|
inline |
AT
Here is the call graph for this function:
Here is the caller graph for this function:| void G3D::Matrix::transpose | ( | Matrix & | out | ) | const |
Transpose in place; more efficient than transpose
Here is the call graph for this function:
|
private |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns a new matrix that is all zero.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Incremented every time a new matrix object is allocated. Useful for profiling your own code that uses Matrix to determine when it is slow due to allocation.
|
static |
Incremented every time the elements of a matrix are copied. Useful for profiling your own code that uses Matrix to determine when it is slow due to copying.
|
private |
1.8.8