Linear solver

This section regroups all of the linear algebra functions concerning linear solver which are currently implemented within castor. In order to access these functions, the user must include castor/linalg.hpp. Two levels of interface are available. The high-level interface provides functions with simplified arguments while the low-level interface is much closer to the BLAS/LAPACK API.

The user will find here high-level linear algebra functions. Some examples of use may also be found at Linear algebra.

inv

template<typename T>
matrix<T> castor::inv(matrix<T> const &A)

Matrix inverse.

inv(X) is the inverse of the square matrix X. A warning message is printed if X is badly scaled or nearly singular.

matrix<> A = rand(3,3);
matrix<> X = inv(A);
disp(mtimes(X,A));

See linsolve, pinv, gmres.

linsolve

matrix<std::complex<double>> castor::linsolve(matrix<std::complex<double>> const &A, matrix<std::complex<double>> const &B)
matrix<double> castor::linsolve(matrix<double> const &A, matrix<double> const &B)
matrix<std::complex<float>> castor::linsolve(matrix<std::complex<float>> const &A, matrix<std::complex<float>> const &B)
matrix<float> castor::linsolve(matrix<float> const &A, matrix<float> const &B)

linsolve Solve linear system A*X=B.

X = linsolve(A,B) solves the linear system A*X=B using LU factorization with partial pivoting when A is square, and QR factorization with column pivoting otherwise. linsolve warns if A is ill conditioned (for square matrices) or rank deficient (for rectangular matrices).

matrix<> A = rand(3,3);
matrix<> B = eye(3,3);
matrix<> X = linsolve(A,B);
disp(mtimes(X,A));

See inv, pinv, gmres.

pinv

template<typename T>
matrix<T> castor::pinv(matrix<T> const &A)

Pseudoinverse.

X = pinv(A) produces a matrix X of the same dimensions as A’ so that A*X*A = A, X*A*X = X and A*X and X*A are Hermitian. The computation is based on QR factorization of A.

matrix<> A = rand(4,3);
matrix<> X = pinv(A);
disp(mtimes(X,A));

See inv, pinv.