openGPMP
Open Source Mathematics Package
Functions/Subroutines
vector_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 float. Contains C++ wrapper function. More...
 
subroutine mtx_add_routine_int_ (A, B, C, mtx_size)
 
subroutine mtx_mult (matrix1, matrix2, result, nrows1, ncols1, ncols2)
 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 float. 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 vector_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 
)

Definition at line 52 of file vector_routines.f90.

53  USE :: iso_fortran_env
54  USE :: iso_c_binding
55 
56  INTEGER, INTENT(IN) :: mtx_size
57  INTEGER(C_INT), DIMENSION(mtx_size, mtx_size), INTENT(IN) :: A, B
58  INTEGER(C_INT), DIMENSION(mtx_size, mtx_size), INTENT(OUT) :: C
59 
60  c = a + b

◆ mtx_mult()

subroutine mtx_mult ( real, dimension(nrows1, ncols1), intent(in)  matrix1,
real, dimension(ncols1, ncols2), intent(in)  matrix2,
real, dimension(nrows1, ncols2), intent(out)  result,
integer, intent(in)  nrows1,
integer, intent(in)  ncols1,
integer, intent(in)  ncols2 
)

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 sum of a + b
nrows_aNumber of rows
ncolsNumber of columns

Definition at line 70 of file vector_routines.f90.

71  implicit none
72  INTEGER, INTENT(IN) :: nrows1, ncols1, ncols2
73  REAL, INTENT(IN) :: matrix1(nrows1, ncols1), matrix2(ncols1, ncols2)
74  REAL, INTENT(OUT) :: result(nrows1, ncols2)
75  INTEGER :: i, j, k
76 
77  ! Perform matrix multiplication
78  do i = 1, nrows1
79  do j = 1, ncols2
80  result(i, j) = 0.0
81  do k = 1, ncols1
82  result(i, j) = result(i, j) + matrix1(i, k)*matrix2(k, j)
83  end do
84  end do
85  end do