GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
sdot3.f
Go to the documentation of this file.
1c Copyright (C) 2009-2025 The Octave Project Developers
2c
3c See the file COPYRIGHT.md in the top-level directory of this
4c distribution or <https://octave.org/copyright/>.
5c
6c This file is part of Octave.
7c
8c Octave is free software: you can redistribute it and/or modify it
9c under the terms of the GNU General Public License as published by
10c the Free Software Foundation, either version 3 of the License, or
11c (at your option) any later version.
12c
13c Octave is distributed in the hope that it will be useful, but
14c WITHOUT ANY WARRANTY; without even the implied warranty of
15c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16c GNU General Public License for more details.
17c
18c You should have received a copy of the GNU General Public License
19c along with Octave; see the file COPYING. If not, see
20c <https://www.gnu.org/licenses/>.
21c
22 subroutine sdot3(m,n,k,a,b,c)
23c purpose: a 3-dimensional dot product.
24c c = sum (a .* b, 2), where a and b are 3d arrays.
25c arguments:
26c m,n,k (in) the dimensions of a and b
27c a,b (in) real input arrays of size (m,k,n)
28c c (out) real output array, size (m,n)
29 integer m,n,k,i,j,l
30 real a(m,k,n),b(m,k,n)
31 real c(m,n)
32
33 real sdot
34 external sdot
35
36c quick return if possible.
37 if (m <= 0 .or. n <= 0) return
38
39 if (m == 1) then
40c the column-major case.
41 do j = 1,n
42 c(1,j) = sdot(k,a(1,1,j),1,b(1,1,j),1)
43 end do
44 else
45c We prefer performance here, because that's what we generally
46c do by default in reduction functions. Besides, the accuracy
47c of xDOT is questionable. Hence, do a cache-aligned nested loop.
48 do j = 1,n
49 do i = 1,m
50 c(i,j) = 0d0
51 end do
52 do l = 1,k
53 do i = 1,m
54 c(i,j) = c(i,j) + a(i,l,j)*b(i,l,j)
55 end do
56 end do
57 end do
58 end if
59
60 end subroutine
subroutine sdot3(m, n, k, a, b, c)
Definition sdot3.f:23