openGPMP
Open Source Mathematics Package
Functions/Subroutines
mtx_routines.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine mtx_add_routine_float_ (A, B, C, mtx_size)
 FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type float32. Contains C++ wrapper function. More...
 
subroutine mtx_add_routine_int_ (A, B, C, mtx_size)
 FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type int32. Contains C++ wrapper function. More...
 
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. More...
 

Function/Subroutine Documentation

◆ mtx_add_routine_float_()

subroutine mtx_add_routine_float_ ( real(kind=c_float), dimension(mtx_size, mtx_size), intent(in)  A,
real(kind=c_float), dimension(mtx_size, mtx_size), intent(in)  B,
real(kind=c_float), dimension(mtx_size, mtx_size), intent(out)  C,
integer, intent(in)  mtx_size 
)

FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type float32. Contains C++ wrapper function.

Parameters
AAddend A, an array representing a Matrix
BAddend B, an array representing a Matrix
CSum C, an array representing the sum of A + B
mtx_sizeAssumes same size M x N

Definition at line 41 of file mtx_routines.f90.

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

◆ mtx_add_routine_int_()

subroutine mtx_add_routine_int_ ( integer(c_int), dimension(mtx_size, mtx_size), intent(in)  A,
integer(c_int), dimension(mtx_size, mtx_size), intent(in)  B,
integer(c_int), dimension(mtx_size, mtx_size), intent(out)  C,
integer, intent(in)  mtx_size 
)

FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type int32. Contains C++ wrapper function.

Parameters
AAddend A, an array representing a Matrix
BAddend B, an array representing a Matrix
CSum C, an array representing the sum of A + B
mtx_sizeAssumes same size M x N

Definition at line 58 of file mtx_routines.f90.

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

◆ mtx_mult_routine_int_()

subroutine mtx_mult_routine_int_ ( integer(kind=c_int), dimension(rows_a, cols_a), intent(in)  A,
integer(kind=c_int), dimension(cols_a, cols_b), intent(in)  B,
integer(kind=c_int), dimension(rows_a, cols_b), intent(out)  C,
integer(kind=c_int), intent(in)  rows_a,
integer(kind=c_int), intent(in)  cols_a,
integer(kind=c_int), intent(in)  cols_b 
)

FORTRAN Subroutine for Matrix Multiplication using Fortran intrinsics. Contains C++ wrapper function.

Parameters
AMultiplier A, an array representing a Matrix
BMultiplicand B, an array representing a Matrix
CProduct C, an array representing the produce Matrix
rows_aNumber of rows Matrix A
cols_aNumber of columns Matrix A
cols_bNumber of columns Matrix B

Definition at line 77 of file mtx_routines.f90.

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