Commit 09119b35 authored by Corson N. Areshenkoff's avatar Corson N. Areshenkoff

Fixes and tests

parent f8fe96f7
logm2 <- function(x){
lx <- logm(x)
return((x + t(x))/2)
return((lx + t(lx))/2)
}
expm2 <- function(x){
ex <- expm(x)
return((x + t(x))/2)
return((ex + t(ex))/2)
}
......@@ -26,7 +26,7 @@ spd.mean.p.est <- function(x, p = .5, tol = .01, max.iter = 20){
expm2(abs(p) * logm(X %*% i %*% t(X)))
})) / n
X <- expm(-phi * logm2(H)) %*% X
X <- expm2(-phi * logm2(H)) %*% X
# Error update
iter <- iter + 1
......
context("spd-expam and spd-logmap")
# Positive definite matrixTesting data
x <- cov(matrix(rnorm(100), ncol = 5))
test_that("Exp and Log are inverses", {
expect_true(compare(x, spd.expmap(spd.logmap(x)))$equal)
})
context("spd-interpolate")
# Positive definite matrixTesting data
x <- cov(matrix(rnorm(100), ncol = 5))
y <- cov(matrix(rnorm(100), ncol = 5))
test_that("Functions accurate interpolate", {
# Euclidean
expect_true(compare(x, spd.interpolate(x, y, t = 0, method = 'euclidean'))$equal)
expect_true(compare(y, spd.interpolate(x, y, t = 1, method = 'euclidean'))$equal)
# Euclidean
expect_true(compare(x, spd.interpolate(x, y, t = 0, method = 'logeuclidean'))$equal)
expect_true(compare(y, spd.interpolate(x, y, t = 1, method = 'logeuclidean'))$equal)
# Euclidean
expect_true(compare(x, spd.interpolate(x, y, t = 0, method = 'riemannian'))$equal)
expect_true(compare(y, spd.interpolate(x, y, t = 1, method = 'riemannian'))$equal)
})
context("spd-transport")
# Positive definite matrixTesting data
from <- cov(matrix(rnorm(300), ncol = 3))
to <- cov(matrix(rnorm(300), ncol = 3))
x <- .8 * from + .2 * cov(matrix(rnorm(300), ncol = 3))
x <- spd.logmap(x, p = from)
y1 <- spd.transport(x, from = from, to = to, nsteps = 10)
y2 <- spd.transport(y1, from = to, to = from, nsteps = 10)
test_that("Transport back and forth is equal", {
expect_true(compare(x, y2)$equal)
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment