https://github.com/cran/pracma
Raw File
Tip revision: 3fdb68cc842f2ab3b59608f8e04d495763584f78 authored by Hans W. Borchers on 27 November 2015, 12:07:10 UTC
version 1.8.8
Tip revision: 3fdb68c
fnorm.R
##
##  f n o r m .R  Function Norm
##


fnorm <- function(f, g, x1, x2, p = 2, npoints = 100) {
    stopifnot(is.numeric(x1), length(x1) == 1,
              is.numeric(x2), length(x2) == 1, x1 < x2,
              is.numeric(npoints), length(npoints) == 1, npoints >= 2)

    f <- match.fun(f)
    g <- match.fun(g)

    x  <- seq(x1, x2, length.out = npoints)
    yf <- f(x)
    yg <- g(x)
    if (length(yf) != npoints || length(yg) != npoints)
        stop("Arguments 'f' and 'g' must be vectorized functions.")

    fd <- Norm(yf - yg, p = p)
    return(fd)
}
back to top