openGPMP
Open Source Mathematics Package
mtx_routines.f90
Go to the documentation of this file.
1 !/*************************************************************************
2 ! *
3 ! * Project
4 ! * _____ _____ __ __ _____
5 ! * / ____| __ \| \/ | __ \
6 ! * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7 ! * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8 ! *| (_) | |_) | __/ | | | |__| | | | | | | |
9 ! * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10 ! * | |
11 ! * |_|
12 ! *
13 ! * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14 ! *
15 ! * This software is licensed as described in the file LICENSE, which
16 ! * you should have received as part of this distribution. The terms
17 ! * among other details are referenced in the official documentation
18 ! * seen here : https://akielaries.github.io/openGPMP/ along with
19 ! * important files seen in this project.
20 ! *
21 ! * You may opt to use, copy, modify, merge, publish, distribute
22 ! * and/or sell copies of the Software, and permit persons to whom
23 ! * the Software is furnished to do so, under the terms of the
24 ! * LICENSE file. As this is an Open Source effort, all implementations
25 ! * must be of the same methodology.
26 ! *
27 ! *
28 ! *
29 ! * This software is distributed on an AS IS basis, WITHOUT
30 ! * WARRANTY OF ANY KIND, either express or implied.
31 ! *
32 ! ************************************************************************/
33 ! mtx_routines.f90
34 
41 SUBROUTINE mtx_add_routine_float_(A, B, C, mtx_size) bind(C)
42  USE :: iso_fortran_env
43  USE :: iso_c_binding
44 
45  INTEGER, INTENT(IN) :: mtx_size
46  REAL(KIND=c_float), DIMENSION(mtx_size, mtx_size), INTENT(IN) :: a, b
47  REAL(KIND=c_float), DIMENSION(mtx_size, mtx_size), INTENT(OUT) :: c
48 
49  c = a + b
50 END SUBROUTINE mtx_add_routine_float_
51 
58 SUBROUTINE mtx_add_routine_int_(A, B, C, mtx_size) bind(C)
59  USE :: iso_fortran_env
60  USE :: iso_c_binding
61 
62  INTEGER, INTENT(IN) :: mtx_size
63  INTEGER(C_INT), DIMENSION(mtx_size, mtx_size), INTENT(IN) :: A, B
64  INTEGER(C_INT), DIMENSION(mtx_size, mtx_size), INTENT(OUT) :: C
65 
66  c = a + b
67 END SUBROUTINE mtx_add_routine_int_
68 
77 SUBROUTINE mtx_mult_routine_int_(A, B, C, rows_a, cols_a, cols_b) bind(C)
78  USE :: iso_fortran_env
79  USE :: iso_c_binding
80  IMPLICIT NONE
81 
82  INTEGER(KIND=C_INT), INTENT(IN) :: rows_a, cols_a, cols_b
83  INTEGER(KIND=C_INT), DIMENSION(rows_a, cols_a), INTENT(IN) :: A
84  INTEGER(KIND=C_INT), DIMENSION(cols_a, cols_b), INTENT(IN) :: B
85  INTEGER(KIND=C_INT), DIMENSION(rows_a, cols_b), INTENT(OUT) :: C
86 
87  INTEGER :: i, j, k
88 
89  ! Perform matrix multiplication flipping indexing to keep standard with
90  ! C/C++ calls
91  DO i = 1, rows_a
92  DO j = 1, cols_b
93 
94  c(j, i) = 0
95  DO k = 1, cols_a
96 
97  c(j, i) = c(j, i) + a(k, i)*b(j, k)
98 
99  END DO
100 
101  END DO
102  END DO
103 
104 END SUBROUTINE mtx_mult_routine_int_
105 
subroutine mtx_add_routine_float_(A, B, C, mtx_size)
FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type float32....
subroutine mtx_mult_routine_int_(A, B, C, rows_a, cols_a, cols_b)
FORTRAN Subroutine for Matrix Multiplication using Fortran intrinsics. Contains C++ wrapper function.
subroutine mtx_add_routine_int_(A, B, C, mtx_size)
FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type int32....