Skip to contents

A arrayish value is any object that can be input to a primitive such as prim_add.

During runtime of a JIT-compiled function, these are AnvlArray objects.

The following types are arrayish (during tracing):

  • AnvlArray: a concrete array holding data on a device.

  • GraphBox: a boxed abstract array representing a value in a graph.

  • Length-1 vectors: numeric(1) and logical(1)

  • R arrays of types: numeric and logical.

Use is_arrayish() to check whether a value is arrayish.

Usage

is_arrayish(x, convert_ok = TRUE)

Arguments

x

(any)
Object to check.

convert_ok

(logical(1))
Whether to accept numeric(1) and logical(1) and R arrays of type numeric and logical.

Value

logical(1)

See also

Examples

# AnvlArrays are arrayish
is_arrayish(nv_array(1:4))
#> [1] TRUE

# Scalar R literals are arrayish by default
is_arrayish(1.5)
#> [1] TRUE
# R arrays are arrayish by default
is_arrayish(array(1.5))
#> [1] TRUE

# R arrays
is_arrayish(array(1:4), convert_ok = TRUE)
#> [1] TRUE
is_arrayish(array(1:4), convert_ok = FALSE)
#> [1] FALSE

# Length 1 vectors
is_arrayish(1.5, convert_ok = FALSE)
#> [1] FALSE
is_arrayish(1.5, convert_ok = TRUE)
#> [1] TRUE