linalg  1.5.0
A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines.
linalg_c_binding Module Reference

linalg_c_binding More...

Functions/Subroutines

subroutine mtx_mult_c (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c)
 Performs the matrix operation: C = alpha * op(A) * op(B) + beta * C. More...
 
subroutine cmtx_mult_c (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c)
 Performs the matrix operation: C = alpha * op(A) * op(B) + beta * C. More...
 
subroutine diag_mtx_mult_left_c (m, n, k, alpha, a, b, beta, c)
 Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix. More...
 
subroutine disg_mtx_mult_right_c (m, n, k, alpha, a, b, beta, c)
 Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix. More...
 
subroutine diag_mtx_mult_cmplx_left_c (m, n, k, alpha, a, b, beta, c)
 Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix. More...
 
subroutine diag_mtx_mult_cmplx_right_c (m, n, k, alpha, a, b, beta, c)
 Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix. More...
 
subroutine diag_cmtx_mult_left_c (m, n, k, alpha, a, b, beta, c)
 Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix. More...
 
subroutine diag_cmtx_mult_right_c (m, n, k, alpha, a, b, beta, c)
 Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix. More...
 
subroutine rank1_update_c (m, n, alpha, x, y, a)
 Performs the rank-1 update to matrix A such that: A = alpha * X * Y**T + A, where A is an M-by-N matrix, alpha is a scalar, X is an M-element array, and N is an N-element array. More...
 
pure real(real64) function trace_c (m, n, x)
 Computes the trace of a matrix (the sum of the main diagonal elements). More...
 
integer(int32) function mtx_rank_c (m, n, a, err)
 Computes the rank of a matrix. More...
 
real(real64) function det_c (n, a, err)
 Computes the determinant of a square matrix. More...
 
subroutine swap_c (n, x, y)
 Swaps the contents of two arrays. More...
 
subroutine tri_mtx_mult_c (upper, n, alpha, a, beta, b, err)
 
subroutine lu_factor_c (m, n, a, ipvt, err)
 Computes the LU factorization of an M-by-N matrix. More...
 
subroutine form_lu_c (n, lu, ipvt, u, p)
 Extracts the L, U, and P matrices from the output of the lu_factor routine. More...
 
subroutine qr_factor_c (m, n, a, tau, err)
 Computes the QR factorization of an M-by-N matrix without pivoting. More...
 
subroutine qr_factor_pivot_c (m, n, a, tau, jpvt, err)
 Computes the QR factorization of an M-by-N matrix with column pivoting such that A * P = Q * R. More...
 
subroutine form_qr_c (m, n, r, tau, q, err)
 Forms the full M-by-M orthogonal matrix Q from the elementary reflectors returned by the base QR factorization algorithm. More...
 
subroutine form_qr_pivot_c (m, n, r, tau, pvt, q, p, err)
 Forms the full M-by-M orthogonal matrix Q from the elementary reflectors returned by the base QR factorization algorithm. More...
 
subroutine mult_qr_c (trans, m, n, q, tau, c, err)
 Multiplies a general matrix by the orthogonal matrix Q from a QR factorization such that: C = op(Q) * C. More...
 
subroutine qr_rank1_update_c (m, n, q, r, u, v, err)
 Computes the rank 1 update to an M-by-N QR factored matrix A (M >= N) where A = Q * R, and A1 = A + U * V**T such that A1 = Q1 * R1. More...
 
subroutine cholesky_factor_c (n, a, upper, err)
 Computes the Cholesky factorization of a symmetric, positive definite matrix. More...
 
subroutine cholesky_rank1_update_c (n, r, u, err)
 Computes the rank 1 update to a Cholesky factored matrix (upper triangular). More...
 
subroutine cholesky_rank1_downdate_c (n, r, u, err)
 Computes the rank 1 downdate to a Cholesky factored matrix (upper triangular). More...
 
subroutine rz_factor_c (m, n, a, tau, err)
 Factors an upper trapezoidal matrix by means of orthogonal transformations such that A = R * Z = (R 0) * Z. Z is an orthogonal matrix of dimension N-by-N, and R is an M-by-M upper triangular matrix. More...
 
subroutine mult_rz_c (trans, m, n, l, a, tau, c, err)
 Multiplies a general matrix by the orthogonal matrix Z from an RZ factorization such that: C = op(Z) * C. More...
 
subroutine svd_c (m, n, a, s, u, vt, err)
 Computes the singular value decomposition of a matrix A. The SVD is defined as: A = U * S * V**T, where U is an M-by-M orthogonal matrix, S is an M-by-N diagonal matrix, and V is an N-by-N orthogonal matrix. More...
 
subroutine solve_tri_mtx_c (upper, trans, nounit, n, nrhs, alpha, a, b)
 Solves one of the matrix equations: op(A) * X = alpha * B, where A is a triangular matrix. More...
 
subroutine solve_lu_c (n, nrhs, a, ipvt, b)
 Solves a system of LU-factored equations. More...
 
subroutine solve_qr_c (m, n, nrhs, a, tau, b, err)
 Solves a system of M QR-factored equations of N unknowns where M >= N. More...
 
subroutine solve_qr_pivot_c (m, n, nrhs, a, tau, jpvt, b, err)
 Solves a system of M QR-factored equations of N unknowns where the QR factorization made use of column pivoting. More...
 
subroutine solve_cholesky_c (upper, n, nrhs, a, b)
 Solves a system of Cholesky factored equations. More...
 
subroutine mtx_inverse_c (n, a, err)
 Computes the inverse of a square matrix. More...
 
subroutine mtx_pinverse_c (m, n, a, ainv, err)
 Computes the Moore-Penrose pseudo-inverse of a M-by-N matrix using the singular value decomposition of the matrix. More...
 
subroutine solve_least_squares_c (m, n, nrhs, a, b, err)
 Solves the overdetermined or underdetermined system (A*X = B) of M equations of N unknowns using a QR or LQ factorization of the matrix A. Notice, it is assumed that matrix A has full rank. More...
 
subroutine eigen_symm_c (n, vecs, a, vals, err)
 Computes the eigenvalues, and optionally the eigenvectors of a real, symmetric matrix. More...
 
subroutine eigen_asymm_c (n, a, vals, vecs, err)
 Computes the eigenvalues, and the right eigenvectors of a square matrix. More...
 
subroutine eigen_gen_c (n, a, b, alpha, beta, vecs, err)
 Computes the eigenvalues, and optionally the right eigenvectors of a square matrix assuming the structure of the eigenvalue problem is A*X = lambda*B*X. More...
 
subroutine sort_dbl_ind_c (ascend, n, x, ind)
 Sorts an array of double-precision values. More...
 
subroutine sort_cmplx_ind_c (ascend, n, x, ind)
 Sorts an array of complex values according to their real components. More...
 
subroutine sort_eigen_cmplx_c (ascend, n, vals, vecs)
 A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach. More...
 
subroutine sort_eigen_dbl_c (ascend, n, vals, vecs)
 A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach. More...
 

Detailed Description

linalg_c_binding

Purpose
Provides a C friendly interface to the LINALG library.

Function/Subroutine Documentation

subroutine linalg_c_binding::cholesky_factor_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  a,
logical(c_bool), intent(in), value  upper,
type(errorhandler), intent(inout)  err 
)

Computes the Cholesky factorization of a symmetric, positive definite matrix.

Parameters
[in]nThe dimension of the matrix.
[in,out]aOn input, the N-by-N matrix to factor. On output, the factored matrix is returned in either the upper or lower triangular portion of the matrix, dependent upon the value of upper.
[in]upperAn optional input that, if specified, provides control over whether the factorization is computed as A = U**T * U (set to true), or as A = L * L**T (set to false). The default value is true such that A = U**T * U.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_MATRIX_FORMAT_ERROR: Occurs if a is not positive definite.

Definition at line 810 of file linalg_c_binding.f90.

subroutine linalg_c_binding::cholesky_rank1_downdate_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  r,
real(real64), dimension(n), intent(inout)  u,
type(errorhandler), intent(inout)  err 
)

Computes the rank 1 downdate to a Cholesky factored matrix (upper triangular).

Parameters
[in]nThe dimension of the matrix.
[in,out]rOn input, the N-by-N upper triangular matrix R. On output, the updated matrix R1.
[in,out]uOn input, the N-element update vector U. On output, the rotation sines used to transform R to R1.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if any of the input array sizes are incorrect.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_MATRIX_FORMAT_ERROR: Occurs if the downdated matrix is not positive definite.
  • LA_SINGULAR_MATRIX_ERROR: Occurs if r is singular.

Definition at line 884 of file linalg_c_binding.f90.

subroutine linalg_c_binding::cholesky_rank1_update_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  r,
real(real64), dimension(n), intent(inout)  u,
type(errorhandler), intent(inout)  err 
)

Computes the rank 1 update to a Cholesky factored matrix (upper triangular).

Parameters
[in]nThe dimension of the matrix.
[in,out]rOn input, the N-by-N upper triangular matrix R. On output, the updated matrix R1.
[in,out]uOn input, the N-element update vector U. On output, the rotation sines used to transform R to R1.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 845 of file linalg_c_binding.f90.

subroutine linalg_c_binding::cmtx_mult_c ( logical(c_bool), intent(in), value  transa,
logical(c_bool), intent(in), value  transb,
integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
complex(real64), dimension(lda,*), intent(in)  a,
integer(int32), intent(in), value  lda,
complex(real64), dimension(ldb,*), intent(in)  b,
integer(int32), intent(in), value  ldb,
real(real64), intent(in), value  beta,
complex(real64), dimension(m,n), intent(inout)  c 
)

Performs the matrix operation: C = alpha * op(A) * op(B) + beta * C.

Parameters
[in]transaSet to true if op(A) == A**T; else, set to false if op(A) == A.
[in]transbSet to true if op(B) == B**T; else, set to false if op(B) == B.
[in]mThe number of rows in matrix C, and the number of rows in matrix op(A).
[in]nThe number of columns in matrix C, and the number of columns in matrix op(B).
[in]kThe number of columns in matrix op(A), and the number of rows in the matrix op(B).
[in]alphaThe scalar multiplier to matrix A.
[in]aThe M-by-K matrix A.
[in]ldaThe leading dimension of matrix A. If transa is true, this value must be at least MAX(1, K); else, if transa is false, this value must be at least MAX(1, M).
[in]bThe K-by-N matrix B.
[in]ldbThe leading dimension of matrix B. If transb is true, this value must be at least MAX(1, N); else, if transb is false, this value must be at least MAX(1, K).
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 92 of file linalg_c_binding.f90.

real(real64) function linalg_c_binding::det_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  a,
type(errorhandler), intent(inout)  err 
)

Computes the determinant of a square matrix.

Parameters
[in]nThe dimension of the matrix.
[in,out]aOn input, the N-by-N matrix on which to operate. On output the contents are overwritten by the LU factorization of the original matrix.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the input matrix is not square.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 370 of file linalg_c_binding.f90.

subroutine linalg_c_binding::diag_cmtx_mult_left_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
complex(real64), dimension(min(m, k)), intent(in)  a,
complex(real64), dimension(k, n), intent(in)  b,
real(real64), intent(in), value  beta,
complex(real64), dimension(m, n), intent(inout)  c 
)

Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of rows in matrix B.
[in]alphaThe scalar multiplier to matrix A.
[in]aA MIN(M,K)-element array containing the diagonal elements of matrix A.
[in]bThe K-by-N matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 236 of file linalg_c_binding.f90.

subroutine linalg_c_binding::diag_cmtx_mult_right_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
complex(real64), dimension(m, k), intent(in)  a,
complex(real64), dimension(min(k, n)), intent(in)  b,
real(real64), intent(in), value  beta,
complex(real64), dimension(m, n), intent(inout)  c 
)

Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of columns in matrix A.
[in]alphaThe scalar multiplier to matrix A.
[in]aThe M-by-K matrix A.
[in]bA MIN(K,N)-element array containing the diagonal elements of matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 261 of file linalg_c_binding.f90.

subroutine linalg_c_binding::diag_mtx_mult_cmplx_left_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
complex(real64), dimension(min(m, k)), intent(in)  a,
real(real64), dimension(k, n), intent(in)  b,
real(real64), intent(in), value  beta,
complex(real64), dimension(m, n), intent(inout)  c 
)

Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of rows in matrix B.
[in]alphaThe scalar multiplier to matrix A.
[in]aA MIN(M,K)-element array containing the diagonal elements of matrix A.
[in]bThe K-by-N matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 184 of file linalg_c_binding.f90.

subroutine linalg_c_binding::diag_mtx_mult_cmplx_right_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
real(real64), dimension(m, k), intent(in)  a,
complex(real64), dimension(min(k, n)), intent(in)  b,
real(real64), intent(in), value  beta,
complex(real64), dimension(m, n), intent(inout)  c 
)

Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of columns in matrix A.
[in]alphaThe scalar multiplier to matrix A.
[in]aThe M-by-K matrix A.
[in]bA MIN(K,N)-element array containing the diagonal elements of matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 210 of file linalg_c_binding.f90.

subroutine linalg_c_binding::diag_mtx_mult_left_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
real(real64), dimension(min(m,k)), intent(in)  a,
real(real64), dimension(k,n), intent(in)  b,
real(real64), intent(in), value  beta,
real(real64), dimension(m,n), intent(inout)  c 
)

Computes the matirx operation: C = alpha * A * B + beta * C, where A is a diagonal amtrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of rows in matrix B.
[in]alphaThe scalar multiplier to matrix A.
[in]aA MIN(M,K)-element array containing the diagonal elements of matrix A.
[in]bThe K-by-N matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 134 of file linalg_c_binding.f90.

subroutine linalg_c_binding::disg_mtx_mult_right_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
real(real64), dimension(m, k), intent(in)  a,
real(real64), dimension(min(k, n)), intent(in)  b,
real(real64), intent(in), value  beta,
real(real64), dimension(m, n), intent(inout)  c 
)

Comptues the matrix operation: C = alpha * A * B + beta * C, where B is a diagonal matrix.

Parameters
[in]mThe number of rows in matrix C.
[in]nThe number of columns in matrix C.
[in]kThe number of columns in matrix A.
[in]alphaThe scalar multiplier to matrix A.
[in]aThe M-by-K matrix A.
[in]bA MIN(K,N)-element array containing the diagonal elements of matrix B.
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 159 of file linalg_c_binding.f90.

subroutine linalg_c_binding::eigen_asymm_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  a,
complex(real64), dimension(n), intent(out)  vals,
complex(real64), dimension(n,n), intent(out)  vecs,
type(errorhandler), intent(inout)  err 
)

Computes the eigenvalues, and the right eigenvectors of a square matrix.

Parameters
[in]nThe dimension of the matrix.
[in,out]aOn input, the N-by-N matrix on which to operate. On output, the contents of this matrix are overwritten.
[out]valsAn N-element array containing the eigenvalues of the matrix on output. The eigenvalues are not sorted.
[out]vecsAn N-by-N matrix containing the right eigenvectors (one per column) on output.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs if the algorithm failed to converge.

Definition at line 1368 of file linalg_c_binding.f90.

subroutine linalg_c_binding::eigen_gen_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n, n), intent(inout)  a,
real(real64), dimension(n, n), intent(inout)  b,
complex(real64), dimension(n), intent(out)  alpha,
real(real64), dimension(n), intent(out)  beta,
complex(real64), dimension(n,n), intent(out)  vecs,
type(errorhandler), intent(inout)  err 
)

Computes the eigenvalues, and optionally the right eigenvectors of a square matrix assuming the structure of the eigenvalue problem is A*X = lambda*B*X.

Parameters
[in]nThe dimension of the matrix.
[in,out]aOn input, the N-by-N matrix A. On output, the contents of this matrix are overwritten.
[in,out]bOn input, the N-by-N matrix B. On output, the contents of this matrix are overwritten.
[out]alphaAn N-element array that, on output, contains the numerator of the eigenvalue ration ALPHA / BETA. Computation of this ratio isn't necessarily as trivial as it seems as it is entirely possible, and likely, that ALPHA / BETA can overflow or underflow. With that said, the values in ALPHA will always be less than and usually comparable with the NORM(A).
[out]betaAn N-element array that, on output, contains the denominator used to determine the eigenvalues as ALPHA / BETA. The values in this array will always be less than and usually comparable with the NORM(B).
[out]vecsAn N-by-N matrix containing the right eigenvectors (one per column) on output.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs if the algorithm failed to converge.

Definition at line 1417 of file linalg_c_binding.f90.

subroutine linalg_c_binding::eigen_symm_c ( integer(int32), intent(in), value  n,
logical(c_bool), intent(in), value  vecs,
real(real64), dimension(n,n), intent(inout)  a,
real(real64), dimension(n), intent(out)  vals,
type(errorhandler), intent(inout)  err 
)

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

Parameters
[in]nThe dimension of the matrix.
[in]vecsSet to true to compute the eigenvectors as well as the eigenvalues; else, set to false to just compute the eigenvalues.
[in,out]aOn input, the N-by-N symmetric matrix on which to operate. On output, and if vecs is set to true, the matrix will contain the eigenvectors (one per column) corresponding to each eigenvalue in vals. If vecs is set to false, the lower triangular portion of the matrix is overwritten.
[out]valsAn N-element array that will contain the eigenvalues sorted into ascending order.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs if the algorithm failed to converge.

Definition at line 1329 of file linalg_c_binding.f90.

subroutine linalg_c_binding::form_lu_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  lu,
integer(int32), dimension(n), intent(in)  ipvt,
real(real64), dimension(n,n), intent(out)  u,
real(real64), dimension(n,n), intent(out)  p 
)

Extracts the L, U, and P matrices from the output of the lu_factor routine.

Parameters
[in]nThe dimension of the original matrix.
[in,out]luOn input, the N-by-N matrix as output by lu_factor. On output, the N-by-N lower triangular matrix L.
[in]ipvtThe N-element pivot array as output by lu_factor.
[out]uAn N-by-N matrix where the U matrix will be written.
[out]pAn N-by-N matrix where the row permutation matrix will be written.
Remarks
This routine allows extraction of the actual "L", "U", and "P" matrices of the decomposition. To use these matrices to solve the system A*X = B, the following approach is used.
  1. First, solve the linear system: L*Y = P*B for Y.
  2. Second, solve the linear system: U*X = Y for X.

Notice, as both L and U are triangular in structure, the above equations can be solved by forward and backward substitution.

See Also

Definition at line 517 of file linalg_c_binding.f90.

subroutine linalg_c_binding::form_qr_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  r,
real(real64), dimension(min(m,n)), intent(in)  tau,
real(real64), dimension(m,m), intent(out)  q,
type(errorhandler), intent(inout)  err 
)

Forms the full M-by-M orthogonal matrix Q from the elementary reflectors returned by the base QR factorization algorithm.

Parameters
[in]mThe number of rows in the original matrix.
[in]nThe number of columns in the original matrix.
[in,out]rOn input, an M-by-N matrix where the elements below the diagonal contain the elementary reflectors generated from the QR factorization. On and above the diagonal, the matrix contains the matrix R. On output, the elements below the diagonal are zeroed such that the remaining matrix is simply the M-by-N matrix R.
[in]tauA MIN(M, N)-element array containing the scalar factors of each elementary reflector defined in r.
[out]qAn M-by-M matrix where the full orthogonal matrix Q will be written. In the event that M > N, Q may be supplied as M-by-N, and therefore only return the useful submatrix Q1 (Q = [Q1, Q2]) as the factorization can be written as Q * R = [Q1, Q2] * [R1; 0].
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the scalar factor array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 639 of file linalg_c_binding.f90.

subroutine linalg_c_binding::form_qr_pivot_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  r,
real(real64), dimension(min(m,n)), intent(in)  tau,
integer(int32), dimension(n), intent(in)  pvt,
real(real64), dimension(m,m), intent(out)  q,
real(real64), dimension(n,n), intent(out)  p,
type(errorhandler), intent(inout)  err 
)

Forms the full M-by-M orthogonal matrix Q from the elementary reflectors returned by the base QR factorization algorithm.

Parameters
[in]mThe number of rows in the original matrix.
[in]nThe number of columns in the original matrix.
[in,out]rOn input, an M-by-N matrix where the elements below the diagonal contain the elementary reflectors generated from the QR factorization. On and above the diagonal, the matrix contains the matrix R. On output, the elements below the diagonal are zeroed such that the remaining matrix is simply the M-by-N matrix R.
[in]tauA MIN(M, N)-element array containing the scalar factors of each elementary reflector defined in r.
[in]pvtAn N-element column pivot array as returned by the QR factorization.
[out]qAn M-by-M matrix where the full orthogonal matrix Q will be written. In the event that M > N, Q may be supplied as M-by-N, and therefore only return the useful submatrix Q1 (Q = [Q1, Q2]) as the factorization can be written as Q * R = [Q1, Q2] * [R1; 0].
[out]pAn N-by-N matrix where the pivot matrix will be written.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the scalar factor array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 688 of file linalg_c_binding.f90.

subroutine linalg_c_binding::lu_factor_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
integer(int32), dimension(min(m,n)), intent(out)  ipvt,
type(errorhandler), intent(inout)  err 
)

Computes the LU factorization of an M-by-N matrix.

Parameters
[in]mThe number of rows in the matrix.
[in]nThe number of columns in the matrix.
[in,out]aOn input, the M-by-N matrix on which to operate. On output, the LU factored matrix in the form [L\U] where the unit diagonal elements of L are not stored.
[out]ipvtAn MIN(M, N)-element array used to track row-pivot operations. The array stored pivot information such that row I is interchanged with row IPVT(I).
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the pivot array is not sized appropriately.
  • LA_SINGULAR_MATRIX_ERROR: Occurs as a warning if a is found to be singular.

Definition at line 471 of file linalg_c_binding.f90.

subroutine linalg_c_binding::mtx_inverse_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n,n), intent(inout)  a,
type(errorhandler), intent(inout)  err 
)

Computes the inverse of a square matrix.

Parameters
[in]nThe dimension of the matrix.
[in,out]aOn input, the N-by-N matrix to invert. On output, the inverted matrix.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_SINGULAR_MATRIX_ERROR: Occurs if the input matrix is singular.

Definition at line 1210 of file linalg_c_binding.f90.

subroutine linalg_c_binding::mtx_mult_c ( logical(c_bool), intent(in), value  transa,
logical(c_bool), intent(in), value  transb,
integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  k,
real(real64), intent(in), value  alpha,
real(real64), dimension(lda,*), intent(in)  a,
integer(int32), intent(in), value  lda,
real(real64), dimension(ldb,*), intent(in)  b,
integer(int32), intent(in), value  ldb,
real(real64), intent(in), value  beta,
real(real64), dimension(m,n), intent(inout)  c 
)

Performs the matrix operation: C = alpha * op(A) * op(B) + beta * C.

Parameters
[in]transaSet to true if op(A) == A**T; else, set to false if op(A) == A.
[in]transbSet to true if op(B) == B**T; else, set to false if op(B) == B.
[in]mThe number of rows in matrix C, and the number of rows in matrix op(A).
[in]nThe number of columns in matrix C, and the number of columns in matrix op(B).
[in]kThe number of columns in matrix op(A), and the number of rows in the matrix op(B).
[in]alphaThe scalar multiplier to matrix A.
[in]aThe M-by-K matrix A.
[in]ldaThe leading dimension of matrix A. If transa is true, this value must be at least MAX(1, K); else, if transa is false, this value must be at least MAX(1, M).
[in]bThe K-by-N matrix B.
[in]ldbThe leading dimension of matrix B. If transb is true, this value must be at least MAX(1, N); else, if transb is false, this value must be at least MAX(1, K).
[in]betaThe scalar multiplier to matrix C.
[in,out]cThe M-by-N matrix C.

Definition at line 43 of file linalg_c_binding.f90.

subroutine linalg_c_binding::mtx_pinverse_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(n,m), intent(out)  ainv,
type(errorhandler), intent(inout)  err 
)

Computes the Moore-Penrose pseudo-inverse of a M-by-N matrix using the singular value decomposition of the matrix.

Parameters
[in]mThe number of rows in the matrix to invert.
[in]nThe number of columns in the matrix to invert.
[in,out]aOn input, the M-by-N matrix to invert. The matrix is overwritten on output.
[out]ainvThe N-by-M matrix where the pseudo-inverse of a will be written.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs as a warning if the QR iteration process could not converge to a zero value.

Definition at line 1247 of file linalg_c_binding.f90.

integer(int32) function linalg_c_binding::mtx_rank_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
type(errorhandler), intent(inout)  err 
)

Computes the rank of a matrix.

Parameters
[in]mThe number of rows in the matrix.
[in]nThe number of columns in the matrix.
[in,out]aOn input, the M-by-N matrix of interest. On output, the contents of the matrix are overwritten.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if any of the input arrays are not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs as a warning if the QR iteration process could not converge to a zero value.

Definition at line 337 of file linalg_c_binding.f90.

subroutine linalg_c_binding::mult_qr_c ( logical(c_bool), intent(in), value  trans,
integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,m), intent(inout)  q,
real(real64), dimension(min(m,n)), intent(in)  tau,
real(real64), dimension(m,n), intent(inout)  c,
type(errorhandler), intent(inout)  err 
)

Multiplies a general matrix by the orthogonal matrix Q from a QR factorization such that: C = op(Q) * C.

Parameters
[in]transSet to true to apply Q**T; else, set to false.
[in]mThe number of rows in the matrix c.
[in]nThe number of columns in the matrix c.
[in]qOn input, an M-by-M matrix containing the elementary reflectors output from the QR factorization. Notice, the contents of this matrix are restored on exit. that the remaining matrix is simply the M-by-N matrix R.
[in]tauA MIN(M,N)-element array containing the scalar factors of each elementary reflector defined in a.
[in,out]cOn input, the M-by-N matrix C. On output, the product of the orthogonal matrix Q and the original matrix C.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the scalar factor array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 733 of file linalg_c_binding.f90.

subroutine linalg_c_binding::mult_rz_c ( logical(c_bool), intent(in), value  trans,
integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  l,
real(real64), dimension(m,m), intent(inout)  a,
real(real64), dimension(m), intent(in)  tau,
real(real64), dimension(m,n), intent(inout)  c,
type(errorhandler), intent(inout)  err 
)

Multiplies a general matrix by the orthogonal matrix Z from an RZ factorization such that: C = op(Z) * C.

Parameters
[in]transSet to true to apply Z**T; else, set to false.
[in]mThe number of rows in the matrix c.
[in]nThe number of columns in the matrix c.
[in]lThe number of columns in matrix a containing the meaningful part of the Householder vectors (M >= L >= 0).
[in,out]aOn input, the M-by-M matrix Z as output by rz_factor. The matrix is used as in-place storage during execution; however, the contents of the matrix are restored on exit.
[in]tauAn M-element array containing the scalar factors of the elementary reflectors found in a.
[in,out]cOn input, the M-by-N matrix C. On output, the product of the orthogonal matrix Z and the original matrix C.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 965 of file linalg_c_binding.f90.

subroutine linalg_c_binding::qr_factor_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(min(m,n)), intent(out)  tau,
type(errorhandler), intent(inout)  err 
)

Computes the QR factorization of an M-by-N matrix without pivoting.

Parameters
[in]mThe number of rows in the matrix.
[in]nThe number of columns in the matrix.
[in,out]aOn input, the M-by-N matrix to factor. On output, the elements on and above the diagonal contain the MIN(M, N)-by-N upper trapezoidal matrix R (R is upper triangular if M >= N). The elements below the diagonal, along with the array tau, represent the orthogonal matrix Q as a product of elementary reflectors.
[out]tauA MIN(M, N)-element array used to store the scalar factors of the elementary reflectors.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the scalar factor array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 549 of file linalg_c_binding.f90.

subroutine linalg_c_binding::qr_factor_pivot_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(min(m,n)), intent(out)  tau,
integer(int32), dimension(n), intent(inout)  jpvt,
type(errorhandler), intent(inout)  err 
)

Computes the QR factorization of an M-by-N matrix with column pivoting such that A * P = Q * R.

Parameters
[in]mThe number of rows in the matrix.
[in]nThe number of columns in the matrix.
[in,out]aOn input, the M-by-N matrix to factor. On output, the elements on and above the diagonal contain the MIN(M, N)-by-N upper trapezoidal matrix R (R is upper triangular if M >= N). The elements below the diagonal, along with the array tau, represent the orthogonal matrix Q as a product of elementary reflectors.
[out]tauA MIN(M, N)-element array used to store the scalar factors of the elementary reflectors.
[in,out]jpvtOn input, an N-element array that if JPVT(I) .ne. 0, the I-th column of A is permuted to the front of A * P; if JPVT(I) = 0, the I-th column of A is a free column. On output, if JPVT(I) = K, then the I-th column of A * P was the K-th column of A.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the scalar factor array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 594 of file linalg_c_binding.f90.

subroutine linalg_c_binding::qr_rank1_update_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,m), intent(inout)  q,
real(real64), dimension(m,n), intent(inout)  r,
real(real64), dimension(m), intent(inout)  u,
real(real64), dimension(n), intent(inout)  v,
type(errorhandler), intent(inout)  err 
)

Computes the rank 1 update to an M-by-N QR factored matrix A (M >= N) where A = Q * R, and A1 = A + U * V**T such that A1 = Q1 * R1.

Parameters
[in]mThe number of rows in the original matrix.
[in]nThe number of columns in the original matrix.
[in,out]qOn input, the original M-by-M orthogonal matrix Q. On output, the updated matrix Q1.
[in,out]rOn input, the M-by-N matrix R. On output, the updated matrix R1.
[in,out]uOn input, the M-element U update vector. On output, the original content of the array is overwritten.
[in,out]vOn input, the N-element V update vector. On output, the original content of the array is overwritten.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 774 of file linalg_c_binding.f90.

subroutine linalg_c_binding::rank1_update_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), intent(in), value  alpha,
real(real64), dimension(m), intent(in)  x,
real(real64), dimension(n), intent(in)  y,
real(real64), dimension(m,n), intent(inout)  a 
)

Performs the rank-1 update to matrix A such that: A = alpha * X * Y**T + A, where A is an M-by-N matrix, alpha is a scalar, X is an M-element array, and N is an N-element array.

Parameters
[in]mThe number of elements in x, and the number of rows in matrix a.
[in]nThe number of elements in y, and the number of columns in matrix a.
[in]alphaThe scalar multiplier.
[in]xAn M-element array.
[in]yAn N-element array.
[in,out]aOn input, the M-by-N matrix to update. On output, the updated M-by-N matrix.
Notes
This routine is based upon the BLAS routine DGER.

Definition at line 290 of file linalg_c_binding.f90.

subroutine linalg_c_binding::rz_factor_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(m), intent(out)  tau,
type(errorhandler), intent(inout)  err 
)

Factors an upper trapezoidal matrix by means of orthogonal transformations such that A = R * Z = (R 0) * Z. Z is an orthogonal matrix of dimension N-by-N, and R is an M-by-M upper triangular matrix.

Parameters
[in]mThe number of rows in the original matrix.
[in]nThe number of columns in the original matrix.
[in,out]aOn input, the M-by-N upper trapezoidal matrix to factor. On output, the leading M-by-M upper triangular part of the matrix contains the upper triangular matrix R, and elements N-L+1 to N of the first M rows of A, with the array tau, represent the orthogonal matrix Z as a product of M elementary reflectors.
[out]tauAn M-element array used to store the scalar factors of the elementary reflectors.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 923 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_cholesky_c ( logical(c_bool), intent(in), value  upper,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), dimension(n,n), intent(in)  a,
real(real64), dimension(n,nrhs), intent(inout)  b 
)

Solves a system of Cholesky factored equations.

Parameters
[in]upperSet to true if the original matrix A was factored such that A = U**T * U; else, set to false if the factorization of A was A = L**T * L.
[in]nThe dimension of the original matrix a.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in]aThe N-by-N Cholesky factored matrix.
[in,out]bOn input, the N-by-NRHS right-hand-side matrix B. On output, the solution matrix X.

Definition at line 1186 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_least_squares_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), dimension(m, n), intent(inout)  a,
real(real64), dimension(max(m,n), nrhs), intent(inout)  b,
type(errorhandler), intent(inout)  err 
)

Solves the overdetermined or underdetermined system (A*X = B) of M equations of N unknowns using a QR or LQ factorization of the matrix A. Notice, it is assumed that matrix A has full rank.

Parameters
[in]mThe number of rows in the original coefficient matrix A.
[in]nThe number of columns in the original coefficient matrix A.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in,out]aOn input, the M-by-N matrix A. On output, the matrix is overwritten by the details of its complete orthogonal factorization.
[in,out]bIf M >= N, the M-by-NRHS matrix B. On output, the first N rows contain the N-by-NRHS solution matrix X. If M < N, an N-by-NRHS matrix with the first M rows containing the matrix B. On output, the N-by-NRHS solution matrix X.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 1288 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_lu_c ( integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), dimension(n,n), intent(in)  a,
integer(int32), dimension(n), intent(in)  ipvt,
real(real64), dimension(n,nrhs), intent(inout)  b 
)

Solves a system of LU-factored equations.

Parameters
[in]nThe dimension of the original matrix a.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in]aThe N-by-N LU factored matrix as output by lu_factor.
[in]ipvtThe N-element pivot array as output by lu_factor.
[in,out]bOn input, the N-by-NRHS right-hand-side matrix. On output, the N-by-NRHS solution matrix.

Definition at line 1075 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_qr_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(min(m,n)), intent(in)  tau,
real(real64), dimension(m,nrhs), intent(inout)  b,
type(errorhandler), intent(inout)  err 
)

Solves a system of M QR-factored equations of N unknowns where M >= N.

Parameters
[in]mThe number of rows in the original coefficient matrix A.
[in]nThe number of columns in the original coefficient matrix A.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in]aOn input, the M-by-N QR factored matrix as returned by qr_factor. On output, the contents of this matrix are restored. Notice, M must be greater than or equal to N.
[in]tauA MIN(M, N)-element array containing the scalar factors of the elementary reflectors as returned by qr_factor.
[in]bOn input, the M-by-NRHS right-hand-side matrix. On output, the first N columns are overwritten by the solution matrix X.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 1108 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_qr_pivot_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(min(m,n)), intent(in)  tau,
integer(int32), dimension(n), intent(in)  jpvt,
real(real64), dimension(max(m,n),nrhs), intent(inout)  b,
type(errorhandler), intent(inout)  err 
)

Solves a system of M QR-factored equations of N unknowns where the QR factorization made use of column pivoting.

Parameters
[in]mThe number of rows in the original coefficient matrix A.
[in]nThe number of columns in the original coefficient matrix A.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in]aOn input, the M-by-N QR factored matrix as returned by qr_factor. On output, the contents of this matrix are altered.
[in]tauA MIN(M, N)-element array containing the scalar factors of the elementary reflectors as returned by qr_factor.
[in]jpvtAn N-element array, as output by qr_factor, used to track the column pivots.
[in]bOn input, the MAX(M, N)-by-NRHS matrix where the first M rows contain the right-hand-side matrix B. On output, the first N rows are overwritten by the solution matrix X.
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if any of the input arrays are not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.

Definition at line 1153 of file linalg_c_binding.f90.

subroutine linalg_c_binding::solve_tri_mtx_c ( logical(c_bool), intent(in), value  upper,
logical(c_bool), intent(in), value  trans,
logical(c_bool), intent(in), value  nounit,
integer(int32), intent(in), value  n,
integer(int32), intent(in), value  nrhs,
real(real64), intent(in), value  alpha,
real(real64), dimension(n,n), intent(in)  a,
real(real64), dimension(n,nrhs), intent(inout)  b 
)

Solves one of the matrix equations: op(A) * X = alpha * B, where A is a triangular matrix.

Parameters
[in]upperSet to true if A is an upper triangular matrix; else, set to false if A is a lower triangular matrix.
[in]transSet to true if op(A) = A**T; else, set to false if op(A) = A.
[in]nounitSet to true if A is not a unit-diagonal matrix (ones on every diagonal element); else, set to false if A is a unit-diagonal matrix.
[in]nThe dimension of the triangular matrix a.
[in]nrhsThe number of right-hand-side vectors (number of columns in matrix b).
[in]alphaThe scalar multiplier to B.
[in]aN-by-N triangular matrix on which to operate.
[in,out]bOn input, the N-by-NRHS right-hand-side. On output, the N-by-NRHS solution.

Definition at line 1052 of file linalg_c_binding.f90.

subroutine linalg_c_binding::sort_cmplx_ind_c ( logical(c_bool), intent(in), value  ascend,
integer(int32), intent(in), value  n,
complex(real64), dimension(n), intent(inout)  x,
type(c_ptr), intent(in), value  ind 
)

Sorts an array of complex values according to their real components.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in]nThe number of elements in the array.
[in,out]xOn input, the N-element array to sort. On output, the sorted array.
[in,out]indOn input, a pointer to an integer array. If NULL, this argument is ignored, and x is sorted as expected. However, if used, on output, the contents of this array are shifted in the same order as that of x as a means of tracking the sorting operation. It is often useful to set this array to an ascending group of values (1, 2, ... n) such that this array tracks the original positions of the sorted array. Such an array can then be used to align other arrays. This array must be the same size as x.

Definition at line 1491 of file linalg_c_binding.f90.

subroutine linalg_c_binding::sort_dbl_ind_c ( logical(c_bool), intent(in), value  ascend,
integer(int32), intent(in), value  n,
real(real64), dimension(n), intent(inout)  x,
type(c_ptr), intent(in), value  ind 
)

Sorts an array of double-precision values.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in]nThe number of elements in the array.
[in,out]xOn input, the N-element array to sort. On output, the sorted array.
[in,out]indOn input, a pointer to an integer array. If NULL, this argument is ignored, and x is sorted as expected. However, if used, on output, the contents of this array are shifted in the same order as that of x as a means of tracking the sorting operation. It is often useful to set this array to an ascending group of values (1, 2, ... n) such that this array tracks the original positions of the sorted array. Such an array can then be used to align other arrays. This array must be the same size as x.

Definition at line 1455 of file linalg_c_binding.f90.

subroutine linalg_c_binding::sort_eigen_cmplx_c ( logical(c_bool), intent(in), value  ascend,
integer(int32), intent(in), value  n,
complex(real64), dimension(n), intent(inout)  vals,
complex(real64), dimension(n,n), intent(inout)  vecs 
)

A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in]nThe number of eigenvalues.
[in,out]valsOn input, an N-element array containing the eigenvalues. On output, the sorted eigenvalues.
[in,out]vecsOn input, an N-by-N matrix containing the eigenvectors associated with vals (one vector per column). On output, the sorted eigenvector matrix.

Definition at line 1523 of file linalg_c_binding.f90.

subroutine linalg_c_binding::sort_eigen_dbl_c ( logical(c_bool), intent(in), value  ascend,
integer(int32), intent(in), value  n,
real(real64), dimension(n), intent(inout)  vals,
real(real64), dimension(n,n), intent(inout)  vecs 
)

A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in]nThe number of eigenvalues.
[in,out]valsOn input, an N-element array containing the eigenvalues. On output, the sorted eigenvalues.
[in,out]vecsOn input, an N-by-N matrix containing the eigenvectors associated with vals (one vector per column). On output, the sorted eigenvector matrix.

Definition at line 1546 of file linalg_c_binding.f90.

subroutine linalg_c_binding::svd_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(inout)  a,
real(real64), dimension(min(m,n)), intent(out)  s,
real(real64), dimension(m,m), intent(out)  u,
real(real64), dimension(n,n), intent(out)  vt,
type(errorhandler), intent(inout)  err 
)

Computes the singular value decomposition of a matrix A. The SVD is defined as: A = U * S * V**T, where U is an M-by-M orthogonal matrix, S is an M-by-N diagonal matrix, and V is an N-by-N orthogonal matrix.

Parameters
[in]mThe number of rows in the original matrix.
[in]nThe number of columns in the original matrix.
[in,out]aOn input, the M-by-N matrix to factor. The matrix is overwritten on output. that the remaining matrix is simply the M-by-N matrix R.
[out]sA MIN(M, N)-element array containing the singular values of a sorted in descending order.
[out]uAn M-by-M matrix that on output contains the left singular vectors (matrix U in the decomposition: A = U * S * V**T)
[out]vtAn N-by-N matrix that on output contains the right singular vectors (matrix V**T in the decomposition: A = U * S * V**T).
[in,out]errThe errorhandler object. If no error handling is desired, simply pass NULL, and errors will be dealt with by the default internal error handler. Possible errors that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if the singular value array is not sized appropriately.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if local memory must be allocated, and there is insufficient memory available.
  • LA_CONVERGENCE_ERROR: Occurs as a warning if the QR iteration process could not converge to a zero value.

Definition at line 1012 of file linalg_c_binding.f90.

subroutine linalg_c_binding::swap_c ( integer(int32), intent(in), value  n,
real(real64), dimension(n), intent(inout)  x,
real(real64), dimension(n), intent(inout)  y 
)

Swaps the contents of two arrays.

Parameters
[in]nThe number of elements either array.
[in,out]xOne of the N-element arrays.
[in,out]yThe other N-element array.

Definition at line 395 of file linalg_c_binding.f90.

pure real(real64) function linalg_c_binding::trace_c ( integer(int32), intent(in), value  m,
integer(int32), intent(in), value  n,
real(real64), dimension(m,n), intent(in)  x 
)

Computes the trace of a matrix (the sum of the main diagonal elements).

Parameters
[in]mThe number of rows in the matrix.
[in]nThe number of columns in the matrix.
[in]xThe matrix on which to operate.
Returns
The trace of x.

Definition at line 310 of file linalg_c_binding.f90.