Mercurial > hg > octave-lyh
comparison src/data.cc @ 4311:a9e0bff33b02
[project @ 2003-01-30 04:11:58 by jwe]
author | jwe |
---|---|
date | Thu, 30 Jan 2003 04:11:58 +0000 |
parents | e15a96673976 |
children | 83d4452bc522 |
comparison
equal
deleted
inserted
replaced
4310:da7226ca8b91 | 4311:a9e0bff33b02 |
---|---|
265 else | 265 else |
266 error ("atan2: nonconformant matrices"); | 266 error ("atan2: nonconformant matrices"); |
267 } | 267 } |
268 else | 268 else |
269 print_usage ("atan2"); | 269 print_usage ("atan2"); |
270 | |
271 return retval; | |
272 } | |
273 | |
274 DEFUN (fmod, args, , | |
275 "-*- texinfo -*-\n\ | |
276 @deftypefn {Mapping Function} {} fmod (@var{x}, @var{y})\n\ | |
277 Compute the floating point remainder of @var{y} / @var{x} using the C\n\ | |
278 library function @code{fmod}. The result has the same sign as @var{x}.\n\ | |
279 If @var{y} is zero, the result implementation-defined.\n\ | |
280 @end deftypefn") | |
281 { | |
282 octave_value retval; | |
283 | |
284 int nargin = args.length (); | |
285 | |
286 if (nargin == 2 && args(0).is_defined () && args(1).is_defined ()) | |
287 { | |
288 octave_value arg_x = args(0); | |
289 octave_value arg_y = args(1); | |
290 | |
291 int y_nr = arg_y.rows (); | |
292 int y_nc = arg_y.columns (); | |
293 | |
294 int x_nr = arg_x.rows (); | |
295 int x_nc = arg_x.columns (); | |
296 | |
297 int arg_y_empty = empty_arg ("fmod", y_nr, y_nc); | |
298 int arg_x_empty = empty_arg ("fmod", x_nr, x_nc); | |
299 | |
300 if (arg_y_empty > 0 && arg_x_empty > 0) | |
301 return octave_value (Matrix ()); | |
302 else if (arg_y_empty || arg_x_empty) | |
303 return retval; | |
304 | |
305 int y_is_scalar = (y_nr == 1 && y_nc == 1); | |
306 int x_is_scalar = (x_nr == 1 && x_nc == 1); | |
307 | |
308 if (y_is_scalar && x_is_scalar) | |
309 { | |
310 double y = arg_y.double_value (); | |
311 | |
312 if (! error_state) | |
313 { | |
314 double x = arg_x.double_value (); | |
315 | |
316 if (! error_state) | |
317 retval = fmod (x, y); | |
318 } | |
319 } | |
320 else if (y_is_scalar) | |
321 { | |
322 double y = arg_y.double_value (); | |
323 | |
324 if (! error_state) | |
325 { | |
326 Matrix x = arg_x.matrix_value (); | |
327 | |
328 if (! error_state) | |
329 retval = map_m_d (fmod, x, y); | |
330 } | |
331 } | |
332 else if (x_is_scalar) | |
333 { | |
334 Matrix y = arg_y.matrix_value (); | |
335 | |
336 if (! error_state) | |
337 { | |
338 double x = arg_x.double_value (); | |
339 | |
340 if (! error_state) | |
341 retval = map_d_m (fmod, x, y); | |
342 } | |
343 } | |
344 else if (y_nr == x_nr && y_nc == x_nc) | |
345 { | |
346 Matrix y = arg_y.matrix_value (); | |
347 | |
348 if (! error_state) | |
349 { | |
350 Matrix x = arg_x.matrix_value (); | |
351 | |
352 if (! error_state) | |
353 retval = map_m_m (fmod, x, y); | |
354 } | |
355 } | |
356 else | |
357 error ("fmod: nonconformant matrices"); | |
358 } | |
359 else | |
360 print_usage ("fmod"); | |
270 | 361 |
271 return retval; | 362 return retval; |
272 } | 363 } |
273 | 364 |
274 #define DATA_REDUCTION(FCN) \ | 365 #define DATA_REDUCTION(FCN) \ |