# HG changeset patch # User address@hidden # Date 1206601391 -3600 # Node ID 3b3e31a6942dd4d2b33c73b7133fcb7fee6348c5 # Parent feb96d654d3adcf6689c483a3e01401e622eea0d Allow convolving real data with complex data diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ 2008-03-26 Soren Hauberg + + * DLD-FUNCTIONS/__convn__.cc: Allow convolving real data with complex data. + 2008-03-26 Soren Hauberg * DLD-FUNCTIONS/__convn__.cc: Changed call to 'complex_matrix_value' to 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 @@ -32,9 +32,9 @@ along with Octave; see the file COPYING. #include "defun-dld.h" // FIXME -- this function should maybe be available in liboctave? -template +template octave_value -convn (const MT& a, const MT& b) +convn (const MTa& a, const MTb& b) { octave_value retval; @@ -56,7 +56,7 @@ convn (const MT& a, const MT& b) for (octave_idx_type n = 0; n < ndims; n++) out_size(n) = std::max (a_size(n) - b_size(n) + 1, 0); - MT out = MT (out_size); + MTout out = MTout (out_size); const octave_idx_type out_numel = out.numel (); @@ -114,7 +114,7 @@ Undocumented internal function.\n\ const NDArray b = args (1).array_value (); if (! error_state) - retval = convn (a, b); + retval = convn (a, b); } else if (args(0).is_complex_type () && args(1).is_complex_type ()) { @@ -122,7 +122,23 @@ Undocumented internal function.\n\ const ComplexNDArray b = args (1).complex_array_value (); if (! error_state) - retval = convn (a, b); + retval = convn (a, b); + } + else if (args(0).is_real_type () && args(1).is_complex_type ()) + { + const NDArray a = args (0).array_value (); + const ComplexNDArray b = args (1).complex_array_value (); + + if (! error_state) + retval = convn (a, b); + } + else if (args(0).is_complex_type () && args(1).is_real_type ()) + { + const ComplexNDArray a = args (0).complex_array_value (); + const NDArray b = args (1).array_value (); + + if (! error_state) + retval = convn (a, b); } else error ("__convn__: first and second input should be real, or complex arrays");