Mercurial > octave
annotate libinterp/corefcn/filter.cc @ 23581:c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
* ov.h (is_complex_type): Use OCTAVE_DEPRECATED macro around function.
* ov.h (iscomplex): New function.
* __ichol__.cc, __ilu__.cc, balance.cc, bsxfun.cc, cellfun.cc, conv2.cc,
daspk.cc, dasrt.cc, dassl.cc, data.cc, det.cc, dot.cc, fft.cc, fft2.cc,
fftn.cc, filter.cc, find.cc, givens.cc, graphics.cc, gsvd.cc, hess.cc,
hex2num.cc, inv.cc, kron.cc, lookup.cc, ls-mat-ascii.cc, ls-mat4.cc,
ls-mat5.cc, lsode.cc, lu.cc, matrix_type.cc, mex.cc, mgorth.cc, ordschur.cc,
pinv.cc, psi.cc, quad.cc, qz.cc, rcond.cc, schur.cc, sparse-xpow.cc, sparse.cc,
sqrtm.cc, svd.cc, sylvester.cc, symtab.cc, typecast.cc, variables.cc, xnorm.cc,
__eigs__.cc, amd.cc, ccolamd.cc, chol.cc, colamd.cc, qr.cc, symbfact.cc,
ov-base.h, ov-complex.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h,
ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, jit-typeinfo.cc,
pt-tm-const.cc: Replace instances of is_complex_type with iscomplex.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 12 Jun 2017 21:18:23 -0700 |
parents | 80c42f4cca13 |
children | 80e3bfb7bd5a |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
10 (at your option) any later version. |
2928 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
15 GNU General Public License for more details. |
2928 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 // Based on Tony Richardson's filter.m. | |
24 // | |
5428 | 25 // Originally translated to C++ by KH (Kurt.Hornik@wu-wien.ac.at) |
2928 | 26 // with help from Fritz Leisch and Andreas Weingessel on Oct 20, 1994. |
27 // | |
28 // Rewritten to use templates to handle both real and complex cases by | |
29 // jwe, Wed Nov 1 19:15:29 1995. | |
30 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21697
diff
changeset
|
31 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
32 # include "config.h" |
2928 | 33 #endif |
34 | |
4153 | 35 #include "quit.h" |
36 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14854
diff
changeset
|
37 #include "defun.h" |
2928 | 38 #include "error.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
39 #include "ovl.h" |
2928 | 40 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20997
diff
changeset
|
41 template <typename T> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
42 MArray<T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
43 filter (MArray<T>& b, MArray<T>& a, MArray<T>& x, MArray<T>& si, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
44 int dim = 0) |
2928 | 45 { |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
46 MArray<T> y; |
2928 | 47 |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
48 octave_idx_type a_len = a.numel (); |
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
49 octave_idx_type b_len = b.numel (); |
2928 | 50 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
51 octave_idx_type ab_len = (a_len > b_len ? a_len : b_len); |
2928 | 52 |
12637
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
53 // FIXME: The two lines below should be unecessary because |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
54 // this template is called with a and b as column vectors |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
55 // already. However the a.resize line is currently (2011/04/26) |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
56 // necessary to stop bug #33164. |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
57 b.resize (dim_vector (ab_len, 1), 0.0); |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
58 if (a_len > 1) |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
59 a.resize (dim_vector (ab_len, 1), 0.0); |
d02798e9eeae
filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents:
12566
diff
changeset
|
60 |
2928 | 61 T norm = a (0); |
62 | |
19739
3fa35defe495
Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
63 if (norm == static_cast<T> (0.0)) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
64 error ("filter: the first element of A must be nonzero"); |
2928 | 65 |
4844 | 66 dim_vector x_dims = x.dims (); |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
67 if (dim < 0 || dim > x_dims.ndims ()) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
68 error ("filter: DIM must be a valid dimension"); |
4844 | 69 |
5275 | 70 octave_idx_type x_len = x_dims(dim); |
4844 | 71 |
72 dim_vector si_dims = si.dims (); | |
5275 | 73 octave_idx_type si_len = si_dims(0); |
4844 | 74 |
75 if (si_len != ab_len - 1) | |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
76 error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1"); |
4844 | 77 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
78 if (si_dims.ndims () != x_dims.ndims ()) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
79 error ("filter: dimensionality of SI and X must agree"); |
4844 | 80 |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
81 for (octave_idx_type i = 1; i < dim; i++) |
4844 | 82 { |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
83 if (si_dims(i) != x_dims(i-1)) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
84 error ("filter: dimensionality of SI and X must agree"); |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
85 } |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
86 for (octave_idx_type i = dim+1; i < x_dims.ndims (); i++) |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
87 { |
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
88 if (si_dims(i) != x_dims(i)) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
89 error ("filter: dimensionality of SI and X must agree"); |
4844 | 90 } |
2928 | 91 |
10241
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
92 if (x_len == 0) |
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
93 return x; |
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
94 |
19739
3fa35defe495
Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
95 if (norm != static_cast<T> (1.0)) |
4844 | 96 { |
20230
e914b5399c67
Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
97 a /= norm; |
e914b5399c67
Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
98 b /= norm; |
4844 | 99 } |
2928 | 100 |
5056 | 101 if (a_len <= 1 && si_len <= 0) |
4844 | 102 return b(0) * x; |
103 | |
104 y.resize (x_dims, 0.0); | |
105 | |
21697
e7f641616581
Make filter work with 64-bit octave_idx_type (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21660
diff
changeset
|
106 octave_idx_type x_stride = 1; |
4844 | 107 for (int i = 0; i < dim; i++) |
108 x_stride *= x_dims(i); | |
2928 | 109 |
5275 | 110 octave_idx_type x_num = x_dims.numel () / x_len; |
111 for (octave_idx_type num = 0; num < x_num; num++) | |
4844 | 112 { |
5275 | 113 octave_idx_type x_offset; |
4844 | 114 if (x_stride == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
115 x_offset = num * x_len; |
4844 | 116 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
117 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
118 octave_idx_type x_offset2 = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
119 x_offset = num; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
120 while (x_offset >= x_stride) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
121 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
122 x_offset -= x_stride; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
123 x_offset2++; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
124 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
125 x_offset += x_offset2 * x_stride * x_len; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
126 } |
5275 | 127 octave_idx_type si_offset = num * si_len; |
2928 | 128 |
4844 | 129 if (a_len > 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
130 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
131 T *py = y.fortran_vec (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
132 T *psi = si.fortran_vec (); |
5114 | 133 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
134 const T *pa = a.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
135 const T *pb = b.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
136 const T *px = x.data (); |
5114 | 137 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
138 psi += si_offset; |
5114 | 139 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 for (octave_idx_type i = 0, idx = x_offset; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 i < x_len; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
142 i++, idx += x_stride) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
143 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
144 py[idx] = psi[0] + pb[0] * px[idx]; |
5114 | 145 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
146 if (si_len > 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
147 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
148 for (octave_idx_type j = 0; j < si_len - 1; j++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
149 { |
22860
0b1e25cc4457
eliminate use of OCTAVE_QUIT macro in C++ sources
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
150 octave_quit (); |
5114 | 151 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
152 psi[j] = psi[j+1] - pa[j+1] * py[idx] + pb[j+1] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
153 } |
5114 | 154 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
155 psi[si_len-1] = pb[si_len] * px[idx] - pa[si_len] * py[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
156 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
157 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
158 { |
22860
0b1e25cc4457
eliminate use of OCTAVE_QUIT macro in C++ sources
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
159 octave_quit (); |
5114 | 160 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
161 psi[0] = pb[si_len] * px[idx] - pa[si_len] * py[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
162 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
163 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
164 } |
5114 | 165 else if (si_len > 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
166 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
167 T *py = y.fortran_vec (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
168 T *psi = si.fortran_vec (); |
5114 | 169 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
170 const T *pb = b.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
171 const T *px = x.data (); |
5114 | 172 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
173 psi += si_offset; |
5114 | 174 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 for (octave_idx_type i = 0, idx = x_offset; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
176 i < x_len; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
177 i++, idx += x_stride) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
178 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
179 py[idx] = psi[0] + pb[0] * px[idx]; |
4844 | 180 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
181 if (si_len > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
182 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
183 for (octave_idx_type j = 0; j < si_len - 1; j++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
184 { |
22860
0b1e25cc4457
eliminate use of OCTAVE_QUIT macro in C++ sources
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
185 octave_quit (); |
4153 | 186 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
187 psi[j] = psi[j+1] + pb[j+1] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
188 } |
4844 | 189 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
190 psi[si_len-1] = pb[si_len] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
191 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
192 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
193 { |
22860
0b1e25cc4457
eliminate use of OCTAVE_QUIT macro in C++ sources
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
194 octave_quit (); |
4844 | 195 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
196 psi[0] = pb[1] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
197 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
198 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
199 } |
2928 | 200 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
201 |
2928 | 202 return y; |
203 } | |
204 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20997
diff
changeset
|
205 template <typename T> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
206 MArray<T> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
207 filter (MArray<T>& b, MArray<T>& a, MArray<T>& x, int dim = -1) |
2928 | 208 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14842
diff
changeset
|
209 dim_vector x_dims = x.dims (); |
4844 | 210 |
211 if (dim < 0) | |
20997
d03babf77549
filter.cc: Use first_non_singleton() rather than handrolled code.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
212 dim = x_dims.first_non_singleton (); |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
213 else if (dim > x_dims.ndims ()) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
214 error ("filter: DIM must be a valid dimension"); |
4844 | 215 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
216 octave_idx_type a_len = a.numel (); |
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
217 octave_idx_type b_len = b.numel (); |
2928 | 218 |
5275 | 219 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
4844 | 220 dim_vector si_dims = x.dims (); |
221 for (int i = dim; i > 0; i--) | |
5059 | 222 si_dims(i) = si_dims(i-1); |
223 si_dims(0) = si_len; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
224 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
225 MArray<T> si (si_dims, T (0.0)); |
2928 | 226 |
4844 | 227 return filter (b, a, x, si, dim); |
2928 | 228 } |
229 | |
20915
a3359fe50966
remove unused nargout variables
John W. Eaton <jwe@octave.org>
parents:
20909
diff
changeset
|
230 DEFUN (filter, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
231 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
232 @deftypefn {} {@var{y} =} filter (@var{b}, @var{a}, @var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
233 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
234 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, [], @var{dim}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
235 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}, @var{dim}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
236 Apply a 1-D digital filter to the data @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
237 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
238 @code{filter} returns the solution to the following linear, time-invariant |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
239 difference equation: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
240 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
241 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
242 \sum_{k=0}^N a_{k+1} y_{n-k} = \sum_{k=0}^M b_{k+1} x_{n-k}, \qquad |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
243 1 \le n \le P |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
244 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
245 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
246 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
247 @c Set example in small font to prevent overfull line |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
248 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
249 @smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
250 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
251 N M |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
252 SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
253 k=0 k=0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
254 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
255 @end smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
256 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
257 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
258 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
259 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
260 where |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
261 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
262 N=length(a)-1 and M=length(b)-1. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
263 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
264 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
265 $a \in \Re^{N-1}$, $b \in \Re^{M-1}$, and $x \in \Re^P$. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
266 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
267 The result is calculated over the first non-singleton dimension of @var{x} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
268 or over @var{dim} if supplied. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
269 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
270 An equivalent form of the equation is: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
271 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
272 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
273 y_n = -\sum_{k=1}^N c_{k+1} y_{n-k} + \sum_{k=0}^M d_{k+1} x_{n-k}, \qquad |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
274 1 \le n \le P |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
275 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
276 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
277 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
278 @c Set example in small font to prevent overfull line |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
279 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
280 @smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
281 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
282 N M |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
283 y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
284 k=1 k=0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
285 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
286 @end smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
287 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
288 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
289 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
290 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
291 where |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
292 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
293 c = a/a(1) and d = b/a(1). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
294 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
295 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
296 $c = a/a_1$ and $d = b/a_1$. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
297 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
298 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
299 If the fourth argument @var{si} is provided, it is taken as the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
300 initial state of the system and the final state is returned as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
301 @var{sf}. The state vector is a column vector whose length is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
302 equal to the length of the longest coefficient vector minus one. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
303 If @var{si} is not supplied, the initial state vector is set to all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
304 zeros. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
305 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
306 In terms of the Z Transform, @var{y} is the result of passing the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
307 discrete-time signal @var{x} through a system characterized by the following |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
308 rational system function: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
309 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
310 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
311 H(z) = {\displaystyle\sum_{k=0}^M d_{k+1} z^{-k} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
312 \over 1 + \displaystyle\sum_{k+1}^N c_{k+1} z^{-k}} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
313 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
314 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
315 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
316 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
317 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
318 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
319 M |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
320 SUM d(k+1) z^(-k) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
321 k=0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
322 H(z) = --------------------- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
323 N |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
324 1 + SUM c(k+1) z^(-k) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
325 k=1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
326 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
327 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
328 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
329 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
330 @seealso{filter2, fftfilt, freqz} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
331 @end deftypefn */) |
2928 | 332 { |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20802
diff
changeset
|
333 int nargin = args.length (); |
2928 | 334 |
4844 | 335 if (nargin < 3 || nargin > 5) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
336 print_usage (); |
2928 | 337 |
4844 | 338 int dim; |
339 dim_vector x_dims = args(2).dims (); | |
2928 | 340 |
4844 | 341 if (nargin == 5) |
342 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14842
diff
changeset
|
343 dim = args(4).nint_value () - 1; |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
344 if (dim < 0 || dim >= x_dims.ndims ()) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
345 error ("filter: DIM must be a valid dimension"); |
4844 | 346 } |
347 else | |
20997
d03babf77549
filter.cc: Use first_non_singleton() rather than handrolled code.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
348 dim = x_dims.first_non_singleton (); |
2928 | 349 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
350 octave_value_list retval; |
20892 | 351 |
20997
d03babf77549
filter.cc: Use first_non_singleton() rather than handrolled code.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
352 const char *a_b_errmsg = "filter: A and B must be vectors"; |
d03babf77549
filter.cc: Use first_non_singleton() rather than handrolled code.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
353 const char *x_si_errmsg = "filter: X and SI must be arrays"; |
d03babf77549
filter.cc: Use first_non_singleton() rather than handrolled code.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
354 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
355 bool isfloat = (args(0).is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
356 || args(1).is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
357 || args(2).is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
358 || (nargin >= 4 && args(3).is_single_type ())); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
359 |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
360 if (args(0).iscomplex () |
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
361 || args(1).iscomplex () |
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
362 || args(2).iscomplex () |
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
363 || (nargin >= 4 && args(3).iscomplex ())) |
2928 | 364 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
365 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
366 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
367 FloatComplexColumnVector b = args(0).xfloat_complex_vector_value (a_b_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
368 FloatComplexColumnVector a = args(1).xfloat_complex_vector_value (a_b_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
369 FloatComplexNDArray x = args(2).xfloat_complex_array_value (x_si_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
370 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
371 FloatComplexNDArray si; |
3088 | 372 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
373 if (nargin == 3 || args(3).isempty ()) |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
374 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
375 octave_idx_type a_len = a.numel (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
376 octave_idx_type b_len = b.numel (); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
377 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
378 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
379 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
380 dim_vector si_dims = x.dims (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
381 for (int i = dim; i > 0; i--) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
382 si_dims(i) = si_dims(i-1); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
383 si_dims(0) = si_len; |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
384 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
385 si.resize (si_dims, 0.0); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
386 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
387 else |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
388 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
389 si = args(3).xfloat_complex_array_value (x_si_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
390 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
391 if (si.is_vector () && x.is_vector ()) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
392 si = si.reshape (dim_vector (si.numel (), 1)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
393 } |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
394 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
395 FloatComplexNDArray y (filter (b, a, x, si, dim)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
396 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
397 retval = ovl (y, si); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
398 } |
2928 | 399 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
400 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
401 ComplexColumnVector b = args(0).xcomplex_vector_value (a_b_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
402 ComplexColumnVector a = args(1).xcomplex_vector_value (a_b_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
403 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
404 ComplexNDArray x = args(2).xcomplex_array_value (x_si_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
405 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
406 ComplexNDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
407 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
408 if (nargin == 3 || args(3).isempty ()) |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
409 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
410 octave_idx_type a_len = a.numel (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
411 octave_idx_type b_len = b.numel (); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
412 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
413 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
414 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
415 dim_vector si_dims = x.dims (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
416 for (int i = dim; i > 0; i--) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
417 si_dims(i) = si_dims(i-1); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
418 si_dims(0) = si_len; |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
419 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
420 si.resize (si_dims, 0.0); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
421 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
422 else |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
423 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
424 si = args(3).xcomplex_array_value (x_si_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
425 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
426 if (si.is_vector () && x.is_vector ()) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
427 si = si.reshape (dim_vector (si.numel (), 1)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
428 } |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
429 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
430 ComplexNDArray y (filter (b, a, x, si, dim)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
431 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
432 retval = ovl (y, si); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
433 } |
2928 | 434 } |
435 else | |
436 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
437 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
438 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
439 FloatColumnVector b = args(0).xfloat_vector_value (a_b_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
440 FloatColumnVector a = args(1).xfloat_vector_value (a_b_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
441 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
442 FloatNDArray x = args(2).xfloat_array_value (x_si_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
443 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
444 FloatNDArray si; |
3088 | 445 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
446 if (nargin == 3 || args(3).isempty ()) |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
447 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
448 octave_idx_type a_len = a.numel (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
449 octave_idx_type b_len = b.numel (); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
450 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
451 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
452 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
453 dim_vector si_dims = x.dims (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
454 for (int i = dim; i > 0; i--) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
455 si_dims(i) = si_dims(i-1); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
456 si_dims(0) = si_len; |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
457 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
458 si.resize (si_dims, 0.0); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
459 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
460 else |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
461 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
462 si = args(3).xfloat_array_value (x_si_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
463 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
464 if (si.is_vector () && x.is_vector ()) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
465 si = si.reshape (dim_vector (si.numel (), 1)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
466 } |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
467 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
468 FloatNDArray y (filter (b, a, x, si, dim)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
469 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
470 retval = ovl (y, si); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
471 } |
2928 | 472 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
473 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
474 ColumnVector b = args(0).xvector_value (a_b_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
475 ColumnVector a = args(1).xvector_value (a_b_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
476 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
477 NDArray x = args(2).xarray_value (x_si_errmsg); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
478 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
479 NDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
480 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
481 if (nargin == 3 || args(3).isempty ()) |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
482 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
483 octave_idx_type a_len = a.numel (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
484 octave_idx_type b_len = b.numel (); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
485 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
486 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
487 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
488 dim_vector si_dims = x.dims (); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
489 for (int i = dim; i > 0; i--) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
490 si_dims(i) = si_dims(i-1); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
491 si_dims(0) = si_len; |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
492 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
493 si.resize (si_dims, 0.0); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
494 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
495 else |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
496 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
497 si = args(3).xarray_value (x_si_errmsg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
498 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
499 if (si.is_vector () && x.is_vector ()) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
500 si = si.reshape (dim_vector (si.numel (), 1)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
501 } |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
502 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
503 NDArray y (filter (b, a, x, si, dim)); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
504 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
505 retval = ovl (y, si); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
506 } |
2928 | 507 } |
508 | |
509 return retval; | |
510 } | |
511 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
512 template MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
513 filter (MArray<double>&, MArray<double>&, MArray<double>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
514 MArray<double>&, int dim); |
2928 | 515 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
516 template MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
517 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim); |
2928 | 518 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
519 template MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
520 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
521 MArray<Complex>&, int dim); |
2928 | 522 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
523 template MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
524 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, int dim); |
2928 | 525 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
526 template MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
527 filter (MArray<float>&, MArray<float>&, MArray<float>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
528 MArray<float>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
529 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
530 template MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
531 filter (MArray<float>&, MArray<float>&, MArray<float>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
532 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
533 template MArray<FloatComplex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
534 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
535 MArray<FloatComplex>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
536 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
537 template MArray<FloatComplex> |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
538 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
539 int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
540 |
2928 | 541 /* |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
542 %!shared a, b, x, r |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
543 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
544 %! a = [1 1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
545 %! b = [1 1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
546 %! x = zeros (1,10); x(1) = 1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
547 %! assert (filter (b, [1], x ), [1 1 0 0 0 0 0 0 0 0]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
548 %! assert (filter (b, [1], x.'), [1 1 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
549 %! assert (filter (b.', [1], x ), [1 1 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
550 %! assert (filter (b.', [1], x.'), [1 1 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
551 %! assert (filter ([1], a, x ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
552 %! assert (filter ([1], a, x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
553 %! assert (filter ([1], a.', x ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
554 %! assert (filter ([1], a.', x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
555 %! assert (filter (b, a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
556 %! assert (filter (b.', a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
557 %! assert (filter (b, a.', x ), [1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
558 %! assert (filter (b.', a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
559 %! assert (filter (b, a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
560 %! assert (filter (b.', a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
561 %! assert (filter (b, a.', x.'), [1 0 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
562 %! assert (filter (b.', a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
563 |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
564 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
565 %! r = sqrt (1/2) * (1+i); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
566 %! a = a*r; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
567 %! b = b*r; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
568 %! assert (filter (b, [1], x ), r*[1 1 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
569 %! assert (filter (b, [1], r*x ), r*r*[1 1 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
570 %! assert (filter (b, [1], x.' ), r*[1 1 0 0 0 0 0 0 0 0].' ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
571 %! assert (filter (b, a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
572 %! assert (filter (b, a, r*x ), r*[1 0 0 0 0 0 0 0 0 0] ); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
573 |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
574 %!shared a, b, x, y, so |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
575 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
576 %! a = [1,1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
577 %! b = [1,1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
578 %! x = zeros (1,10); x(1) = 1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
579 %! [y, so] = filter (b, [1], x, [-1]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
580 %! assert (y, [0 1 0 0 0 0 0 0 0 0]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
581 %! assert (so, 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
582 |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
583 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
584 %! x = zeros (10,3); x(1,1) = -1; x(1,2) = 1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
585 %! y0 = zeros (10,3); y0(1:2,1) = -1; y0(1:2,2) = 1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
586 %! y = filter (b, [1], x); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
587 %! assert (y, y0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
588 |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
589 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
590 %! a = [1,1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
591 %! b=[1,1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
592 %! x = zeros (4,4,2); x(1,1:4,1) = +1; x(1,1:4,2) = -1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
593 %! y0 = zeros (4,4,2); y0(1:2,1:4,1) = +1; y0(1:2,1:4,2) = -1; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
594 %! y = filter (b, [1], x); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
595 %! assert (y, y0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
596 |
14854
5ae9f0f77635
maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
597 %!assert (filter (1, ones (10,1) / 10, []), []) |
5ae9f0f77635
maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
598 %!assert (filter (1, ones (10,1) / 10, zeros (0,10)), zeros (0,10)) |
5ae9f0f77635
maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
599 %!assert (filter (1, ones (10,1) / 10, single (1:5)), repmat (single (10), 1, 5)) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
600 |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
601 ## Test using initial conditions |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
602 %!assert (filter ([1, 1, 1], [1, 1], [1 2], [1, 1]), [2 2]) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
603 %!assert (filter ([1, 1, 1], [1, 1], [1 2], [1, 1]'), [2 2]) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
604 %!assert (filter ([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18]) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
605 %!error (filter ([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]')) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
606 %!assert (filter ([1, 3, 2], [1], [1 2; 3 4; 5 6], [1 0 0; 1 0 0], 2), [2 6; 3 13; 5 21]) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
607 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
608 ## Test of DIM parameter |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
609 %!test |
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
610 %! x = ones (2, 1, 3, 4); |
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
611 %! x(1,1,:,:) = [1 2 3 4; 5 6 7 8; 9 10 11 12]; |
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
612 %! y0 = [1 1 6 2 15 3 2 1 8 2 18 3 3 1 10 2 21 3 4 1 12 2 24 3]; |
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
613 %! y0 = reshape (y0, size (x)); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
614 %! y = filter ([1 1 1], 1, x, [], 3); |
12774
ec6c52496485
Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents:
12707
diff
changeset
|
615 %! assert (y, y0); |
10155
d0ce5e973937
DLD-FUNCTIONS/*.cc: delete Emacs local-variables settings
John W. Eaton <jwe@octave.org>
parents:
10154
diff
changeset
|
616 */ |