golib
0.5
|
Classes | |
class | goMath::Eigenvalue< Real > |
Eigenvalue computation of real matrices. More... | |
class | goMath::LU< Real > |
LU Decomposition. More... | |
class | goMath::VectorIterator< T > |
Vector iterator for multi-dimensional array data. More... | |
class | goMath::ConstVectorIterator< T > |
Cons iterator over vectors. More... | |
class | goMath::Matrix< T > |
Matrix class. More... | |
class | goMath::SVD< T > |
Singular value decomposition. This class can do full SVD or thin SVD. It uses sgesvd_() or dgesvd_() from the linked LAPACK library (as opposed to goMath::ThinSVD). Instantiated for goFloat and goDouble types. More... | |
class | goMath::Vector< T > |
General vector class. More... | |
Typedefs | |
typedef goMath::Matrix< goDouble > | goMath::Matrixd |
typedef goMath::Matrix< goFloat > | goMath::Matrixf |
typedef goMath::Vector< goFloat > | goMath::Vectorf |
typedef goMath::Vector< goDouble > | goMath::Vectord |
typedef goMath::Vector< goInt32 > | goMath::Vectori |
Functions | |
goSize_t | goMath::complexEigenvaluesHermite (const goMath::Matrix< goComplexf > &m, goMath::Vectorf &eigenvaluesRet, goFixedArray< goMath::Vector< goComplexf > > *eigenvectorsRet=0) |
template<class T > | |
void | goMath::matrixMult (T alpha, const goMath::Matrix< T > &A, bool transA, const goMath::Matrix< T > &B, bool transB, T beta, goMath::Matrix< T > &C) |
Calculate ![]() | |
template<class T > | |
void | goMath::matrixPower (goMath::Matrix< T > &A, T scalar) |
template<class T > | |
bool | goMath::matrixVectorMult (T alpha, const goMath::Matrix< T > &A, bool transA, const goMath::Vector< T > &x, T beta, goMath::Vector< T > &y) |
calculate ![]() | |
template<class T > | |
bool | goMath::vectorAdd (T alpha, const Vector< T > &x, Vector< T > &y) |
y = alpha * x + y More... | |
template<class T > | |
void | goMath::vectorOuter (T alpha, const Vector< T > &x, const Vector< T > &y, goMath::Matrix< T > &ret) |
Outer vector product ![]() | |
template<class matrix_type , class pivot_vector > | |
bool | goMath::Lapack::getrf (matrix_type &A, pivot_vector &ipiv) |
Lapack getrf. More... | |
template<class matrix_type , class pivot_vector > | |
bool | goMath::Lapack::getrs (const matrix_type &A, bool transA, matrix_type &B, const pivot_vector &ipiv) |
Lapack getrs. More... | |
template<class matrix_type , class pivot_vector > | |
bool | goMath::Lapack::getrs (const matrix_type &A, bool transA, goMath::Vector< typename matrix_type::value_type > &B, const pivot_vector &ipiv) |
template<class matrix_type , class pivot_vector > | |
bool | goMath::Lapack::getri (matrix_type &A, const pivot_vector &ipiv) |
Lapack getri, invert a LU-decomposed matrix. More... | |
template<class matrix_type , class vector_type > | |
bool | goMath::Lapack::gels (matrix_type &A, bool transA, vector_type &b) |
Lapack gels. Least square solution of a linear system. More... | |
template<class matrix_type , class vector_type > | |
bool | goMath::Lapack::gelss (matrix_type &A, bool transA, vector_type &b, vector_type *singularValues=0) |
Lapack gelss. More... | |
template<class matrix_type , class vector_type > | |
bool | goMath::Lapack::posv (matrix_type &A, vector_type &b) |
Lapack *posv procedure for solving symmetric linear systems. More... | |
template<class matrix_type > | |
bool | goMath::Lapack::posv (matrix_type &A, matrix_type &b) |
Lapack *posv procedure for solving symmetric linear systems. More... | |
T | goMath::Vector< T >::conjInnerProduct (const Vector< T > &) const |
Use goMatrix and goVector for matrix and vector operations. Others, like go4Vector and such will be deprecated and replaced solely by the former two classes. goMatrix and goVector use CBLAS routines for some operations and more will be added. Using CBLAS moves the matter of optimisation for a specific platform outside of golib. The operator* and operator*= operators use CBLAS. For best performance, when you want to do something like C = A^\top \cdot B + C, use goMatrixMult(). Explicitly transposing a matrix should not be necessary, if I find it is for some operation, I will add functions that overcome this. Transposition of a goMatrix is possible with getTranspose() or transpose(), but is very slow since the data are copied.
Singular value decomposition can be done using goSVD. Eigenvalues and eigenvectors can be calculated with goEigenvalue. Both are adapted versions from the Template Numerical Toolkit, a freely available implementation of a few linear algebra algorithms.
bool goMath::Lapack::gels | ( | matrix_type & | A, |
bool | transA, | ||
vector_type & | b | ||
) |
Lapack gels. Least square solution of a linear system.
For solves
or
if m >= n, or it finds the minimum norm solution of
or
if m < n, so that
is underdetermined. A must have full rank.
A | Matrix A. Will be overwritten by QR or LQ decompositions. |
transA | If true, A is used transposed. |
b | Right hand side vector. Will be overwritten with the solution vector. |
bool goMath::Lapack::gelss | ( | matrix_type & | A, |
bool | transA, | ||
vector_type & | b, | ||
vector_type * | singularValues = 0 |
||
) |
Lapack gelss.
A | |
transA | |
b | |
singularValues |
bool goMath::Lapack::getrf | ( | matrix_type & | A, |
pivot_vector & | ipiv | ||
) |
Lapack getrf.
Replaces A by its LU-decomposed form, so that
U is unit diagonal, P pivots columns.
A | Matrix to be decomposed. |
ipiv | Pivot vector (filled by this function). |
bool goMath::Lapack::getri | ( | matrix_type & | A, |
const pivot_vector & | ipiv | ||
) |
bool goMath::Lapack::getrs | ( | const matrix_type & | A, |
bool | transA, | ||
matrix_type & | B, | ||
const pivot_vector & | ipiv | ||
) |
Lapack getrs.
Solves for x, assuming A is LU-decomposed e.g. with getrf(). Implemented for goFloat and goDouble. pivot_vector must be of type
int
, and provide getSize(), resize() as well as getPtr() methods (such as goMath::Vector). matrix_type must essentially be goMath::Matrix.
A | Matrix A |
transA | Use A transposed |
B | Right hand side (the right hand side vectors are in the rows of B, not the columns!). On success, the rows contain the solutions. |
ipiv | Pivot vector (from getrf()). |
void goMath::matrixMult | ( | T | alpha, |
const goMath::Matrix< T > & | A, | ||
bool | transA, | ||
const goMath::Matrix< T > & | B, | ||
bool | transB, | ||
T | beta, | ||
goMath::Matrix< T > & | C | ||
) |
Calculate .
A and B can optionally be used as transpose. This function uses CBLAS functions.
This function is implemented for goFloat and goDouble, using cblas_[s|d]gemm functions from CBLAS.
bool goMath::matrixVectorMult | ( | T | alpha, |
const goMath::Matrix< T > & | A, | ||
bool | transA, | ||
const goMath::Vector< T > & | x, | ||
T | beta, | ||
goMath::Vector< T > & | y | ||
) |
calculate .
Sizes of A and x are checked. If y has mismatching size, it is resized and initialised with 0 before the operation.
Parameters are named as in the formula above.
Uses cblas_<>gemv().
alpha | Scalar factor |
A | Matrix A |
transA | If true, A is used as transposed. |
x | Vector x |
beta | Scalar factor (for y) |
y | Vector y, also holds the result. |
bool goMath::Lapack::posv | ( | matrix_type & | A, |
matrix_type & | b | ||
) |
Lapack *posv procedure for solving symmetric linear systems.
A | Symmetric matrix, no special storage, must be upper right. |
b | Contains the right hand side vectors in its rows. This is due to the actual lapack routine using column major storage and we use the more C-like row major. Contains the solutions if the method returns true. The solutions are contained in the rows, again because of the underlying routine using column major storage. |
bool goMath::Lapack::posv | ( | matrix_type & | A, |
vector_type & | b | ||
) |
Lapack *posv procedure for solving symmetric linear systems.
A | Symmetric matrix, no special storage, must be upper right. |
b | Right hand side vector. Contains the solution if the method returns true. |
void goMath::vectorOuter | ( | T | alpha, |
const Vector< T > & | x, | ||
const Vector< T > & | y, | ||
goMath::Matrix< T > & | ret | ||
) |
Outer vector product .