outerprod Function

public pure function outerprod(a, b) result(c)

Implements the outer product of two vectors, c(i, j) = a(i) * b(j)

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a(:)

First vector

real(kind=wp), intent(in) :: b(:)

Second vector

Return Value real(kind=wp), (size(a),size(b))

Outer product matrix


Source Code

pure function outerprod(a, b) result(c)

   !> First vector
   real(wp), intent(in) :: a(:)

   !> Second vector
   real(wp), intent(in) :: b(:)

   !> Outer product matrix
   real(wp) :: c(size(a), size(b))

   integer :: i, j

   do j = 1, size(b)
      do i = 1, size(a)
         c(i, j) = a(i) * b(j)
      end do
   end do

end function outerprod