GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
cruft
blas-xtra
ddot3.f
Go to the documentation of this file.
1
c Copyright (C) 2009-2013 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
8
c it 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 This program is distributed in the hope that it will be useful,
13
c but 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 this software; see the file COPYING. If not, see
19
c <http://www.gnu.org/licenses/>.
20
c
21
subroutine
ddot3
(m,n,k,a,b,c)
22
c purpose: a 3-dimensional dot product.
23
c c = sum (a .* b, 2), where a and b are 3d arrays.
24
c arguments:
25
c m,n,k (in) the dimensions of a and b
26
c a,b (in) double prec. input arrays of size (m,k,n)
27
c c (out) double prec. output array, size (m,n)
28
integer
m,n,k,i,j,l
29
double precision
a(m,k,n),b(m,k,n)
30
double precision
c(m,n)
31
32
double precision
ddot
33
external
ddot
34
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) = ddot(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) = 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
Generated on Mon Dec 30 2013 03:04:45 for GNU Octave by
1.8.1.2