Mercurial > hg > octave-lyh
changeset 16971:259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
* libinterp/corefcn/graphics.cc(max_axes_scale, check_limit_vals, FIX_LIMITS,
update_axis_limits): Use xfinite.
* libinterp/corefcn/ls-mat5.cc(save_mat5_array_length): Use xfinite.
* libinterp/corefcn/pr-output.cc(pr_max_internal, pr_min_internal, set_format):
Use xfinite.
* liboctave/numeric/lo-mappers.h(X_NINT): Use xfinite.
* liboctave/numeric/oct-rand.cc(do_scalar, do_float_scalar, fill): Use xfinite.
* liboctave/util/lo-utils.cc(xtoo_large_for_float): Use xfinite.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 13 Jul 2013 08:08:15 -0700 |
parents | 78116b88dbf5 |
children | 45afabc5f7c8 |
files | libinterp/corefcn/graphics.cc libinterp/corefcn/ls-mat5.cc libinterp/corefcn/pr-output.cc liboctave/numeric/lo-mappers.h liboctave/numeric/oct-rand.cc liboctave/util/lo-utils.cc |
diffstat | 6 files changed, 33 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -5491,8 +5491,7 @@ double min_pos = octave_Inf; double max_neg = -octave_Inf; get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type); - if (!xisinf (minval) && !xisnan (minval) - && !xisinf (maxval) && !xisnan (maxval)) + if (xfinite (minval) && xfinite (maxval)) { limits(0) = minval; limits(1) = maxval; @@ -5973,16 +5972,16 @@ const array_property& data) { double val = data.min_val (); - if (! (xisinf (val) || xisnan (val)) && val < min_val) + if (xfinite (val) && val < min_val) min_val = val; val = data.max_val (); - if (! (xisinf (val) || xisnan (val)) && val > max_val) + if (xfinite (val) && val > max_val) max_val = val; val = data.min_pos (); - if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) + if (xfinite (val) && val > 0 && val < min_pos) min_pos = val; val = data.max_neg (); - if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) + if (xfinite (val) && val < 0 && val > max_neg) max_neg = val; } */ @@ -6001,19 +6000,19 @@ double val; val = m(0); - if (! (xisinf (val) || xisnan (val)) && val < min_val) + if (xfinite (val) && val < min_val) min_val = val; val = m(1); - if (! (xisinf (val) || xisnan (val)) && val > max_val) + if (xfinite (val) && val > max_val) max_val = val; val = m(2); - if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) + if (xfinite (val) && val > 0 && val < min_pos) min_pos = val; val = m(3); - if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) + if (xfinite (val) && val < 0 && val > max_neg) max_neg = val; } } @@ -6478,16 +6477,16 @@ if (limits.numel () == 4) \ { \ val = limits(0); \ - if (! (xisinf (val) || xisnan (val))) \ + if (xfinite (val)) \ min_val = val; \ val = limits(1); \ - if (! (xisinf (val) || xisnan (val))) \ + if (xfinite (val)) \ max_val = val; \ val = limits(2); \ - if (! (xisinf (val) || xisnan (val))) \ + if (xfinite (val)) \ min_pos = val; \ val = limits(3); \ - if (! (xisinf (val) || xisnan (val))) \ + if (xfinite (val)) \ max_neg = val; \ } \ else \ @@ -7451,16 +7450,16 @@ if (limits.numel () == 4) { val = limits(0); - if (! (xisinf (val) || xisnan (val))) + if (xfinite (val)) min_val = val; val = limits(1); - if (! (xisinf (val) || xisnan (val))) + if (xfinite (val)) max_val = val; val = limits(2); - if (! (xisinf (val) || xisnan (val))) + if (xfinite (val)) min_pos = val; val = limits(3); - if (! (xisinf (val) || xisnan (val))) + if (xfinite (val)) max_neg = val; } else
--- a/libinterp/corefcn/ls-mat5.cc +++ b/libinterp/corefcn/ls-mat5.cc @@ -1960,7 +1960,7 @@ { double tmp = val[i]; - if (! (xisnan (tmp) || xisinf (tmp)) + if (xfinite (tmp) && fabs (tmp) > std::numeric_limits<float>::max ()) { too_large_for_float = true;
--- a/libinterp/corefcn/pr-output.cc +++ b/libinterp/corefcn/pr-output.cc @@ -493,7 +493,7 @@ for (octave_idx_type i = 0; i < nr; i++) { double val = m(i,j); - if (xisinf (val) || xisnan (val)) + if (! xfinite (val)) continue; all_inf_or_nan = false; @@ -522,7 +522,7 @@ for (octave_idx_type i = 0; i < nr; i++) { double val = m(i,j); - if (xisinf (val) || xisnan (val)) + if (xfinite (val)) continue; all_inf_or_nan = false; @@ -998,11 +998,9 @@ double r_abs = rp < 0.0 ? -rp : rp; double i_abs = ip < 0.0 ? -ip : ip; - int r_x = (xisinf (rp) || xisnan (rp) || r_abs == 0.0) - ? 0 : num_digits (r_abs); - - int i_x = (xisinf (ip) || xisnan (ip) || i_abs == 0.0) - ? 0 : num_digits (i_abs); + int r_x = (! xfinite (rp) || r_abs == 0.0) ? 0 : num_digits (r_abs); + + int i_x = (! xfinite (ip) || i_abs == 0.0) ? 0 : num_digits (i_abs); int x_max, x_min;
--- a/liboctave/numeric/lo-mappers.h +++ b/liboctave/numeric/lo-mappers.h @@ -234,7 +234,7 @@ T X_NINT (T x) { - return (xisinf (x) || xisnan (x)) ? x : xfloor (x + 0.5); + return (xfinite (x) ? xfloor (x + 0.5) : x); } inline OCTAVE_API double D_NINT (double x) { return X_NINT (x); }
--- a/liboctave/numeric/oct-rand.cc +++ b/liboctave/numeric/oct-rand.cc @@ -360,7 +360,7 @@ break; case poisson_dist: - if (a < 0.0 || xisnan (a) || xisinf (a)) + if (a < 0.0 || ! xfinite (a)) retval = octave_NaN; else { @@ -371,7 +371,7 @@ break; case gamma_dist: - if (a <= 0.0 || xisnan (a) || xisinf (a)) + if (a <= 0.0 || ! xfinite (a)) retval = octave_NaN; else F77_FUNC (dgengam, DGENGAM) (1.0, a, retval); @@ -443,7 +443,7 @@ break; case poisson_dist: - if (da < 0.0 || xisnan (da) || xisinf (da)) + if (da < 0.0 || ! xfinite (a)) dretval = octave_NaN; else { @@ -454,7 +454,7 @@ break; case gamma_dist: - if (da <= 0.0 || xisnan (da) || xisinf (da)) + if (da <= 0.0 || ! xfinite (a)) retval = octave_NaN; else F77_FUNC (dgengam, DGENGAM) (1.0, da, dretval); @@ -748,7 +748,7 @@ case poisson_dist: if (use_old_generators) { - if (a < 0.0 || xisnan (a) || xisinf (a)) + if (a < 0.0 || ! xfinite (a)) #define RAND_FUNC(x) x = octave_NaN; MAKE_RAND (len); #undef RAND_FUNC @@ -769,7 +769,7 @@ case gamma_dist: if (use_old_generators) { - if (a <= 0.0 || xisnan (a) || xisinf (a)) + if (a <= 0.0 || ! xfinite (a)) #define RAND_FUNC(x) x = octave_NaN; MAKE_RAND (len); #undef RAND_FUNC @@ -838,7 +838,7 @@ if (use_old_generators) { double da = a; - if (da < 0.0 || xisnan (da) || xisinf (da)) + if (da < 0.0 || ! xfinite (a)) #define RAND_FUNC(x) x = octave_NaN; MAKE_RAND (len); #undef RAND_FUNC @@ -860,7 +860,7 @@ if (use_old_generators) { double da = a; - if (da <= 0.0 || xisnan (da) || xisinf (da)) + if (da <= 0.0 || ! xfinite (a)) #define RAND_FUNC(x) x = octave_NaN; MAKE_RAND (len); #undef RAND_FUNC
--- a/liboctave/util/lo-utils.cc +++ b/liboctave/util/lo-utils.cc @@ -55,8 +55,7 @@ bool xtoo_large_for_float (double x) { - return (! (xisnan (x) || xisinf (x)) - && fabs (x) > std::numeric_limits<float>::max ()); + return (xfinite (x) && fabs (x) > std::numeric_limits<float>::max ()); } bool xtoo_large_for_float (const Complex& x)