Skip to contents

Broadcasts an array to a target shape, aligning the array's axes with the leading axes of shape, so that a vector fills a column. See nv_broadcast_arrays for more information.

Usage

nv_broadcast_to(x, shape)

Arguments

x

(arrayish)
One input. Can be any data type. An R value materializes at its default data type.

shape

(integer())
Target shape. The input's axes are matched against its leading axes, and each must either match or be 1; trailing axes are added.

Value

(arrayish)
Has the given shape and the same data type as x.

See also

Examples

# the vector fills a column and is repeated along the new trailing axis
x <- nv_array(c(1, 2, 3))
nv_broadcast_to(x, shape = c(3, 2))
#> AnvlArray
#>  1 1
#>  2 2
#>  3 3
#> [ CPUf32{3,2} ]