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