Skip to contents

Element-wise cosine.

Usage

prim_cos(x)

Arguments

x

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

Value

(arrayish)
Has the input's shape and data type.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_cosine(), specified under cosine.

See also

Examples

# the input's data type carries through
x <- nv_array(c(0, pi / 2, pi))
prim_cos(x)
#> AnvlArray
#>   1.0000e+00
#>  -4.3711e-08
#>  -1.0000e+00
#> [ CPUf32{3} ] 

# an R value materializes at its default data type
prim_cos(0)
#> AnvlArray
#>  1
#> [ CPUf32{} ]