Mercurial > hg > octave-nkf
changeset 5059:38dd53c8935e
[project @ 2004-11-02 02:42:25 by jwe]
author | jwe |
---|---|
date | Tue, 02 Nov 2004 02:42:25 +0000 |
parents | 11bea7392e69 |
children | 34a904ac130d |
files | src/ChangeLog src/DLD-FUNCTIONS/filter.cc |
diffstat | 2 files changed, 30 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-11-01 David Bateman <dbateman@free.fr> + + * DLD-FUNCTIONS/filter.cc (filter (MArray<T>&, MArray<T>&, + MArrayN<T>&, MArrayN<T>&, int)): The variable si is now at least 2-D. + (Ffilter): Force si to be 2-D, while allowing arbitrary vector + orientation. + 2004-11-01 John W. Eaton <jwe@octave.org> * data.cc (INSTANTIATE_EYE): New macro. Use it to instantiate
--- a/src/DLD-FUNCTIONS/filter.cc +++ b/src/DLD-FUNCTIONS/filter.cc @@ -77,10 +77,10 @@ return y; } - int x_len = x_dims (dim); + int x_len = x_dims(dim); dim_vector si_dims = si.dims (); - int si_len = si_dims (0); + int si_len = si_dims(0); if (si_len != ab_len - 1) { @@ -88,19 +88,7 @@ return y; } - if (si_dims.length () == 1) - { - // Special case as x_dims.length () might be 2, but be a vector. - if (x_dims.length () > 2 - || (x_dims.length () == 2 - && (x_dims(0) != 1 || x_dims(1) != si_dims(0)) - && (x_dims(1) != 1 || x_dims(0) != si_dims(0)))) - { - error ("filter: dimensionality of si and x must agree"); - return y; - } - } - else if (si_dims.length () != x_dims.length ()) + if (si_dims.length () != x_dims.length ()) { error ("filter: dimensionality of si and x must agree"); return y; @@ -115,7 +103,7 @@ if (x_dims(i) == 1) continue; - if (si_dims (++si_dim) != x_dims (i)) + if (si_dims(++si_dim) != x_dims(i)) { error ("filter: dimensionality of si and x must agree"); return y; @@ -223,12 +211,12 @@ MArrayN<T> filter (MArray<T>& b, MArray<T>& a, MArrayN<T>& x, int dim = -1) { - dim_vector x_dims = x.dims (); + dim_vector x_dims = x.dims(); if (dim < 0) { // Find first non-singleton dimension - while (dim < x_dims.length () && x_dims (dim) <= 1) + while (dim < x_dims.length () && x_dims(dim) <= 1) dim++; // All dimensions singleton, pick first dimension @@ -248,8 +236,8 @@ int si_len = (a_len > b_len ? a_len : b_len) - 1; dim_vector si_dims = x.dims (); for (int i = dim; i > 0; i--) - si_dims (i) = si_dims (i-1); - si_dims (0) = si_len; + si_dims(i) = si_dims(i-1); + si_dims(0) = si_len; MArrayN<T> si (si_dims, T (0.0)); @@ -381,7 +369,7 @@ { // Find first non-singleton dimension dim = 0; - while (dim < x_dims.length () && x_dims (dim) <= 1) + while (dim < x_dims.length () && x_dims(dim) <= 1) dim++; // All dimensions singleton, pick first dimension @@ -412,8 +400,8 @@ dim_vector si_dims = x.dims (); for (int i = dim; i > 0; i--) - si_dims (i) = si_dims (i-1); - si_dims (0) = si_len; + si_dims(i) = si_dims(i-1); + si_dims(0) = si_len; si.resize (si_dims, 0.0); } @@ -421,18 +409,17 @@ { dim_vector si_dims = args (3).dims (); bool si_is_vector = true; - for (int i=0; i < si_dims.length (); i++) - if (si_dims (i) != 1 && si_dims (i) < si_dims.numel ()) + for (int i = 0; i < si_dims.length (); i++) + if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) { si_is_vector = false; break; } + si = args(3).complex_array_value (); + if (si_is_vector) - // XXX FIXME XXX -- there must be a better way... - si = ComplexNDArray (MArrayN<Complex> (ArrayN<Complex> (args(3).complex_vector_value ()))); - else - si = args(3).complex_array_value (); + si = si.reshape (dim_vector (si.numel (), 1)); } if (! error_state) @@ -470,8 +457,8 @@ dim_vector si_dims = x.dims (); for (int i = dim; i > 0; i--) - si_dims (i) = si_dims (i-1); - si_dims (0) = si_len; + si_dims(i) = si_dims(i-1); + si_dims(0) = si_len; si.resize (si_dims, 0.0); } @@ -479,18 +466,17 @@ { dim_vector si_dims = args (3).dims (); bool si_is_vector = true; - for (int i=0; i < si_dims.length (); i++) - if (si_dims (i) != 1 && si_dims (i) < si_dims.numel ()) + for (int i = 0; i < si_dims.length (); i++) + if (si_dims(i) != 1 && si_dims(i) < si_dims.numel ()) { si_is_vector = false; break; } + si = args(3).array_value (); + if (si_is_vector) - // XXX FIXME XXX -- there must be a better way... - si = NDArray (MArrayN<double> (ArrayN<double> (args(3).vector_value ()))); - else - si = args(3).array_value (); + si = si.reshape (dim_vector (si.numel (), 1)); } if (! error_state)