Mercurial > hg > octave-nkf
diff liboctave/CNDArray.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 |
line wrap: on
line diff
--- a/liboctave/CNDArray.cc +++ b/liboctave/CNDArray.cc @@ -584,23 +584,7 @@ bool ComplexNDArray::too_large_for_float (void) const { - octave_idx_type nel = nelem (); - - for (octave_idx_type i = 0; i < nel; i++) - { - Complex val = elem (i); - - 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); } boolNDArray