Mercurial > octave
annotate libinterp/corefcn/conv2.cc @ 20940:48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
* libinterp/corefcn/oct-obj.h: Replaced. Contains a #warning issued if used in
compilation and includes "ovl.h" instead. Original file renamed to
libinterp/octave-value/ovl.h
* libinterp/corefcn/oct-obj.cc: Renamed to libinterp/octave-value/ovl.cc.
* oct-obj.cc (ovl ()): Added new function to return empty octave_value_list.
* libinterp/corefcn/module.mk: Remove oct-obj.cc from build system.
* libinterp/octave-value/module.mk: Add ovl.h and ovl.cc to build system.
* mk-opts.pl, annotation-dialog.h, Cell.cc, __contourc__.cc, __dsearchn__.cc,
__lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc,
betainc.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, dlmread.cc, eig.cc,
error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc,
graphics.cc, gripes.cc, help.cc, hess.cc, hex2num.cc, hook-fcn.h, input.cc,
input.h, inv.cc, kron.cc, load-save.cc, lookup.cc, ls-hdf5.cc, ls-mat-ascii.cc,
ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lsode.cc, lu.cc,
luinc.cc, max.cc, mex.cc, oct-hist.cc, oct-lvalue.cc, oct-lvalue.h, oct-map.h,
oct-stream.cc, oct.h, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, quad.cc,
quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sparse-xpow.cc,
strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.h, syscalls.cc, sysdep.cc,
time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc,
variables.cc, xpow.cc, __delaunayn__.cc, __glpk__.cc, __voronoi__.cc,
audiodevinfo.cc, audioread.cc, chol.cc, convhulln.cc, dmperm.cc, qr.cc,
symbfact.cc, mkbuiltins, ov-base-diag.h, ov-base-int.cc, ov-base-mat.cc,
ov-base-mat.h, ov-base-scalar.cc, ov-base-sparse.cc, ov-base-sparse.h,
ov-base.cc, ov-bool-mat.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-colon.cc,
ov-complex.cc, ov-cs-list.h, ov-cx-mat.cc, ov-dld-fcn.cc, ov-fcn.cc, ov-fcn.h,
ov-float.cc, ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc,
ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.h, ov-mex-fcn.cc,
ov-perm.h, ov-range.cc, ov-re-mat.cc, ov-scalar.cc, ov-str-mat.cc,
ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, octave.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc,
op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc,
op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc,
op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc,
op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc,
op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc,
op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc,
op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc,
op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc,
op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc,
parse.h, pt-arg-list.cc, pt-assign.cc, pt-binop.cc, pt-cbinop.cc, pt-cell.cc,
pt-colon.cc, pt-const.cc, pt-eval.h, pt-fcn-handle.cc, pt-funcall.h, pt-id.cc,
pt-idx.cc, pt-jump.cc, pt-mat.cc, pt-select.cc, pt-unop.cc, token.cc,
Array-sym.cc: replace '#include "oct-obj.h"' with '#include "ovl.h"'.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Dec 2015 16:04:56 -0800 |
parents | 6f0bd96f93c0 |
children | fcac5dbbf9ed |
rev | line source |
---|---|
5819 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17837
diff
changeset
|
3 Copyright (C) 1999-2015 Andy Adler |
10498
8615b55b5caf
fix & improve cat (bug #29465)
Jaroslav Hajek <highegg@gmail.com>
parents:
10384
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
5819 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5819 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5819 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
28 #include "oct-convn.h" |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
29 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14607
diff
changeset
|
30 #include "defun.h" |
5819 | 31 #include "error.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20918
diff
changeset
|
32 #include "ovl.h" |
5819 | 33 #include "utils.h" |
34 | |
35 enum Shape { SHAPE_FULL, SHAPE_SAME, SHAPE_VALID }; | |
36 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14607
diff
changeset
|
37 DEFUN (conv2, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
38 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20808
diff
changeset
|
39 @deftypefn {} {} conv2 (@var{A}, @var{B})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20808
diff
changeset
|
40 @deftypefnx {} {} conv2 (@var{v1}, @var{v2}, @var{m})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20808
diff
changeset
|
41 @deftypefnx {} {} conv2 (@dots{}, @var{shape})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
42 Return the 2-D convolution of @var{A} and @var{B}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
43 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
44 The size of the result is determined by the optional @var{shape} argument\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
45 which takes the following values\n\ |
5819 | 46 \n\ |
47 @table @asis\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
48 @item @var{shape} = @qcode{\"full\"}\n\ |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
11083
diff
changeset
|
49 Return the full convolution. (default)\n\ |
10840 | 50 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
51 @item @var{shape} = @qcode{\"same\"}\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
52 Return the central part of the convolution with the same size as @var{A}.\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 The central part of the convolution begins at the indices\n\ |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 @code{floor ([size(@var{B})/2] + 1)}.\n\ |
10840 | 55 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
56 @item @var{shape} = @qcode{\"valid\"}\n\ |
11083
bb8bf77f2242
conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
57 Return only the parts which do not include zero-padded edges.\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 The size of the result is @code{max (size (A) - size (B) + 1, 0)}.\n\ |
5819 | 59 @end table\n\ |
60 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
61 When the third argument is a matrix, return the convolution of the matrix\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
62 @var{m} by the vector @var{v1} in the column direction and by the vector\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
63 @var{v2} in the row direction.\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 @seealso{conv, convn}\n\ |
5819 | 65 @end deftypefn") |
66 { | |
67 int nargin = args.length (); | |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
68 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
69 if (nargin < 2 || nargin > 4) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
70 print_usage (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
71 |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
72 std::string shape = "full"; // default |
10371 | 73 bool separable = false; |
20808 | 74 convn_type ct = convn_full; |
5819 | 75 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
76 if (nargin == 3) |
5819 | 77 { |
5822 | 78 if (args(2).is_string ()) |
5819 | 79 shape = args(2).string_value (); |
80 else | |
81 separable = true; | |
82 } | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
83 else if (nargin == 4) |
5819 | 84 { |
85 separable = true; | |
86 shape = args(3).string_value (); | |
87 } | |
88 | |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
89 if (args(0).ndims () > 2 || args(1).ndims () > 2) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
90 error ("conv2: A and B must be 1-D vectors or 2-D matrices"); |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
91 |
5819 | 92 if (shape == "full") |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
93 ct = convn_full; |
5819 | 94 else if (shape == "same") |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
95 ct = convn_same; |
5819 | 96 else if (shape == "valid") |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
97 ct = convn_valid; |
5819 | 98 else |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
99 error ("conv2: SHAPE type not valid"); |
5819 | 100 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
101 octave_value retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
102 |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
103 if (separable) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
104 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 // If user requests separable, check first two params are vectors |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
106 if (! (1 == args(0).rows () || 1 == args(0).columns ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
107 || ! (1 == args(1).rows () || 1 == args(1).columns ())) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
108 error ("conv2: arguments must be vectors for separable option"); |
5819 | 109 |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
110 if (args(0).is_single_type () || args(1).is_single_type () |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
111 || args(2).is_single_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
112 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
113 if (args(0).is_complex_type () || args(1).is_complex_type () |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
114 || args(2).is_complex_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
115 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
116 FloatComplexMatrix a (args(2).float_complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
117 if (args(1).is_real_type () && args(2).is_real_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
118 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
119 FloatColumnVector v1 (args(0).float_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
120 FloatRowVector v2 (args(1).float_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
121 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
122 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
123 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
124 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
125 FloatComplexColumnVector v1 (args(0).float_complex_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
126 FloatComplexRowVector v2 (args(1).float_complex_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
127 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
128 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
129 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
130 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
131 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
132 FloatColumnVector v1 (args(0).float_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
133 FloatRowVector v2 (args(1).float_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
134 FloatMatrix a (args(2).float_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
135 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
136 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
137 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
138 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
139 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
140 if (args(0).is_complex_type () || args(1).is_complex_type () |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
141 || args(2).is_complex_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
142 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
143 ComplexMatrix a (args(2).complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
144 if (args(1).is_real_type () && args(2).is_real_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
145 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
146 ColumnVector v1 (args(0).vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
147 RowVector v2 (args(1).vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
148 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
149 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
150 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
151 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
152 ComplexColumnVector v1 (args(0).complex_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
153 ComplexRowVector v2 (args(1).complex_vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
154 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
155 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
156 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
157 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
158 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
159 ColumnVector v1 (args(0).vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
160 RowVector v2 (args(1).vector_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
161 Matrix a (args(2).matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
162 retval = convn (a, v1, v2, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
163 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
164 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
165 } // if (separable) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
166 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
167 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
168 if (args(0).is_single_type () || args(1).is_single_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
169 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
170 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
171 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
172 FloatComplexMatrix a (args(0).float_complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
173 if (args(1).is_real_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
174 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
175 FloatMatrix b (args(1).float_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
176 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
177 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
178 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
179 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
180 FloatComplexMatrix b (args(1).float_complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
181 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
182 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
183 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
184 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
185 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
186 FloatMatrix a (args(0).float_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
187 FloatMatrix b (args(1).float_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
188 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
189 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
190 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
191 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
192 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
193 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
194 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
195 ComplexMatrix a (args(0).complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
196 if (args(1).is_real_type ()) |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
197 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
198 Matrix b (args(1).matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
199 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
200 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
201 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
202 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
203 ComplexMatrix b (args(1).complex_matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
204 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
205 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
206 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
207 else |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
208 { |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
209 Matrix a (args(0).matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
210 Matrix b (args(1).matrix_value ()); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
211 retval = convn (a, b, ct); |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
212 } |
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
213 } |
5819 | 214 |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
215 } // if (separable) |
5819 | 216 |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
217 return retval; |
5819 | 218 } |
219 | |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
220 /* |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
221 %!test |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
222 %! c = [0,1,2,3;1,8,12,12;4,20,24,21;7,22,25,18]; |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
223 %! assert (conv2 ([0,1;1,2], [1,2,3;4,5,6;7,8,9]), c); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
224 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
225 %!test |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
226 %! c = single ([0,1,2,3;1,8,12,12;4,20,24,21;7,22,25,18]); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
227 %! assert (conv2 (single ([0,1;1,2]), single ([1,2,3;4,5,6;7,8,9])), c); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
228 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
229 %!test |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
230 %! c = [1,4,4;5,18,16;14,48,40;19,62,48;15,48,36]; |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
231 %! assert (conv2 (1:3, 1:2, [1,2;3,4;5,6]), c); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
232 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
233 %!assert (conv2 (1:3, 1:2, [1,2;3,4;5,6], "full"), |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
234 %! conv2 (1:3, 1:2, [1,2;3,4;5,6])); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
235 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
236 %% Test shapes |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
237 %!shared A, B, C |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
238 %! A = rand (3, 4); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
239 %! B = rand (4); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
240 %! C = conv2 (A, B); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
241 %!assert (conv2 (A,B, "full"), C) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
242 %!assert (conv2 (A,B, "same"), C(3:5,3:6)) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
243 %!assert (conv2 (A,B, "valid"), zeros (0, 1)) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
244 %!assert (size (conv2 (B,A, "valid")), [2 1]) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
245 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
246 %!test |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
247 %! B = rand (5); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
248 %! C = conv2 (A, B); |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
249 %!assert (conv2 (A,B, "full"), C) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
250 %!assert (conv2 (A,B, "same"), C(3:5,3:6)) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
251 %!assert (conv2 (A,B, "valid"), zeros (0, 0)) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
252 %!assert (size (conv2 (B,A, "valid")), [3 2]) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
253 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
254 %% Clear shared variables so they are not reported for tests below |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
255 %!shared |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
256 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
257 %% Test cases from Bug #34893 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14209
diff
changeset
|
258 %!assert (conv2 ([1:5;1:5], [1:2], "same"), [4 7 10 13 10; 4 7 10 13 10]) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14209
diff
changeset
|
259 %!assert (conv2 ([1:5;1:5]', [1:2]', "same"), [4 7 10 13 10; 4 7 10 13 10]') |
14607
34f067bcac12
maint: Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
diff
changeset
|
260 %!assert (conv2 ([1:5;1:5], [1:2], "valid"), [4 7 10 13; 4 7 10 13]) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14209
diff
changeset
|
261 %!assert (conv2 ([1:5;1:5]', [1:2]', "valid"), [4 7 10 13; 4 7 10 13]') |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
262 |
14597
6980b0f35df9
conv2.c: Unmark a test as a known failure (bug #34893)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14596
diff
changeset
|
263 %!test |
14596
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
264 %! rand ("seed", 42); |
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
265 %! x = rand (100); |
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
266 %! y = ones (5); |
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
267 %! A = conv2 (x, y)(5:end-4,5:end-4); |
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
268 %! B = conv2 (x, y, "valid"); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
269 %! assert (B, A); # Yes, this test is for *exact* equivalence. |
14596
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
270 |
ad1d7a53b1ca
perform convolution properly independently of matrix orientation (bug #34893)
Sunghyun Cho <sodomau@gmail.com>
parents:
14209
diff
changeset
|
271 |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
272 %% Test input validation |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
273 %!error conv2 () |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
274 %!error conv2 (1) |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
275 %!error <must be 1-D vectors or 2-D matrices> conv2 (ones (2), ones (2,2,2)) |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
276 %!error <SHAPE type not valid> conv2 (1,2, "NOT_A_SHAPE") |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
277 %% Test alternate calling form which should be 2 vectors and a matrix |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
278 %!error conv2 (ones (2), 1, 1) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
279 %!error conv2 (1, ones (2), 1) |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
280 */ |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
281 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14607
diff
changeset
|
282 DEFUN (convn, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
283 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20808
diff
changeset
|
284 @deftypefn {} {@var{C} =} convn (@var{A}, @var{B})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20808
diff
changeset
|
285 @deftypefnx {} {@var{C} =} convn (@var{A}, @var{B}, @var{shape})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
286 Return the n-D convolution of @var{A} and @var{B}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
287 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
288 The size of the result is determined by the optional @var{shape} argument\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
289 which takes the following values\n\ |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
290 \n\ |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
291 @table @asis\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
292 @item @var{shape} = @qcode{\"full\"}\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
293 Return the full convolution. (default)\n\ |
10840 | 294 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
295 @item @var{shape} = @qcode{\"same\"}\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
296 Return central part of the convolution with the same size as @var{A}.\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
297 The central part of the convolution begins at the indices\n\ |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
298 @code{floor ([size(@var{B})/2] + 1)}.\n\ |
10840 | 299 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15241
diff
changeset
|
300 @item @var{shape} = @qcode{\"valid\"}\n\ |
11083
bb8bf77f2242
conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
301 Return only the parts which do not include zero-padded edges.\n\ |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
302 The size of the result is @code{max (size (A) - size (B) + 1, 0)}.\n\ |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
303 @end table\n\ |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
304 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
305 @seealso{conv2, conv}\n\ |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
306 @end deftypefn") |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
307 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
308 int nargin = args.length (); |
5819 | 309 |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
310 if (nargin < 2 || nargin > 3) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
311 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
312 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
313 std::string shape = "full"; // default |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
314 convn_type ct = convn_full; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
315 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
316 if (nargin == 3) |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
317 shape = args(2).xstring_value ("convn: SHAPE must be a string"); |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
318 |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
319 if (shape == "full") |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
320 ct = convn_full; |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
321 else if (shape == "same") |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
322 ct = convn_same; |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
323 else if (shape == "valid") |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
324 ct = convn_valid; |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
325 else |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
326 error ("convn: SHAPE type not valid"); |
5819 | 327 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
328 octave_value retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
329 |
11083
bb8bf77f2242
conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
330 if (args(0).is_single_type () || args(1).is_single_type ()) |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
331 { |
11083
bb8bf77f2242
conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
332 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
333 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
334 FloatComplexNDArray a (args(0).float_complex_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
335 if (args(1).is_real_type ()) |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
336 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
337 FloatNDArray b (args(1).float_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
338 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
339 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
340 else |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
341 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
342 FloatComplexNDArray b (args(1).float_complex_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
343 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
344 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
345 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
346 else |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
347 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
348 FloatNDArray a (args(0).float_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
349 FloatNDArray b (args(1).float_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
350 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
351 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
352 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
353 else |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
354 { |
11083
bb8bf77f2242
conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
355 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
356 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
357 ComplexNDArray a (args(0).complex_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
358 if (args(1).is_real_type ()) |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
359 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
360 NDArray b (args(1).array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
361 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
362 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
363 else |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
364 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
365 ComplexNDArray b (args(1).complex_array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
366 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
367 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
368 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
369 else |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
370 { |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
371 NDArray a (args(0).array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
372 NDArray b (args(1).array_value ()); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
373 retval = convn (a, b, ct); |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
374 } |
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
375 } |
5819 | 376 |
15241
2cdace1ba287
Validate conv2 inputs are 2-D matrices (Bug #37200)
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
377 return retval; |
10384
978f5c94b11f
initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10371
diff
changeset
|
378 } |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
379 |
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
380 /* |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
381 ## Check for bug #39314 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
382 %!test |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
383 %! v = reshape ([1 2], [1 1 2]); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
384 %! assert (convn (v, v), reshape ([1 4 4], [1 1 3])); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
385 %! assert (convn (v, v, "same"), reshape ([4 4], [1 1 2])); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
386 %! assert (convn (v, v, "valid"), 4); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
387 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
388 ## The following test may look weird since we are using the output |
17837 | 389 ## of convn to test itself. However, because calculations are done |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
390 ## differently based on the shape option, it will help to catch some |
17837 | 391 ## bugs. See also bug #39314. |
392 ## FIXME: The "valid" option uses an entirely different code path | |
393 ## through C++ and Fortran to calculate inner convolution. | |
394 ## The terms in the convolution added in reverse order compared | |
395 ## to the "full" option. This produces differences on the order | |
396 ## of tens of eps. This should be fixed, but in the meantime | |
397 ## the tests will be marked as xtests. | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
398 %!shared a, b, c |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
399 %! ## test 3D by 3D |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
400 %! a = rand (10, 10, 10); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
401 %! b = rand (3, 3, 3); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
402 %! c = convn (a, b, "full"); |
17834 | 403 %!assert (convn (a, b, "same"), c(2:11,2:11,2:11)) |
17837 | 404 %!xtest |
405 %! assert (convn (a, b, "valid"), c(3:10,3:10,3:10)); | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
406 %! |
17834 | 407 %!test |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
408 %! ## test 3D by 2D |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
409 %! a = rand (10, 10, 10); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
410 %! b = rand (3, 3); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
411 %! c = convn (a, b, "full"); |
17834 | 412 %!assert (convn (a, b, "same"), c(2:11,2:11,:)) |
17837 | 413 %!xtest |
414 %! assert (convn (a, b, "valid"), c(3:10,3:10,:)) | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
415 %! |
17834 | 416 %!test |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
417 %! ## test 2D by 3D |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
418 %! a = rand (10, 10); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
419 %! b = rand (3, 3, 3); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
420 %! c = convn (a, b, "full"); |
17834 | 421 %!assert (convn (a, b, "same"), c(2:11,2:11,2)) |
422 %!assert (convn (a, b, "valid"), c(3:10,3:10,3:2)) # a 7x7x0 matrix | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
423 %! |
17834 | 424 %!test |
425 %! ## test multiple different number of dimensions, with odd and even numbers | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
426 %! a = rand (10, 15, 7, 8, 10); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
427 %! b = rand (4, 3, 2, 3); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
428 %! c = convn (a, b, "full"); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
429 %!assert (convn (a, b, "same"), c(3:12,2:16,2:8,2:9,:)) |
17837 | 430 %!xtest |
431 %! assert (convn (a, b, "valid"), c(4:10,3:15,2:7,3:8,:)) | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
432 |
17834 | 433 %!test |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
434 %! a = reshape (floor (magic (16) /10), [4 8 4 2]); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
435 %! b = reshape (magic (6), [4 3 3]); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
436 %! c = zeros (7, 10, 6, 2); |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
437 %! c(:,:,1,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
438 %! 875 1415 1215 741 288 264 635 1109 687 171 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
439 %! 110 467 1551 1790 1891 1651 1165 900 659 568 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
440 %! 883 1047 1475 1964 2181 2302 2117 1674 579 234 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
441 %! 940 2330 3099 2573 2306 2207 2442 2918 2272 1004 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
442 %! 161 500 1564 2066 2355 2270 2099 1621 1144 831 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
443 %! 644 622 886 1121 1652 1967 1907 1668 529 228 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
444 %! 160 752 1232 768 360 284 668 1132 1380 864]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
445 %! c(:,:,2,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
446 %! 150 1174 1903 1971 2030 1719 1467 1420 1220 472 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
447 %! 986 2243 2603 2385 2308 2530 2971 3181 2266 768 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
448 %! 914 2443 3750 3782 3976 3821 3723 3709 2599 1178 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
449 %! 1922 3374 5198 5472 5563 5853 5794 5543 3578 1820 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
450 %! 1060 2471 3846 3724 3682 3803 3812 3927 2876 1390 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
451 %! 470 2078 3283 3225 2701 2265 2165 2261 2324 1124 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
452 %! 700 1130 1486 1515 1830 2097 2081 2028 1009 348]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
453 %! c(:,:,3,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
454 %! 1350 2127 2461 2082 1694 1909 2230 2621 1681 683 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
455 %! 877 2473 4362 4556 4543 4314 3879 3703 2863 1497 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
456 %! 1934 4219 5874 6117 5966 6051 5984 5714 3891 1562 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
457 %! 1927 5997 8573 8456 8517 8025 7957 8101 6121 2500 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
458 %! 1558 3533 5595 6064 6453 6491 6275 5743 3794 1832 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
459 %! 1950 2762 3455 3423 4019 4578 4807 4857 2304 907 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
460 %! 525 1860 2731 2392 1872 1724 1961 2312 2315 1141]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
461 %! c(:,:,4,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
462 %! 150 1317 2230 2621 2996 2767 2472 2049 1514 583 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
463 %! 1429 3056 3879 3703 3756 3964 4394 4570 3111 1250 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
464 %! 1833 4037 5984 5714 5846 5788 5883 6129 4157 2011 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
465 %! 3143 5469 7957 8101 8063 8475 8564 8439 5306 2538 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
466 %! 2001 4514 6275 5743 5391 5389 5578 6110 4473 1953 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
467 %! 817 3196 4807 4857 4229 3659 3477 3375 3208 1400 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
468 %! 750 1365 1961 2312 2840 2993 2722 2344 1092 323]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
469 %! c(:,:,5,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
470 %! 475 734 1296 1352 1400 1595 1557 1517 960 490 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
471 %! 751 1977 2831 2746 2607 2665 2733 2833 2186 912 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
472 %! 1065 3142 4344 4150 3768 3734 3876 4086 3366 1327 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
473 %! 976 3712 5530 5921 6158 5802 5481 5071 3821 1491 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
474 %! 1397 2996 3971 4003 4088 4180 4199 4146 2649 985 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
475 %! 1273 2121 2555 2247 2378 2624 2908 3229 1788 705 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
476 %! 365 1108 1530 1652 1550 1407 1274 1127 889 264]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
477 %! c(:,:,6,1) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
478 %! 0 133 345 683 982 1058 960 623 310 100 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
479 %! 437 806 1313 1332 1383 1391 1397 1370 864 495 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
480 %! 928 1573 2201 1928 1864 1932 2183 2445 1557 855 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
481 %! 1199 2083 2739 2573 2507 2656 2786 2928 1795 736 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
482 %! 912 1997 2404 2028 1692 1591 1803 2159 1603 599 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
483 %! 345 1092 1526 1666 1593 1437 1275 1116 863 253 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
484 %! 50 235 510 811 998 894 615 318 77 0]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
485 %! c(:,:,1,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
486 %! 840 1350 1176 697 293 320 674 1153 717 180 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
487 %! 142 490 1563 1824 1929 1604 1132 857 624 587 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
488 %! 890 1084 1539 1979 2238 2333 2072 1610 509 202 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
489 %! 966 2263 3034 2518 2250 2235 2512 2992 2305 1016 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
490 %! 200 561 1607 2107 2361 2277 2030 1548 1102 818 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
491 %! 652 631 922 1128 1670 1997 1895 1665 467 197 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
492 %! 160 744 1192 692 292 256 708 1208 1448 900]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
493 %! c(:,:,2,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
494 %! 179 1199 1886 1987 1997 1716 1479 1383 1215 485 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
495 %! 988 2213 2552 2358 2304 2615 3011 3210 2246 744 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
496 %! 921 2483 3747 3768 3960 3835 3712 3698 2588 1183 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
497 %! 1903 3416 5254 5490 5572 5826 5761 5505 3502 1814 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
498 %! 1064 2507 3825 3666 3680 3748 3821 3958 2892 1395 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
499 %! 495 2129 3277 3228 2566 2216 2154 2250 2390 1154 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
500 %! 700 1105 1472 1524 1856 2113 2059 2019 975 325]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
501 %! c(:,:,3,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
502 %! 1302 2104 2439 2006 1723 1931 2280 2685 1678 690 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
503 %! 877 2507 4408 4580 4523 4233 3852 3647 2850 1516 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
504 %! 1949 4238 5895 6143 6018 6063 5930 5656 3847 1538 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
505 %! 1953 5975 8547 8433 8407 8060 7955 8069 6170 2506 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
506 %! 1621 3536 5624 6117 6459 6456 6180 5666 3735 1815 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
507 %! 1904 2751 3429 3366 4122 4622 4840 4864 2242 882 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
508 %! 517 1843 2674 2337 1777 1686 2005 2367 2385 1175]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
509 %! c(:,:,4,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
510 %! 198 1346 2280 2685 2980 2759 2396 1982 1497 576 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
511 %! 1413 2994 3852 3647 3756 4035 4418 4595 3109 1231 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
512 %! 1873 4025 5930 5656 5792 5772 5909 6152 4185 2035 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
513 %! 3110 5510 7955 8069 8139 8456 8541 8439 5276 2541 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
514 %! 1964 4462 6180 5666 5315 5409 5631 6178 4536 1998 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
515 %! 869 3215 4840 4864 4121 3579 3420 3386 3271 1430 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
516 %! 725 1361 2005 2367 2925 3006 2667 2297 1054 325]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
517 %! c(:,:,5,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
518 %! 462 754 1285 1359 1441 1605 1556 1488 938 488 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
519 %! 729 1967 2788 2732 2608 2683 2744 2830 2195 912 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
520 %! 1052 3139 4302 4101 3742 3730 3895 4103 3403 1335 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
521 %! 1007 3725 5577 5964 6165 5754 5407 5006 3846 1507 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
522 %! 1375 2969 3951 3990 4144 4183 4200 4150 2661 998 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
523 %! 1258 2090 2495 2188 2403 2664 2954 3279 1814 723 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
524 %! 388 1127 1551 1673 1525 1390 1253 1139 912 275]; |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
525 %! c(:,:,6,2) = [ |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
526 %! 19 147 384 716 1016 1059 927 570 276 80 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
527 %! 441 791 1298 1320 1401 1396 1409 1367 865 500 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
528 %! 932 1537 2155 1870 1860 1946 2221 2487 1584 874 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
529 %! 1201 2067 2705 2538 2512 2687 2806 2971 1812 756 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
530 %! 925 1976 2363 1971 1636 1600 1844 2239 1664 626 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
531 %! 372 1133 1558 1687 1570 1401 1243 1122 883 264 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
532 %! 60 270 556 857 1024 870 569 282 66 0]; |
17834 | 533 %!assert (convn(a, b, "full"), c) |
534 %!assert (convn(a, b, "same"), c(3:6,2:9,2:5,:)) | |
535 %!assert (convn(a, b, "valid"), c(4,3:8,3:4,:)) | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
536 |
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
537 ## test correct class |
17834 | 538 %!assert (class (convn (rand(5), rand(3))), "double") |
539 %!assert (class (convn (rand(5, "single"), rand(3))), "single") | |
540 %!assert (class (convn (rand(5), rand(3, "single"))), "single") | |
541 %!assert (class (convn (true (5), rand(3))), "double") | |
542 %!assert (class (convn (true (5), rand(3, "single"))), "single") | |
543 %!assert (class (convn (ones(5, "uint8"), rand(3))), "double") | |
544 %!assert (class (convn (rand (3, "single"), ones(5, "uint8"))), "single") | |
17696
92226d09f91a
Return correct convolution for valid shape argument in convn (bug #39314)
Marco Cecchetti <mrcekets@gmail.com>
parents:
17695
diff
changeset
|
545 |
17695
d6f4b01075e0
convn: give error for non-string shape argument.
Carnë Draug <carandraug@octave.org>
parents:
17336
diff
changeset
|
546 %!error convn () |
d6f4b01075e0
convn: give error for non-string shape argument.
Carnë Draug <carandraug@octave.org>
parents:
17336
diff
changeset
|
547 %!error convn (1) |
d6f4b01075e0
convn: give error for non-string shape argument.
Carnë Draug <carandraug@octave.org>
parents:
17336
diff
changeset
|
548 %!error <SHAPE type not valid> convn (1,2, "NOT_A_SHAPE") |
d6f4b01075e0
convn: give error for non-string shape argument.
Carnë Draug <carandraug@octave.org>
parents:
17336
diff
changeset
|
549 %!error convn (rand (3), 1, 1) |
14209
846273dae16b
Return correct part of convolution for 'same' parameter in conv2, convn (Bug #34893).
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
550 */ |