R/hadamard.R

Defines functions hadamard

Documented in hadamard

#' Calculate the Hadamard product between two matrices.
#'
#' Commonly referred to as elementwise matrix multiplication.
#'
#' @param A First matrix.
#' @param B Second matrix of same dimensions as \code{A}.
#' @return Elementwise product between the two matices.
#' @export
hadamard <- function(A, B) {
  if(!is.matrix(A) || !is.matrix(B) || !identical(dim(A), dim(B))) {
    stop("A and B must be matrices of the same dimension.")
  }
  .hadamard(A = A, B = B)
}
mlysy/TMBtools documentation built on April 1, 2022, 6:18 p.m.