linalg  1.4.3
A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines.
linalg_solve::solve_cholesky Interface Reference

Solves a system of Cholesky factored equations. More...

Private Member Functions

subroutine solve_cholesky_mtx (upper, a, b, err)
 Solves a system of Cholesky factored equations. More...
 
subroutine solve_cholesky_vec (upper, a, b, err)
 Solves a system of Cholesky factored equations. More...
 

Detailed Description

Solves a system of Cholesky factored equations.

Usage
The following example illustrates the solution of a positive-definite system of equations via Cholesky factorization.
program example
use iso_fortran_env, only : real64, int32
use linalg_factor, only : cholesky_factor
implicit none
! Variables
real(real64) :: a(3, 3), b(3), bu(3)
integer(int32) :: i
! Build the 3-by-3 positive-definite matrix A.
! | 4 12 -16 |
! A = | 12 37 -43 |
! |-16 -43 98 |
a = reshape([4.0d0, 12.0d0, -16.0d0, 12.0d0, 37.0d0, -43.0d0, -16.0d0, &
-43.0d0, 98.0d0], [3, 3])
! Build the 3-element array B
! | 5 |
! b = | 1 |
! | 3 |
b = [5.0d0, 1.0d0, 3.0d0]
! Make a copy of B for later use - not necessary, but just for example to
! illustrate the long or manual method of solving a Cholesky factored system
bu = b
! Compute the Cholesky factorization of A considering only the upper
! triangular portion of A (the default configuration).
call cholesky_factor(a)
! Compute the solution
call solve_cholesky(.true., a, b)
! Display the results
print '(A)', "Cholesky Solution: X = "
print '(F8.4)', (b(i), i = 1, size(b))
! The solution could also be computed manually noting the Cholesky
! factorization causes A = U**T * U. Then U**T * U * X = B.
! Step 1 would then be to solve the problem U**T * Y = B, for Y.
call solve_triangular_system(.true., .true., .true., a, bu)
! Now, solve the problem U * X = Y, for X
call solve_triangular_system(.true., .false., .true., a, bu)
! Display the results
print '(A)', "Cholesky Solution (Manual Approach): X = "
print '(F8.4)', (bu(i), i = 1, size(bu))
end program
The above program produces the following output.
Cholesky Solution: X =
239.5833
-65.6667
10.3333
Cholesky Solution (Manual Approach): X =
239.5833
-65.6667
10.3333

Definition at line 299 of file linalg_solve.f90.

Member Function/Subroutine Documentation

◆ solve_cholesky_mtx()

subroutine linalg_solve::solve_cholesky::solve_cholesky_mtx ( logical, intent(in)  upper,
real(real64), dimension(:,:), intent(in)  a,
real(real64), dimension(:,:), intent(inout)  b,
class(errors), intent(inout), optional, target  err 
)
private

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]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.
[out]errAn optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if any of the input array sizes are incorrect.
Notes
This routine utilizes the LAPACK routine DPOTRS.

Definition at line 1400 of file linalg_solve.f90.

◆ solve_cholesky_vec()

subroutine linalg_solve::solve_cholesky::solve_cholesky_vec ( logical, intent(in)  upper,
real(real64), dimension(:,:), intent(in)  a,
real(real64), dimension(:), intent(inout)  b,
class(errors), intent(inout), optional, target  err 
)
private

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]aThe N-by-N Cholesky factored matrix.
[in,out]bOn input, the N-element right-hand-side vector B. On output, the solution vector X.
[out]errAn optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if any of the input array sizes are incorrect.
Notes
This routine utilizes the LAPACK routine DPOTRS.

Definition at line 1466 of file linalg_solve.f90.


The documentation for this interface was generated from the following file: