annotate src/DLD-FUNCTIONS/filter.cc @ 14501:60e5cf354d80

Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions. * __contourc__.cc, __delaunayn__.cc, __dispatch__.cc, __dsearchn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, __voronoi__.cc, besselj.cc, betainc.cc, bsxfun.cc, cellfun.cc, chol.cc, conv2.cc, convhulln.cc, dassl.cc, det.cc, dlmread.cc, dmperm.cc, dot.cc, eig.cc, eigs.cc, fft.cc, fft2.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, givens.cc, hess.cc, hex2num.cc, inv.cc, kron.cc, lookup.cc, lsode.cc, lu.cc, luinc.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, sub2ind.cc, svd.cc, syl.cc, time.cc, tril.cc, tsearch.cc: Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
author Rik <octave@nomad.inbox5.com>
date Tue, 27 Mar 2012 22:46:45 -0700
parents 97883071e8e4
children aa4c25ca498e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
3 Copyright (C) 1996-2012 John W. Eaton
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
4
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6476
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6476
diff changeset
10 option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
11
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
15 for more details.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6476
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6476
diff changeset
19 <http://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
20
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
21 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
23 // Based on Tony Richardson's filter.m.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
24 //
5428
2a16423e4aa0 [project @ 2005-08-23 18:38:27 by jwe]
jwe
parents: 5307
diff changeset
25 // Originally translated to C++ by KH (Kurt.Hornik@wu-wien.ac.at)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26 // with help from Fritz Leisch and Andreas Weingessel on Oct 20, 1994.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27 //
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28 // Rewritten to use templates to handle both real and complex cases by
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29 // jwe, Wed Nov 1 19:15:29 1995.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
30
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
31 #ifdef HAVE_CONFIG_H
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
32 #include <config.h>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
33 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
34
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3419
diff changeset
35 #include "quit.h"
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3419
diff changeset
36
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
37 #include "defun-dld.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "error.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "oct-obj.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
40
3109
fcb2f5063e7f [project @ 1997-11-20 08:52:42 by jwe]
jwe
parents: 3107
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 3097
diff changeset
53 #endif
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
54
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
59 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
60 MArray<T> y;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
61
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
62 octave_idx_type a_len = a.length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
63 octave_idx_type b_len = b.length ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
64
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
65 octave_idx_type ab_len = a_len > b_len ? a_len : b_len;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
66
12637
d02798e9eeae filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents: 12566
diff changeset
67 // 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
68 // 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
69 // 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
70 // 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
71 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
72 if (a_len > 1)
d02798e9eeae filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents: 12566
diff changeset
73 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
74
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
75 T norm = a (0);
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
76
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
77 if (norm == static_cast<T>(0.0))
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
78 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
79 error ("filter: the first element of A must be non-zero");
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
80 return y;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
81 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
82
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
83 dim_vector x_dims = x.dims ();
5056
9379d8716407 [project @ 2004-10-22 14:58:05 by jwe]
jwe
parents: 5055
diff changeset
84 if (dim < 0 || dim > x_dims.length ())
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
85 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
86 error ("filter: DIM must be a valid dimension");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
87 return y;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
88 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
89
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
90 octave_idx_type x_len = x_dims(dim);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
91
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
92 dim_vector si_dims = si.dims ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
93 octave_idx_type si_len = si_dims(0);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
94
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
95 if (si_len != ab_len - 1)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
96 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
97 error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
98 return y;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
99 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
100
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
101 if (si_dims.length () != x_dims.length ())
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
102 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
103 error ("filter: dimensionality of SI and X must agree");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
104 return y;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
105 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
106
12774
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
107 for (octave_idx_type i = 1; i < dim; i++)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
108 {
12774
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
109 if (si_dims(i) != x_dims(i-1))
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
110 {
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
111 error ("filter: dimensionality of SI and X must agree");
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
112 return y;
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
113 }
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
114 }
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
115 for (octave_idx_type i = dim+1; i < x_dims.length (); i++)
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
116 {
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
117 if (si_dims(i) != x_dims(i))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
118 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
119 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
120 return y;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
121 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
122 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
123
10241
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
124 if (x_len == 0)
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
125 return x;
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
126
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
127 if (norm != static_cast<T>(1.0))
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
128 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
129 a = a / norm;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
130 b = b / norm;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
131 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
132
5056
9379d8716407 [project @ 2004-10-22 14:58:05 by jwe]
jwe
parents: 5055
diff changeset
133 if (a_len <= 1 && si_len <= 0)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
134 return b(0) * x;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
135
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
136 y.resize (x_dims, 0.0);
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
137
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
138 int x_stride = 1;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
139 for (int i = 0; i < dim; i++)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
140 x_stride *= x_dims(i);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
141
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
142 octave_idx_type x_num = x_dims.numel () / x_len;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
143 for (octave_idx_type num = 0; num < x_num; num++)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
144 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
145 octave_idx_type x_offset;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
146 if (x_stride == 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
147 x_offset = num * x_len;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
148 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
149 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
150 octave_idx_type x_offset2 = 0;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
151 x_offset = num;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
152 while (x_offset >= x_stride)
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 x_offset -= x_stride;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
155 x_offset2++;
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 x_offset += x_offset2 * x_stride * x_len;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
158 }
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
159 octave_idx_type si_offset = num * si_len;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
160
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
161 if (a_len > 1)
10154
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 T *py = y.fortran_vec ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
164 T *psi = si.fortran_vec ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
165
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
166 const T *pa = a.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
167 const T *pb = b.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
168 const T *px = x.data ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
169
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
170 psi += si_offset;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
171
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
172 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
173 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
174 py[idx] = psi[0] + pb[0] * px[idx];
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
175
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
176 if (si_len > 0)
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 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
179 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
180 OCTAVE_QUIT;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
181
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
182 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
183 }
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
184
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
185 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
186 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
187 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
188 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
189 OCTAVE_QUIT;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
190
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
191 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
192 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
193 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
194 }
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
195 else if (si_len > 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
196 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
197 T *py = y.fortran_vec ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
198 T *psi = si.fortran_vec ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
199
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
200 const T *pb = b.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
201 const T *px = x.data ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
202
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
203 psi += si_offset;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
204
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
205 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
206 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
207 py[idx] = psi[0] + pb[0] * px[idx];
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
208
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
209 if (si_len > 1)
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 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
212 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
213 OCTAVE_QUIT;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3419
diff changeset
214
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
215 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
216 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
217
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
218 psi[si_len-1] = pb[si_len] * px[idx];
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
219 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
220 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
221 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
222 OCTAVE_QUIT;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
223
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
224 psi[0] = pb[1] * px[idx];
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
225 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
226 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
227 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
228 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
229
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
230 return y;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
231 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
232
3109
fcb2f5063e7f [project @ 1997-11-20 08:52:42 by jwe]
jwe
parents: 3107
diff changeset
233 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
234 extern MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
235 filter (MArray<double>&, MArray<double>&, MArray<double>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
236 MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
237
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
238 extern MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
239 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
240 MArray<Complex>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
241
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
242 extern MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
243 filter (MArray<float>&, MArray<float>&, MArray<float>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
244 MArray<float>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
245
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
246 extern MArray<FloatComplex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
247 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
248 MArray<FloatComplex>&, int dim);
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 3097
diff changeset
249 #endif
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
250
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
251 template <class T>
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
252 MArray<T>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
253 filter (MArray<T>& b, MArray<T>& a, MArray<T>& x, int dim = -1)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
254 {
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
255 dim_vector x_dims = x.dims();
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
256
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
257 if (dim < 0)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
258 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
259 // Find first non-singleton dimension
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
260 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
261 dim++;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
262
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
263 // All dimensions singleton, pick first dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
264 if (dim == x_dims.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
265 dim = 0;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
266 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
267 else
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
268 if (dim < 0 || dim > x_dims.length ())
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
269 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
270 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
271 return MArray<T> ();
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
272 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
273
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
274 octave_idx_type a_len = a.length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
275 octave_idx_type b_len = b.length ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
276
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
277 octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
278 dim_vector si_dims = x.dims ();
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
279 for (int i = dim; i > 0; i--)
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
280 si_dims(i) = si_dims(i-1);
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
281 si_dims(0) = si_len;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
282
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
283 MArray<T> si (si_dims, T (0.0));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
284
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
285 return filter (b, a, x, si, dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
286 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
287
3097
d12c312d1cfb [project @ 1997-11-14 08:03:47 by jwe]
jwe
parents: 3088
diff changeset
288 DEFUN_DLD (filter, args, nargout,
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
289 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
290 @deftypefn {Loadable Function} {y =} filter (@var{b}, @var{a}, @var{x})\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
291 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si})\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
292 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, [], @var{dim})\n\
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
293 @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}, @var{dim})\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
294 Return the solution to the following linear, time-invariant difference\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
295 equation:\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
296 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
297 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
298 \\sum_{k=0}^N a_{k+1} y_{n-k} = \\sum_{k=0}^M b_{k+1} x_{n-k}, \\qquad\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
299 1 \\le n \\le P\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
300 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
301 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
302 @ifnottex\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
303 @c Set example in small font to prevent overfull line\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
304 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
305 @smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
306 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
307 N M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
308 SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
309 k=0 k=0\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
310 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
311 @end smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
312 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
313 @end ifnottex\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
314 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
315 @noindent\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
316 where\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
317 @ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
318 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
319 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
320 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
321 $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
322 @end tex\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
323 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
324 supplied. An equivalent form of this equation is:\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
325 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
326 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
327 y_n = -\\sum_{k=1}^N c_{k+1} y_{n-k} + \\sum_{k=0}^M d_{k+1} x_{n-k}, \\qquad\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
328 1 \\le n \\le P\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
329 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
330 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
331 @ifnottex\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
332 @c Set example in small font to prevent overfull line\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
333 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
334 @smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
335 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
336 N M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
337 y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
338 k=1 k=0\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
339 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
340 @end smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
341 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
342 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
343 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
344 @noindent\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
345 where\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
346 @ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
347 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
348 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
349 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
350 $c = a/a_1$ and $d = b/a_1$.\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
351 @end tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
352 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
353 If the fourth argument @var{si} is provided, it is taken as the\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
354 initial state of the system and the final state is returned as\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
355 @var{sf}. The state vector is a column vector whose length is\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
356 equal to the length of the longest coefficient vector minus one.\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
357 If @var{si} is not supplied, the initial state vector is set to all\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
358 zeros.\n\
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
359 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
360 In terms of the Z Transform, y is the result of passing the discrete-\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
361 time signal x through a system characterized by the following rational\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
362 system function:\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
363 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
364 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
365 H(z) = {\\displaystyle\\sum_{k=0}^M d_{k+1} z^{-k}\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
366 \\over 1 + \\displaystyle\\sum_{k+1}^N c_{k+1} z^{-k}}\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
367 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
368 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
369 @ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
370 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
371 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
372 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
373 M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
374 SUM d(k+1) z^(-k)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
375 k=0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
376 H(z) = ---------------------\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
377 N\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
378 1 + SUM c(k+1) z^(-k)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
379 k=1\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
380 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
381 @end example\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
382 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
383 @end ifnottex\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
384 @seealso{filter2, fftfilt, freqz}\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
385 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
386 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
387 octave_value_list retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
388
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
389 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
390
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
391 if (nargin < 3 || nargin > 5)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
392 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5428
diff changeset
393 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
394 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
395 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
396
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
397 const char *errmsg = "filter: arguments a and b must be vectors";
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
398
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
399 int dim;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
400 dim_vector x_dims = args(2).dims ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
401
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
402 if (nargin == 5)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
403 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
404 dim = args(4).nint_value() - 1;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
405 if (dim < 0 || dim >= x_dims.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
406 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
407 error ("filter: DIM must be a valid dimension");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
408 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
409 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
410 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
411 else
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
412 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
413 // Find first non-singleton dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
414 dim = 0;
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
415 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
416 dim++;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
417
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
418 // All dimensions singleton, pick first dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
419 if (dim == x_dims.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
420 dim = 0;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
421 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
422
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
423 bool isfloat = (args(0).is_single_type ()
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
424 || args(1).is_single_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
425 || args(2).is_single_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
426 || (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
427
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
428 if (args(0).is_complex_type ()
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
429 || args(1).is_complex_type ()
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
430 || args(2).is_complex_type ()
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
431 || (nargin >= 4 && args(3).is_complex_type ()))
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
432 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
433 if (isfloat)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
434 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
435 FloatComplexColumnVector b (args(0).float_complex_vector_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
436 FloatComplexColumnVector a (args(1).float_complex_vector_value ());
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
437
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
438 FloatComplexNDArray x (args(2).float_complex_array_value ());
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
439
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
440 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
441 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
442 FloatComplexNDArray si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
443
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
444 if (nargin == 3 || args(3).is_empty ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
445 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
446 octave_idx_type a_len = a.length ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
447 octave_idx_type b_len = b.length ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
448
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
449 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
450
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
451 dim_vector si_dims = x.dims ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
452 for (int i = dim; i > 0; i--)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
453 si_dims(i) = si_dims(i-1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
454 si_dims(0) = si_len;
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
455
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
456 si.resize (si_dims, 0.0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
457 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
458 else
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 si = args(3).float_complex_array_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
461
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
462 if (si.is_vector () && x.is_vector ())
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
463 si = si.reshape (dim_vector (si.numel (), 1));
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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 si = args(3).complex_array_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
509
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
510 if (si.is_vector () && x.is_vector ())
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
511 si = si.reshape (dim_vector (si.numel (), 1));
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
512 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
513
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
514 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
515 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
516 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
517
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
518 if (nargout == 2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
519 retval(1) = si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
520
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
521 retval(0) = y;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
522 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
523 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
524 error (errmsg);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
525 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
526 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
527 error (errmsg);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
528 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
529 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
530 else
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
531 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
532 if (isfloat)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
533 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
534 FloatColumnVector b (args(0).float_vector_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
535 FloatColumnVector a (args(1).float_vector_value ());
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
536
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
537 FloatNDArray x (args(2).float_array_value ());
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
538
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
539 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
540 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
541 FloatNDArray si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
542
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
543 if (nargin == 3 || args(3).is_empty ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
544 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
545 octave_idx_type a_len = a.length ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
546 octave_idx_type b_len = b.length ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
547
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
548 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
549
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
550 dim_vector si_dims = x.dims ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
551 for (int i = dim; i > 0; i--)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
552 si_dims(i) = si_dims(i-1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
553 si_dims(0) = si_len;
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
554
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
555 si.resize (si_dims, 0.0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
556 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
557 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
558 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
559 si = args(3).float_array_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
560
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
561 if (si.is_vector () && x.is_vector ())
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
562 si = si.reshape (dim_vector (si.numel (), 1));
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
563 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
564
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
565 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
566 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
567 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
568
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
569 if (nargout == 2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
570 retval(1) = si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
571
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
572 retval(0) = y;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
573 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
574 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
575 error (errmsg);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
576 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
577 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
578 error (errmsg);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
579 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
580 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
581 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
582 ColumnVector b (args(0).vector_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
583 ColumnVector a (args(1).vector_value ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
584
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
585 NDArray x (args(2).array_value ());
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 (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
588 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
589 NDArray si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
590
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
591 if (nargin == 3 || args(3).is_empty ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
592 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
593 octave_idx_type a_len = a.length ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
594 octave_idx_type b_len = b.length ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
595
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
596 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
597
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
598 dim_vector si_dims = x.dims ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
599 for (int i = dim; i > 0; i--)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
600 si_dims(i) = si_dims(i-1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
601 si_dims(0) = si_len;
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 si.resize (si_dims, 0.0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
604 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
605 else
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 si = args(3).array_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
608
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
609 if (si.is_vector () && x.is_vector ())
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
610 si = si.reshape (dim_vector (si.numel (), 1));
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
611 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
612
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
613 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
614 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
615 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
616
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
617 if (nargout == 2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
618 retval(1) = si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
619
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
620 retval(0) = y;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
621 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
622 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
623 error (errmsg);
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 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
626 error (errmsg);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
627 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
628 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
629
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
630 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
631 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
632
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
633 template MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
634 filter (MArray<double>&, MArray<double>&, MArray<double>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
635 MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
636
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
637 template MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
638 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
639
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
640 template MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
641 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
642 MArray<Complex>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
643
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
644 template MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
645 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
646
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
647 template MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
648 filter (MArray<float>&, MArray<float>&, MArray<float>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
649 MArray<float>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
650
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
651 template MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
652 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
653
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
654 template MArray<FloatComplex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
655 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
656 MArray<FloatComplex>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
657
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
658 template MArray<FloatComplex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
659 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
660
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
661 /*
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
662 %!shared a, b, x, r
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
663 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
664 %! a = [1 1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
665 %! b = [1 1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
666 %! 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
667 %! 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
668 %! 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
669 %! 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
670 %! 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
671 %! 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
672 %! 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
673 %! 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
674 %! 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
675 %! 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
676 %! 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
677 %! 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
678 %! 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
679 %! 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
680 %! 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
681 %! 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
682 %! 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
683
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
684 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
685 %! 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
686 %! a = a*r;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
687 %! b = b*r;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
688 %! 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
689 %! 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
690 %! 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
691 %! 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
692 %! 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
693
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
694 %!shared a, b, x, y, so
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
695 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
696 %! a = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
697 %! b = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
698 %! 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
699 %! [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
700 %! 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
701 %! assert (so, 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
702
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
703 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
704 %! 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
705 %! 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
706 %! 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
707 %! assert (y, y0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
708
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
709 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
710 %! a = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
711 %! b=[1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
712 %! 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
713 %! 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
714 %! 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
715 %! assert (y, y0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
716
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
717 %!assert (filter (1, ones(10,1)/10, []), [])
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
718 %!assert (filter (1, ones(10,1)/10, zeros(0,10)), zeros(0,10))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
719 %!assert (filter (1, ones(10,1)/10, single (1:5)), repmat (single (10), 1, 5))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
720
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
721 %% 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
722 %!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
723 %!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
724 %!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
725 %!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
726 %!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
727
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
728 ## 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
729 %!test
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
730 %! 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
731 %! 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
732 %! 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
733 %! 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
734 %! 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
735 %! assert (y, y0);
10155
d0ce5e973937 DLD-FUNCTIONS/*.cc: delete Emacs local-variables settings
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
736 */