Mercurial > hg > octave-terminal
changeset 12706:7c8b50cd4fb4 stable
Backout 12700:9843b3b055e0 from stable branch
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Mon, 06 Jun 2011 12:38:15 -0500 |
parents | d326be468b13 |
children | a5f4dad4ec27 e34f2bf7319d |
files | src/DLD-FUNCTIONS/filter.cc |
diffstat | 1 files changed, 45 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/filter.cc +++ b/src/DLD-FUNCTIONS/filter.cc @@ -456,10 +456,19 @@ } else { + 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 ()) + { + si_is_vector = false; + break; + } + si = args(3).float_complex_array_value (); - if (si.is_vector () && x.is_vector ()) - si = si.reshape (dim_vector (si.numel (), 1)); + if (si_is_vector) + si = si.reshape (dim_vector (1, si.numel ())); } if (! error_state) @@ -504,10 +513,19 @@ } else { + 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 ()) + { + si_is_vector = false; + break; + } + si = args(3).complex_array_value (); - if (si.is_vector () && x.is_vector ()) - si = si.reshape (dim_vector (si.numel (), 1)); + if (si_is_vector) + si = si.reshape (dim_vector (1, si.numel ())); } if (! error_state) @@ -555,10 +573,19 @@ } else { + 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 ()) + { + si_is_vector = false; + break; + } + si = args(3).float_array_value (); - if (si.is_vector () && x.is_vector ()) - si = si.reshape (dim_vector (si.numel (), 1)); + if (si_is_vector) + si = si.reshape (dim_vector (1, si.numel ())); } if (! error_state) @@ -603,10 +630,19 @@ } else { + 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 ()) + { + si_is_vector = false; + break; + } + si = args(3).array_value (); - if (si.is_vector () && x.is_vector ()) - si = si.reshape (dim_vector (si.numel (), 1)); + if (si_is_vector) + si = si.reshape (dim_vector (1, si.numel ())); } if (! error_state) @@ -713,13 +749,8 @@ %! %!assert(filter (1, ones(10,1)/10, []), []); %!assert(filter (1, ones(10,1)/10, zeros(0,10)), zeros(0,10)); +%!assert(filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18]); %!assert(filter (1, ones(10,1)/10, single (1:5)), repmat (single (10), 1, 5)); -%% Test using initial conditions -%!assert(filter([1, 1, 1], [1, 1], [1 2], [1, 1]), [2 2]); -%!assert(filter([1, 1, 1], [1, 1], [1 2], [1, 1]'), [2 2]); -%!assert(filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18]); -%!error (filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]')); -%!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]); %% Should put some tests of the "DIM" parameter in here. */