diff liboctave/lo-utils.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 52cb71787cd1
children 336f42406671
line wrap: on
line diff
--- a/liboctave/lo-utils.cc
+++ b/liboctave/lo-utils.cc
@@ -56,6 +56,12 @@
 bool xtoo_large_for_float (double x)
 { return (! (xisnan (x) || xisinf (x)) && fabs (x) > FLT_MAX); }
 
+bool xtoo_large_for_float (const Complex& x)
+{
+  return (xtoo_large_for_float (x.real ())
+          || xtoo_large_for_float (x.imag ()));
+}
+
 bool xis_int_or_inf_or_nan (float x)
 { return xisnan (x) || D_NINT (x) == x; }