Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/conv2.cc @ 11083:bb8bf77f2242
conv2.cc: style fixes; update docstrings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Oct 2010 03:14:59 -0400 |
parents | 89f4d7e294cc |
children | 2beacd515e09 |
comparison
equal
deleted
inserted
replaced
11082:4558aad4c41d | 11083:bb8bf77f2242 |
---|---|
50 | 50 |
51 | 51 |
52 DEFUN_DLD (conv2, args, , | 52 DEFUN_DLD (conv2, args, , |
53 "-*- texinfo -*-\n\ | 53 "-*- texinfo -*-\n\ |
54 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\ | 54 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\ |
55 @deftypefnx {Loadable Function} {y =} conv2 (@var{v1}, @var{v2}, @var{M}, @var{shape})\n\ | 55 @deftypefnx {Loadable Function} {y =} conv2 (@var{v1}, @var{v2}, @var{m}, @var{shape})\n\ |
56 \n\ | 56 Return the 2-D convolution of @var{a} and @var{b} where the size\n\ |
57 Returns 2D convolution of @var{a} and @var{b} where the size\n\ | |
58 of @var{c} is given by\n\ | 57 of @var{c} is given by\n\ |
59 \n\ | 58 \n\ |
60 @table @asis\n\ | 59 @table @asis\n\ |
61 @item @var{shape} = 'full'\n\ | 60 @item @var{shape} = \"full\"\n\ |
62 returns full 2-D convolution\n\ | 61 Return the full convolution.\n\ |
63 \n\ | 62 \n\ |
64 @item @var{shape} = 'same'\n\ | 63 @item @var{shape} = \"same\"\n\ |
65 same size as a. 'central' part of convolution\n\ | 64 Return central part of the convolution with the same size as @var{a}.\n\ |
66 \n\ | 65 \n\ |
67 @item @var{shape} = 'valid'\n\ | 66 @item @var{shape} = \"valid\"\n\ |
68 only parts which do not include zero-padded edges\n\ | 67 Return only the parts which do not include zero-padded edges.\n\ |
69 @end table\n\ | 68 @end table\n\ |
70 \n\ | 69 \n\ |
71 By default @var{shape} is 'full'. When the third argument is a matrix\n\ | 70 By default @var{shape} is @samp{\"full\"}. When the third argument\n\ |
72 returns the convolution of the matrix @var{M} by the vector @var{v1}\n\ | 71 is a matrix, return the convolution of the matrix @var{m} by the vector\n\ |
73 in the column direction and by vector @var{v2} in the row direction\n\ | 72 @var{v1} in the column direction and by vector @var{v2} in the row direction\n\ |
74 @end deftypefn") | 73 @end deftypefn") |
75 { | 74 { |
76 octave_value retval; | 75 octave_value retval; |
77 octave_value tmp; | 76 octave_value tmp; |
78 int nargin = args.length (); | 77 int nargin = args.length (); |
120 { | 119 { |
121 print_usage (); | 120 print_usage (); |
122 return retval; | 121 return retval; |
123 } | 122 } |
124 | 123 |
125 if (args(0).is_single_type () || | 124 if (args(0).is_single_type () || args(1).is_single_type () |
126 args(1).is_single_type () || | 125 || args(2).is_single_type ()) |
127 args(2).is_single_type ()) | 126 { |
128 { | 127 if (args(0).is_complex_type () || args(1).is_complex_type () |
129 if (args(0).is_complex_type () | |
130 || args(1).is_complex_type () | |
131 || args(2).is_complex_type ()) | 128 || args(2).is_complex_type ()) |
132 { | 129 { |
133 FloatComplexMatrix a (args(2).float_complex_matrix_value ()); | 130 FloatComplexMatrix a (args(2).float_complex_matrix_value ()); |
134 if (args(1).is_real_type () && args(2).is_real_type ()) | 131 if (args(1).is_real_type () && args(2).is_real_type ()) |
135 { | 132 { |
152 retval = convn (a, v1, v2, ct); | 149 retval = convn (a, v1, v2, ct); |
153 } | 150 } |
154 } | 151 } |
155 else | 152 else |
156 { | 153 { |
157 if (args(0).is_complex_type () | 154 if (args(0).is_complex_type () || args(1).is_complex_type () |
158 || args(1).is_complex_type () | |
159 || args(2).is_complex_type ()) | 155 || args(2).is_complex_type ()) |
160 { | 156 { |
161 ComplexMatrix a (args(2).complex_matrix_value ()); | 157 ComplexMatrix a (args(2).complex_matrix_value ()); |
162 if (args(1).is_real_type () && args(2).is_real_type ()) | 158 if (args(1).is_real_type () && args(2).is_real_type ()) |
163 { | 159 { |
181 } | 177 } |
182 } | 178 } |
183 } // if (separable) | 179 } // if (separable) |
184 else | 180 else |
185 { | 181 { |
186 if (args(0).is_single_type () || | 182 if (args(0).is_single_type () || args(1).is_single_type ()) |
187 args(1).is_single_type ()) | 183 { |
188 { | 184 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
189 if (args(0).is_complex_type () | |
190 || args(1).is_complex_type ()) | |
191 { | 185 { |
192 FloatComplexMatrix a (args(0).float_complex_matrix_value ()); | 186 FloatComplexMatrix a (args(0).float_complex_matrix_value ()); |
193 if (args(1).is_real_type ()) | 187 if (args(1).is_real_type ()) |
194 { | 188 { |
195 FloatMatrix b (args(1).float_matrix_value ()); | 189 FloatMatrix b (args(1).float_matrix_value ()); |
208 retval = convn (a, b, ct); | 202 retval = convn (a, b, ct); |
209 } | 203 } |
210 } | 204 } |
211 else | 205 else |
212 { | 206 { |
213 if (args(0).is_complex_type () | 207 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
214 || args(1).is_complex_type ()) | |
215 { | 208 { |
216 ComplexMatrix a (args(0).complex_matrix_value ()); | 209 ComplexMatrix a (args(0).complex_matrix_value ()); |
217 if (args(1).is_real_type ()) | 210 if (args(1).is_real_type ()) |
218 { | 211 { |
219 Matrix b (args(1).matrix_value ()); | 212 Matrix b (args(1).matrix_value ()); |
239 } | 232 } |
240 | 233 |
241 DEFUN_DLD (convn, args, , | 234 DEFUN_DLD (convn, args, , |
242 "-*- texinfo -*-\n\ | 235 "-*- texinfo -*-\n\ |
243 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\ | 236 @deftypefn {Loadable Function} {y =} conv2 (@var{a}, @var{b}, @var{shape})\n\ |
244 \n\ | 237 Return the n-D convolution of @var{a} and @var{b} where the size\n\ |
245 Returns n-D convolution of @var{a} and @var{b} where the size\n\ | |
246 of @var{c} is given by\n\ | 238 of @var{c} is given by\n\ |
247 \n\ | 239 \n\ |
248 @table @asis\n\ | 240 @table @asis\n\ |
249 @item @var{shape} = 'full'\n\ | 241 @item @var{shape} = \"full\"\n\ |
250 returns full n-D convolution\n\ | 242 Return the full convolution.\n\ |
251 \n\ | 243 \n\ |
252 @item @var{shape} = 'same'\n\ | 244 @item @var{shape} = \"same\"\n\ |
253 same size as a. 'central' part of convolution\n\ | 245 Return central part of the convolution with the same size as @var{a}.\n\ |
254 \n\ | 246 \n\ |
255 @item @var{shape} = 'valid'\n\ | 247 @item @var{shape} = \"valid\"\n\ |
256 only parts which do not include zero-padded edges\n\ | 248 Return only the parts which do not include zero-padded edges.\n\ |
257 @end table\n\ | 249 @end table\n\ |
258 \n\ | 250 \n\ |
259 By default @var{shape} is 'full'.\n\ | 251 By default @var{shape} is @samp{\"full\"}.\n\ |
260 @end deftypefn") | 252 @end deftypefn") |
261 { | 253 { |
262 octave_value retval; | 254 octave_value retval; |
263 octave_value tmp; | 255 octave_value tmp; |
264 int nargin = args.length (); | 256 int nargin = args.length (); |
290 error ("convn: shape type not valid"); | 282 error ("convn: shape type not valid"); |
291 print_usage (); | 283 print_usage (); |
292 return retval; | 284 return retval; |
293 } | 285 } |
294 | 286 |
295 if (args(0).is_single_type () || | 287 if (args(0).is_single_type () || args(1).is_single_type ()) |
296 args(1).is_single_type ()) | 288 { |
297 { | 289 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
298 if (args(0).is_complex_type () | |
299 || args(1).is_complex_type ()) | |
300 { | 290 { |
301 FloatComplexNDArray a (args(0).float_complex_array_value ()); | 291 FloatComplexNDArray a (args(0).float_complex_array_value ()); |
302 if (args(1).is_real_type ()) | 292 if (args(1).is_real_type ()) |
303 { | 293 { |
304 FloatNDArray b (args(1).float_array_value ()); | 294 FloatNDArray b (args(1).float_array_value ()); |
317 retval = convn (a, b, ct); | 307 retval = convn (a, b, ct); |
318 } | 308 } |
319 } | 309 } |
320 else | 310 else |
321 { | 311 { |
322 if (args(0).is_complex_type () | 312 if (args(0).is_complex_type () || args(1).is_complex_type ()) |
323 || args(1).is_complex_type ()) | |
324 { | 313 { |
325 ComplexNDArray a (args(0).complex_array_value ()); | 314 ComplexNDArray a (args(0).complex_array_value ()); |
326 if (args(1).is_real_type ()) | 315 if (args(1).is_real_type ()) |
327 { | 316 { |
328 NDArray b (args(1).array_value ()); | 317 NDArray b (args(1).array_value ()); |