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

Functions/Subroutines

real(dp) function, dimension(size(a, dim=2), size(a, dim=1)), public pinv (a)

Function/Subroutine Documentation

◆ pinv()

real(dp) function, dimension(size(a, dim=2), size(a, dim=1)), public pseudoinversemodule::pinv ( real(dp), dimension(:, :), intent(in) a)

Definition at line 26 of file PseudoInverse.f90.

27 ! -- dummy
28 real(DP), intent(in) :: A(:, :)
29 real(DP) :: B(SIZE(A, DIM=2), size(a, dim=1)) !! The pseudoinverse of A (size n x m, where A is m x n)
30 ! -- locals
31 integer(I4B) :: m, n
32 integer(I4B) :: pos
33 real(DP), dimension(:, :), allocatable :: U
34 real(DP), dimension(:, :), allocatable :: Vt
35 real(DP), dimension(:, :), allocatable :: Sigma
36
37 m = size(a, dim=1)
38 n = size(a, dim=2)
39
40 CALL svd(a, u, sigma, vt)
41
42 ! Transform Sigma to its Sigma^+
43 do pos = 1, min(m, n)
44 if (dabs(sigma(pos, pos)) < dprec) then
45 sigma(pos, pos) = 0.0_dp
46 else
47 sigma(pos, pos) = 1.0_dp / sigma(pos, pos)
48 end if
49 end do
50
51 b = matmul(transpose(vt), matmul(transpose(sigma), transpose(u)))
52
Here is the call graph for this function:
Here is the caller graph for this function: