R/euclidean.R

Defines functions norm_vec row_norm3

Documented in norm_vec row_norm3

#' Calculate the Euclidean norm of an nx3 matrix rowwise.
#'
#' @param x nx3 matrix
#' @return vector of length n
row_norm3 <- function(x) sqrt(.Internal(rowSums(x^2, nrow(x), 3, FALSE)))

#' Return the normed vector.
#'
#' @param v numeric vector
#' @return the normed vector
norm_vec <- function(v) v / sqrt(sum(v^2))
chroetz/spheregr documentation built on April 10, 2022, 12:03 a.m.