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

Solves a system of LU-factored equations. More...

Private Member Functions

subroutine solve_lu_mtx (a, ipvt, b, err)
 Solves a system of LU-factored equations. More...
 
subroutine solve_lu_vec (a, ipvt, b, err)
 Solves a system of LU-factored equations. More...
 

Detailed Description

Solves a system of LU-factored equations.

Usage
To solve a system of 3 equations of 3 unknowns using LU factorization, the following code will suffice.
program example
use iso_fortran_env
use linalg_factor, only : lu_factor
use linalg_solve, only : solve_lu
implicit none
! Local Variables
real(real64) :: a(3,3), b(3)
integer(int32) :: i, pvt(3)
! Build the 3-by-3 matrix A.
! | 1 2 3 |
! A = | 4 5 6 |
! | 7 8 0 |
a = reshape( &
[1.0d0, 4.0d0, 7.0d0, 2.0d0, 5.0d0, 8.0d0, 3.0d0, 6.0d0, 0.0d0], &
[3, 3])
! Build the right-hand-side vector B.
! | -1 |
! b = | -2 |
! | -3 |
b = [-1.0d0, -2.0d0, -3.0d0]
! The solution is:
! | 1/3 |
! x = | -2/3 |
! | 0 |
! Compute the LU factorization
call lu_factor(a, pvt)
! Compute the solution. The results overwrite b.
call solve_lu(a, pvt, b)
! Display the results.
print '(A)', "LU Solution: X = "
print '(F8.4)', (b(i), i = 1, size(b))
end program
The program generates the following output.
LU Solution: X =
0.3333
-0.6667
0.0000
See Also

Definition at line 155 of file linalg_solve.f90.

Member Function/Subroutine Documentation

◆ solve_lu_mtx()

subroutine linalg_solve::solve_lu::solve_lu_mtx ( real(real64), dimension(:,:), intent(in)  a,
integer(int32), dimension(:), intent(in)  ipvt,
real(real64), dimension(:,:), intent(inout)  b,
class(errors), intent(inout), optional, target  err 
)
private

Solves a system of LU-factored equations.

Parameters
[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.
[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
The routine is based upon the LAPACK routine DGETRS.

Definition at line 678 of file linalg_solve.f90.

◆ solve_lu_vec()

subroutine linalg_solve::solve_lu::solve_lu_vec ( real(real64), dimension(:,:), intent(in)  a,
integer(int32), dimension(:), intent(in)  ipvt,
real(real64), dimension(:), intent(inout)  b,
class(errors), intent(inout), optional, target  err 
)
private

Solves a system of LU-factored equations.

Parameters
[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-element right-hand-side array. On output, the N-element solution array.
[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
The routine is based upon the LAPACK routine DGETRS.

Definition at line 739 of file linalg_solve.f90.


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