Skip to contents

Element-wise square or power-2 operations on numeric or complex vectors (or objects which can be coerced to them).

Usage

# S3 method for default
square(x)

Arguments

x

numeric or complex vectors or objects which can be coerced to such, or other objects for which methods have been written.

Value

Vector or array of elements from x elevated to the power-2.

Details

square(x) is equivalent to x^2 where ^ is the default power function, i.e. \(x^2\).

From base::Arithmetic: if applied to arrays the result will be an array if this is sensible (for example it will not if the recycling rule has been invoked).

See also

Author

Chloe Serre-Combe, Amelie Vernay

Examples

square(4)
#> [1] 16
square(1:10)
#>  [1]   1   4   9  16  25  36  49  64  81 100