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

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

Private Member Functions

subroutine lu_factor_imp (a, ipvt, err)
 Computes the LU factorization of an M-by-N matrix. More...
 

Detailed Description

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

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_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
Notes
This routine utilizes the LAPACK routine DGETRF.
See Also

Definition at line 89 of file linalg_factor.f90.

Member Function/Subroutine Documentation

subroutine linalg_factor::lu_factor::lu_factor_imp ( real(dp), dimension(:,:), intent(inout)  a,
integer(i32), dimension(:), intent(out)  ipvt,
class(errors), intent(inout), optional, target  err 
)
private

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

Parameters
[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).
[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 ipvt is not sized appropriately.
  • LA_SINGULAR_MATRIX_ERROR: Occurs as a warning if a is found to be singular.

Definition at line 419 of file linalg_factor.f90.


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