For logical and integer vectors, there is !anyNA(x)
. For double vectors, there is length(x) == 0L || all(is.finite(range(x)))
.
For complex vectors, is there an analogous, O(1)-allocating expression equivalent to all(is.finite(x))
, in base R?
I considered is.finite(sum(x))
, but that could overflow DBL_MAX
and in that case give a false negative result ...
> r <- .Machine$double.xmax
> x <- complex(2L, r, r)
> all(is.finite(x))
[1] TRUE
> is.finite(sum(x))
[1] FALSE
I should add:
> str(.Machine)
List of 19
$ double.eps : num 2.22e-16
$ double.neg.eps : num 1.11e-16
$ double.xmin : num 2.23e-308
$ double.xmax : num 1.8e+308
$ double.base : int 2
$ double.digits : int 53
$ double.rounding : int 5
$ double.guard : int 0
$ double.ulp.digits : int -52
$ double.neg.ulp.digits: int -53
$ double.exponent : int 11
$ double.min.exp : int -1022
$ double.max.exp : int 1024
$ integer.max : int 2147483647
$ sizeof.long : int 8
$ sizeof.longlong : int 8
$ sizeof.longdouble : int 8
$ sizeof.pointer : int 8
$ sizeof.time_t : int 8