GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
zmatm3.f
Go to the documentation of this file.
1 c Copyright (C) 2009-2018 VZLU Prague, a.s., Czech Republic
2 c
3 c Author: Jaroslav Hajek <highegg@gmail.com>
4 c
5 c This file is part of Octave.
6 c
7 c Octave is free software: you can redistribute it and/or modify it
8 c under the terms of the GNU General Public License as published by
9 c the Free Software Foundation, either version 3 of the License, or
10 c (at your option) any later version.
11 c
12 c Octave is distributed in the hope that it will be useful, but
13 c WITHOUT ANY WARRANTY; without even the implied warranty of
14 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 c GNU General Public License for more details.
16 c
17 c You should have received a copy of the GNU General Public License
18 c along with Octave; see the file COPYING. If not, see
19 c <https://www.gnu.org/licenses/>.
20 c
21  subroutine zmatm3(m,n,k,np,a,b,c)
22 c purpose: a 3-dimensional matrix product.
23 c given a (m,k,np) array a and (k,n,np) array b,
24 c calculates a (m,n,np) array c such that
25 c for i = 1:np
26 c c(:,:,i) = a(:,:,i) * b(:,:,i)
27 c
28 c arguments:
29 c m,n,k (in) the dimensions
30 c np (in) number of multiplications
31 c a (in) a double complex input array, size (m,k,np)
32 c b (in) a double complex input array, size (k,n,np)
33 c c (out) a double complex output array, size (m,n,np)
34  integer m,n,k,np
35  double complex a(m*k,np),b(k*n,np)
36  double complex c(m*n,np)
37 
38  double complex zdotu,one,zero
39  parameter(one = 1d0, zero = 0d0)
40  external zdotu,zgemv,zgemm
41  integer i
42 
43 c quick return if possible.
44  if (np <= 0) return
45 
46  if (m == 1) then
47  if (n == 1) then
48  do i = 1,np
49  c(1,i) = zdotu(k,a(1,i),1,b(1,i),1)
50  end do
51  else
52  do i = 1,np
53  call zgemv("T",k,n,one,b(1,i),k,a(1,i),1,zero,c(1,i),1)
54  end do
55  end if
56  else
57  if (n == 1) then
58  do i = 1,np
59  call zgemv("N",m,k,one,a(1,i),m,b(1,i),1,zero,c(1,i),1)
60  end do
61  else
62  do i = 1,np
63  call zgemm("N","N",m,n,k,
64  + one,a(1,i),m,b(1,i),k,zero,c(1,i),m)
65  end do
66  end if
67  end if
68 
69  end subroutine
subroutine zmatm3(m, n, k, np, a, b, c)
Definition: zmatm3.f:22