Mercurial > hg > octave-avbm
changeset 7648:e7b999840056
Added tests to scripts/polynomial/convn.m and allow '__convn__' to actually get N-dimensional complex data.
author | sh@sh-laptop |
---|---|
date | Wed, 26 Mar 2008 15:55:20 -0400 |
parents | 7b382848a18f |
children | 1eac99a280a2 |
files | scripts/ChangeLog scripts/polynomial/convn.m src/ChangeLog src/DLD-FUNCTIONS/__convn__.cc |
diffstat | 4 files changed, 51 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-03-26 Soren Hauberg <hauberg@gmail.com> + + * polynomial/convn.m: New tests. + 2008-03-20 Ben Abbott <bpabbott@mac.com> * statistics/base/statistics.m: Calculate median and quantiles in
--- a/scripts/polynomial/convn.m +++ b/scripts/polynomial/convn.m @@ -1,4 +1,4 @@ -## Copyright (C) 2008 SÃ?ren Hauberg +## Copyright (C) 2008 Soren Hauberg ## ## This file is part of Octave. ## @@ -87,3 +87,42 @@ a = cat (dim, zeros (l, cl), a, zeros (r, cl)); endfor endfunction + +%!test +%! ## Compare to conv2 +%! a = rand (100); +%! b = ones (3); +%! c2 = conv2 (a, b, "full"); +%! cn = convn (a, b, "full"); +%! assert (max (abs (cn(:)-c2(:))), 0, 100*eps); + +%!test +%! ## Compare to conv2 +%! a = rand (100); +%! b = ones (3); +%! c2 = conv2 (a, b, "same"); +%! cn = convn (a, b, "same"); +%! assert (max (abs (cn(:)-c2(:))), 0, 100*eps); + +%!test +%! ## Compare to conv2 +%! a = rand (100); +%! b = ones (3); +%! c2 = conv2 (a, b, "valid"); +%! cn = convn (a, b, "valid"); +%! assert (max (abs (cn(:)-c2(:))), 0, 100*eps); + +%!test +%! ## Real data +%! a = ones (10,10,10); +%! b = ones (3,3,3); +%! c = convn (a, b, "valid"); +%! assert (all (c == numel (b))); + +%!test +%! ## Complex data +%! a = complex( ones (10,10,10), ones(10,10,10) ); +%! b = complex( ones (3,3,3), ones(3,3,3) ); +%! c = convn (a, b, "valid"); +%! assert (all (c == 2*i*numel (b))); +
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-03-26 Soren Hauberg <hauberg@gmail.com> + + * DLD-FUNCTIONS/__convn__.cc (Fconvn): + Call complex_array_value to extract N-d array. + 2008-03-26 John W. Eaton <jwe@octave.org> * ov-base-sparse.cc (octave_base_sparse<T>::print_raw):
--- a/src/DLD-FUNCTIONS/__convn__.cc +++ b/src/DLD-FUNCTIONS/__convn__.cc @@ -118,8 +118,8 @@ } else if (args(0).is_complex_type () && args(1).is_complex_type ()) { - const ComplexNDArray a = args (0).complex_matrix_value (); - const ComplexNDArray b = args (1).complex_matrix_value (); + const ComplexNDArray a = args (0).complex_array_value (); + const ComplexNDArray b = args (1).complex_array_value (); if (! error_state) retval = convn<ComplexNDArray, Complex> (a, b);