annotate src/DLD-FUNCTIONS/conv2.cc @ 14138:72c96de7a403 stable

maint: update copyright notices for 2012
author John W. Eaton <jwe@octave.org>
date Mon, 02 Jan 2012 14:25:41 -0500
parents cf5ebc0e47e4
children 846273dae16b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
1 /*
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13219
diff changeset
3 Copyright (C) 1999-2012 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
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
5
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
7
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
11 option) any later version.
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
12
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
16 for more details.
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
17
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
20 <http://www.gnu.org/licenses/>.
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
21
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
22 */
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
23
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
26 #endif
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
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
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
30 #include "defun-dld.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
31 #include "error.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
32 #include "oct-obj.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
33 #include "utils.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
34
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
35 enum Shape { SHAPE_FULL, SHAPE_SAME, SHAPE_VALID };
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
36
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
37 /*
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
38 %!test
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
39 %! b = [0,1,2,3;1,8,12,12;4,20,24,21;7,22,25,18];
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
40 %! assert(conv2([0,1;1,2],[1,2,3;4,5,6;7,8,9]),b);
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
41
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
42 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
43 %! b = single([0,1,2,3;1,8,12,12;4,20,24,21;7,22,25,18]);
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
44 %! assert(conv2(single([0,1;1,2]),single([1,2,3;4,5,6;7,8,9])),b);
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
45
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
46 %!assert (conv2 (1:3, 1:2, [1,2;3,4;5,6]),
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
47 %! [1,4,4;5,18,16;14,48,40;19,62,48;15,48,36;]);
11085
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
48
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
49 %!assert (conv2 (1:3, 1:2, [1,2;3,4;5,6], "full"),
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
50 %! conv2 (1:3, 1:2, [1,2;3,4;5,6]));
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
51
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
52 */
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
53
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
54
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
55 DEFUN_DLD (conv2, args, ,
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
56 "-*- texinfo -*-\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
57 @deftypefn {Loadable Function} {} conv2 (@var{A}, @var{B})\n\
11085
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
58 @deftypefnx {Loadable Function} {} conv2 (@var{v1}, @var{v2}, @var{m})\n\
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
59 @deftypefnx {Loadable Function} {} conv2 (@dots{}, @var{shape})\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
60 Return the 2-D convolution of @var{A} and @var{B}. The size of the result\n\
11085
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
61 is determined by the optional @var{shape} argument which takes the following\n\
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
62 values\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
63 \n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
64 @table @asis\n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
65 @item @var{shape} = \"full\"\n\
11085
2beacd515e09 Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents: 11083
diff changeset
66 Return the full convolution. (default)\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
67 \n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
68 @item @var{shape} = \"same\"\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
69 Return the central part of the convolution with the same size as @var{A}.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
70 \n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
71 @item @var{shape} = \"valid\"\n\
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
72 Return only the parts which do not include zero-padded edges.\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
73 @end table\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
74 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
75 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
76 @var{m} by the vector @var{v1} in the column direction and by the vector\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
77 @var{v2} in the row direction\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
78 @seealso{conv, convn}\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
79 @end deftypefn")
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
80 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
81 octave_value retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
82 octave_value tmp;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
83 int nargin = args.length ();
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
84 std::string shape = "full"; //default
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
85 bool separable = false;
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
86 convn_type ct;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
87
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
88 if (nargin < 2)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
89 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5822
diff changeset
90 print_usage ();
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
91 return retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
92 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
93 else if (nargin == 3)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
94 {
5822
4fdc2515ebad [project @ 2006-05-18 19:31:36 by jwe]
jwe
parents: 5819
diff changeset
95 if (args(2).is_string ())
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
96 shape = args(2).string_value ();
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
97 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
98 separable = true;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
99 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
100 else if (nargin >= 4)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
101 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
102 separable = true;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
103 shape = args(3).string_value ();
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
104 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
105
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
106 if (shape == "full")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
107 ct = convn_full;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
108 else if (shape == "same")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
109 ct = convn_same;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
110 else if (shape == "valid")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
111 ct = convn_valid;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
112 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
113 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
114 error ("conv2: SHAPE type not valid");
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5822
diff changeset
115 print_usage ();
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
116 return retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
117 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
118
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
119 if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
120 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
121 // If user requests separable, check first two params are vectors
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
122
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
123 if (! (1 == args(0).rows () || 1 == args(0).columns ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
124 || ! (1 == args(1).rows () || 1 == args(1).columns ()))
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
125 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
126 print_usage ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
127 return retval;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
128 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
129
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
130 if (args(0).is_single_type () || args(1).is_single_type ()
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
131 || args(2).is_single_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
132 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
133 if (args(0).is_complex_type () || args(1).is_complex_type ()
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
134 || args(2).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
135 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
136 FloatComplexMatrix a (args(2).float_complex_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
137 if (args(1).is_real_type () && args(2).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
138 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
139 FloatColumnVector v1 (args(0).float_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
140 FloatRowVector v2 (args(1).float_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
141 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
142 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
143 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
144 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
145 FloatComplexColumnVector v1 (args(0).float_complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
146 FloatComplexRowVector v2 (args(1).float_complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
147 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
148 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
149 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
150 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
151 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
152 FloatColumnVector v1 (args(0).float_vector_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
153 FloatRowVector v2 (args(1).float_vector_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
154 FloatMatrix a (args(2).float_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
155 retval = convn (a, v1, v2, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
156 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
157 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
158 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
159 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
160 if (args(0).is_complex_type () || args(1).is_complex_type ()
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
161 || args(2).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
162 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
163 ComplexMatrix a (args(2).complex_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
164 if (args(1).is_real_type () && args(2).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
165 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
166 ColumnVector v1 (args(0).vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
167 RowVector v2 (args(1).vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
168 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
169 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
170 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
171 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
172 ComplexColumnVector v1 (args(0).complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
173 ComplexRowVector v2 (args(1).complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
174 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
175 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
176 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
177 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
178 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
179 ColumnVector v1 (args(0).vector_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
180 RowVector v2 (args(1).vector_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
181 Matrix a (args(2).matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
182 retval = convn (a, v1, v2, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
183 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
184 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
185 } // if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
186 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
187 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
188 if (args(0).is_single_type () || args(1).is_single_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
189 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
190 if (args(0).is_complex_type () || args(1).is_complex_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
191 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
192 FloatComplexMatrix a (args(0).float_complex_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
193 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
194 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
195 FloatMatrix b (args(1).float_matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
196 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
197 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
198 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
199 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
200 FloatComplexMatrix b (args(1).float_complex_matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
201 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
202 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
203 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
204 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
205 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
206 FloatMatrix a (args(0).float_matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
207 FloatMatrix b (args(1).float_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
208 retval = convn (a, b, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
209 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
210 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
211 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
212 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
213 if (args(0).is_complex_type () || args(1).is_complex_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
214 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
215 ComplexMatrix a (args(0).complex_matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
216 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
217 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
218 Matrix b (args(1).matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
219 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
220 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
221 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
222 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
223 ComplexMatrix b (args(1).complex_matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
224 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
225 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
226 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
227 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
228 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
229 Matrix a (args(0).matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
230 Matrix b (args(1).matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
231 retval = convn (a, b, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
232 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
233 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
234
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
235 } // if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
236
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
237 return retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
238 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
239
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
240 DEFUN_DLD (convn, args, ,
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
241 "-*- texinfo -*-\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
242 @deftypefn {Loadable Function} {@var{C} =} convn (@var{A}, @var{B}, @var{shape})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
243 Return the n-D convolution of @var{A} and @var{B} where the size\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
244 of @var{C} is given by\n\
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
245 \n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
246 @table @asis\n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
247 @item @var{shape} = \"full\"\n\
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
248 Return the full convolution.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
249 \n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
250 @item @var{shape} = \"same\"\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
251 Return central part of the convolution with the same size as @var{A}.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
252 \n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
253 @item @var{shape} = \"valid\"\n\
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
254 Return only the parts which do not include zero-padded edges.\n\
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
255 @end table\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
256 \n\
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
257 By default @var{shape} is @samp{\"full\"}.\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
258 @seealso{conv2, conv}\n\
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
259 @end deftypefn")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
260 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
261 octave_value retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
262 octave_value tmp;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
263 int nargin = args.length ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
264 std::string shape = "full"; //default
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
265 convn_type ct;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
266
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
267 if (nargin < 2 || nargin > 3)
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
268 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
269 print_usage ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
270 return retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
271 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
272 else if (nargin == 3)
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
273 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
274 if (args(2).is_string ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
275 shape = args(2).string_value ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
276 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
277
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
278 if (shape == "full")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
279 ct = convn_full;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
280 else if (shape == "same")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
281 ct = convn_same;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
282 else if (shape == "valid")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
283 ct = convn_valid;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
284 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
285 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
286 error ("convn: SHAPE type not valid");
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
287 print_usage ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
288 return retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
289 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
290
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
291 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
292 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
293 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
294 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
295 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
296 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
297 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
298 FloatNDArray b (args(1).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
299 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
300 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
301 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
302 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
303 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
304 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
305 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
306 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
307 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
308 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
309 FloatNDArray a (args(0).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
310 FloatNDArray b (args(1).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
311 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
312 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
313 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
314 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
315 {
11083
bb8bf77f2242 conv2.cc: style fixes; update docstrings
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
316 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
317 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
318 ComplexNDArray a (args(0).complex_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
319 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
320 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
321 NDArray b (args(1).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
322 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
323 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
324 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
325 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
326 ComplexNDArray b (args(1).complex_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
327 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
328 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
329 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
330 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
331 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
332 NDArray a (args(0).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
333 NDArray b (args(1).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
334 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
335 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
336 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
337
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
338 return retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
339 }