Skip to contents

len calculates the Euclidean length (also called Euclidean norm) of a vector or the length of each column of a numeric matrix.

Usage

len(X)

Arguments

X

a numeric vector or matrix

Value

a scalar or vector containing the length(s)

See also

norm for more general matrix norms

Examples

len(1:3)
#> [1] 3.741657
len(matrix(1:9, 3, 3))
#> [1]  3.741657  8.774964 13.928388

# distance between two vectors
len(1:3 - c(1,1,1))
#> [1] 2.236068