library("mypkg", lib="~/.Rlibs") (m <- matrix(as.double(c(3,1,-1, 1,2,.5, -1,.5,.5)), 3)) identical(solve(m), myinv(m)) identical(det(m), mydet(m)) identical(mahalanobis(c(0:2), -2:0, m), .C("mahalanobis", as.integer(3), as.double(0:2), as.double(-2:0), as.double(solve(m)), res=double(1))$res) m2 <- cov(matrix(rnorm(100*1000), 1000)) identical(solve(m2), myinv(m2)) identical(det(m2), mydet(m2)) x <- as.double(runif(nrow(m2))) y <- as.double(rnorm(nrow(m2))) identical(mahalanobis(x, y, m2), .C("mahalanobis", as.integer(nrow(m2)), x, y, as.double(solve(m2)), res=double(1))$res) .C("mahalanobis", as.integer(nrow(m2)), x, y, as.double(solve(m2)), res=double(1))$res sum((x-y)^2) sdists <- as.matrix(dist(cbind(1, runif(nrow(m2), 0, 5)))) .C("lpostgeo", as.integer(nrow(m2)), as.double(0:3), x, y, as.double(sdists), double(prod(dim(m2))), double(prod(dim(m2))), res=double(1))$res postgeo(0:3, x, sdists)