Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Functions

Interface to LAPACK routines. More...

Functions

template<typename Array2d , typename Array1d >
void cusp::lapack::getrf (Array2d &A, Array1d &piv)
 Compute LU factorization of matrix. More...
 
template<typename Array2d >
void cusp::lapack::potrf (Array2d &A, char uplo= 'U')
 Computes the Cholesky factorization of a symmetric (Hermitian) positive-definite matrix. More...
 
template<typename Array2d , typename Array1d >
void cusp::lapack::sytrf (Array2d &A, Array1d &piv, char uplo= 'U')
 Computes the Bunch-Kaufman factorization of a symmetric matrix. More...
 
template<typename Array2d , typename Array1d >
void cusp::lapack::getrs (const Array2d &A, const Array1d &piv, Array2d &B, char trans= 'N')
 Solves a system of linear equations with an LU-factored square matrix, with multiple right-hand sides. More...
 
template<typename Array2d >
void cusp::lapack::potrs (const Array2d &A, Array2d &B, char uplo= 'U')
 Solves a system of linear equations with a Cholesky-factored symmetric (Hermitian) positive-definite matrix. More...
 
template<typename Array2d , typename Array1d >
void cusp::lapack::sytrs (const Array2d &A, const Array1d &piv, Array2d &B, char uplo= 'U')
 Solves a system of linear equations with a UDU- or LDL-factored symmetric matrix. More...
 
template<typename Array2d >
void cusp::lapack::trtrs (const Array2d &A, Array2d &B, char uplo= 'U', char trans= 'N', char diag= 'N')
 Solves a system of linear equations with a triangular matrix, with multiple right-hand sides. More...
 
template<typename Array2d >
void cusp::lapack::trtri (Array2d &A, char uplo= 'U', char diag= 'N')
 This routine computes the inverse of a triangular matrix. More...
 
template<typename Array2d , typename Array1d >
void cusp::lapack::syev (const Array2d &A, Array1d &eigvals, Array2d &eigvecs, char uplo= 'U')
 Computes all eigenvalues and eigenvectors of a real symmetric matrix. More...
 
template<typename Array1d1 , typename Array1d2 , typename Array1d3 , typename Array2d >
void cusp::lapack::stev (const Array1d1 &alphas, const Array1d2 &betas, Array1d3 &eigvals, Array2d &eigvecs, char job= 'V')
 Computes all eigenvalues and, optionally, eigenvectors of a real symmetric tridiagonal matrix. More...
 
template<typename Array2d1 , typename Array2d2 , typename Array1d , typename Array2d3 >
void cusp::lapack::sygv (const Array2d1 &A, const Array2d2 &B, Array1d &eigvals, Array2d3 &eigvecs)
 Computes all eigenvalues and, optionally, eigenvectors of a real generalized symmetric definite eigenproblem. More...
 
template<typename Array2d , typename Array1d >
void cusp::lapack::gesv (const Array2d &A, Array2d &B, Array1d &piv)
 Computes the solution of a system of linear equations with a square matrix A and multiple right-hand sides. More...
 

Function Documentation

template<typename Array2d , typename Array1d >
void cusp::lapack::gesv ( const Array2d &  A,
Array2d &  B,
Array1d &  piv 
)

Computes the solution of a system of linear equations with a square matrix A and multiple right-hand sides.

Template Parameters
Array2dType of the input matrix
Array1dType of the input pivots array
Parameters
AContains the upper or lower triangle of a symmetric matrix
BContains the upper or lower triangle of a symmetric positive definite matrix
pivArray containing pivots
Overview
This routine solves the system of linear equations A*X = B, where A is an n-by-n matrix for X, the columns of matrix B are individual right-hand sides, and the columns of X are the corresponding solutions.

An LU decomposition with partial pivoting and row interchanges is used to factor A as A = P*L*U, where P is a permutation matrix, L is unit lower triangular, and U is upper triangular. The factored form of A is then used to solve the system of equations A*X = B.

Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// solve multiple RHS vectors
cusp::lapack::gesv(A, B, piv);
// print the contents of B
}
template<typename Array2d , typename Array1d >
void cusp::lapack::getrf ( Array2d &  A,
Array1d &  piv 
)

Compute LU factorization of matrix.

Template Parameters
Array2dType of the input matrix to factor
Array1dType of pivot array
Parameters
AInput matrix to factor
pivArray containing pivots
Overview
This routine computes the LU factorization of a general m-by-n matrix A as A = P*L*U, where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n) and U is upper triangular (upper trapezoidal if m < n). The routine uses partial pivoting, with row interchanges.
Example
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// compute LU factorization of A
// print the contents of A
// print the contents of piv
}
template<typename Array2d , typename Array1d >
void cusp::lapack::getrs ( const Array2d &  A,
const Array1d &  piv,
Array2d &  B,
char  trans = 'N' 
)

Solves a system of linear equations with an LU-factored square matrix, with multiple right-hand sides.

Template Parameters
Array2dType of the input matrices
Array1dType of pivot array
Parameters
ALU factored input matrix
pivArray containing pivots
Bmatrix containing multiple right-hand side vectors
transIf 'N', then A*X = B is solved for X.
Overview
This routine solves for X the following systems of linear equations: A*X = B if trans='N', AT*X = B if trans='T', AH*X = B if trans='C' (for complex matrices only).
Note
Before calling this routine, you must call getrf to compute the LU factorization of A.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// create initial RHS of 2 vectors and initialize
B.values = cusp::random_array<float>(B.values.size());
// compute LU factorization of A
// solve multiple RHS vectors
cusp::lapack::getrs(A, piv, B);
// print the contents of B
}
template<typename Array2d >
void cusp::lapack::potrf ( Array2d &  A,
char  uplo = 'U' 
)

Computes the Cholesky factorization of a symmetric (Hermitian) positive-definite matrix.

Template Parameters
Array2dType of the input matrix to factor
Parameters
AInput matrix to factor
uploIndicates whether A is upper or lower triangular
Overview
This routine forms the Cholesky factorization of a symmetric positive-definite or, for complex data, Hermitian positive-definite matrix A: A = UT*U for real data, A = UH*U for complex data if uplo='U' A = L*LT for real data, A = L*LH for complex data if uplo='L' where L is a lower triangular matrix and U is upper triangular.
Example
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// compute Cholesky factorization of A
// print the contents of A
}
template<typename Array2d >
void cusp::lapack::potrs ( const Array2d &  A,
Array2d &  B,
char  uplo = 'U' 
)

Solves a system of linear equations with a Cholesky-factored symmetric (Hermitian) positive-definite matrix.

Template Parameters
Array2dType of the input matrices
Parameters
ACholesky factored input matrix
Bmatrix containing multiple right-hand side vectors
uploIndicates whether A is upper or lower triangular
Overview
This routine solves for X the system of linear equations A*X = B with a symmetric positive-definite or, for complex data, Hermitian positive-definite matrix A, given the Cholesky factorization of A:

A = UT*U for real data, A = UH*U for complex dataif UHplo='U' A = L*LT for real data, A = L*LH for complex dataif uplo='L'

where L is a lower triangular matrix and U is upper triangular. The system is solved with multiple right-hand sides stored in the columns of the matrix B.

Note
Before calling this routine, you must call potrf to compute the Cholesky factorization of A.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// create initial RHS of 2 vectors and initialize
B.values = cusp::random_array<float>(B.values.size());
// compute Bunch-Kaufman factorization of A
// solve multiple RHS vectors
// print the contents of B
}
template<typename Array1d1 , typename Array1d2 , typename Array1d3 , typename Array2d >
void cusp::lapack::stev ( const Array1d1 &  alphas,
const Array1d2 &  betas,
Array1d3 &  eigvals,
Array2d &  eigvecs,
char  job = 'V' 
)

Computes all eigenvalues and, optionally, eigenvectors of a real symmetric tridiagonal matrix.

Template Parameters
Array1d1Type of the input array
Array1d2Type of the input array
Array1d3Type of the input array
Array2dType of the input array
Parameters
alphasMain diagonal entries
betasFirst sub-diagonal entries
eigvalsOn return contain eigenvalues of matrix
eigvecsOn return contain eigenvectors of the matrix
jobIf 'V', then eigenvalues and eigenvectors are computed
Overview
This routine computes all eigenvalues and eigenvectors of a real symmetric matrix.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// solve multiple RHS vectors
cusp::lapack::syev(A, eigvals, eigvecs);
// print the contents of B
cusp::print(eigvals);
}
template<typename Array2d , typename Array1d >
void cusp::lapack::syev ( const Array2d &  A,
Array1d &  eigvals,
Array2d &  eigvecs,
char  uplo = 'U' 
)

Computes all eigenvalues and eigenvectors of a real symmetric matrix.

Template Parameters
Array2dType of the input matrices
Array1dType of the input array
Parameters
ASymmetric input matrix
eigvalsOn return contain eigenvalues of matrix
eigvecsOn return contain eigenvectors of the matrix
uploIndicates whether upper or lower portion of symmetric matrix is stored.
Overview
This routine computes all eigenvalues and eigenvectors of a real symmetric matrix.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// solve multiple RHS vectors
cusp::lapack::syev(A, eigvals, eigvecs);
// print the contents of B
cusp::print(eigvals);
}
template<typename Array2d1 , typename Array2d2 , typename Array1d , typename Array2d3 >
void cusp::lapack::sygv ( const Array2d1 &  A,
const Array2d2 &  B,
Array1d &  eigvals,
Array2d3 &  eigvecs 
)

Computes all eigenvalues and, optionally, eigenvectors of a real generalized symmetric definite eigenproblem.

Template Parameters
Array2d1Type of the input array
Array2d2Type of the input array
Array1dType of the input array
Array2d3Type of the input array
Parameters
AContains the upper or lower triangle of a symmetric matrix
BContains the upper or lower triangle of a symmetric positive definite matrix
eigvalsOn return contain eigenvalues of matrix
eigvecsOn return contain eigenvectors of the matrix
Overview
This routine computes all the eigenvalues, and optionally, the eigenvectors of a real generalized symmetric-definite eigenproblem, of the form

A*x = λ*B*x, A*B*x = λ*x, or B*A*x = λ*x.

Here A and B are assumed to be symmetric and B is also positive definite.

Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// compute eigvals and eigvecs
cusp::lapack::sygv(A, A, eigvals, eigvecs);
// print the eigenvalues
cusp::print(eigvals);
}
template<typename Array2d , typename Array1d >
void cusp::lapack::sytrf ( Array2d &  A,
Array1d &  piv,
char  uplo = 'U' 
)

Computes the Bunch-Kaufman factorization of a symmetric matrix.

Template Parameters
Array2dType of the input matrix to factor
Array1dType of pivot array
Parameters
AInput matrix to factor
pivArray containing pivots
uploIndicates whether A is upper or lower triangular
Overview
This routine computes the factorization of a symmetric or hermitian matrix using the Bunch-Kaufman diagonal pivoting method. The form of the factorization is: A = P*U*D*UT*PT, if uplo='U' A = P*L*D*LT*PT, if uplo='L' where A is the input matrix, P is a permutation matrix, U and L are upper and lower triangular matrices with unit diagonal, and D is a symmetric block-diagonal matrix with 1-by-1 and 2-by-2 diagonal blocks. U and L have 2-by-2 unit diagonal blocks corresponding to the 2-by-2 blocks of D.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// compute Bunch-Kaufman factorization of A
// print the contents of A
// print the contents of piv
}
template<typename Array2d , typename Array1d >
void cusp::lapack::sytrs ( const Array2d &  A,
const Array1d &  piv,
Array2d &  B,
char  uplo = 'U' 
)

Solves a system of linear equations with a UDU- or LDL-factored symmetric matrix.

Template Parameters
Array2dType of the input matrices
Array1dType of pivot array
Parameters
AInput matrix to factor
pivArray containing pivots
Bmatrix containing multiple right-hand side vectors
uploIndicates whether A is upper or lower triangular
Overview
The routine solves for X the system of linear equations A*X = B with a symmetric matrix A, given the Bunch-Kaufman factorization of A:

A = P*U*D*UT*PT, if uplo='U' A = P*L*D*LT*PT, if uplo='L'

where P is a permutation matrix, U and L are upper and lower triangular matrices with unit diagonal, and D is a symmetric block-diagonal matrix. The system is solved with multiple right-hand sides stored in the columns of the matrix B.

Note
You must supply the factor U (or L) and the array of pivots returned by the factorization routine sytrf.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// create initial RHS of 2 vectors and initialize
B.values = cusp::random_array<float>(B.values.size());
// compute Bunch-Kaufman factorization of A
// solve multiple RHS vectors
cusp::lapack::sytrs(A, piv, B);
// print the contents of B
}
template<typename Array2d >
void cusp::lapack::trtri ( Array2d &  A,
char  uplo = 'U',
char  diag = 'N' 
)

This routine computes the inverse of a triangular matrix.

Template Parameters
Array2dType of the input matrix
Parameters
ATriangular input matrix
uploIndicates whether A is upper or lower triangular
diagIf 'N', then A is not a unit triangular matrix.
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// print the contents of A
}
template<typename Array2d >
void cusp::lapack::trtrs ( const Array2d &  A,
Array2d &  B,
char  uplo = 'U',
char  trans = 'N',
char  diag = 'N' 
)

Solves a system of linear equations with a triangular matrix, with multiple right-hand sides.

Template Parameters
Array2dType of the input matrices
Parameters
ATriangular input matrix
Bmatrix containing multiple right-hand side vectors
uploIndicates whether A is upper or lower triangular
transIf 'N', then A*X = B is solved for X.
diagIf 'N', then A is not a unit triangular matrix.
Overview
This routine solves for X the following systems of linear equations with a triangular matrix A, with multiple right-hand sides stored in B: A*X = B if trans='N', AT*X = B if trans='T', AH*X = B if trans='C' (for complex matrices only).
Example
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/print.h>
// include cusp lapack header file
int main()
{
// create an empty dense matrix structure
// create 2D Poisson problem
// create initial RHS of 2 vectors and initialize
B.values = cusp::random_array<float>(B.values.size());
// solve multiple RHS vectors
// print the contents of B
}