linalg 1.8.2
A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines.
Loading...
Searching...
No Matches
linalg::solve_lu Interface Reference

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

Public Member Functions

 solve_lu_mtx
 
 solve_lu_mtx_cmplx
 
 solve_lu_vec
 
 solve_lu_vec_cmplx
 
 csr_lu_solve
 

Detailed Description

Solves a system of LU-factored equations.

Syntax
subroutine solve_lu(real(real64) a(:,:), integer(int32) ipvt(:), real(real64) b(:,:), optional class(errors) err)
subroutine solve_lu(complex(real64) a(:,:), integer(int32) ipvt(:), complex(real64) b(:,:), optional class(errors) err)
subroutine solve_lu(real(real64) a(:,:), integer(int32) ipvt(:), real(real64) b(:), optional class(errors) err)
subroutine solve_lu(complex(real64) a(:,:), integer(int32) ipvt(:), complex(real64) b(:), optional class(errors) err)
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.
[in,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.
Sparse Syntax
subroutine solve_lu(class(msr_matrix) lu, integer(int32) ju(:), real(real64) b(:), real(real64) x(:), optional class(errors) err)
Parameters
[in]luThe N-by-N LU-factored matrix from lu_factor.
[in]juThe N-element U row tracking array from lu_factor.
[in]bThe N-element right-hand-side array.
[out]xThe N-element solution array.
[in,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 dense routine is based upon the LAPACK routine DGETRS (ZGETRS in the complex case).
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
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
Computes the LU factorization of an M-by-N matrix.
Definition linalg.f90:844
Solves a system of LU-factored equations.
Definition linalg.f90:2421
Provides a set of common linear algebra routines.
Definition linalg.f90:145
The program generates the following output.
LU Solution: X =
0.3333
-0.6667
0.0000
See Also

Definition at line 2421 of file linalg.f90.


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