Computes the squared norm of a sparse_numeric vector which is the square root of the sum of the squared individual elements of the vector.

norm(x, ...)

# S4 method for class 'sparse_numeric'
norm(x, ...)

Arguments

x

A sparse_numeric object.

...

Additional arguments.

Value

A numeric scalar representing the squared norm.

Examples

x <- new("sparse_numeric", value = c(1, 2), pos = c(2L, 5L), length = 6L)
norm(x)
#> [1] 2.236068