annotate liboctave/numeric/oct-convn.cc @ 22323:bac0d6f07a3e

maint: Update copyright notices for 2016.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 01:05:19 -0400
parents e43d83253e28
children 4caa7b28d183
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 /*
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
3 Copyright (C) 2010-2016 VZLU Prague
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 This file is part of Octave.
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 option) any later version.
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 for more details.
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 */
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25 #endif
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 #include <iostream>
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 #include <algorithm>
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
29
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
30 #include "f77-fcn.h"
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
31
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 #include "oct-convn.h"
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 #include "oct-locbuf.h"
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 // 2d convolution with a matrix kernel.
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
36 template <typename T, typename R>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
37 static void
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 convolve_2d (const T *a, octave_idx_type ma, octave_idx_type na,
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 const R *b, octave_idx_type mb, octave_idx_type nb,
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
40 T *c, bool inner);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
42 // Forward instances to our Fortran implementations.
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
43 #define FORWARD_IMPL(T_CXX, R_CXX, T, R, T_CAST, T_CONST_CAST, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
44 R_CONST_CAST, f, F) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
45 extern "C" \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
46 F77_RET_T \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
47 F77_FUNC (f##conv2o, F##CONV2O) (const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
48 const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
49 const T*, const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
50 const F77_INT&, const R*, T *); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
51 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
52 extern "C" \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
53 F77_RET_T \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
54 F77_FUNC (f##conv2i, F##CONV2I) (const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
55 const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
56 const T*, const F77_INT&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
57 const F77_INT&, const R*, T *); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
58 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
59 template <> void \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
60 convolve_2d<T_CXX, R_CXX> (const T_CXX *a, F77_INT ma, F77_INT na, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
61 const R_CXX *b, F77_INT mb, F77_INT nb, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
62 T_CXX *c, bool inner) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
63 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
64 if (inner) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
65 F77_XFCN (f##conv2i, F##CONV2I, (ma, na, T_CONST_CAST (a), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
66 mb, nb, R_CONST_CAST (b), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
67 T_CAST (c))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
68 else \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
69 F77_XFCN (f##conv2o, F##CONV2O, (ma, na, T_CONST_CAST (a), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
70 mb, nb, R_CONST_CAST (b), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
71 T_CAST (c))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
72 }
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
74 FORWARD_IMPL (double, double, F77_DBLE, F77_DBLE, , , , d, D)
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
75 FORWARD_IMPL (float, float, F77_REAL, F77_REAL, , , , s, S)
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
76
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
77 FORWARD_IMPL (std::complex<double>, std::complex<double>,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
78 F77_DBLE_CMPLX, F77_DBLE_CMPLX, F77_DBLE_CMPLX_ARG,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
79 F77_CONST_DBLE_CMPLX_ARG, F77_CONST_DBLE_CMPLX_ARG, z, Z)
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
80 FORWARD_IMPL (std::complex<float>, std::complex<float>,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
81 F77_CMPLX, F77_CMPLX, F77_CMPLX_ARG,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
82 F77_CONST_CMPLX_ARG, F77_CONST_CMPLX_ARG, c, C)
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
83
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
84 FORWARD_IMPL (std::complex<double>, double,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
85 F77_DBLE_CMPLX, F77_DBLE, F77_DBLE_CMPLX_ARG,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
86 F77_CONST_DBLE_CMPLX_ARG, , zd, ZD)
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
87 FORWARD_IMPL (std::complex<float>, float, F77_CMPLX, F77_REAL, F77_CMPLX_ARG,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
88 F77_CONST_CMPLX_ARG, , cs, CS)
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
89
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
90 template <typename T, typename R>
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
91 void convolve_nd (const T *a, const dim_vector& ad, const dim_vector& acd,
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
92 const R *b, const dim_vector& bd, const dim_vector& bcd,
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
93 T *c, const dim_vector& ccd, int nd, bool inner)
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
94 {
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95 if (nd == 2)
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
96 convolve_2d<T, R> (a, ad(0), ad(1), b, bd(0), bd(1), c, inner);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
97 else
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
99 octave_idx_type ma = acd(nd-2);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 octave_idx_type na = ad(nd-1);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
101 octave_idx_type mb = bcd(nd-2);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
102 octave_idx_type nb = bd(nd-1);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 octave_idx_type ldc = ccd(nd-2);
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
104 if (inner)
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
105 {
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
106 for (octave_idx_type ja = 0; ja < na - nb + 1; ja++)
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
107 for (octave_idx_type jb = 0; jb < nb; jb++)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
108 convolve_nd<T, R> (a + ma*(ja+jb), ad, acd,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
109 b + mb*(nb-jb-1), bd, bcd,
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
110 c + ldc*ja, ccd, nd-1, inner);
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
111 }
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
112 else
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 {
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
114 for (octave_idx_type ja = 0; ja < na; ja++)
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
115 for (octave_idx_type jb = 0; jb < nb; jb++)
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
116 convolve_nd<T, R> (a + ma*ja, ad, acd, b + mb*jb, bd, bcd,
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
117 c + ldc*(ja+jb), ccd, nd-1, inner);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
118 }
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 }
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
120 }
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
121
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
122 // Arbitrary convolutor.
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123 // The 2nd array is assumed to be the smaller one.
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
124 template <typename T, typename R>
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125 static MArray<T>
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
126 convolve (const MArray<T>& a, const MArray<R>& b,
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
127 convn_type ct)
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
128 {
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
129 if (a.is_empty () || b.is_empty ())
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130 return MArray<T> ();
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
131
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
132 int nd = std::max (a.ndims (), b.ndims ());
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
133 const dim_vector adims = a.dims ().redim (nd);
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
134 const dim_vector bdims = b.dims ().redim (nd);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
135 dim_vector cdims = dim_vector::alloc (nd);
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
137 for (int i = 0; i < nd; i++)
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
138 {
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
139 if (ct == convn_valid)
10389
8a551f02f10d oct-convn.cc (convolve): cast int constant to octave_idx_type in call to std::max
John W. Eaton <jwe@octave.org>
parents: 10388
diff changeset
140 cdims(i) = std::max (adims(i) - bdims(i) + 1,
8a551f02f10d oct-convn.cc (convolve): cast int constant to octave_idx_type in call to std::max
John W. Eaton <jwe@octave.org>
parents: 10388
diff changeset
141 static_cast<octave_idx_type> (0));
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
142 else
10389
8a551f02f10d oct-convn.cc (convolve): cast int constant to octave_idx_type in call to std::max
John W. Eaton <jwe@octave.org>
parents: 10388
diff changeset
143 cdims(i) = std::max (adims(i) + bdims(i) - 1,
8a551f02f10d oct-convn.cc (convolve): cast int constant to octave_idx_type in call to std::max
John W. Eaton <jwe@octave.org>
parents: 10388
diff changeset
144 static_cast<octave_idx_type> (0));
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
145 }
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
146
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14209
diff changeset
147 MArray<T> c (cdims, T ());
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
148
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
149 convolve_nd<T, R> (a.fortran_vec (), adims, adims.cumulative (),
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
150 b.fortran_vec (), bdims, bdims.cumulative (),
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
151 c.fortran_vec (), cdims.cumulative (),
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
152 nd, ct == convn_valid);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
153
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
154 if (ct == convn_same)
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
155 {
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
156 // Pick the relevant part.
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
157 Array<idx_vector> sidx (dim_vector (nd, 1));
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
158
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
159 for (int i = 0; i < nd; i++)
14209
846273dae16b Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
160 sidx(i) = idx_vector::make_range (bdims(i)/2, 1, adims(i));
10388
5af0b4bb384d rewrite convn optimizations based on xAXPY
Jaroslav Hajek <highegg@gmail.com>
parents: 10385
diff changeset
161 c = c.index (sidx);
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
162 }
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
163
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
164 return c;
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
165 }
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
166
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
167 #define CONV_DEFS(TPREF, RPREF) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
168 TPREF ## NDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
169 convn (const TPREF ## NDArray& a, const RPREF ## NDArray& b, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
170 convn_type ct) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
171 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
172 return convolve (a, b, ct); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
173 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
174 TPREF ## Matrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
175 convn (const TPREF ## Matrix& a, const RPREF ## Matrix& b, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
176 convn_type ct) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
177 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
178 return convolve (a, b, ct); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
179 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
180 TPREF ## Matrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
181 convn (const TPREF ## Matrix& a, const RPREF ## ColumnVector& c, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
182 const RPREF ## RowVector& r, convn_type ct) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
183 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
184 return convolve (a, c * r, ct); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
185 }
10385
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
186
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
187 CONV_DEFS ( , )
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
188 CONV_DEFS (Complex, )
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
189 CONV_DEFS (Complex, Complex)
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
190 CONV_DEFS (Float, Float)
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
191 CONV_DEFS (FloatComplex, Float)
56116dceb1e0 add omitted source from the last change
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
192 CONV_DEFS (FloatComplex, FloatComplex)