annotate libinterp/corefcn/filter.cc @ 20915:a3359fe50966

remove unused nargout variables * __ichol__.cc, __ilu__.cc, ellipj.cc, filter.cc, mgorth.cc, nproc.cc, pr-output.cc, quad.cc, quadcc.cc, sylvester.cc: Remove unused nargout from DEFUNs that no longer use it.
author John W. Eaton <jwe@octave.org>
date Wed, 16 Dec 2015 17:02:23 -0500
parents 03e4ddd49396
children 48b2ad5ee801
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
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18812
diff changeset
3 Copyright (C) 1996-2015 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
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14854
diff changeset
37 #include "defun.h"
2928
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
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20704
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>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
52 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
53 int dim);
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 3097
diff changeset
54 #endif
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
55
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
56 template <class T>
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
57 MArray<T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
58 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
59 int dim = 0)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
60 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
61 MArray<T> y;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
62
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20230
diff changeset
63 octave_idx_type a_len = a.numel ();
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20230
diff changeset
64 octave_idx_type b_len = b.numel ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
65
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
66 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
67
12637
d02798e9eeae filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents: 12566
diff changeset
68 // 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
69 // 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
70 // 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
71 // 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
72 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
73 if (a_len > 1)
d02798e9eeae filter.cc: Stop test errors in residue.m (bug #33164)
Rik <octave@nomad.inbox5.com>
parents: 12566
diff changeset
74 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
75
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
76 T norm = a (0);
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
77
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
78 if (norm == static_cast<T> (0.0))
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
79 error ("filter: the first element of A must be nonzero");
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
80
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
81 dim_vector x_dims = x.dims ();
5056
9379d8716407 [project @ 2004-10-22 14:58:05 by jwe]
jwe
parents: 5055
diff changeset
82 if (dim < 0 || dim > x_dims.length ())
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
83 error ("filter: DIM must be a valid dimension");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
84
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
85 octave_idx_type x_len = x_dims(dim);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
86
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
87 dim_vector si_dims = si.dims ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
88 octave_idx_type si_len = si_dims(0);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
89
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
90 if (si_len != ab_len - 1)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
91 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
92
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
93 if (si_dims.length () != x_dims.length ())
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
94 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
95
12774
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
96 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
97 {
12774
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
98 if (si_dims(i) != x_dims(i-1))
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
99 error ("filter: dimensionality of SI and X must agree");
12774
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
100 }
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
101 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
102 {
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
103 if (si_dims(i) != x_dims(i))
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
104 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
105 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
106
10241
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
107 if (x_len == 0)
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
108 return x;
a277ba5da4dc filter.cc: return early if X is empty
John W. Eaton <jwe@octave.org>
parents: 10155
diff changeset
109
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
110 if (norm != static_cast<T> (1.0))
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
111 {
20230
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20172
diff changeset
112 a /= norm;
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20172
diff changeset
113 b /= norm;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
114 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
115
5056
9379d8716407 [project @ 2004-10-22 14:58:05 by jwe]
jwe
parents: 5055
diff changeset
116 if (a_len <= 1 && si_len <= 0)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
117 return b(0) * x;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
118
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
119 y.resize (x_dims, 0.0);
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
120
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
121 int x_stride = 1;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
122 for (int i = 0; i < dim; i++)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
123 x_stride *= x_dims(i);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
124
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
125 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
126 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
127 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
128 octave_idx_type x_offset;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
129 if (x_stride == 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
130 x_offset = num * x_len;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
131 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
132 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
133 octave_idx_type x_offset2 = 0;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
134 x_offset = num;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
135 while (x_offset >= x_stride)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
136 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
137 x_offset -= x_stride;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
138 x_offset2++;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
139 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
140 x_offset += x_offset2 * x_stride * x_len;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
141 }
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
142 octave_idx_type si_offset = num * si_len;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
143
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
144 if (a_len > 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
145 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
146 T *py = y.fortran_vec ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
147 T *psi = si.fortran_vec ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
148
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
149 const T *pa = a.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
150 const T *pb = b.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
151 const T *px = x.data ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
152
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
153 psi += si_offset;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
154
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
155 for (octave_idx_type i = 0, idx = x_offset;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
156 i < x_len;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
157 i++, idx += x_stride)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
158 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
159 py[idx] = psi[0] + pb[0] * px[idx];
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
160
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
161 if (si_len > 0)
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 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
164 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
165 OCTAVE_QUIT;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
166
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
167 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
168 }
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_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
171 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
172 else
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 OCTAVE_QUIT;
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 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
177 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
178 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
179 }
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
180 else if (si_len > 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
181 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
182 T *py = y.fortran_vec ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
183 T *psi = si.fortran_vec ();
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 const T *pb = b.data ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
186 const T *px = x.data ();
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
187
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
188 psi += si_offset;
5114
cda8c0a823c5 [project @ 2005-01-21 17:02:21 by jwe]
jwe
parents: 5059
diff changeset
189
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
190 for (octave_idx_type i = 0, idx = x_offset;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
191 i < x_len;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
192 i++, idx += x_stride)
10154
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 py[idx] = psi[0] + pb[0] * px[idx];
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
195
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
196 if (si_len > 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
197 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
198 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
199 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
200 OCTAVE_QUIT;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3419
diff changeset
201
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
202 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
203 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
204
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
205 psi[si_len-1] = pb[si_len] * px[idx];
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 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
208 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
209 OCTAVE_QUIT;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
210
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
211 psi[0] = pb[1] * px[idx];
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
214 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
215 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
216
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
217 return y;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
218 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
219
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20704
diff changeset
220 #if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
221 extern MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
222 filter (MArray<double>&, MArray<double>&, MArray<double>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
223 MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
224
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
225 extern MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
226 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
227 MArray<Complex>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
228
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
229 extern MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
230 filter (MArray<float>&, MArray<float>&, MArray<float>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
231 MArray<float>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
232
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
233 extern MArray<FloatComplex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
234 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
235 MArray<FloatComplex>&, int dim);
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 3097
diff changeset
236 #endif
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
237
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
238 template <class T>
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
239 MArray<T>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
240 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
241 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14842
diff changeset
242 dim_vector x_dims = x.dims ();
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
243
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
244 if (dim < 0)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
245 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
246 // Find first non-singleton dimension
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
247 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
248 dim++;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
249
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
250 // All dimensions singleton, pick first dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
251 if (dim == x_dims.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
252 dim = 0;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
253 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
254 else if (dim < 0 || dim > x_dims.length ())
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
255 error ("filter: DIM must be a valid dimension");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
256
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20230
diff changeset
257 octave_idx_type a_len = a.numel ();
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20230
diff changeset
258 octave_idx_type b_len = b.numel ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
259
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5114
diff changeset
260 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
261 dim_vector si_dims = x.dims ();
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
262 for (int i = dim; i > 0; i--)
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
263 si_dims(i) = si_dims(i-1);
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
264 si_dims(0) = si_len;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
265
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
266 MArray<T> si (si_dims, T (0.0));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
267
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
268 return filter (b, a, x, si, dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
269 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
270
20915
a3359fe50966 remove unused nargout variables
John W. Eaton <jwe@octave.org>
parents: 20909
diff changeset
271 DEFUN (filter, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
272 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
273 @deftypefn {} {@var{y} =} filter (@var{b}, @var{a}, @var{x})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
274 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
275 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, [], @var{dim})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
276 @deftypefnx {} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}, @var{dim})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
277 Apply a 1-D digital filter to the data @var{x}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
278 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
279 @code{filter} returns the solution to the following linear, time-invariant\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
280 difference equation:\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
281 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
282 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
283 \\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
284 1 \\le n \\le P\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
285 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
286 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
287 @ifnottex\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
288 @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
289 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
290 @smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
291 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
292 N M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
293 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
294 k=0 k=0\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
295 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
296 @end smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
297 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
298 @end ifnottex\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
299 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
300 @noindent\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
301 where\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
302 @ifnottex\n\
14842
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
303 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
304 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
305 @tex\n\
14842
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
306 $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
307 @end tex\n\
14842
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
308 The result is calculated over the first non-singleton dimension of @var{x}\n\
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
309 or over @var{dim} if supplied.\n\
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
310 \n\
aa4c25ca498e doc: Improve docstring for filter.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
311 An equivalent form of the equation is:\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
312 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
313 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
314 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
315 1 \\le n \\le P\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
316 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
317 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
318 @ifnottex\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
319 @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
320 \n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
321 @smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
322 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
323 N M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
324 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
325 k=1 k=0\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
326 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
327 @end smallexample\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
328 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
329 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
330 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
331 @noindent\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
332 where\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
333 @ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
334 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
335 @end ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
336 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
337 $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
338 @end tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
339 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
340 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
341 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
342 @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
343 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
344 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
345 zeros.\n\
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
346 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
347 In terms of the Z Transform, @var{y} is the result of passing the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
348 discrete-time signal @var{x} through a system characterized by the following\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19739
diff changeset
349 rational system function:\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
350 @tex\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
351 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
352 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
353 \\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
354 $$\n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
355 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
356 @ifnottex\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
357 \n\
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
358 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
359 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
360 M\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
361 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
362 k=0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
363 H(z) = ---------------------\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
364 N\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
365 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
366 k=1\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
367 @end group\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
368 @end example\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10350
diff changeset
369 \n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7789
diff changeset
370 @end ifnottex\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
371 @seealso{filter2, fftfilt, freqz}\n\
3367
0748b03c3510 [project @ 1999-11-20 14:52:38 by jwe]
jwe
parents: 3109
diff changeset
372 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
373 {
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20802
diff changeset
374 int nargin = args.length ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
375
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
376 if (nargin < 3 || nargin > 5)
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
377 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
378
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
379 const char *a_b_errmsg = "filter: A and B must be vectors";
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
380 const char *x_si_errmsg = "filter: X and SI must be arrays";
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
381
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
382 int dim;
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
383 dim_vector x_dims = args(2).dims ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
384
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
385 if (nargin == 5)
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
386 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14842
diff changeset
387 dim = args(4).nint_value () - 1;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
388 if (dim < 0 || dim >= x_dims.length ())
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
389 error ("filter: DIM must be a valid dimension");
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
390 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
391 else
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
392 {
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
393 // Find first non-singleton dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
394 dim = 0;
5059
38dd53c8935e [project @ 2004-11-02 02:42:25 by jwe]
jwe
parents: 5056
diff changeset
395 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
396 dim++;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
397
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
398 // All dimensions singleton, pick first dimension
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
399 if (dim == x_dims.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
400 dim = 0;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
401 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
402
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20892
diff changeset
403 octave_value_list retval;
20892
c07bee629973 2015 Code Sprint: use ovl ().
Rik <rik@octave.org>
parents: 20853
diff changeset
404
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
405 bool isfloat = (args(0).is_single_type ()
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
406 || args(1).is_single_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
407 || args(2).is_single_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
408 || (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
409
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
410 if (args(0).is_complex_type ()
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
411 || args(1).is_complex_type ()
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
412 || args(2).is_complex_type ()
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4153
diff changeset
413 || (nargin >= 4 && args(3).is_complex_type ()))
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
414 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
415 if (isfloat)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
416 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
417 FloatComplexColumnVector b = args(0).xfloat_complex_vector_value (a_b_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
418 FloatComplexColumnVector a = args(1).xfloat_complex_vector_value (a_b_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
419 FloatComplexNDArray x = args(2).xfloat_complex_array_value (x_si_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
420
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
421 FloatComplexNDArray si;
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
422
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
423 if (nargin == 3 || args(3).is_empty ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
424 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
425 octave_idx_type a_len = a.numel ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
426 octave_idx_type b_len = b.numel ();
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
427
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
428 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
429
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
430 dim_vector si_dims = x.dims ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
431 for (int i = dim; i > 0; i--)
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
432 si_dims(i) = si_dims(i-1);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
433 si_dims(0) = si_len;
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
434
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
435 si.resize (si_dims, 0.0);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
436 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
437 else
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
438 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
439 si = args(3).xfloat_complex_array_value (x_si_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
440
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
441 if (si.is_vector () && x.is_vector ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
442 si = si.reshape (dim_vector (si.numel (), 1));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
443 }
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
444
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
445 FloatComplexNDArray y (filter (b, a, x, si, dim));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
446
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20892
diff changeset
447 retval = ovl (y, si);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
448 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
449 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
450 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
451 ComplexColumnVector b = args(0).xcomplex_vector_value (a_b_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
452 ComplexColumnVector a = args(1).xcomplex_vector_value (a_b_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
453
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
454 ComplexNDArray x = args(2).xcomplex_array_value (x_si_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
455
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
456 ComplexNDArray si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
457
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
458 if (nargin == 3 || args(3).is_empty ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
459 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
460 octave_idx_type a_len = a.numel ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
461 octave_idx_type b_len = b.numel ();
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
462
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
463 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
464
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
465 dim_vector si_dims = x.dims ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
466 for (int i = dim; i > 0; i--)
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
467 si_dims(i) = si_dims(i-1);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
468 si_dims(0) = si_len;
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
469
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
470 si.resize (si_dims, 0.0);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
471 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
472 else
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
473 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
474 si = args(3).xcomplex_array_value (x_si_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
475
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
476 if (si.is_vector () && x.is_vector ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
477 si = si.reshape (dim_vector (si.numel (), 1));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
478 }
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
479
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
480 ComplexNDArray y (filter (b, a, x, si, dim));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
481
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20892
diff changeset
482 retval = ovl (y, si);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
483 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
484 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
485 else
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
486 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
487 if (isfloat)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
488 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
489 FloatColumnVector b = args(0).xfloat_vector_value (a_b_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
490 FloatColumnVector a = args(1).xfloat_vector_value (a_b_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
491
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
492 FloatNDArray x = args(2).xfloat_array_value (x_si_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
493
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
494 FloatNDArray si;
3088
f33738510eb2 [project @ 1997-10-02 06:38:36 by jwe]
jwe
parents: 3014
diff changeset
495
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
496 if (nargin == 3 || args(3).is_empty ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
497 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
498 octave_idx_type a_len = a.numel ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
499 octave_idx_type b_len = b.numel ();
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
500
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
501 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
502
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
503 dim_vector si_dims = x.dims ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
504 for (int i = dim; i > 0; i--)
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
505 si_dims(i) = si_dims(i-1);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
506 si_dims(0) = si_len;
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
507
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
508 si.resize (si_dims, 0.0);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
509 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
510 else
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
511 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
512 si = args(3).xfloat_array_value (x_si_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
513
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
514 if (si.is_vector () && x.is_vector ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
515 si = si.reshape (dim_vector (si.numel (), 1));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
516 }
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
517
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
518 FloatNDArray y (filter (b, a, x, si, dim));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
519
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20892
diff changeset
520 retval = ovl (y, si);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
521 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
522 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
523 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
524 ColumnVector b = args(0).xvector_value (a_b_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
525 ColumnVector a = args(1).xvector_value (a_b_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
526
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
527 NDArray x = args(2).xarray_value (x_si_errmsg);
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
528
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
529 NDArray si;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
530
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
531 if (nargin == 3 || args(3).is_empty ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
532 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
533 octave_idx_type a_len = a.numel ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
534 octave_idx_type b_len = b.numel ();
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
535
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
536 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
537
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
538 dim_vector si_dims = x.dims ();
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
539 for (int i = dim; i > 0; i--)
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
540 si_dims(i) = si_dims(i-1);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
541 si_dims(0) = si_len;
20687
5f04bfc7c17a backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents: 20682
diff changeset
542
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
543 si.resize (si_dims, 0.0);
10154
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 else
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
546 {
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
547 si = args(3).xarray_value (x_si_errmsg);
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
548
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
549 if (si.is_vector () && x.is_vector ())
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
550 si = si.reshape (dim_vector (si.numel (), 1));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
551 }
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
552
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
553 NDArray y (filter (b, a, x, si, dim));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
554
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20892
diff changeset
555 retval = ovl (y, si);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
556 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
557 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
558
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
559 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
560 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
561
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
562 template MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
563 filter (MArray<double>&, MArray<double>&, MArray<double>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
564 MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
565
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
566 template MArray<double>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
567 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
568
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
569 template MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
570 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
571 MArray<Complex>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
572
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
573 template MArray<Complex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
574 filter (MArray<Complex>&, MArray<Complex>&, MArray<Complex>&, int dim);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
575
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
576 template MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
577 filter (MArray<float>&, MArray<float>&, MArray<float>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
578 MArray<float>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
579
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
580 template MArray<float>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
581 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
582
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
583 template MArray<FloatComplex>
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
584 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
585 MArray<FloatComplex>&, int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
586
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10247
diff changeset
587 template MArray<FloatComplex>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
588 filter (MArray<FloatComplex>&, MArray<FloatComplex>&, MArray<FloatComplex>&,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
589 int dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
590
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
591 /*
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
592 %!shared a, b, x, r
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
593 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
594 %! a = [1 1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
595 %! b = [1 1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
596 %! 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
597 %! 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
598 %! 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
599 %! 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
600 %! 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
601 %! 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
602 %! 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
603 %! 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
604 %! 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
605 %! 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
606 %! 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
607 %! 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
608 %! 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
609 %! 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
610 %! 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
611 %! 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
612 %! 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
613
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
614 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
615 %! 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
616 %! a = a*r;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
617 %! b = b*r;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
618 %! 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
619 %! 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
620 %! 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
621 %! 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
622 %! 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
623
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
624 %!shared a, b, x, y, so
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
625 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
626 %! a = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
627 %! b = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
628 %! 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
629 %! [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
630 %! 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
631 %! assert (so, 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
632
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
633 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
634 %! 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
635 %! 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
636 %! 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
637 %! assert (y, y0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
638
9432
8cc2d087f3c1 src/DLD-FUNCTIONS/filter.cc: new tests
Robert T. Short <octave@phaselockedsystems.com>
parents: 9153
diff changeset
639 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
640 %! a = [1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
641 %! b=[1,1];
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
642 %! 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
643 %! 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
644 %! 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
645 %! assert (y, y0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
646
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
647 %!assert (filter (1, ones (10,1) / 10, []), [])
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
648 %!assert (filter (1, ones (10,1) / 10, zeros (0,10)), zeros (0,10))
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
649 %!assert (filter (1, ones (10,1) / 10, single (1:5)), repmat (single (10), 1, 5))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
650
12707
a5f4dad4ec27 Merge with stable; recover on default backed-out 9843b3b055e0 from stable
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12706
diff changeset
651 %% 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
652 %!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
653 %!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
654 %!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
655 %!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
656 %!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
657
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
658 ## 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
659 %!test
ec6c52496485 Fix input validation of SI vector for filter() when DIM used (Bug #33625)
Rik <octave@nomad.inbox5.com>
parents: 12707
diff changeset
660 %! 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
661 %! 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
662 %! 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
663 %! 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
664 %! 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
665 %! assert (y, y0);
10155
d0ce5e973937 DLD-FUNCTIONS/*.cc: delete Emacs local-variables settings
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
666 */