MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
LinearAlgebraUtils.f90
Go to the documentation of this file.
2  use kindmodule, only: dp, i4b
3 
4  implicit none
5  private
6 
8 
9 contains
10 
11  pure function eye(n) result(A)
12  ! -- dummy
13  integer(I4B), intent(in) :: n
14  real(dp), dimension(:, :), allocatable :: a
15  ! -- locals
16  integer(I4B) :: i
17 
18  allocate (a(n, n))
19  a = 0.0_dp
20  do i = 1, n
21  a(i, i) = 1.0_dp
22  end do
23  end function eye
24 
25  pure function outer_product(A, B) result(AB)
26  ! -- dummy
27  real(dp), intent(in) :: a(:), b(:)
28  real(dp) :: ab(size(a), size(b))
29  ! -- locals
30  integer :: na, nb
31 
32  na = size(a)
33  nb = size(b)
34 
35  ab = spread(source=a, dim=2, ncopies=nb) * &
36  spread(source=b, dim=1, ncopies=na)
37  end function outer_product
38 
39  function cross_product(a, b) result(c)
40  ! -- return
41  real(dp), dimension(3) :: c
42  ! -- dummy
43  real(dp), dimension(3), intent(in) :: a
44  real(dp), dimension(3), intent(in) :: b
45 
46  c(1) = a(2) * b(3) - a(3) * b(2)
47  c(2) = a(3) * b(1) - a(1) * b(3)
48  c(3) = a(1) * b(2) - a(2) * b(1)
49  end function cross_product
50 
51 end module linearalgebrautilsmodule
This module defines variable data types.
Definition: kind.f90:8
pure real(dp) function, dimension(size(a), size(b)), public outer_product(A, B)
real(dp) function, dimension(3), public cross_product(a, b)
pure real(dp) function, dimension(:, :), allocatable, public eye(n)