R/norm_matrix_K.R

Defines functions norm_matrix_K

Documented in norm_matrix_K

#' Computation of the K-norm of a set of functions
#'
#' It computes the norm associated to the kernel K of a set of functions.
#' The functions are represented as their projection on a
#' kernel basis.
#'
#' @param M matrix. \code{J} \eqn{\times} \code{N} matrix containing in the column
#' \eqn{n} the coefficients of the projection of a function \eqn{y_n} on the
#' \code{J} eigenfunctions of the kernel.
#' @param eigenval vector. \code{J}-length vector of the eigenvalues of the
#' kernel.
#'
#' @return vector of length \code{N} containing the K-norm of the functions
#' @export
#'
#' @examples
#' data(SobolevKernel)
#' data(simulation)
#' norm_K = sum(norm_matrix_K(Y_matrix, eigenval))
#'

## @A: For each column, it does not give the norm K of the column! It actually compute the norm K of
## the function whose projection on basis is the column.

norm_matrix_K <- function(M, eigenval)
{
    if (is.null(dim(M)))
    {
        M <- matrix(M, length(M),1)
    }
    norm <- apply(M,2, function(x){sqrt(sum(x^2/eigenval))} )
    return(norm)
}
ardeeshany/FLAME documentation built on May 14, 2019, 8:41 a.m.