src_c/pcg.c File Reference

Source file for a preconditioned conjugate gradient method implementation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "blas.h"
#include "def.h"
#include "pcg.h"

Functions

void init_pcg_status (pcg_status_t *pcgstat)
 Initialize pcg_status_t structure.
int pcg (double *x, pcg_status_t *pcgstat, 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.


Detailed Description

Source file for a preconditioned conjugate gradient method implementation.

This PCG implementation is based on the algorithm in the book Numerical Optimization by Nocedal and Write.


Function Documentation

void init_pcg_status ( pcg_status_t pcgstat  ) 

Initialize pcg_status_t structure.

Parameters:
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.

Parameters:
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.
Call back functions:
  • afun(double *out, const double *in, const void *adata): -- afun is a function which computes out = A*in.
  • mfun(double *out, const double *in, const void *mdata) -- mfun is a function which computes out = M^(-1)*in.

References pcg_status_t::flag, pcg_status_t::iter, and pcg_status_t::relres.

Referenced by compute_searchdir_pcg().


Generated on Mon May 25 19:15:19 2009 for l1_logreg by Doxygen 1.5.5