Commit 39f82046 authored by Corson N. Areshenkoff's avatar Corson N. Areshenkoff

Fix exp/log maps

parent dcdc9baa
......@@ -17,7 +17,7 @@ spd.expmap <- function(x, p){
}
p.sqrt <- sqrtm(p)
p.inv.sqrt <- solve(p.inv)
p.inv.sqrt <- solve(p.sqrt)
return(p.sqrt %*% expm2(p.inv.sqrt %*% x %*% p.inv.sqrt) %*% p.sqrt)
}
......@@ -4,7 +4,7 @@ spd.interpolate.euclidean <- function(x, y, t, ...){
}
spd.interpolate.logeuclidean <- function(x, y, t, ...){
return(expm((1-t)*logm(x) + t*logm(y)))
return(expm((1-t)*logm2(x) + t*logm2(y)))
}
spd.interpolate.riemannian <- function(x, y, t, ...){
......
......@@ -16,7 +16,7 @@ spd.logmap <- function(x, p){
}
p.sqrt <- sqrtm(p)
p.inv.sqrt <- solve(p.inv)
p.inv.sqrt <- solve(p.sqrt)
return(p.sqrt %*% logm2(p.inv.sqrt %*% x %*% p.inv.sqrt) %*% p.sqrt)
}
#' Parallel transport of a tangent vector
#'
#' Whitens an SPD matrix using the procedure advocated by Ng, et al. (2014)
#'
#' @param x An SPD matrix to be whitened
#' @param p The SPD baseline whitening matrix
#' @param unwhiten Logical. If TRUE, reverses a previously applied whitening transform.
#' @return A symmetric, positive-definite matrix.
to <- cov(matrix(rnorm(30), ncol = 3))
from <- cov(matrix(rnorm(30), ncol = 3))
x <- cov(matrix(rnorm(30), ncol = 3))
x <- spd.logmap(x, from)
spd.transport <- function(x, to, from){
if (!'s.mat' %in% input.type(x)){
stop('x must be a positive definite matrix')
}
if (!'spd.mat' %in% input.type(to)){
stop('to must be a positive definite matrix')
}
if (!'spd.mat' %in% input.type(from)){
stop('from must be a positive definite matrix')
}
return(x)
}
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