Skip to contents

Compare two abstract arrays for type equality.

Usage

eq_type(e1, e2, ambiguity)

neq_type(e1, e2, ambiguity)

Arguments

e1

(AbstractArray)
First array to compare.

e2

(AbstractArray)
Second array to compare.

ambiguity

(logical(1))
Whether to consider the ambiguous field when comparing. If TRUE, arrays with different ambiguity are not equal. If FALSE, only dtype and shape are compared.

Value

logical(1) - TRUE if the arrays are equal, FALSE otherwise.

Examples

a <- nv_aval("f32", c(2L, 3L))
b <- nv_aval("f32", c(2L, 3L))

# Same dtype and shape
eq_type(a, b, ambiguity = FALSE)
#> [1] TRUE

# Different dtype
eq_type(a, nv_aval("i32", c(2L, 3L)), ambiguity = FALSE)
#> [1] FALSE

# Different shape
eq_type(a, nv_aval("f32", c(3L, 2L)), ambiguity = FALSE)
#> [1] FALSE

# ambiguity parameter controls whether ambiguous field is compared
c <- nv_aval("f32", c(2L, 3L), ambiguous = TRUE)
eq_type(a, c, ambiguity = FALSE)
#> [1] TRUE
eq_type(a, c, ambiguity = TRUE)
#> [1] FALSE

# neq_type is the negation of eq_type
neq_type(a, b, ambiguity = FALSE)
#> [1] FALSE