GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
dmatm3.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 dmatm3(m,n,k,np,a,b,c)
23c purpose: a 3-dimensional matrix product.
24c given a (m,k,np) array a and (k,n,np) array b,
25c calculates a (m,n,np) array c such that
26c for i = 1:np
27c c(:,:,i) = a(:,:,i) * b(:,:,i)
28c
29c arguments:
30c m,n,k (in) the dimensions
31c np (in) number of multiplications
32c a (in) a double prec. input array, size (m,k,np)
33c b (in) a double prec. input array, size (k,n,np)
34c c (out) a double prec. output array, size (m,n,np)
35 integer m,n,k,np
36 double precision a(m*k,np),b(k*n,np)
37 double precision c(m*n,np)
38
39 double precision ddot,one,zero
40 parameter(one = 1d0, zero = 0d0)
41 external ddot,dgemv,dgemm
42 integer i
43
44c quick return if possible.
45 if (np <= 0) return
46
47 if (m == 1) then
48 if (n == 1) then
49 do i = 1,np
50 c(1,i) = ddot(k,a(1,i),1,b(1,i),1)
51 end do
52 else
53 do i = 1,np
54 call dgemv("T",k,n,one,b(1,i),k,a(1,i),1,zero,c(1,i),1)
55 end do
56 end if
57 else
58 if (n == 1) then
59 do i = 1,np
60 call dgemv("N",m,k,one,a(1,i),m,b(1,i),1,zero,c(1,i),1)
61 end do
62 else
63 do i = 1,np
64 call dgemm("N","N",m,n,k,
65 + one,a(1,i),m,b(1,i),k,zero,c(1,i),m)
66 end do
67 end if
68 end if
69
70 end subroutine
subroutine dmatm3(m, n, k, np, a, b, c)
Definition dmatm3.f:23