comparison liboctave/fCNDArray.cc @ 11008:3622db30ff05

simplify some array tests in liboctave
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 21 Sep 2010 13:09:12 +0200
parents b47ab50a6aa8
children 7c573eb981eb
comparison
equal deleted inserted replaced
11007:ffe58182db89 11008:3622db30ff05
501 // FIXME -- this is not quite the right thing. 501 // FIXME -- this is not quite the right thing.
502 502
503 bool 503 bool
504 FloatComplexNDArray::any_element_is_nan (void) const 504 FloatComplexNDArray::any_element_is_nan (void) const
505 { 505 {
506 octave_idx_type nel = nelem (); 506 return do_mx_check<FloatComplex> (*this, mx_inline_any_nan);
507
508 for (octave_idx_type i = 0; i < nel; i++)
509 {
510 FloatComplex val = elem (i);
511 if (xisnan (val))
512 return true;
513 }
514 return false;
515 } 507 }
516 508
517 bool 509 bool
518 FloatComplexNDArray::any_element_is_inf_or_nan (void) const 510 FloatComplexNDArray::any_element_is_inf_or_nan (void) const
519 { 511 {
520 octave_idx_type nel = nelem (); 512 return ! do_mx_check<FloatComplex> (*this, mx_inline_all_finite);
521
522 for (octave_idx_type i = 0; i < nel; i++)
523 {
524 FloatComplex val = elem (i);
525 if (xisinf (val) || xisnan (val))
526 return true;
527 }
528 return false;
529 } 513 }
530 514
531 // Return true if no elements have imaginary components. 515 // Return true if no elements have imaginary components.
532 516
533 bool 517 bool
534 FloatComplexNDArray::all_elements_are_real (void) const 518 FloatComplexNDArray::all_elements_are_real (void) const
535 { 519 {
536 return mx_inline_all_real (numel (), data ()); 520 return do_mx_check<FloatComplex> (*this, mx_inline_all_real);
537 } 521 }
538 522
539 // Return nonzero if any element of CM has a non-integer real or 523 // Return nonzero if any element of CM has a non-integer real or
540 // imaginary part. Also extract the largest and smallest (real or 524 // imaginary part. Also extract the largest and smallest (real or
541 // imaginary) values and return them in MAX_VAL and MIN_VAL. 525 // imaginary) values and return them in MAX_VAL and MIN_VAL.