o2scl_linalg Namespace Reference


Detailed Description

Namespace for O2scl linear algebra function templates with operator[].


Functions

void create_givens (const double a, const double b, double &c, double &s)
 Desc.
template<class mat1_t, class mat2_t>
void apply_givens_qr (size_t M, size_t N, mat1_t &Q, mat2_t &R, size_t i, size_t j, double c, double s)
 Desc.
template<class mat1_t, class mat2_t>
void apply_givens_lq (size_t M, size_t N, mat1_t &Q, mat2_t &L, size_t i, size_t j, double c, double s)
 Desc.
template<class vec_t>
void apply_givens_vec (vec_t &v, size_t i, size_t j, double c, double s)
 Desc.
template<class mat_t, class vec_t>
int HH_solve (size_t n, mat_t &A, const vec_t &b, vec_t &x)
 Desc.
template<class mat_t, class vec_t>
int HH_svx (size_t N, size_t M, mat_t &A, vec_t &x)
 Desc.
template<class vec_t>
double householder_transform (const size_t n, vec_t &v)
 Replace the vector v with a householder vector and a coefficient tau that annihilates the last n-1 elements of v.
template<class mat_t>
double householder_transform_subcol (mat_t &A, const size_t ir, const size_t ic, const size_t n)
 Compute the householder transform of a vector formed with the last n rows of a column of a matrix.
template<class vec_t, class mat_t>
int householder_hm (const size_t M, const size_t N, double tau, const vec_t &v, mat_t &A)
 Apply a householder transformation v,tau to matrix m.
template<class mat_t>
int householder_hm_sub (mat_t &M, const size_t ir, const size_t ic, const size_t nr, const size_t nc, const mat_t &M2, const size_t ir2, const size_t ic2, double tau)
 Apply a householder transformation v, tau to submatrix of m.
template<class vec_t>
int householder_hv (const size_t N, double tau, const vec_t &v, vec_t &w)
 Apply a householder transformation v to vector w.
template<class mat_t, class vec_t>
int householder_hv_sub (const mat_t &M, vec_t &w, double tau, const size_t ie, const size_t N)
 Apply a householder transformation v to vector w.
template<class mat1_t, class mat2_t>
int householder_hm_sub2 (const size_t M, const size_t ic, double tau, const mat1_t &mv, mat2_t &A)
 Special version of householder transformation for QR_unpack().
template<class mat_t>
int LU_decomp (const size_t N, mat_t &A, o2scl::permutation &p, int &signum)
 Compute the LU decomposition of the matrix A.
template<class mat_t, class vec_t>
int LU_solve (const size_t N, const mat_t &LU, const o2scl::permutation &p, const vec_t &b, vec_t &x)
 Solve a linear system after LU decomposition.
template<class mat_t, class vec_t>
int LU_svx (const size_t N, const mat_t &LU, const o2scl::permutation &p, vec_t &x)
 Solve a linear system after LU decomposition in place.
template<class mat_t, class vec_t>
int LU_refine (const size_t N, const mat_t &A, const mat_t &LU, const o2scl::permutation &p, const vec_t &b, vec_t &x, vec_t &residual)
 Refine the solution of a linear system.
template<class mat_t, class mat_col_t>
int LU_invert (const size_t N, const mat_t &LU, const o2scl::permutation &p, mat_t &inverse)
 Compute the inverse of a matrix from its LU decomposition.
template<class mat_t>
double LU_det (const size_t N, const mat_t &LU, int signum)
 Compute the determinant of a matrix from its LU decomposition.
template<class mat_t>
double LU_lndet (const size_t N, const mat_t &LU)
 Compute the logarithm of the absolute value of the determinant of a matrix from its LU decomposition.
template<class mat_t>
int LU_sgndet (const size_t N, const mat_t &LU, int signum)
 Compute the sign of the determinant of a matrix from its LU decomposition.
template<class mat_t, class vec_t>
int QR_decomp (size_t M, size_t N, mat_t &A, vec_t &tau)
 Compute the QR decomposition of matrix A.
template<class mat_t, class vec_t>
int QR_solve (size_t N, const mat_t &QR, const vec_t &tau, const vec_t &b, vec_t &x)
 Solve the system A x = b using the QR factorization.
template<class mat_t, class vec_t>
int QR_svx (size_t M, size_t N, const mat_t &QR, const vec_t &tau, vec_t &x)
 Solve the system A x = b in place using the QR factorization.
template<class mat_t, class vec_t>
int QR_QTvec (const size_t M, const size_t N, const mat_t &QR, const vec_t &tau, vec_t &v)
 Form the product Q^T v from a QR factorized matrix.
template<class mat1_t, class mat2_t, class mat3_t, class vec_t>
int QR_unpack (const size_t M, const size_t N, const mat1_t &QR, const vec_t &tau, mat2_t &Q, mat3_t &R)
 Unpack the QR matrix to the individual Q and R components.
template<class mat1_t, class mat2_t, class vec1_t, class vec2_t>
int QR_update (size_t M, size_t N, mat1_t &Q, mat2_t &R, vec1_t &w, vec2_t &v)
 Update a QR factorisation for A= Q R , A' = A + u v^T,.


Function Documentation

int o2scl_linalg::householder_hm_sub ( mat_t &  M,
const size_t  ir,
const size_t  ic,
const size_t  nr,
const size_t  nc,
const mat_t &  M2,
const size_t  ir2,
const size_t  ic2,
double  tau 
) [inline]

Apply a householder transformation v, tau to submatrix of m.

Used in QR_decomp().

Definition at line 143 of file householder_base.h.

int o2scl_linalg::householder_hv_sub ( const mat_t &  M,
vec_t &  w,
double  tau,
const size_t  ie,
const size_t  N 
) [inline]

Apply a householder transformation v to vector w.

Used in QR_QTvec().

Definition at line 211 of file householder_base.h.

double o2scl_linalg::householder_transform_subcol ( mat_t &  A,
const size_t  ir,
const size_t  ic,
const size_t  n 
) [inline]

Compute the householder transform of a vector formed with the last n rows of a column of a matrix.

Used in QR_decomp().

Definition at line 75 of file householder_base.h.

int o2scl_linalg::LU_decomp ( const size_t  N,
mat_t &  A,
o2scl::permutation &  p,
int &  signum 
) [inline]

Compute the LU decomposition of the matrix A.

On output the diagonal and upper triangular part of the input matrix A contain the matrix U. The lower triangular part of the input matrix (excluding the diagonal) contains L. The diagonal elements of L are unity, and are not stored.

The permutation matrix P is encoded in the permutation p. The j-th column of the matrix P is given by the k-th column of the identity matrix, where k = p_j the j-th element of the permutation vector. The sign of the permutation is given by signum. It has the value (-1)^n, where n is the number of interchanges in the permutation.

The algorithm used in the decomposition is Gaussian Elimination with partial pivoting (Golub & Van Loan, Matrix Computations, Algorithm 3.4.1).

Definition at line 51 of file lu_base.h.

double o2scl_linalg::LU_det ( const size_t  N,
const mat_t &  LU,
int  signum 
) [inline]

Compute the determinant of a matrix from its LU decomposition.

These functions compute the determinant of a matrix A from its LU decomposition, LU. The determinant is computed as the product of the diagonal elements of U and the sign of the row permutation signum.

Definition at line 230 of file lu_base.h.

int o2scl_linalg::LU_invert ( const size_t  N,
const mat_t &  LU,
const o2scl::permutation &  p,
mat_t &  inverse 
) [inline]

Compute the inverse of a matrix from its LU decomposition.

These functions compute the inverse of a matrix A from its LU decomposition (LU,p), storing the result in the matrix inverse. The inverse is computed by solving the system A x = b for each column of the identity matrix. It is preferable to avoid direct use of the inverse whenever possible, as the linear solver functions can obtain the same result more efficiently and reliably (consult any introductory textbook on numerical linear algebra for details).

Idea for future:
could rewrite to avoid mat_col_t

Definition at line 195 of file lu_base.h.

double o2scl_linalg::LU_lndet ( const size_t  N,
const mat_t &  LU 
) [inline]

Compute the logarithm of the absolute value of the determinant of a matrix from its LU decomposition.

These functions compute the logarithm of the absolute value of the determinant of a matrix A, $ \ln|\det(A)| $, from its LU decomposition, LU. This function may be useful if the direct computation of the determinant would overflow or underflow.

Definition at line 253 of file lu_base.h.

int o2scl_linalg::LU_refine ( const size_t  N,
const mat_t &  A,
const mat_t &  LU,
const o2scl::permutation &  p,
const vec_t &  b,
vec_t &  x,
vec_t &  residual 
) [inline]

Refine the solution of a linear system.

These functions apply an iterative improvement to x, the solution of A x = b, using the LU decomposition of A into (LU,p). The initial residual r = A x - b is also computed and stored in residual.

Definition at line 162 of file lu_base.h.

int o2scl_linalg::LU_sgndet ( const size_t  N,
const mat_t &  LU,
int  signum 
) [inline]

Compute the sign of the determinant of a matrix from its LU decomposition.

These functions compute the sign or phase factor of the determinant of a matrix A, $ \det(A)/|\det(A)| $, from its LU decomposition, LU.

Definition at line 274 of file lu_base.h.

int o2scl_linalg::LU_solve ( const size_t  N,
const mat_t &  LU,
const o2scl::permutation &  p,
const vec_t &  b,
vec_t &  x 
) [inline]

Solve a linear system after LU decomposition.

This function solve the square system A x = b using the LU decomposition of A into (LU, p) given by gsl_linalg_LU_decomp or gsl_linalg_complex_LU_decomp.

Definition at line 113 of file lu_base.h.

int o2scl_linalg::LU_svx ( const size_t  N,
const mat_t &  LU,
const o2scl::permutation &  p,
vec_t &  x 
) [inline]

Solve a linear system after LU decomposition in place.

These functions solve the square system A x = b in-place using the LU decomposition of A into (LU,p). On input x should contain the right-hand side b, which is replaced by the solution on output.

Definition at line 134 of file lu_base.h.

int o2scl_linalg::QR_update ( size_t  M,
size_t  N,
mat1_t &  Q,
mat2_t &  R,
vec1_t &  w,
vec2_t &  v 
) [inline]

Update a QR factorisation for A= Q R , A' = A + u v^T,.

M and N are the number of rows and columns of R.

      * Q' R' = QR + u v^T
      *       = Q (R + Q^T u v^T)
      *       = Q (R + w v^T)
      *
      * where w = Q^T u.
      *
      * Algorithm from Golub and Van Loan, "Matrix Computations", Section
      * 12.5 (Updating Matrix Factorizations, Rank-One Changes)
      

Definition at line 147 of file qr_base.h.


Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page