aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-04-23 22:35:16 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-04-23 22:35:16 +0200
commit2157bcd5276d35f2c462d8bf711dbd392ad2d11b (patch)
tree31dcc046a5f3f88865d99c27fae21dd5e8586beb
parent67db729b18f38c51908569de269d45d00ea9bf32 (diff)
downloadfortran-assignment1-2157bcd5276d35f2c462d8bf711dbd392ad2d11b.tar.gz
fortran-assignment1-2157bcd5276d35f2c462d8bf711dbd392ad2d11b.zip
implement multiplication using dot_product
-rw-r--r--src/dotmath.F9050
1 files changed, 50 insertions, 0 deletions
diff --git a/src/dotmath.F90 b/src/dotmath.F90
index bb1725b..81f1f13 100644
--- a/src/dotmath.F90
+++ b/src/dotmath.F90
@@ -38,5 +38,55 @@ MODULE dotmat
CONTAINS
+ FUNCTION dotmull_4(A, B) result(C)
+ IMPLICIT none
+ real(kind=4), intent(in), dimension(1:,1:) :: A, B
+ real(kind=4), dimension(:,:), allocatable :: C
+ integer :: i, j
+
+ allocate(C(size(A, 1), size(B, 2)))
+
+ DO j = 1, size(B, 2)
+ DO i = 1, size(A, 1)
+
+ C(i,j) = dot_product(A(i,:), B(:,j))
+ END DO
+ END DO
+
+ END FUNCTION dotmull_4
+
+ FUNCTION dotmull_8(A, B) result(C)
+ IMPLICIT none
+ real(kind=8), intent(in), dimension(1:,1:) :: A, B
+ real(kind=8), dimension(:,:), allocatable :: C
+ integer :: i, j
+
+ allocate(C(size(A, 1), size(B, 2)))
+
+ DO j = 1, size(B, 2)
+ DO i = 1, size(A, 1)
+
+ C(i,j) = dot_product(A(i,:), B(:,j))
+ END DO
+ END DO
+
+ END FUNCTION dotmull_8
+ FUNCTION dotmull_16(A, B) result(C)
+ IMPLICIT none
+ real(kind=16), intent(in), dimension(1:,1:) :: A, B
+ real(kind=16), dimension(:,:), allocatable :: C
+ integer :: i, j
+
+ allocate(C(size(A, 1), size(B, 2)))
+
+ DO j = 1, size(B, 2)
+ DO i = 1, size(A, 1)
+
+ C(i,j) = dot_product(A(i,:), B(:,j))
+ END DO
+ END DO
+
+ END FUNCTION dotmull_16
+
END MODULE dotmat