# HG changeset patch # User address@hidden # Date 1206543401 -3600 # Node ID feb96d654d3adcf6689c483a3e01401e622eea0d # Parent 0220da981c2a4f9fc5171ea037c1bec4efc5271b Added tests to scripts/polynomial/convn.m and allow '__convn__' to actually get N-dimensional complex data. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ 2008-03-20 Ben Abbott + + * polynomial/convn.m: Added test cases. + 2008-03-20 Ben Abbott * statistics/base/statistics.m: Calculate median and quantiles in diff --git a/scripts/polynomial/convn.m b/scripts/polynomial/convn.m --- 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 @@ function a = pad (a, left, right) 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))); + diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ 2008-03-25 Soren Hauberg + + * DLD-FUNCTIONS/__convn__.cc: Changed call to 'complex_matrix_value' to + 'complex_array_value' to actually support N-dimensonal complex data. + 2008-03-25 Soren Hauberg * DLD-FUNCTIONS/__convn__.cc: New file. diff --git a/src/DLD-FUNCTIONS/__convn__.cc b/src/DLD-FUNCTIONS/__convn__.cc --- a/src/DLD-FUNCTIONS/__convn__.cc +++ b/src/DLD-FUNCTIONS/__convn__.cc @@ -118,8 +118,8 @@ Undocumented internal function.\n\ } 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 (a, b);