From aa8a066530a5baed35050c4b4caf4e5770c0cbce Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Mon, 1 Feb 2021 10:01:02 +0100 Subject: [PATCH] Improved array dropping --- R/computePopulationLogml.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/computePopulationLogml.R b/R/computePopulationLogml.R index b2675d7..d4516e0 100644 --- a/R/computePopulationLogml.R +++ b/R/computePopulationLogml.R @@ -13,14 +13,14 @@ computePopulationLogml <- function(pops, adjprior, priorTerm = 0) { # ======================================================== # # Computation # # ======================================================== # + isarray <- length(dim(repmat(adjprior, c(1, 1, length(pops))))) > 2 term1 <- squeeze( - # FIXME: assumes COUNTS has 3 dims. Where does this come from? sum( sum( reshape( lgamma( repmat(adjprior, c(1, 1, length(pops))) + - COUNTS[seq_len(nrow(adjprior)), seq_len(ncol(adjprior)), pops, drop=FALSE] + COUNTS[seq_len(nrow(adjprior)), seq_len(ncol(adjprior)), pops, drop=!isarray] ), c(x, y, z) ),