![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
Contains functions that implement some relevant BLAS level 1,2 or 3 and Lapack functionalities. More...
#include <cstring>
#include <cmath>
#include <cfloat>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <limits>
#include "gurls++/exports.h"
#include "gurls++/exceptions.h"
#include "gurls++/blas_lapack.h"
Go to the source code of this file.
Namespaces | |
namespace | gurls |
The main namespace of GURLS++. | |
Enumerations | |
enum | gurls::InversionAlgorithm { LU, GaussJ } |
Implemented inversion algorithms. | |
Functions | |
template<typename T > | |
void | gurls::argmin (const T *A, unsigned long *result, const int A_rows, const int A_cols, const int res_length) throw (gException) |
Coputes the smallest elements along the rows of a matrix. | |
template<typename T > | |
void | gurls::binOperation (const T *A, const T *B, T *result, const int len, T(*op)(T, T)) |
Applies an element by element binary operation ![]() ![]() | |
template<typename T > | |
void | gurls::cholesky (const gMat2D< T > &A, gMat2D< T > &L, bool upper=true) |
Computes the Cholesky factorization of a symmetric, positive definite matrix using the LAPACK routine SPOTRF. | |
template<typename T > | |
void | gurls::cholesky (const T *matrix, const int rows, const int cols, T *result, bool upper=true) |
Computes the Cholesky factorization of a symmetric, positive definite matrix using the LAPACK routine SPOTRF. | |
template<typename T > | |
void | gurls::clearLowerTriangular (T *matrix, int rows, int cols) |
Zeroes on the lower triangle of a matrix. | |
template<typename T > | |
T * | gurls::compare (const T *vector1, const T *vector2, const int size, bool(*pred)(T, T)) |
Compares element by element two vectors using a binary predicate, and returns a vector where each element is: | |
template<typename T > | |
T * | gurls::compare (const T *vector, const T thr, const int size, bool(*pred)(T, T)) |
Compares each element of a vector with a threshold using a binary predicate and returns a vector where each element is: | |
template<typename T > | |
void | gurls::copy (T *dst, const T *src, const int size) |
Copies element form one vector to another one. | |
template<> | |
GURLS_EXPORT void | gurls::copy (float *dst, const float *src, const int size) |
Specialized version of copy for float buffers. | |
template<> | |
GURLS_EXPORT void | gurls::copy (double *dst, const double *src, const int size) |
Specialized version of copy for double buffers. | |
template<typename T > | |
void | gurls::copy (T *dst, const T *src, const int size, const int dstIncr, const int srcIncr) |
Copies element form one vector to another one. | |
template<> | |
GURLS_EXPORT void | gurls::copy (float *dst, const float *src, const int size, const int dstIncr, const int srcIncr) |
Specialized version of copy for float buffers. | |
template<> | |
GURLS_EXPORT void | gurls::copy (double *dst, const double *src, const int size, const int dstIncr, const int srcIncr) |
Specialized version of copy for double buffers. | |
template<typename T > | |
void | gurls::copy_submatrix (T *dst, const T *src, const int src_Rows, const int sizeRows, const int sizeCols, unsigned long *indices_rows, unsigned long *indices_cols) |
Generates a submatrix from an input matrix. | |
template<typename T > | |
void | gurls::copyLocations (const unsigned long *locs, const T *src, const int locs_len, const int src_len, T *result) |
Returns a subvector of an input vector, containing elements of the input vector whose index is contained into an indices vector. | |
template<typename T > | |
void | gurls::diag (T *vector, const int len, T *result) |
Returns a squared matrix initialized in the diagonal with values from a vector. | |
template<typename T > | |
T | gurls::div (T a, T b) |
Division of two scalars. | |
template<typename T > | |
void | gurls::dot (const gMat2D< T > &A, const gMat2D< T > &B, gMat2D< T > &C) |
Implements the standard GEMM routine from Level3 BLAS General Matrix-Matrix multiplication of two single/double precision real matrices A and B (the corresponding Matlab code is: C = A*B;). | |
template<typename T > | |
void | gurls::dot (const gMat2D< T > &A, const gVec< T > &x, gVec< T > &y) |
Implements the standard DOT routine from Level 1 BLAS General Matrix-Vector multiplication of a single/double precision matrix A with a vector x (the corresponding Matlab code is y = A*x;). | |
template<typename T > | |
T | gurls::dot (const gVec< T > &x, const gVec< T > &y) |
Implements the standard scalar product between vectors General routine from Level1 BLAS: n <-- x^T * y General Vector-Vector multiplication for single/double precision real data. | |
template<typename T > | |
void | gurls::dot (const T *A, const T *B, T *C, int A_rows, int A_cols, int B_rows, int B_cols, int C_rows, int C_cols, const CBLAS_TRANSPOSE TransA, const CBLAS_TRANSPOSE TransB, const CBLAS_ORDER Order) |
General Matrix-Matrix multiplication of two single/double precision real matrices A and B. | |
template<typename T > | |
void | gurls::eig (const gMat2D< T > &A, gMat2D< T > &V, gVec< T > &Wr, gVec< T > &Wi) |
Implements the computation of the eigenvalues of A using the LAPACK routine SGEEV with default computation of the right eigenvectors. | |
template<typename T > | |
void | gurls::eig (const gMat2D< T > &A, gMat2D< T > &V, gVec< T > &W) |
Implements the computation of the eigenvalues of A using the LAPACK routine SGEEV with default computation of the right eigenvectors. | |
template<typename T > | |
void | gurls::eig (const gMat2D< T > &A, gVec< T > &Wr, gVec< T > &Wi) |
Implements the computation of the eigenvalues of A. | |
template<typename T > | |
void | gurls::eig (const gMat2D< T > &A, gVec< T > &W) |
Implements the computation of the eigenvalues of A. | |
template<typename T > | |
void | gurls::eig_sm (T *A, T *L, int A_rows_cols) throw (gException) |
Computes the eigenvalues/eigenvectors of a squared and symmetric input matrix. | |
template<typename T > | |
bool | gurls::eq (T val1, T val2) |
"Equals" operator between two scalars | |
template<> | |
GURLS_EXPORT bool | gurls::eq (float val1, float val2) |
"Equals" operator between two scalars, specialized for float values | |
template<> | |
GURLS_EXPORT bool | gurls::eq (double val1, double val2) |
"Equals" operator between two scalars, specialized for double values | |
template<typename T > | |
T | gurls::eucl_dist (const T *A, const T *B, const int len, T *work) |
Computes Euclidean distance between two vectors. | |
template<typename T > | |
void | gurls::exp (T *v, const int length) |
In place computation of the exponential for each element of a vector. | |
template<typename T > | |
void | gurls::getRow (const T *M, const int rows, const int cols, const int row_index, T *row) |
Generates a vector containing a copy of a row of an input matrix. | |
template<typename T > | |
bool | gurls::gt (T a, T b) |
"Greater than" operator between two scalars | |
template<> | |
GURLS_EXPORT bool | gurls::gt (float a, float b) |
"Greater than" operator between two scalars, specialized for float values | |
template<> | |
GURLS_EXPORT bool | gurls::gt (double a, double b) |
"Greater than" operator between two scalars, specialized for double values | |
template<typename T > | |
bool | gurls::gte (T a, T b) |
"Greater than or equals" operator between two scalars | |
template<typename T > | |
void | gurls::indicesOfEqualsTo (const T *V, const int len, const T value, unsigned long *ind, int &ind_length) |
Computes a vector containing the indices of all elements of an input vector that are equals to a given value. | |
template<typename T > | |
void | gurls::indicesOfMax (const T *A, const int A_rows, const int A_cols, unsigned long *ind, T *work, const int dimension) throw (gException) |
Returns the indices of the largest elements along different dimensions of a matrix. | |
template<typename T > | |
void | gurls::inv (const gMat2D< T > &A, gMat2D< T > &Ainv, InversionAlgorithm alg=LU) |
Computes the inverse ![]() ![]() | |
template<typename T > | |
T * | gurls::lambdaguesses (const T *eigvals, const int len, const int r, const int n, const int nlambda, const T minl) |
Builds array of possible values for the regularization parameter, generating a geometric series from the values in EIGVALS Internal function, not to be called from gurls. | |
template<typename T > | |
bool | gurls::le (T a, T b) |
"Less or equal than" operator between two scalars | |
template<typename T > | |
void | gurls::linspace (T a, T b, unsigned long n, T *res) |
Generates a row vector of n points linearly spaced between and including a and b. | |
template<typename T > | |
bool | gurls::lt (T a, T b) |
"Less than" operator between two scalars | |
template<> | |
GURLS_EXPORT bool | gurls::lt (float a, float b) |
"Less than" operator between two scalars, specialized for float values | |
template<> | |
GURLS_EXPORT bool | gurls::lt (double a, double b) |
"Less than" operator between two scalars, specialized for double values | |
template<typename T > | |
void | gurls::lu (gMat2D< T > &A) |
Implements the LU decomposition usig LAPACK routines. | |
template<typename T > | |
void | gurls::lu (gMat2D< T > &A, gVec< int > &pv) |
Implements the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges, using LAPACK routines. | |
template<typename T > | |
void | gurls::maxValues (const T *A, const int A_rows, const int A_cols, T *maxv, T *work, const int dimension) throw (gException) |
Returns the largest elements along different dimensions of a matrix. | |
template<typename T > | |
void | gurls::mean (const T *A, T *result, const int A_rows, const int A_cols, const int res_length) throw (gException) |
Computes the mean values along the rows of a matrix. | |
template<typename T > | |
T | gurls::median (T *v, const int length) |
Returns the median value of a vector. | |
template<typename T > | |
void | gurls::median (const T *M, const int rows, const int cols, const int dimension, T *res, T *work) |
Computes the median values of the elements along different dimensions of a matrix. | |
template<typename T > | |
void | gurls::mldivide_squared (const T *A, T *B, const int a_rows, const int a_cols, const int b_rows, const int b_cols, const CBLAS_TRANSPOSE transA) |
Performs left division of squared matrices. | |
template<typename T > | |
T | gurls::mul (T a, T b) |
Multiplication of two scalars. | |
template<typename T > | |
void | gurls::mult (const T *A, const T *B, T *result, const int len) |
Element by element multiplication of two vectors. | |
template<typename T > | |
void | gurls::pdist (const T *A, const int N, const int P, T *D) |
Computes a vector D containing the Euclidean distances between each pair of observations in the N-by-P data matrix A. | |
template<typename T > | |
void | gurls::pinv (const gMat2D< T > &A, gMat2D< T > &Ainv, T RCOND=0) |
Computes the pseudo-inverse of a non square matrix A. | |
template<typename T > | |
T * | gurls::pinv (const T *A, const int rows, const int cols, int &res_rows, int &res_cols, T *RCOND=NULL) |
Computes the pseudo-inverse of a matrix. | |
template<typename T > | |
void | gurls::qr_econ (const T *A, int m, int n, T *Q, T *R, int *E) |
Computes an economy-size QR decomposition of an input matrix A so that A(:,E) = Q*R. | |
template<typename T > | |
void | gurls::randperm (const unsigned long n, T *seq, bool generate=true, unsigned long start=1) |
Generates a vector containing a random permutation of the values from start to start+n inclusive. | |
template<typename T > | |
void | gurls::rdivide (const T *A, const T *B, T *result, const int len) |
Element by element division of two vectors. | |
template<typename T > | |
gMat2D< T > | gurls::repmat (const gVec< T > &x, unsigned long n, bool transpose=false) |
Replicates a vector n times along the columns (or along the rows if transpose==true) If x is a vector of length N, then the output is an N-by-N matrix whose columns (or rows) are copies of x. | |
template<typename T > | |
void | gurls::rls_eigen (const T *Q, const T *L, const T *Qty, T *C, const T lambda, const int n, const int Q_rows, const int Q_cols, const int L_length, const int Qty_rows, const int Qty_cols) |
Computes RLS estimator given the singular value decomposition of the kernel matrix. | |
template<typename T > | |
void | gurls::rls_eigen (const T *Q, const T *L, const T *Qty, T *C, const T lambda, const int n, const int Q_rows, const int Q_cols, const int L_length, const int Qty_rows, const int Qty_cols, T *work) |
Computes RLS estimator given the singular value decomposition of the kernel matrix. | |
template<typename T > | |
int | gurls::round (const T value) |
Rounds an input value to the nearest integer. | |
template<typename T > | |
void | gurls::set (T *buffer, const T value, const int size, const int incr) |
Sets elements of a vector to a specified value. | |
template<typename T > | |
void | gurls::set (T *buffer, const T value, const int size) |
Sets all elements of a vector to a specified value. | |
template<> | |
void GURLS_EXPORT | gurls::set (float *buffer, const float value, const int size) |
Specialized version of set for float buffers. | |
template<> | |
void GURLS_EXPORT | gurls::set (double *buffer, const double value, const int size) |
Specialized version of set for double buffers. | |
template<typename T > | |
void | gurls::setReciprocal (T *matrix, const int len) |
Computes the element-by-element multiplicative inverse of an input matrix. | |
template<typename T > | |
T * | gurls::sign (const T *vector, const int size) |
Computes a "signum vector" of the same size as an input vector, where each element is: | |
template<typename T > | |
void | gurls::sort (const T *M, const unsigned long rows, const unsigned long cols, bool(*pred)(T, T), T *values, unsigned long *indices) |
Sorts the elements of a matrix along the columns. | |
template<typename T > | |
void | gurls::squareform (const T *A, const int N, const int P, T *D, const int d_cols) |
Reformats a distance matrix between upper triangular and square form. | |
template<typename T > | |
void | gurls::stdDev (const T *X, const int rows, const int cols, T *res, T *work) |
Generates a row vector containing the standard deviation of the elements of each column of an input matrix. | |
template<typename T > | |
void | gurls::subMatrixFromColumns (const T *matrix, const int mRows, const int mCols, const unsigned long *colsIndices, const int nIndices, T *submat) |
Generates a submatrix from an input matrix. | |
template<typename T > | |
void | gurls::subMatrixFromRows (const T *matrix, const int mRows, const int mCols, const unsigned long *rowsIndices, const int nIndices, T *submat) |
Generates a submatrix from an input matrix. | |
template<typename T > | |
void | gurls::sum (const T *A, T *result, const int A_rows, const int A_cols, const int res_length) throw (gException) |
Sums all elements along the rows of a matrix. | |
template<typename T > | |
void | gurls::sum_col (const T *A, T *result, const int A_rows, const int A_cols) throw (gException) |
Sums all elements along the columns of a matrix. | |
template<typename T > | |
T | gurls::sumv (const T *V, const int len) throw (gException) |
Computes the sum of all elements of a vector. | |
template<typename T > | |
void | gurls::svd (const gMat2D< T > &A, gMat2D< T > &U, gVec< T > &W, gMat2D< T > &Vt) |
Implements the SVD decomposition of a general rectangular matrix: A = U*W*Vt. | |
template<typename T > | |
void | gurls::svd (const T *A, T *&U, T *&S, T *&Vt, const int A_rows, const int A_cols, int &U_rows, int &U_cols, int &S_len, int &Vt_rows, int &Vt_cols, bool econ=false) throw (gException) |
Computes singular value decomposition of an input matrix A such that A = U*diag(S)*Vt. | |
template<typename T > | |
void | gurls::transpose (const T *matrix, const int rows, const int cols, T *transposed) |
Transpose a matrix. |
Definition in file gmath.h.