Skip to content
Snippets Groups Projects
Commit 3222d2a8 authored by Walmes Marques Zeviani's avatar Walmes Marques Zeviani
Browse files

Add roxygen tags and tidy

  - Add @title, @name and @author.
  - Tidy the code and text.
parent 2b5a2762
No related branches found
No related tags found
No related merge requests found
#' Matrix product in sandwich form
#' @title Matrix product in sandwich form
#' @name mc_sandwich
#' @author Wagner Hugo Bonat
#'
#' @description The function \code{mc_sandwich} is just an auxiliar function to compute product matrix
#' in the sandwich form bord1*middle*bord2. An special case appears when computing the derivative of
#' the covariance matrix with respect to the power parameter. Always the bord1 and bord2 should be
#' diagonal matrix. If it is not true, this product is too slow.
#' @description The function \code{mc_sandwich} is just an auxiliar
#' function to compute product matrix in the sandwich form
#' bord1*middle*bord2. An special case appears when computing the
#' derivative of the covariance matrix with respect to the power
#' parameter. Always the bord1 and bord2 should be diagonal
#' matrix. If it is not true, this product is too slow.
#'
#' @param middle A matrix.
#' @param bord1 A matrix.
#' @param bord2 A matrix.
#' @return The matrix product bord1*middle*bord2.
## Auxiliar function to multiply matrices
## Auxiliar function to multiply matrices ------------------------------
mc_sandwich <- function(middle, bord1, bord2) {
bord1 %*% middle %*% bord2
}
#' @rdname mc_sandwich
#' @rdname mc_sandwich -------------------------------------------------
mc_sandwich_negative <- function(middle, bord1, bord2) {
-bord1 %*% middle %*% bord2
}
#' @rdname mc_sandwich
#' @rdname mc_sandwich -------------------------------------------------
mc_sandwich_power <- function(middle, bord1, bord2) {
temp1 <- mc_sandwich(middle = middle, bord1 = bord1, bord2 = bord2)
return(temp1 + t(temp1))
}
#' @rdname mc_sandwich
#' @rdname mc_sandwich -------------------------------------------------
mc_sandwich_cholesky <- function(bord1, middle, bord2) {
p1 <- bord1 %*% middle %*% bord2
return(p1 + t(p1))
}
#' @rdname mc_sandwich
#' @rdname mc_sandwich -------------------------------------------------
mc_multiply <- function(bord1, bord2) {
return(bord2 %*% bord1)
}
#' @rdname mc_sandwich
#' @rdname mc_sandwich -------------------------------------------------
mc_multiply2 <- function(bord1, bord2) {
return(bord1 %*% bord2)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment