MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
linearalgebrautilsmodule Module Reference

Functions/Subroutines

pure real(dp) function, dimension(:, :), allocatable, public eye (n)
pure real(dp) function, dimension(size(a), size(b)), public outer_product (a, b)
real(dp) function, dimension(3), public cross_product (a, b)
subroutine, public solve_tridiagonal (n, tl, td, tu, b, x, w)
 Solve a tridiagonal system with the Thomas algorithm.

Function/Subroutine Documentation

◆ cross_product()

real(dp) function, dimension(3), public linearalgebrautilsmodule::cross_product ( real(dp), dimension(3), intent(in) a,
real(dp), dimension(3), intent(in) b )

Definition at line 40 of file LinearAlgebraUtils.f90.

41 ! -- return
42 real(DP), dimension(3) :: c
43 ! -- dummy
44 real(DP), dimension(3), intent(in) :: a
45 real(DP), dimension(3), intent(in) :: b
46
47 c(1) = a(2) * b(3) - a(3) * b(2)
48 c(2) = a(3) * b(1) - a(1) * b(3)
49 c(3) = a(1) * b(2) - a(2) * b(1)

◆ eye()

pure real(dp) function, dimension(:, :), allocatable, public linearalgebrautilsmodule::eye ( integer(i4b), intent(in) n)

Definition at line 12 of file LinearAlgebraUtils.f90.

13 ! -- dummy
14 integer(I4B), intent(in) :: n
15 real(DP), dimension(:, :), allocatable :: A
16 ! -- locals
17 integer(I4B) :: i
18
19 allocate (a(n, n))
20 a = 0.0_dp
21 do i = 1, n
22 a(i, i) = 1.0_dp
23 end do
Here is the caller graph for this function:

◆ outer_product()

pure real(dp) function, dimension(size(a), size(b)), public linearalgebrautilsmodule::outer_product ( real(dp), dimension(:), intent(in) a,
real(dp), dimension(:), intent(in) b )

Definition at line 26 of file LinearAlgebraUtils.f90.

27 ! -- dummy
28 real(DP), intent(in) :: A(:), B(:)
29 real(DP) :: AB(size(A), size(B))
30 ! -- locals
31 integer :: nA, nB
32
33 na = size(a)
34 nb = size(b)
35
36 ab = spread(source=a, dim=2, ncopies=nb) * &
37 spread(source=b, dim=1, ncopies=na)
Here is the caller graph for this function:

◆ solve_tridiagonal()

subroutine, public linearalgebrautilsmodule::solve_tridiagonal ( integer(i4b), intent(in) n,
real(dp), dimension(n), intent(in) tl,
real(dp), dimension(n), intent(in) td,
real(dp), dimension(n), intent(in) tu,
real(dp), dimension(n), intent(in) b,
real(dp), dimension(n), intent(inout) x,
real(dp), dimension(n), intent(inout) w )
Parameters
[in]nnumber of matrix rows
[in]tllower matrix terms
[in]tddiagonal matrix terms
[in]tuupper matrix terms
[in]bright-hand side vector
[in,out]xsolution vector
[in,out]wwork vector

Definition at line 54 of file LinearAlgebraUtils.f90.

55 ! -- dummy variables
56 integer(I4B), intent(in) :: n !< number of matrix rows
57 real(DP), dimension(n), intent(in) :: tl !< lower matrix terms
58 real(DP), dimension(n), intent(in) :: td !< diagonal matrix terms
59 real(DP), dimension(n), intent(in) :: tu !< upper matrix terms
60 real(DP), dimension(n), intent(in) :: b !< right-hand side vector
61 real(DP), dimension(n), intent(inout) :: x !< solution vector
62 real(DP), dimension(n), intent(inout) :: w !< work vector
63 ! -- local variables
64 integer(I4B) :: j
65 real(DP) :: bet
66 real(DP) :: beti
67 !
68 ! -- initialize variables
69 w(1) = dzero
70 bet = td(1)
71 beti = done / bet
72 x(1) = b(1) * beti
73 !
74 ! -- decomposition and forward substitution
75 do j = 2, n
76 w(j) = tu(j - 1) * beti
77 bet = td(j) - tl(j) * w(j)
78 beti = done / bet
79 x(j) = (b(j) - tl(j) * x(j - 1)) * beti
80 end do
81 !
82 ! -- backsubstitution
83 do j = n - 1, 1, -1
84 x(j) = x(j) - w(j + 1) * x(j + 1)
85 end do