tests/norm.r

suppressPackageStartupMessages(library(float))
set.seed(1234)

tol = 1e-6
m = 10
n = 3

x = matrix(stats::rnorm(m*n), m, n)
s = fl(x)

type = "O"
test = dbl(norm(s, type))
truth = norm(x, type)
stopifnot(all.equal(test, truth, tol=tol))

type = "I"
test = dbl(norm(s, type))
truth = norm(x, type)
stopifnot(all.equal(test, truth, tol=tol))

type = "F"
test = dbl(norm(s, type))
truth = norm(x, type)
stopifnot(all.equal(test, truth, tol=tol))

type = "M"
test = dbl(norm(s, type))
truth = norm(x, type)
stopifnot(all.equal(test, truth, tol=tol))

type = "2"
test = dbl(norm(s, type))
truth = norm(x, type)
stopifnot(all.equal(test, truth, tol=tol))

Try the float package in your browser

Any scripts or data that you put into this service are public.

float documentation built on Feb. 16, 2023, 6:43 p.m.