Go to the source code of this file.
Data Structures | |
| struct | dmatrix |
Structure for both dense and sparse matrix.
| |
Functions | |
| double | dmat_norm1 (const int n, const double *x) |
| |
| double | dmat_norm2 (const int n, const double *x) |
| |
| double | dmat_norminf (const int n, const double *x) |
| |
| double | dmat_dot (const int n, const double *x, const double *y) |
| |
| void | dmat_vset (int n, const double val, double *dst) |
| |
| void | dmat_vcopy (const int n, const double *src, double *dst) |
| |
| void | dmat_yexpx (const int n, const double *x, double *y) |
| |
| void | dmat_ysqrtx (const int n, const double *x, double *y) |
| |
| void | dmat_yinvx (const int n, const double *x, double *y) |
| |
| void | dmat_waxpby (int n, double alpha, const double *x, double beta, const double *y, double *w) |
| |
| void | dmat_elemprod (const int n, const double *x, const double *y, double *z) |
| |
| void | dmat_elemdivi (const int n, const double *x, const double *y, double *z) |
| |
| void | dmat_yATx (const dmatrix *A, const double *x, double *y) |
| |
| void | dmat_yAx (const dmatrix *A, const double *x, double *y) |
| |
| void | dmat_yAmpqTx (const dmatrix *A, const double *p, const double *q, const double *x, double *y) |
| |
| void | dmat_yAmpqx (const dmatrix *A, const double *p, const double *q, const double *x, double *y) |
| |
| void | dmat_yHx_ (const dmatrix *A, const double *b, const double *d0, const double *d1, const double *d2, const double *x, double *y) |
| |
| void | dmat_yHx (const dmatrix *A, const double *p, const double *q, const double *b, const double *d0, const double *d1, const double *d2, const double *x, double *y) |
| |
| void | dmat_elemAA (const dmatrix *A, dmatrix **A2) |
| |
| void | dmat_diagscale (dmatrix *M, const double *dl, const int invl, const double *dr, const int invr) |
| |
| void | dmat_colsum (const dmatrix *M, double *vsum) |
| |
| void | dmat_colavg (const dmatrix *M, double *vavg) |
| |
| void | dmat_colstd (const dmatrix *M, const double *vavg, double *vstd) |
| |
| void | dmat_diagadd (dmatrix *M, const double *d) |
| |
| void | dmat_new_dense (dmatrix **M, const int m, const int n) |
| Allocate memory for a dense matrix. | |
| void | dmat_free (dmatrix *M) |
| Free memory for a matrix. | |
| void | dmat_duplicate (const dmatrix *M, dmatrix **Mcopy) |
| Duplicates a matrix. | |
| void | dmat_copy (const dmatrix *M, dmatrix *dst) |
| Copies the contents of a matrix. | |
| void | dmat_get_row (const dmatrix *M, const int rowidx, double *dst) |
| void | dmat_vprint (const int n, const double *v) |
| Shows the content of a vector. | |
| void | dmat_print (const dmatrix *mat) |
| Shows the content of a matrix. | |
| void | dmat_summary (dmatrix *M) |
| Shows the summary of a matrix. | |
| void | dmat_build_idx (dmatrix *M) |
| Build row index from csr info. (jdx and rdx). | |
| void | dmat_B_AAT (dmatrix *A, dmatrix *B) |
| |
| void | dmat_B_ATA (dmatrix *A, dmatrix *B) |
| |
| void | dmat_A_axxTpA (double a, double *x, dmatrix *A) |
| |
| void | dmat_potrs (const dmatrix *A, double *b) |
| |
| void | dmat_posv (const dmatrix *A, double *b) |
| |
| void | dmat_profile () |
| void dmat_A_axxTpA | ( | double | a, | |
| double * | x, | |||
| dmatrix * | A | |||
| ) |
Computes a row-rank update of a dense matrix.
| a | scalar. | |
| x | pointer to a vector. | |
| A | pointer to a matrix. |
References dmatrix::n, and dmatrix::val.
Referenced by compute_searchdir_chol_thin().
Computes dense matrix-matrix-transpose product.
| A | pointer to a matrix. | |
| B | pointer to a result matrix. |
References dmatrix::m, dmatrix::n, and dmatrix::val.
Referenced by compute_searchdir_chol_fat().
Computes dense matrix-transpose-matrix product.
| A | pointer to a matrix. | |
| B | pointer to a result matrix. |
References dmatrix::m, dmatrix::n, and dmatrix::val.
Referenced by compute_searchdir_chol_thin().
| void dmat_build_idx | ( | dmatrix * | M | ) |
Build row index from csr info. (jdx and rdx).
| M | pointer to a matrix. |
References dmatrix::idx, dmatrix::m, dmatrix::nz, and dmatrix::rdx.
Referenced by main().
| void dmat_colavg | ( | const dmatrix * | M, | |
| double * | y | |||
| ) |
Computes column average of a matrix.
| M | pointer to a matrix. | |
| y | pointer to a result vector (column average). |
References dmat_vset(), dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, and dmatrix::val.
Referenced by standardize_data().
| void dmat_colstd | ( | const dmatrix * | M, | |
| const double * | a, | |||
| double * | s | |||
| ) |
Computes column standard-deviation of a matrix.
| M | pointer to a matrix. | |
| a | pointer to a column average vector. | |
| s | pointer to a result vector (column std-dev). |
References dmat_vset(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, and dmatrix::val.
Referenced by standardize_data().
| void dmat_colsum | ( | const dmatrix * | M, | |
| double * | y | |||
| ) |
Computes column sum of a matrix.
| M | pointer to a matrix. | |
| y | pointer to a result vector (column sum). |
References dmat_vset(), dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, and dmatrix::val.
Copies the contents of a matrix.
Only copies the contents, NOT allocate memory.
| M | pointer to a source matrix. | |
| dst | pointer to a destination matrix. |
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), compute_searchdir_chol_thin(), find_lambdamax(), and l1_logreg_train().
| void dmat_diagadd | ( | dmatrix * | M, | |
| const double * | d | |||
| ) |
Adds diagonal entries to a matrix.
| M | pointer to a matrix. | |
| d | pointer to a diagonal vector. |
References dmatrix::m, dmatrix::n, dmatrix::nz, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), and compute_searchdir_chol_thin().
| void dmat_diagscale | ( | dmatrix * | M, | |
| const double * | dl, | |||
| const int | invl, | |||
| const double * | dr, | |||
| const int | invr | |||
| ) |
Computes left and right diagonal scaleing of M.
| M | pointer to a matrix. | |
| dl | pointer to a diagonal vector. | |
| invl | inverse flag of left diagonal matrix.
| |
| dr | pointer to a diagonal vector. | |
| invr | inverse flag of right diagonal matrix.
|
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), compute_searchdir_chol_thin(), find_lambdamax(), l1_logreg_train(), and standardize_data().
| double dmat_dot | ( | const int | n, | |
| const double * | x, | |||
| const double * | y | |||
| ) |
Returns dot product of a vector x and y.
| n | length of a vector x. | |
| x | pointer to a vector x. | |
| y | pointer to a vector y. |
Referenced by backtracking_linesearch(), compute_searchdir_chol_fat(), compute_searchdir_chol_thin(), and l1_logreg_train().
Duplicates a matrix.
Allocates all the memory and set sizes as in M, but DO NOT copy the contents. To copy the contents, call dmat_copy.
| M | pointer to a source matrix. | |
| dst | pointer to a destination matrix. |
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by find_lambdamax(), and l1_logreg_train().
Computes elementwise matrix square.
| A | pointer to a matrix. | |
| B | pointer to a result matrix. |
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by l1_logreg_train().
| void dmat_elemdivi | ( | const int | n, | |
| const double * | x, | |||
| const double * | y, | |||
| double * | z | |||
| ) |
Computes elementwise division of vectors.
NOTE: y = x./y is not allowed, i.e., w should not be the same with y.
| n | length of a vector x. | |
| x | pointer to a vector x. | |
| y | pointer to a vector y. | |
| z | pointer to a result vector z. |
Referenced by l1_logreg_train(), and standardize_data().
| void dmat_elemprod | ( | const int | n, | |
| const double * | x, | |||
| const double * | y, | |||
| double * | z | |||
| ) |
Computes elementwise product of vectors.
NOTE: x = x.*y is not allowed, i.e., w should not be the same with x.
| n | length of a vector x. | |
| x | pointer to a vector x. | |
| y | pointer to a vector y. | |
| z | pointer to a result vector z. |
Referenced by compute_searchdir_chol_fat(), and compute_searchdir_pcg().
| void dmat_free | ( | dmatrix * | M | ) |
Free memory for a matrix.
| M | pointer to a matrix to be freed. |
References dmatrix::idx, dmatrix::jdx, dmatrix::rdx, and dmatrix::val.
Referenced by find_lambdamax(), and main().
| void dmat_new_dense | ( | dmatrix ** | M, | |
| const int | m, | |||
| const int | n | |||
| ) |
Allocate memory for a dense matrix.
| M | pointer to an allocated matrix. | |
| m | size of matrix (row). | |
| n | size of matrix (column). |
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by l1_logreg_train().
| double dmat_norm1 | ( | const int | n, | |
| const double * | x | |||
| ) |
Returns 1-norm of a vector x.
| n | length of a vector x. | |
| x | pointer to a vector x. |
Referenced by l1_logreg_train().
| double dmat_norm2 | ( | const int | n, | |
| const double * | x | |||
| ) |
Returns 2-norm of a vector x.
| n | length of a vector x. | |
| x | pointer to a vector x. |
Referenced by compute_searchdir_pcg().
| double dmat_norminf | ( | const int | n, | |
| const double * | x | |||
| ) |
Returns infinity-norm of a vector x
| n | length of a vector x | |
| x | pointer to a vector x |
Referenced by find_lambdamax(), and l1_logreg_train().
| void dmat_posv | ( | const dmatrix * | A, | |
| double * | b | |||
| ) |
Computes the solution of a linear system Ax = b via Cholesky method. Wrapper function to dposv. That is, A should be a Cholesky factor computed by potrs.
| A | pointer to a matrix (Cholesky factor). | |
| b | pointer to a vector. |
References dmatrix::m, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), and compute_searchdir_chol_thin().
| void dmat_potrs | ( | const dmatrix * | A, | |
| double * | b | |||
| ) |
Computes the solution of a linear system Ax = b via Cholesky method. Wrapper function to dports. That is, the cholesky factor is stored in A after computation.
| A | pointer to a matrix. | |
| b | pointer to a vector. |
References dmatrix::m, and dmatrix::val.
Referenced by compute_searchdir_chol_fat().
| void dmat_print | ( | const dmatrix * | M | ) |
Shows the content of a matrix.
It only shows at most 10 x 10 elements of a matrix.
| M | pointer to a matrix. |
References dmatrix::idx, dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
| void dmat_summary | ( | dmatrix * | M | ) |
Shows the summary of a matrix.
| M | pointer to a matrix. |
References dmatrix::m, dmatrix::n, and dmatrix::nz.
| void dmat_vcopy | ( | const int | n, | |
| const double * | src, | |||
| double * | dst | |||
| ) |
Copies a vector.
| n | length of vectors. | |
| src | pointer to a source vector. | |
| dst | pointer to a destination vector. |
Referenced by backtracking_linesearch(), l1_logreg_train(), and standardize_data().
| void dmat_vprint | ( | const int | n, | |
| const double * | v | |||
| ) |
Shows the content of a vector.
It only shows at most 10 elements of a vector.
| n | size of a vector. | |
| v | pointer to a vector. |
| void dmat_vset | ( | int | n, | |
| const double | val, | |||
| double * | dst | |||
| ) |
Sets all the elements of a vector with a constant value.
| n | length of a vector. | |
| val | constant value to set. | |
| dst | pointer to a vector. |
Referenced by compute_searchdir_pcg(), dmat_colavg(), dmat_colstd(), dmat_colsum(), dmat_waxpby(), dmat_yAmpqTx(), dmat_yATx(), dmat_yHx(), dmat_yHx_(), l1_logreg_train(), and standardize_data().
| void dmat_waxpby | ( | int | n, | |
| double | alpha, | |||
| const double * | x, | |||
| double | beta, | |||
| const double * | y, | |||
| double * | w | |||
| ) |
Computes weighted vector sum.
| n | length of vectors. | |
| alpha | constant | |
| x | pointer to a vector. | |
| beta | constant | |
| y | pointer to a vector. | |
| w | pointer to a result vector. |
References dmat_vset().
Referenced by backtracking_linesearch(), compute_searchdir_chol_fat(), compute_searchdir_pcg(), l1_logreg_train(), and optimize_intercept().
| void dmat_yAmpqTx | ( | const dmatrix * | A, | |
| const double * | p, | |||
| const double * | q, | |||
| const double * | x, | |||
| double * | y | |||
| ) |
Computes transposed row-rank updated matrix-vector product.
| A | pointer to a matrix. | |
| p | pointer to a column vector. | |
| q | pointer to a row vector. | |
| x | pointer to a vector x. | |
| y | pointer to a result vector y. |
References dmat_vset(), dmat_yATx(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by compute_searchdir_pcg(), find_lambdamax(), and l1_logreg_train().
| void dmat_yAmpqx | ( | const dmatrix * | A, | |
| const double * | p, | |||
| const double * | q, | |||
| const double * | x, | |||
| double * | y | |||
| ) |
Computes row-rank updated matrix-vector product.
| A | pointer to a matrix. | |
| p | pointer to a column vector. | |
| q | pointer to a row vector. | |
| x | pointer to a vector x. | |
| y | pointer to a result vector y. |
References dmat_yAx(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by backtracking_linesearch(), and l1_logreg_train().
| void dmat_yATx | ( | const dmatrix * | A, | |
| const double * | x, | |||
| double * | y | |||
| ) |
Computes transposed matrixr-vector product.
| A | pointer to a matrix. | |
| x | pointer to a vector x. | |
| y | pointer to a result vector y. |
References dmat_vset(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), compute_searchdir_chol_thin(), compute_searchdir_pcg(), and dmat_yAmpqTx().
| void dmat_yAx | ( | const dmatrix * | A, | |
| const double * | x, | |||
| double * | y | |||
| ) |
Computes matrix-vector product.
| A | pointer to a matrix. | |
| x | pointer to a vector x. | |
| y | pointer to a result vector y. |
References dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by compute_searchdir_chol_fat(), dmat_yAmpqx(), and l1_logreg_classify().
| void dmat_yexpx | ( | const int | n, | |
| const double * | x, | |||
| double * | y | |||
| ) |
Computes elementwise exp() of a vector.
| n | length of vectors. | |
| x | pointer to a source vector. | |
| y | pointer to a destination vector. |
Referenced by backtracking_linesearch(), and optimize_intercept().
| void dmat_yHx | ( | const dmatrix * | A, | |
| const double * | p, | |||
| const double * | q, | |||
| const double * | b, | |||
| const double * | d0, | |||
| const double * | d1, | |||
| const double * | d2, | |||
| const double * | x, | |||
| double * | y | |||
| ) |
Computes complex matrix-vector product.
| A | pointer to a matrix. | |
| p | pointer to a column vector. | |
| q | pointer to a row vector. | |
| b | pointer to a vector. | |
| d0 | pointer to a vector. | |
| d1 | pointer to a vector. | |
| d2 | pointer to a vector. | |
| x | pointer to a vector. | |
| y | pointer to a result vector. |
References dmat_vset(), dmat_yHx_(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
| void dmat_yHx_ | ( | const dmatrix * | A, | |
| const double * | b, | |||
| const double * | d0, | |||
| const double * | d1, | |||
| const double * | d2, | |||
| const double * | x, | |||
| double * | y | |||
| ) |
Computes complex matrix-vector product.
| A | pointer to a matrix. | |
| b | pointer to a vector. | |
| d0 | pointer to a vector. | |
| d1 | pointer to a vector. | |
| d2 | pointer to a vector. | |
| x | pointer to a vector. | |
| y | pointer to a result vector. |
References dmat_vset(), dmatrix::jdx, dmatrix::m, dmatrix::n, dmatrix::nz, dmatrix::rdx, and dmatrix::val.
Referenced by dmat_yHx().
| void dmat_yinvx | ( | const int | n, | |
| const double * | x, | |||
| double * | y | |||
| ) |
Computes elementwise inv() of a vector.
| n | length of vectors. | |
| x | pointer to a source vector. | |
| y | pointer to a destination vector. |
Referenced by backtracking_linesearch(), compute_searchdir_chol_fat(), and optimize_intercept().
| void dmat_ysqrtx | ( | const int | n, | |
| const double * | x, | |||
| double * | y | |||
| ) |
Computes elementwise sqrt() of a vector.
| n | length of vectors. | |
| x | pointer to a source vector. | |
| y | pointer to a destination vector. |
Referenced by compute_searchdir_chol_thin().