Mercurial > octave-nkf
annotate src/DLD-FUNCTIONS/filter.cc @ 12566:3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Revamp test vectors.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 01 Apr 2011 18:53:14 -0700 |
parents | 7a5aacf65f81 |
children | d02798e9eeae |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 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 | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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 | |
31 #ifdef HAVE_CONFIG_H | |
32 #include <config.h> | |
33 #endif | |
34 | |
4153 | 35 #include "quit.h" |
36 | |
2928 | 37 #include "defun-dld.h" |
38 #include "error.h" | |
39 #include "oct-obj.h" | |
40 | |
3109 | 41 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
42 extern MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
43 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim); |
2928 | 44 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
45 extern MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
46 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
47 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
48 extern MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
49 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
|
50 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
51 extern MArray<FloatComplex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
52 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, int dim); |
3107 | 53 #endif |
2928 | 54 |
55 template <class T> | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
56 MArray<T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
57 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
|
58 int dim = 0) |
2928 | 59 { |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
60 MArray<T> y; |
2928 | 61 |
5275 | 62 octave_idx_type a_len = a.length (); |
63 octave_idx_type b_len = b.length (); | |
2928 | 64 |
5275 | 65 octave_idx_type ab_len = a_len > b_len ? a_len : b_len; |
2928 | 66 |
67 T norm = a (0); | |
68 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
69 if (norm == static_cast<T>(0.0)) |
2928 | 70 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 error ("filter: the first element of A must be non-zero"); |
2928 | 72 return y; |
73 } | |
74 | |
4844 | 75 dim_vector x_dims = x.dims (); |
5056 | 76 if (dim < 0 || dim > x_dims.length ()) |
4844 | 77 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
78 error ("filter: DIM must be a valid dimension"); |
4844 | 79 return y; |
80 } | |
81 | |
5275 | 82 octave_idx_type x_len = x_dims(dim); |
4844 | 83 |
84 dim_vector si_dims = si.dims (); | |
5275 | 85 octave_idx_type si_len = si_dims(0); |
4844 | 86 |
87 if (si_len != ab_len - 1) | |
88 { | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
89 error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1"); |
4844 | 90 return y; |
91 } | |
92 | |
5059 | 93 if (si_dims.length () != x_dims.length ()) |
4844 | 94 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
95 error ("filter: dimensionality of SI and X must agree"); |
4844 | 96 return y; |
97 } | |
98 | |
5275 | 99 octave_idx_type si_dim = 0; |
100 for (octave_idx_type i = 0; i < x_dims.length (); i++) | |
4844 | 101 { |
102 if (i == dim) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
103 continue; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
104 |
5055 | 105 if (x_dims(i) == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
106 continue; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
107 |
5059 | 108 if (si_dims(++si_dim) != x_dims(i)) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
109 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
110 error ("filter: dimensionality of SI and X must agree"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
111 return y; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
112 } |
4844 | 113 } |
2928 | 114 |
10241
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
115 if (x_len == 0) |
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
116 return x; |
a277ba5da4dc
filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents:
10155
diff
changeset
|
117 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
118 if (norm != static_cast<T>(1.0)) |
4844 | 119 { |
120 a = a / norm; | |
121 b = b / norm; | |
122 } | |
2928 | 123 |
5056 | 124 if (a_len <= 1 && si_len <= 0) |
4844 | 125 return b(0) * x; |
126 | |
127 y.resize (x_dims, 0.0); | |
128 | |
129 int x_stride = 1; | |
130 for (int i = 0; i < dim; i++) | |
131 x_stride *= x_dims(i); | |
2928 | 132 |
5275 | 133 octave_idx_type x_num = x_dims.numel () / x_len; |
134 for (octave_idx_type num = 0; num < x_num; num++) | |
4844 | 135 { |
5275 | 136 octave_idx_type x_offset; |
4844 | 137 if (x_stride == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
138 x_offset = num * x_len; |
4844 | 139 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
140 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
141 octave_idx_type x_offset2 = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
142 x_offset = num; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
143 while (x_offset >= x_stride) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
144 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
145 x_offset -= x_stride; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
146 x_offset2++; |
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 x_offset += x_offset2 * x_stride * x_len; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
149 } |
5275 | 150 octave_idx_type si_offset = num * si_len; |
2928 | 151 |
4844 | 152 if (a_len > 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
153 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
154 T *py = y.fortran_vec (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
155 T *psi = si.fortran_vec (); |
5114 | 156 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
157 const T *pa = a.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
158 const T *pb = b.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
159 const T *px = x.data (); |
5114 | 160 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
161 psi += si_offset; |
5114 | 162 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
163 for (octave_idx_type i = 0, idx = x_offset; i < x_len; i++, idx += x_stride) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
164 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
165 py[idx] = psi[0] + pb[0] * px[idx]; |
5114 | 166 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
167 if (si_len > 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
168 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
169 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
|
170 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
171 OCTAVE_QUIT; |
5114 | 172 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
173 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
|
174 } |
5114 | 175 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
176 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
|
177 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
178 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
179 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
180 OCTAVE_QUIT; |
5114 | 181 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
182 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
|
183 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
184 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
185 } |
5114 | 186 else if (si_len > 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
187 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
188 T *py = y.fortran_vec (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
189 T *psi = si.fortran_vec (); |
5114 | 190 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
191 const T *pb = b.data (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
192 const T *px = x.data (); |
5114 | 193 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
194 psi += si_offset; |
5114 | 195 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
196 for (octave_idx_type i = 0, idx = x_offset; i < x_len; i++, idx += x_stride) |
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 py[idx] = psi[0] + pb[0] * px[idx]; |
4844 | 199 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
200 if (si_len > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
201 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
202 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
|
203 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
204 OCTAVE_QUIT; |
4153 | 205 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
206 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
|
207 } |
4844 | 208 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
209 psi[si_len-1] = pb[si_len] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
210 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
211 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
212 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
213 OCTAVE_QUIT; |
4844 | 214 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
215 psi[0] = pb[1] * px[idx]; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
216 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
217 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
218 } |
2928 | 219 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
220 |
2928 | 221 return y; |
222 } | |
223 | |
3109 | 224 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
225 extern MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
226 filter (MArray<double>&, MArray<double>&, MArray<double>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
227 MArray<double>&, int dim); |
2928 | 228 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
229 extern MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
230 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
231 MArray<Complex>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
232 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
233 extern MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
234 filter (MArray<float>&, MArray<float>&, MArray<float>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
235 MArray<float>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
236 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
237 extern MArray<FloatComplex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
238 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
239 MArray<FloatComplex>&, int dim); |
3107 | 240 #endif |
2928 | 241 |
242 template <class T> | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
243 MArray<T> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
244 filter (MArray<T>& b, MArray<T>& a, MArray<T>& x, int dim = -1) |
2928 | 245 { |
5059 | 246 dim_vector x_dims = x.dims(); |
4844 | 247 |
248 if (dim < 0) | |
249 { | |
250 // Find first non-singleton dimension | |
5059 | 251 while (dim < x_dims.length () && x_dims(dim) <= 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
252 dim++; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
253 |
4844 | 254 // All dimensions singleton, pick first dimension |
255 if (dim == x_dims.length ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
256 dim = 0; |
4844 | 257 } |
258 else | |
259 if (dim < 0 || dim > x_dims.length ()) | |
260 { | |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
261 error ("filter: DIM must be a valid dimension"); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
262 return MArray<T> (); |
4844 | 263 } |
264 | |
5275 | 265 octave_idx_type a_len = a.length (); |
266 octave_idx_type b_len = b.length (); | |
2928 | 267 |
5275 | 268 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; |
4844 | 269 dim_vector si_dims = x.dims (); |
270 for (int i = dim; i > 0; i--) | |
5059 | 271 si_dims(i) = si_dims(i-1); |
272 si_dims(0) = si_len; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
273 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
274 MArray<T> si (si_dims, T (0.0)); |
2928 | 275 |
4844 | 276 return filter (b, a, x, si, dim); |
2928 | 277 } |
278 | |
3097 | 279 DEFUN_DLD (filter, args, nargout, |
3367 | 280 "-*- texinfo -*-\n\ |
10840 | 281 @deftypefn {Loadable Function} {y =} filter (@var{b}, @var{a}, @var{x})\n\ |
3367 | 282 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si})\n\ |
4844 | 283 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, [], @var{dim})\n\ |
284 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}, @var{dim})\n\ | |
3367 | 285 Return the solution to the following linear, time-invariant difference\n\ |
286 equation:\n\ | |
287 @tex\n\ | |
288 $$\n\ | |
289 \\sum_{k=0}^N a_{k+1} y_{n-k} = \\sum_{k=0}^M b_{k+1} x_{n-k}, \\qquad\n\ | |
290 1 \\le n \\le P\n\ | |
291 $$\n\ | |
292 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
293 @ifnottex\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
294 @c Set example in small font to prevent overfull line\n\ |
2928 | 295 \n\ |
3367 | 296 @smallexample\n\ |
10840 | 297 @group\n\ |
3367 | 298 N M\n\ |
299 SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x)\n\ | |
300 k=0 k=0\n\ | |
10840 | 301 @end group\n\ |
3367 | 302 @end smallexample\n\ |
10840 | 303 \n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
304 @end ifnottex\n\ |
2928 | 305 \n\ |
3367 | 306 @noindent\n\ |
307 where\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
308 @ifnottex\n\ |
3367 | 309 N=length(a)-1 and M=length(b)-1.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
310 @end ifnottex\n\ |
3367 | 311 @tex\n\ |
312 $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\ | |
313 @end tex\n\ | |
4844 | 314 over the first non-singleton dimension of @var{x} or over @var{dim} if\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
315 supplied. An equivalent form of this equation is:\n\ |
3367 | 316 @tex\n\ |
317 $$\n\ | |
318 y_n = -\\sum_{k=1}^N c_{k+1} y_{n-k} + \\sum_{k=0}^M d_{k+1} x_{n-k}, \\qquad\n\ | |
319 1 \\le n \\le P\n\ | |
320 $$\n\ | |
321 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
322 @ifnottex\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
323 @c Set example in small font to prevent overfull line\n\ |
2928 | 324 \n\ |
3367 | 325 @smallexample\n\ |
10840 | 326 @group\n\ |
3367 | 327 N M\n\ |
328 y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x)\n\ | |
329 k=1 k=0\n\ | |
10840 | 330 @end group\n\ |
3367 | 331 @end smallexample\n\ |
10840 | 332 \n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
333 @end ifnottex\n\ |
3367 | 334 \n\ |
335 @noindent\n\ | |
336 where\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
337 @ifnottex\n\ |
3367 | 338 c = a/a(1) and d = b/a(1).\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
339 @end ifnottex\n\ |
3367 | 340 @tex\n\ |
341 $c = a/a_1$ and $d = b/a_1$.\n\ | |
342 @end tex\n\ | |
343 \n\ | |
344 If the fourth argument @var{si} is provided, it is taken as the\n\ | |
345 initial state of the system and the final state is returned as\n\ | |
346 @var{sf}. The state vector is a column vector whose length is\n\ | |
347 equal to the length of the longest coefficient vector minus one.\n\ | |
348 If @var{si} is not supplied, the initial state vector is set to all\n\ | |
2928 | 349 zeros.\n\ |
350 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
351 In terms of the Z Transform, y is the result of passing the discrete-\n\ |
3367 | 352 time signal x through a system characterized by the following rational\n\ |
353 system function:\n\ | |
354 @tex\n\ | |
355 $$\n\ | |
356 H(z) = {\\displaystyle\\sum_{k=0}^M d_{k+1} z^{-k}\n\ | |
357 \\over 1 + \\displaystyle\\sum_{k+1}^N c_{k+1} z^{-k}}\n\ | |
358 $$\n\ | |
359 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
360 @ifnottex\n\ |
3367 | 361 \n\ |
362 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
363 @group\n\ |
3367 | 364 M\n\ |
365 SUM d(k+1) z^(-k)\n\ | |
366 k=0\n\ | |
367 H(z) = ----------------------\n\ | |
368 N\n\ | |
6476 | 369 1 + SUM c(k+1) z^(-k)\n\ |
3367 | 370 k=1\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
371 @end group\n\ |
3367 | 372 @end example\n\ |
10840 | 373 \n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7789
diff
changeset
|
374 @end ifnottex\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
375 @seealso{filter2, fftfilt, freqz}\n\ |
3367 | 376 @end deftypefn") |
2928 | 377 { |
378 octave_value_list retval; | |
379 | |
380 int nargin = args.length (); | |
381 | |
4844 | 382 if (nargin < 3 || nargin > 5) |
2928 | 383 { |
5823 | 384 print_usage (); |
2928 | 385 return retval; |
386 } | |
387 | |
4844 | 388 const char *errmsg = "filter: arguments a and b must be vectors"; |
389 | |
390 int dim; | |
391 dim_vector x_dims = args(2).dims (); | |
2928 | 392 |
4844 | 393 if (nargin == 5) |
394 { | |
395 dim = args(4).nint_value() - 1; | |
396 if (dim < 0 || dim >= x_dims.length ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
397 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
398 error ("filter: DIM must be a valid dimension"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
399 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
400 } |
4844 | 401 } |
402 else | |
403 { | |
404 // Find first non-singleton dimension | |
405 dim = 0; | |
5059 | 406 while (dim < x_dims.length () && x_dims(dim) <= 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
407 dim++; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
408 |
4844 | 409 // All dimensions singleton, pick first dimension |
410 if (dim == x_dims.length ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
411 dim = 0; |
4844 | 412 } |
2928 | 413 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
414 bool isfloat = (args(0).is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
415 || args(1).is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
416 || args(2).is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
417 || (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
|
418 |
2928 | 419 if (args(0).is_complex_type () |
420 || args(1).is_complex_type () | |
421 || args(2).is_complex_type () | |
4844 | 422 || (nargin >= 4 && args(3).is_complex_type ())) |
2928 | 423 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
424 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
425 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
426 FloatComplexColumnVector b (args(0).float_complex_vector_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
427 FloatComplexColumnVector a (args(1).float_complex_vector_value ()); |
3088 | 428 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
429 FloatComplexNDArray x (args(2).float_complex_array_value ()); |
3088 | 430 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
431 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
432 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
433 FloatComplexNDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
434 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
435 if (nargin == 3 || args(3).is_empty ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
436 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
437 octave_idx_type a_len = a.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
438 octave_idx_type b_len = b.length (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
439 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
440 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
|
441 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
442 dim_vector si_dims = x.dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
443 for (int i = dim; i > 0; i--) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
444 si_dims(i) = si_dims(i-1); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
445 si_dims(0) = si_len; |
3088 | 446 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
447 si.resize (si_dims, 0.0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
448 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
449 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
450 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
451 dim_vector si_dims = args (3).dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
452 bool si_is_vector = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
453 for (int i = 0; i < si_dims.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
454 if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
455 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
456 si_is_vector = false; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
457 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
458 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
459 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
460 si = args(3).float_complex_array_value (); |
2928 | 461 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
462 if (si_is_vector) |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
463 si = si.reshape (dim_vector (1, si.numel ())); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
464 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
465 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
466 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
467 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
468 FloatComplexNDArray y (filter (b, a, x, si, dim)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
469 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
470 if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
471 retval(1) = si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
472 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
473 retval(0) = y; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
474 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
475 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
476 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
477 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
478 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
479 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
480 } |
2928 | 481 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
482 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
483 ComplexColumnVector b (args(0).complex_vector_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
484 ComplexColumnVector a (args(1).complex_vector_value ()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
485 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
486 ComplexNDArray x (args(2).complex_array_value ()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
487 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
488 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
489 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
490 ComplexNDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
491 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
492 if (nargin == 3 || args(3).is_empty ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
493 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
494 octave_idx_type a_len = a.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
495 octave_idx_type b_len = b.length (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
496 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
497 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
|
498 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
499 dim_vector si_dims = x.dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
500 for (int i = dim; i > 0; i--) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
501 si_dims(i) = si_dims(i-1); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
502 si_dims(0) = si_len; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
503 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
504 si.resize (si_dims, 0.0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
505 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
506 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
507 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
508 dim_vector si_dims = args (3).dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
509 bool si_is_vector = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
510 for (int i = 0; i < si_dims.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
511 if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
512 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
513 si_is_vector = false; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
514 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
515 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
516 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
517 si = args(3).complex_array_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
518 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
519 if (si_is_vector) |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
520 si = si.reshape (dim_vector (1, si.numel ())); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
521 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
522 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
523 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
524 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
525 ComplexNDArray y (filter (b, a, x, si, dim)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
526 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
527 if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
528 retval(1) = si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
529 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
530 retval(0) = y; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
531 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
532 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
533 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
534 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
535 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
536 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
537 } |
2928 | 538 } |
539 else | |
540 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
541 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
542 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
543 FloatColumnVector b (args(0).float_vector_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
544 FloatColumnVector a (args(1).float_vector_value ()); |
3088 | 545 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
546 FloatNDArray x (args(2).float_array_value ()); |
3088 | 547 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
548 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
549 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
550 FloatNDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
551 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
552 if (nargin == 3 || args(3).is_empty ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
553 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
554 octave_idx_type a_len = a.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
555 octave_idx_type b_len = b.length (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
556 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
557 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
|
558 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
559 dim_vector si_dims = x.dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
560 for (int i = dim; i > 0; i--) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
561 si_dims(i) = si_dims(i-1); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
562 si_dims(0) = si_len; |
3088 | 563 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
564 si.resize (si_dims, 0.0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
565 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
566 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
567 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
568 dim_vector si_dims = args (3).dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
569 bool si_is_vector = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
570 for (int i = 0; i < si_dims.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
571 if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
572 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
573 si_is_vector = false; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
574 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
575 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
576 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
577 si = args(3).float_array_value (); |
2928 | 578 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
579 if (si_is_vector) |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
580 si = si.reshape (dim_vector (1, si.numel ())); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
581 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
582 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
583 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
584 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
585 FloatNDArray y (filter (b, a, x, si, dim)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
586 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
587 if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
588 retval(1) = si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
589 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
590 retval(0) = y; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
591 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
592 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
593 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
594 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
595 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
596 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
597 } |
2928 | 598 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
599 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
600 ColumnVector b (args(0).vector_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
601 ColumnVector a (args(1).vector_value ()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
602 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
603 NDArray x (args(2).array_value ()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
604 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
605 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
606 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
607 NDArray si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
608 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
609 if (nargin == 3 || args(3).is_empty ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
610 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
611 octave_idx_type a_len = a.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
612 octave_idx_type b_len = b.length (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
613 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
614 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
|
615 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
616 dim_vector si_dims = x.dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
617 for (int i = dim; i > 0; i--) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
618 si_dims(i) = si_dims(i-1); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
619 si_dims(0) = si_len; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
620 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
621 si.resize (si_dims, 0.0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
622 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
623 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
624 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
625 dim_vector si_dims = args (3).dims (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
626 bool si_is_vector = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
627 for (int i = 0; i < si_dims.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
628 if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
629 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
630 si_is_vector = false; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
631 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
632 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
633 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
634 si = args(3).array_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
635 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
636 if (si_is_vector) |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
637 si = si.reshape (dim_vector (1, si.numel ())); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
638 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
639 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
640 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
641 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
642 NDArray y (filter (b, a, x, si, dim)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
643 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
644 if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
645 retval(1) = si; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
646 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
647 retval(0) = y; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
648 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
649 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
650 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
651 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
652 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
653 error (errmsg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
654 } |
2928 | 655 } |
656 | |
657 return retval; | |
658 } | |
659 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
660 template MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
661 filter (MArray<double>&, MArray<double>&, MArray<double>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
662 MArray<double>&, int dim); |
2928 | 663 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
664 template MArray<double> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
665 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim); |
2928 | 666 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
667 template MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
668 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
669 MArray<Complex>&, int dim); |
2928 | 670 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
671 template MArray<Complex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
672 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, int dim); |
2928 | 673 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
674 template MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
675 filter (MArray<float>&, MArray<float>&, MArray<float>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
676 MArray<float>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
677 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
678 template MArray<float> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
679 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
|
680 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
681 template MArray<FloatComplex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
682 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
683 MArray<FloatComplex>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
684 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
685 template MArray<FloatComplex> |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10247
diff
changeset
|
686 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&, int dim); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
687 |
2928 | 688 /* |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
689 %!shared a, b, x, r |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
690 %!test |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
691 %! a = [1 1]; |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
692 %! b = [1 1]; |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
693 %! x = zeros (1,10); x(1) = 1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
694 %! assert(filter(b, [1], x ), [1 1 0 0 0 0 0 0 0 0]); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
695 %! assert(filter(b, [1], x.'), [1 1 0 0 0 0 0 0 0 0].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
696 %! assert(filter(b.', [1], x ), [1 1 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
697 %! assert(filter(b.', [1], x.'), [1 1 0 0 0 0 0 0 0 0].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
698 %! assert(filter([1], a, x ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
699 %! assert(filter([1], a, x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
700 %! assert(filter([1], a.', x ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
701 %! assert(filter([1], a.', x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
702 %! assert(filter(b, a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
703 %! assert(filter(b.', a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
704 %! assert(filter(b, a.', x ), [1 0 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
705 %! assert(filter(b.', a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
706 %! assert(filter(b, a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
707 %! assert(filter(b.', a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
708 %! assert(filter(b, a.', x.'), [1 0 0 0 0 0 0 0 0 0].'); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
709 %! assert(filter(b.', a, x.'), [1 0 0 0 0 0 0 0 0 0].'); |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
710 %! |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
711 %!test |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
712 %! r = sqrt(1/2)*(1+i); |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
713 %! a = a*r; |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
714 %! b = b*r; |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
715 %! assert(filter(b, [1], x ), r*[1 1 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
716 %! assert(filter(b, [1], r*x ), r*r*[1 1 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
717 %! assert(filter(b, [1], x.' ), r*[1 1 0 0 0 0 0 0 0 0].' ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
718 %! assert(filter(b, a, x ), [1 0 0 0 0 0 0 0 0 0] ); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
719 %! assert(filter(b, a, r*x ), r*[1 0 0 0 0 0 0 0 0 0] ); |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
720 %! |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
721 %!shared a, b, x, y, so |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
722 %!test |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
723 %! a = [1,1]; b = [1,1]; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
724 %! x = zeros (1,10); x(1) = 1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
725 %! [y, so] = filter (b, [1], x, [-1]); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
726 %! assert(y, [0 1 0 0 0 0 0 0 0 0]); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
727 %! assert(so,0); |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
728 %! |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
729 %!test |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
730 %! x = zeros (10,3); x(1,1)=-1; x(1,2)=1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
731 %! y0 = zeros (10,3); y0(1:2,1)=-1; y0(1:2,2)=1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
732 %! y = filter (b, [1], x); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
733 %! assert(y,y0); |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
734 %! |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
735 %!test |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
736 %! a = [1,1]; b=[1,1]; |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
737 %! x = zeros (4,4,2); x(1,1:4,1) = +1; x(1,1:4,2) = -1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
738 %! y0 = zeros (4,4,2); y0(1:2,1:4,1) = +1; y0(1:2,1:4,2) = -1; |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
739 %! y = filter (b, [1], x); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
740 %! assert(y, y0); |
10247
edfceeab945a
Add test case for empty argument in filter()
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
10241
diff
changeset
|
741 %! |
12566
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
742 %!assert(filter (1, ones(10,1)/10, []), []); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
743 %!assert(filter (1, ones(10,1)/10, zeros(0,10)), zeros(0,10)); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
744 %!assert(filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18]); |
3b0eb443c519
Fix orientation of initial conditions vector for filter (bug #32741).
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
745 %!assert(filter (1, ones(10,1)/10, single (1:5)), repmat (single (10), 1, 5)); |
9432
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
746 %% Should put some tests of the "DIM" parameter in here. |
8cc2d087f3c1
src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents:
9153
diff
changeset
|
747 |
10155
d0ce5e973937
DLD-FUNCTIONS/*.cc: delete Emacs local-variables settings
John W. Eaton <jwe@octave.org>
parents:
10154
diff
changeset
|
748 */ |