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