Skip to contents

Converts a tensor() to an array() by stripping the index labels. An index label order needs to be provided so that the array's dim() order is well defined.

Usage

# S3 method for class 'tensor'
as.array(
  x,
  index_order = NULL,
  ...,
  arg = "index_order",
  call = rlang::caller_env()
)

Arguments

x

A labeled array ("tensor" object) created by %_% or tensor().

index_order

An index specification created with .(). The specification needs to match all the labels occurring in x. The label order determines the dimension order of the resulting array.

...

Not used.

arg, call

Used for error handling. Can be ignored by the user.

Examples

array(1:8, dim = c(2, 2, 2)) %_% .(i, +i, k) |> as.array(.(k))
#> [1]  5 13