39 @deftypefn {Built-in Function} {} conv2 (@var{A}, @var{B})\n\
40 @deftypefnx {Built-in Function} {} conv2 (@var{v1}, @var{v2}, @var{m})\n\
41 @deftypefnx {Built-in Function} {} conv2 (@dots{}, @var{shape})\n\
42 Return the 2-D convolution of @var{A} and @var{B}.\n\
44 The size of the result is determined by the optional @var{shape} argument\n\
45 which takes the following values\n\
48 @item @var{shape} = @qcode{\"full\"}\n\
49 Return the full convolution. (default)\n\
51 @item @var{shape} = @qcode{\"same\"}\n\
52 Return the central part of the convolution with the same size as @var{A}.\n\
53 The central part of the convolution begins at the indices\n\
54 @code{floor ([size(@var{B})/2] + 1)}.\n\
56 @item @var{shape} = @qcode{\"valid\"}\n\
57 Return only the parts which do not include zero-padded edges.\n\
58 The size of the result is @code{max (size (A) - size (B) + 1, 0)}.\n\
61 When the third argument is a matrix, return the convolution of the matrix\n\
62 @var{m} by the vector @var{v1} in the column direction and by the vector\n\
63 @var{v2} in the row direction.\n\
64 @seealso{conv, convn}\n\
69 int nargin = args.
length ();
70 std::string shape =
"full";
71 bool separable =
false;
81 if (args(2).is_string ())
89 shape = args(3).string_value ();
92 if (args(0).ndims () > 2 || args(1).ndims () > 2)
94 error (
"conv2: A and B must be 1-D vectors or 2-D matrices");
100 else if (shape ==
"same")
102 else if (shape ==
"valid")
106 error (
"conv2: SHAPE type not valid");
115 if (! (1 == args(0).rows () || 1 == args(0).columns ())
116 || ! (1 == args(1).rows () || 1 == args(1).columns ()))
122 if (args(0).is_single_type () || args(1).is_single_type ()
123 || args(2).is_single_type ())
125 if (args(0).is_complex_type () || args(1).is_complex_type ()
126 || args(2).is_complex_type ())
129 if (args(1).is_real_type () && args(2).is_real_type ())
133 retval =
convn (a, v1, v2, ct);
139 retval =
convn (a, v1, v2, ct);
147 retval =
convn (a, v1, v2, ct);
152 if (args(0).is_complex_type () || args(1).is_complex_type ()
153 || args(2).is_complex_type ())
156 if (args(1).is_real_type () && args(2).is_real_type ())
160 retval =
convn (a, v1, v2, ct);
166 retval =
convn (a, v1, v2, ct);
173 Matrix a (args(2).matrix_value ());
174 retval =
convn (a, v1, v2, ct);
180 if (args(0).is_single_type () || args(1).is_single_type ())
182 if (args(0).is_complex_type () || args(1).is_complex_type ())
185 if (args(1).is_real_type ())
188 retval =
convn (a, b, ct);
193 retval =
convn (a, b, ct);
200 retval =
convn (a, b, ct);
205 if (args(0).is_complex_type () || args(1).is_complex_type ())
208 if (args(1).is_real_type ())
210 Matrix b (args(1).matrix_value ());
211 retval =
convn (a, b, ct);
216 retval =
convn (a, b, ct);
221 Matrix a (args(0).matrix_value ());
222 Matrix b (args(1).matrix_value ());
223 retval =
convn (a, b, ct);
296 @deftypefn {Built-in Function} {@var{C} =} convn (@var{A}, @var{B})\n\
297 @deftypefnx {Built-in Function} {@var{C} =} convn (@var{A}, @var{B}, @var{shape})\n\
298 Return the n-D convolution of @var{A} and @var{B}.\n\
300 The size of the result is determined by the optional @var{shape} argument\n\
301 which takes the following values\n\
304 @item @var{shape} = @qcode{\"full\"}\n\
305 Return the full convolution. (default)\n\
307 @item @var{shape} = @qcode{\"same\"}\n\
308 Return central part of the convolution with the same size as @var{A}.\n\
309 The central part of the convolution begins at the indices\n\
310 @code{floor ([size(@var{B})/2] + 1)}.\n\
312 @item @var{shape} = @qcode{\"valid\"}\n\
313 Return only the parts which do not include zero-padded edges.\n\
314 The size of the result is @code{max (size (A) - size (B) + 1, 0)}.\n\
317 @seealso{conv2, conv}\n\
322 int nargin = args.
length ();
323 std::string shape =
"full";
326 if (nargin < 2 || nargin > 3)
331 else if (nargin == 3)
333 if (args(2).is_string ())
337 error (
"convn: SHAPE must be a string");
344 else if (shape ==
"same")
346 else if (shape ==
"valid")
350 error (
"convn: SHAPE type not valid");
355 if (args(0).is_single_type () || args(1).is_single_type ())
357 if (args(0).is_complex_type () || args(1).is_complex_type ())
360 if (args(1).is_real_type ())
363 retval =
convn (a, b, ct);
368 retval =
convn (a, b, ct);
375 retval =
convn (a, b, ct);
380 if (args(0).is_complex_type () || args(1).is_complex_type ())
383 if (args(1).is_real_type ())
386 retval =
convn (a, b, ct);
391 retval =
convn (a, b, ct);
398 retval =
convn (a, b, ct);
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
NDArray convn(const NDArray &a, const NDArray &b, convn_type ct)
const octave_base_value const Array< octave_idx_type > &ra_idx octave_int16_scalar & v1
std::string string_value(bool force=false) const
octave_idx_type length(void) const
const octave_char_matrix & v2
Array< octave_value > array_value(void) const