From b0e521de10f5964e935c63bcc1c6658d5acfbb4e Mon Sep 17 00:00:00 2001 From: Gavin Quinn Collins Date: Thu, 12 Oct 2023 12:11:22 -0700 Subject: [PATCH] navigate rounding errors in inv_exp_map() --- R/geometry.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/geometry.R b/R/geometry.R index 4720106..ae43f64 100644 --- a/R/geometry.R +++ b/R/geometry.R @@ -9,7 +9,13 @@ l2_curvenorm <- function(psi, time=seq(0,1,length.out=ncol(psi))){ } inv_exp_map<-function(Psi, psi){ - theta <- acos(inner_product(Psi,psi)) + ip <- inner_product(Psi, psi) + if(ip < -1){ + ip = -1 + }else if(ip > 1){ + ip = 1 + } + theta <- acos(ip) if (theta < 1e-10){ exp_inv = rep(0,length(psi))