diff liboctave/CMatrix.cc @ 15212:4bbd3bbb8912

reduce code duplication in too_large_for_float array functions * lo-utils.h (any_all_test): New function. * lo-utils.h, lo-utils.cc (xtoo_large_for_float (const Complex&)): New function. * Array.h (Array<T>::test): Call any_all_test. * Sparse.h (Sparse<T>::test, Sparse<T>::test_any, Sparse<T>::test_all, Sparse<T>::test_any, Sparse<T>::test_any, Sparse<T>::test_all, Sparse<T>::test_all): New functions. * CMatrix.cc (ComplexMatrix::too_large_for_float): Simplify with test_any and xtoo_large_for_float. * CNDArray.cc (ComplexNDArray::too_large_for_float): Likewise. * CSparse.cc (SparseComplexMatrix::too_large_for_float): Likewise. * dSparse.cc (SparseMatrix::too_large_for_float): Likewise. * dMatrix.cc (Matrix::too_large_for_float): Use test_any, not test_all. * dNDArray.cc (NDArray::too_large_for_float): Likewise. * fCMatrix.cc (FloatComplexMatrix::too_large_for_float): Unconditionlly return false. * fCNDArray.cc (FloatComplexNDArray::too_large_for_float): Likewise.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Aug 2012 16:16:31 -0400
parents 3d8ace26c5b4
children 61822c866ba1
line wrap: on
line diff
--- a/liboctave/CMatrix.cc	Tue Aug 21 17:48:19 2012 -0400
+++ b/liboctave/CMatrix.cc	Wed Aug 22 16:16:31 2012 -0400
@@ -3162,25 +3162,7 @@
 bool
 ComplexMatrix::too_large_for_float (void) const
 {
-  octave_idx_type nr = rows ();
-  octave_idx_type nc = cols ();
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      {
-        Complex val = elem (i, j);
-
-        double r_val = std::real (val);
-        double i_val = std::imag (val);
-
-        if ((! (xisnan (r_val) || xisinf (r_val))
-             && fabs (r_val) > FLT_MAX)
-            || (! (xisnan (i_val) || xisinf (i_val))
-                && fabs (i_val) > FLT_MAX))
-          return true;
-      }
-
-  return false;
+  return test_any (xtoo_large_for_float);
 }
 
 // FIXME Do these really belong here?  Maybe they should be