annotate src/DLD-FUNCTIONS/conv2.cc @ 10840:89f4d7e294cc

Grammarcheck .cc files
author Rik <octave@nomad.inbox5.com>
date Sat, 31 Jul 2010 11:18:11 -0700
parents 8615b55b5caf
children bb8bf77f2242
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 7814
diff changeset
3 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 Andy Adler
10498
8615b55b5caf fix & improve cat (bug #29465)
Jaroslav Hajek <highegg@gmail.com>
parents: 10384
diff changeset
5 Copyright (C) 2010 VZLU Prague
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
6
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
8
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
9 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
10 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
11 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
12 option) any later version.
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
13
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
14 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
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
16 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
17 for more details.
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
18
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
19 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
20 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
21 <http://www.gnu.org/licenses/>.
5819
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
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
27 #endif
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
28
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
29 #include "oct-convn.h"
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
30
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
31 #include "defun-dld.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
32 #include "error.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
33 #include "oct-obj.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
34 #include "utils.h"
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
35
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
36 enum Shape { SHAPE_FULL, SHAPE_SAME, SHAPE_VALID };
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 /*
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
39 %!test
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
40 %! 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
41 %! 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
42
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
43 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
44 %! 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
45 %! 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
46
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
47 %!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
48 %! [1,4,4;5,18,16;14,48,40;19,62,48;15,48,36;]);
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
49 */
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
50
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
51
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
52 DEFUN_DLD (conv2, args, ,
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
53 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
54 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
55 @deftypefnx {Loadable Function} {y =} conv2 (@var{v1}, @var{v2}, @var{M}, @var{shape})\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
56 \n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
57 Returns 2D convolution of @var{a} and @var{b} where the size\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
58 of @var{c} is given by\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
59 \n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
60 @table @asis\n\
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
61 @item @var{shape} = 'full'\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
62 returns full 2-D convolution\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
63 \n\
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
64 @item @var{shape} = 'same'\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
65 same size as a. 'central' part of convolution\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
66 \n\
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
67 @item @var{shape} = 'valid'\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
68 only parts which do not include zero-padded edges\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
69 @end table\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
70 \n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
71 By default @var{shape} is 'full'. When the third argument is a matrix\n\
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
72 returns the convolution of the matrix @var{M} by the vector @var{v1}\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
73 in the column direction and by vector @var{v2} in the row direction\n\
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
74 @end deftypefn")
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
75 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
76 octave_value retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
77 octave_value tmp;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
78 int nargin = args.length ();
10371
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
79 std::string shape = "full"; //default
dc8637fd7a76 improve conv2 performance
John W. Eaton <jwe@octave.org>
parents: 10368
diff changeset
80 bool separable = false;
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
81 convn_type ct;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
82
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
83 if (nargin < 2)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
84 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5822
diff changeset
85 print_usage ();
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
86 return retval;
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 else if (nargin == 3)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
89 {
5822
4fdc2515ebad [project @ 2006-05-18 19:31:36 by jwe]
jwe
parents: 5819
diff changeset
90 if (args(2).is_string ())
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
91 shape = args(2).string_value ();
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
92 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
93 separable = true;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
94 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
95 else if (nargin >= 4)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
96 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
97 separable = true;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
98 shape = args(3).string_value ();
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
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
101 if (shape == "full")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
102 ct = convn_full;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
103 else if (shape == "same")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
104 ct = convn_same;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
105 else if (shape == "valid")
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
106 ct = convn_valid;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
107 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
108 {
5822
4fdc2515ebad [project @ 2006-05-18 19:31:36 by jwe]
jwe
parents: 5819
diff changeset
109 error ("conv2: shape type not valid");
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5822
diff changeset
110 print_usage ();
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
111 return retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
112 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
113
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
114 if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
115 {
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
116 // If user requests separable, check first two params are vectors
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 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
119 || ! (1 == args(1).rows () || 1 == args(1).columns ()))
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
120 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
121 print_usage ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
122 return retval;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
123 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
124
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
125 if (args(0).is_single_type () ||
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
126 args(1).is_single_type () ||
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
127 args(2).is_single_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
128 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
129 if (args(0).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
130 || args(1).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
131 || args(2).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
132 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
133 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
134 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
135 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
136 FloatColumnVector v1 (args(0).float_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
137 FloatRowVector v2 (args(1).float_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
138 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
139 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
140 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
141 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
142 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
143 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
144 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
145 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
146 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
147 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
148 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
149 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
150 FloatRowVector v2 (args(1).float_vector_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
151 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
152 retval = convn (a, v1, v2, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
153 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
154 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
155 else
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 if (args(0).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
158 || args(1).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
159 || args(2).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
160 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
161 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
162 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
163 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
164 ColumnVector v1 (args(0).vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
165 RowVector v2 (args(1).vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
166 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
167 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
168 else
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 ComplexColumnVector v1 (args(0).complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
171 ComplexRowVector v2 (args(1).complex_vector_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
172 retval = convn (a, v1, v2, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
173 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
174 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
175 else
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 ColumnVector v1 (args(0).vector_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
178 RowVector v2 (args(1).vector_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
179 Matrix a (args(2).matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
180 retval = convn (a, v1, v2, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
181 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
182 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
183 } // if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
184 else
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
185 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
186 if (args(0).is_single_type () ||
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
187 args(1).is_single_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
188 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
189 if (args(0).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
190 || args(1).is_complex_type ())
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 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
213 if (args(0).is_complex_type ()
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
214 || args(1).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
215 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
216 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
217 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
218 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
219 Matrix b (args(1).matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
220 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
221 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
222 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
223 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
224 ComplexMatrix b (args(1).complex_matrix_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
225 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
226 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
227 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
228 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
229 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
230 Matrix a (args(0).matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
231 Matrix b (args(1).matrix_value ());
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
232 retval = convn (a, b, ct);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
233 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
234 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
235
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
236 } // if (separable)
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
237
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
238 return retval;
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
239 }
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
240
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
241 DEFUN_DLD (convn, args, ,
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
242 "-*- texinfo -*-\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
243 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
244 \n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
245 Returns n-D convolution of @var{a} and @var{b} where the size\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
246 of @var{c} is given by\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
247 \n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
248 @table @asis\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
249 @item @var{shape} = 'full'\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
250 returns full n-D convolution\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
251 \n\
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
252 @item @var{shape} = 'same'\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
253 same size as a. 'central' part of convolution\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10498
diff changeset
254 \n\
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
255 @item @var{shape} = 'valid'\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
256 only parts which do not include zero-padded edges\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
257 @end table\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
258 \n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
259 By default @var{shape} is 'full'.\n\
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
260 @end deftypefn")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
261 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
262 octave_value retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
263 octave_value tmp;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
264 int nargin = args.length ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
265 std::string shape = "full"; //default
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
266 bool separable = false;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
267 convn_type ct;
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
268
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
269 if (nargin < 2 || nargin > 3)
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
270 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
271 print_usage ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
272 return retval;
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 else if (nargin == 3)
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
275 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
276 if (args(2).is_string ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
277 shape = args(2).string_value ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
278 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
279 separable = true;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
280 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
281
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
282 if (shape == "full")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
283 ct = convn_full;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
284 else if (shape == "same")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
285 ct = convn_same;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
286 else if (shape == "valid")
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
287 ct = convn_valid;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
288 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
289 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
290 error ("convn: shape type not valid");
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
291 print_usage ();
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
292 return retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
293 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
294
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
295 if (args(0).is_single_type () ||
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
296 args(1).is_single_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 if (args(0).is_complex_type ()
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
299 || args(1).is_complex_type ())
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 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
302 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
303 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
304 FloatNDArray b (args(1).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
305 retval = convn (a, b, ct);
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 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
310 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
311 }
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 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
314 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
315 FloatNDArray a (args(0).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
316 FloatNDArray b (args(1).float_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
317 retval = convn (a, b, ct);
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 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
320 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
321 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
322 if (args(0).is_complex_type ()
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
323 || args(1).is_complex_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
324 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
325 ComplexNDArray a (args(0).complex_array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
326 if (args(1).is_real_type ())
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
327 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
328 NDArray b (args(1).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
329 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
330 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
331 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
332 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
333 ComplexNDArray b (args(1).complex_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 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
337 else
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
338 {
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
339 NDArray a (args(0).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
340 NDArray b (args(1).array_value ());
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
341 retval = convn (a, b, ct);
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
342 }
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
343 }
5819
e54c11df0524 [project @ 2006-05-17 20:34:52 by jwe]
jwe
parents:
diff changeset
344
10384
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
345 return retval;
978f5c94b11f initial implementation of conv2/convn in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10371
diff changeset
346 }