Created
March 15, 2018 11:32
-
-
Save jenssss/31fb98973b192c785ca76b5b785fd857 to your computer and use it in GitHub Desktop.
Function for calculating the outer product of two vectors in fortran
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function outer_product(A,B) result(AB) | |
double precision, intent(in) :: A(:),B(:) | |
double precision, allocatable :: AB(:,:) | |
integer :: nA,nB | |
nA=size(A) | |
nB=size(B) | |
allocate(AB(nA,nB)) | |
AB = spread(source = A, dim = 2, ncopies = nB) * & | |
spread(source = B, dim = 1, ncopies = nA) | |
end function outer_product |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment