Xmipp
v3.23.11-Nereus
|
Classes | |
class | SparseMatrix2D |
class | Matrix2D< T > |
Functions | |
template<typename T > | |
void | ludcmp (const Matrix2D< T > &A, Matrix2D< T > &LU, Matrix1D< int > &indx, T &d) |
template<typename T > | |
void | lubksb (const Matrix2D< T > &LU, Matrix1D< int > &indx, Matrix1D< T > &b) |
void | svbksb (Matrix2D< double > &u, Matrix1D< double > &w, Matrix2D< double > &v, Matrix1D< double > &b, Matrix1D< double > &x) |
template<typename T > | |
void | svdcmp (const Matrix2D< T > &a, Matrix2D< double > &u, Matrix1D< double > &w, Matrix2D< double > &v) |
Matrices speed up macros | |
typedef Matrix2D< double > | DMatrix |
typedef Matrix2D< int > | IMatrix |
template<typename T > | |
bool | operator== (const Matrix2D< T > &op1, const Matrix2D< T > &op2) |
#define | MATRIX2D_ARRAY(m) ((m).mdata) |
#define | FOR_ALL_ELEMENTS_IN_MATRIX2D(m) |
#define | MAT_ELEM(m, i, j) ((m).mdata[((size_t)i)*(m).mdimx+((size_t)j)]) |
#define | MAT_XSIZE(m) ((m).mdimx) |
#define | MAT_YSIZE(m) ((m).mdimy) |
#define | MAT_SIZE(m) ((m).mdim) |
#define | dMij(m, i, j) MAT_ELEM(m, i, j) |
#define | dMn(m, n) ((m).mdata[(n)]) |
#define | M3x3_BY_V3x1(a, M, b) |
#define | M3x3_BY_M3x3(A, B, C) |
#define | M2x2_BY_V2x1(a, M, b) |
#define | M2x2_BY_CT(M2, M1, k) |
#define | M3x3_BY_CT(M2, M1, k) |
#define | M4x4_BY_CT(M2, M1, k) |
#define | M2x2_INV(Ainv, A) |
#define | M3x3_INV(Ainv, A) |
#define | M4x4_INV(Ainv, A) |
Matrix Related functions | |
These functions are not methods of Matrix2D | |
void | generalizedEigs (const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix1D< double > &D, Matrix2D< double > &P) |
void | firstEigs (const Matrix2D< double > &A, size_t M, Matrix1D< double > &D, Matrix2D< double > &P, bool Pneeded=true) |
void | lastEigs (const Matrix2D< double > &A, size_t M, Matrix1D< double > &D, Matrix2D< double > &P) |
void | eigsBetween (const Matrix2D< double > &A, size_t I1, size_t I2, Matrix1D< double > &D, Matrix2D< double > &P) |
void | allEigs (const Matrix2D< double > &A, std::vector< std::complex< double > > &eigs) |
void | connectedComponentsOfUndirectedGraph (const Matrix2D< double > &G, Matrix1D< int > &component) |
template<typename T1 , typename T2 > | |
void | typeCast (const Matrix2D< T1 > &v1, Matrix2D< T2 > &v2) |
template<typename T1 > | |
void | typeCast (const Matrix2D< T1 > &v1, Matrix2D< T1 > &v2) |
void | orthogonalizeColumnsGramSchmidt (Matrix2D< double > &M) |
void | normalizeColumns (Matrix2D< double > &A) |
void | normalizeColumnsBetween0and1 (Matrix2D< double > &A) |
void | subtractColumnMeans (Matrix2D< double > &A) |
void | matrixOperation_AtA (const Matrix2D< double > &A, Matrix2D< double > &B) |
void | matrixOperation_AAt (const Matrix2D< double > &A, Matrix2D< double > &C) |
void | matrixOperation_AB (const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix2D< double > &C) |
void | matrixOperation_Ax (const Matrix2D< double > &A, const Matrix1D< double > &x, Matrix1D< double > &y) |
void | matrixOperation_ABt (const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix2D< double > &C) |
void | matrixOperation_AtB (const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix2D< double > &C) |
void | matrixOperation_Atx (const Matrix2D< double > &A, const Matrix1D< double > &x, Matrix1D< double > &y) |
void | matrixOperation_AtBt (const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix2D< double > &C) |
void | matrixOperation_XtAX_symmetric (const Matrix2D< double > &X, const Matrix2D< double > &A, Matrix2D< double > &B) |
void | matrixOperation_IplusA (Matrix2D< double > &A) |
void | matrixOperation_IminusA (Matrix2D< double > &A) |
void | eraseFirstColumn (Matrix2D< double > &A) |
void | keepColumns (Matrix2D< double > &A, int j0, int jF) |
#define | VIA_BILIB |
Matrix element: Element access
This is just a redefinition of the function above
Definition at line 146 of file matrix2d.h.
#define FOR_ALL_ELEMENTS_IN_MATRIX2D | ( | m | ) |
For all elements in the array
This macro is used to generate loops for the matrix in an easy way. It defines internal indexes 'i' and 'j' which ranges the matrix using its mathematical definition (ie, logical access).
Definition at line 104 of file matrix2d.h.
Matrix (2x2) by constant (M2=M1*k)
You must create the result matrix with the appropriate size. You can reuse the matrix M1 to store the results (that is, M2x2_BY_CT(M, M, k);, is allowed).
Definition at line 237 of file matrix2d.h.
Matrix (2x2) by vector (2x1) (a=M*b)
You must "load" the temporary variables, and create the result vector with the appropriate size. You can reuse the vector b to store the results (that is, M2x2_BY_V2x1(b, M, b);, is allowed).
Definition at line 225 of file matrix2d.h.
#define M2x2_INV | ( | Ainv, | |
A | |||
) |
Inverse of a matrix (2x2)
Input and output matrix cannot be the same one. The output is supposed to be already resized.
Definition at line 286 of file matrix2d.h.
Matrix (3x3) by constant (M2=M1*k)
You must create the result matrix with the appropriate size. You can reuse the matrix M1 to store the results (that is, M2x2_BY_CT(M, M, k);, is allowed).
Definition at line 248 of file matrix2d.h.
#define M3x3_BY_M3x3 | ( | A, | |
B, | |||
C | |||
) |
Matrix (3x3) by Matrix (3x3) (A=B*C)
You must "load" the temporary variables, and create the result vector with the appropriate size. You can reuse any of the multiplicands to store the results (that is, M3x3_BY_M3x3(A, A, B);, is allowed).
Definition at line 182 of file matrix2d.h.
Matrix (3x3) by vector (3x1) (a=M*b)
You must "load" the temporary variables, and create the result vector with the appropriate size. You can reuse the vector b to store the results (that is, M3x3_BY_V3x1(b, M, b);, is allowed).
Definition at line 170 of file matrix2d.h.
#define M3x3_INV | ( | Ainv, | |
A | |||
) |
Inverse of a matrix (3x3)
Input and output matrix cannot be the same one. The output is supposed to be already resized.
Definition at line 302 of file matrix2d.h.
Matrix (4x4) by constant (M2=M1*k)
You must create the result matrix with the appropriate size. You can reuse the matrix M1 to store the results (that is, M2x2_BY_CT(M, M, k);, is allowed).
Definition at line 263 of file matrix2d.h.
#define M4x4_INV | ( | Ainv, | |
A | |||
) |
Inverse of a matrix (4x4)
Input and output matrix cannot be the same one. The output is supposed to be already resized.
Definition at line 323 of file matrix2d.h.
Total elements of the matrix
Definition at line 128 of file matrix2d.h.
X dimension of the matrix
Definition at line 120 of file matrix2d.h.
Y dimension of the matrix
Definition at line 124 of file matrix2d.h.
Array access.
This macro gives you access to the array (T)
Definition at line 89 of file matrix2d.h.
#define VIA_BILIB |
Definition at line 1196 of file matrix2d.h.
Definition at line 1163 of file matrix2d.h.
Definition at line 1164 of file matrix2d.h.
void allEigs | ( | const Matrix2D< double > & | A, |
std::vector< std::complex< double > > & | eigs | ||
) |
Compute all eigenvalues, even if they are complex
Definition at line 345 of file matrix2d.cpp.
void connectedComponentsOfUndirectedGraph | ( | const Matrix2D< double > & | G, |
Matrix1D< int > & | component | ||
) |
Find connected components of a graph. Assuming that the matrix G represents an undirected graph (of size NxN), this function returns a vector (of size N) that indicates for each element which is the number of its connected component.
Definition at line 360 of file matrix2d.cpp.
void eigsBetween | ( | const Matrix2D< double > & | A, |
size_t | I1, | ||
size_t | I2, | ||
Matrix1D< double > & | D, | ||
Matrix2D< double > & | P | ||
) |
Compute eigenvectors between two indexes of a real, symmetric matrix. Solves the problem Av=dv. Only the eigenvectors of the smallest eigenvalues between indexes I1 and I2 are returned as columns of P. Indexes start at 0.
Definition at line 324 of file matrix2d.cpp.
void eraseFirstColumn | ( | Matrix2D< double > & | A | ) |
Erase first column
Definition at line 542 of file matrix2d.cpp.
void firstEigs | ( | const Matrix2D< double > & | A, |
size_t | M, | ||
Matrix1D< double > & | D, | ||
Matrix2D< double > & | P, | ||
bool | Pneeded = true |
||
) |
First eigenvectors of a real, symmetric matrix. Solves the problem Av=dv. Only the eigenvectors of the largest M eigenvalues are returned as columns of P
Definition at line 284 of file matrix2d.cpp.
void generalizedEigs | ( | const Matrix2D< double > & | A, |
const Matrix2D< double > & | B, | ||
Matrix1D< double > & | D, | ||
Matrix2D< double > & | P | ||
) |
Generalized eigenvector decomposition. Solves the problem Av=dBv. The decomposition is such that A=B P D P^-1. A and B must be square matrices of the same size.
Definition at line 267 of file matrix2d.cpp.
void keepColumns | ( | Matrix2D< double > & | A, |
int | j0, | ||
int | jF | ||
) |
Keep columns between j0 and jF
Definition at line 551 of file matrix2d.cpp.
void lastEigs | ( | const Matrix2D< double > & | A, |
size_t | M, | ||
Matrix1D< double > & | D, | ||
Matrix2D< double > & | P | ||
) |
Last eigenvectors of a real, symmetric matrix. Solves the problem Av=dv. Only the eigenvectors of the smallest M eigenvalues are returned as columns of P
Definition at line 305 of file matrix2d.cpp.
void lubksb | ( | const Matrix2D< T > & | LU, |
Matrix1D< int > & | indx, | ||
Matrix1D< T > & | b | ||
) |
LU Backsubstitution
Definition at line 596 of file matrix2d.cpp.
void ludcmp | ( | const Matrix2D< T > & | A, |
Matrix2D< T > & | LU, | ||
Matrix1D< int > & | indx, | ||
T & | d | ||
) |
LU Decomposition
Definition at line 586 of file matrix2d.cpp.
Matrix operation: C=A*A^t.
Definition at line 449 of file matrix2d.cpp.
void matrixOperation_AB | ( | const Matrix2D< double > & | A, |
const Matrix2D< double > & | B, | ||
Matrix2D< double > & | C | ||
) |
Matrix operation: C=A*B.
Definition at line 411 of file matrix2d.cpp.
void matrixOperation_ABt | ( | const Matrix2D< double > & | A, |
const Matrix2D< double > & | B, | ||
Matrix2D< double > & | C | ||
) |
Matrix operation: C=A*B^t.
Definition at line 462 of file matrix2d.cpp.
Matrix operation: B=A^t*A.
Definition at line 436 of file matrix2d.cpp.
void matrixOperation_AtB | ( | const Matrix2D< double > & | A, |
const Matrix2D< double > & | B, | ||
Matrix2D< double > & | C | ||
) |
Matrix operation: C=A^t*B.
Definition at line 475 of file matrix2d.cpp.
void matrixOperation_AtBt | ( | const Matrix2D< double > & | A, |
const Matrix2D< double > & | B, | ||
Matrix2D< double > & | C | ||
) |
Matrix operation: C=A^t*Bt.
Definition at line 500 of file matrix2d.cpp.
void matrixOperation_Atx | ( | const Matrix2D< double > & | A, |
const Matrix1D< double > & | x, | ||
Matrix1D< double > & | y | ||
) |
Matrix operation: y=A^t*x.
Definition at line 488 of file matrix2d.cpp.
void matrixOperation_Ax | ( | const Matrix2D< double > & | A, |
const Matrix1D< double > & | x, | ||
Matrix1D< double > & | y | ||
) |
Matrix operation: y=A*x.
Definition at line 424 of file matrix2d.cpp.
void matrixOperation_IminusA | ( | Matrix2D< double > & | A | ) |
void matrixOperation_IplusA | ( | Matrix2D< double > & | A | ) |
void matrixOperation_XtAX_symmetric | ( | const Matrix2D< double > & | X, |
const Matrix2D< double > & | A, | ||
Matrix2D< double > & | B | ||
) |
Matrix operation: B=X^t*A*X. We know that the result B must be symmetric
Definition at line 513 of file matrix2d.cpp.
void normalizeColumns | ( | Matrix2D< double > & | A | ) |
Normalize columns. So that they have zero mean and unit variance.
Definition at line 188 of file matrix2d.cpp.
void normalizeColumnsBetween0and1 | ( | Matrix2D< double > & | A | ) |
Normalize columns. So that the minimum is 0 and the maximum is 1
Definition at line 221 of file matrix2d.cpp.
Definition at line 1167 of file matrix2d.h.
void orthogonalizeColumnsGramSchmidt | ( | Matrix2D< double > & | M | ) |
void subtractColumnMeans | ( | Matrix2D< double > & | A | ) |
void svbksb | ( | Matrix2D< double > & | u, |
Matrix1D< double > & | w, | ||
Matrix2D< double > & | v, | ||
Matrix1D< double > & | b, | ||
Matrix1D< double > & | x | ||
) |
SVD Backsubstitution
Definition at line 174 of file matrix2d.cpp.
void svdcmp | ( | const Matrix2D< T > & | a, |
Matrix2D< double > & | u, | ||
Matrix1D< double > & | w, | ||
Matrix2D< double > & | v | ||
) |
SVD Decomposition
Definition at line 125 of file matrix2d.cpp.
void typeCast | ( | const Matrix2D< T1 > & | v1, |
Matrix2D< T2 > & | v2 | ||
) |
Conversion from one type to another.
If we have an integer array and we need a double one, we can use this function. The conversion is done through a type casting of each element If n >= 0, only the nth volumes will be converted, otherwise all NSIZE volumes
Definition at line 1245 of file matrix2d.h.
Conversion from one type to another. In some cases, the two types are the same. So a faster way is simply by assignment.
Definition at line 1263 of file matrix2d.h.