R/projorth.R

Defines functions projorth

Documented in projorth

#' Compute the projection of a vector onto the space orthogonal to a given
#' matrix.
#'
#' @param x A vector of numerics
#' @param M A matrix of vectors
#' @return The projection of \eqn{x} onto \eqn{V^\perp}.
#' @examples
#' projorth(1:10, projl2(rnorm(10)))
#' @export
projorth <- function(x, M) {
  Mtx <- t(M) %*% x
  MMtx <- M %*% Mtx
  x - MMtx
}
vguillemot/sparseMCA documentation built on Nov. 5, 2019, 12:02 p.m.