Go to the source code of this file.
Data Structures | |
| struct | pcg_status_t |
| Contains pcg status information. More... | |
Defines | |
| #define | PCG_INIT (-1) |
| #define | PCG_OK (0) |
| #define | PCG_MAXITER (1) |
Functions | |
| void | init_pcg_status (pcg_status_t *pstst) |
| Initialize pcg_status_t structure. | |
| int | pcg (double *x, pcg_status_t *pstat, void(*afun)(double *, const double *, const void *), const void *adata, void(*mfun)(double *, const double *, const void *), const void *mdata, double *b, double tol, double maxiter, int n) |
| Solves Ax = b via PCG. | |
| void init_pcg_status | ( | pcg_status_t * | pcgstat | ) |
Initialize pcg_status_t structure.
| pcgstat | pointer to a pcg_status_t structure. |
References pcg_status_t::flag, pcg_status_t::iter, and pcg_status_t::relres.
Referenced by l1_logreg_train().
| int pcg | ( | double * | x, | |
| pcg_status_t * | pcgstat, | |||
| void(*)(double *, const double *, const void *) | afun, | |||
| const void * | adata, | |||
| void(*)(double *, const double *, const void *) | mfun, | |||
| const void * | mdata, | |||
| double * | b, | |||
| double | tol, | |||
| double | maxiter, | |||
| int | n | |||
| ) |
Solves Ax = b via PCG.
PCG implements a preconditioned conjugate gradient method, which solves a positive definite linear system Ax = b. Here, A is a (m x n) matrix, b is an m-vector, and variable x is an n-vector.
| x | double array of size n; This parameter is used for both taking an initial value and returning the result. | |
| pcgstat | pointer to a structure of PCG status. | |
| afun | pointer to a function that computes A*x. | |
| adata | pointer to a data structure for afun; | |
| mfun | pointer to a function that computes M^{-1}r. | |
| mdata | pointer to a data structure for mfun; | |
| b | pointer to a n-vector | |
| tol | integer; terminates algorithm when ||r|| < ||b||*tol. | |
| maxiter | integer; terminates algorithm when iteration exceeds maxiter. | |
| n | integer; dimension of the problem. |
References pcg_status_t::flag, pcg_status_t::iter, and pcg_status_t::relres.
Referenced by compute_searchdir_pcg().