openGPMP
Open Source Mathematics Package
vector_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 ! vector_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 
52 SUBROUTINE mtx_add_routine_int_(A, B, C, mtx_size) bind(C)
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
61 END SUBROUTINE mtx_add_routine_int_
62 
70 SUBROUTINE mtx_mult(matrix1, matrix2, result, nrows1, ncols1, ncols2)
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
86 END SUBROUTINE mtx_mult
87 
void mtx_mult(std::vector< double > A, std::vector< double > B, std::vector< double > C)
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_add_routine_int_(A, B, C, mtx_size)
FORTRAN Subroutine for Matrix Addition on flattened matrices as arrays of type int32....