From e96f9d9345664fc9022975b553d98c8af214bd43 Mon Sep 17 00:00:00 2001 From: Lu Yuxiao <123642782+LuYuxiaoPKU@users.noreply.github.com> Date: Thu, 1 Jan 2026 16:26:54 +0800 Subject: [PATCH] Update prob_model.R - Fixed a bug where SQ_mat could be NULL, causing computation failures - Enhanced performance of inversion of tri-diagonal matrix in SQ_mat processing --- R/prob_model.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/prob_model.R b/R/prob_model.R index 15e4bb2..bedf915 100644 --- a/R/prob_model.R +++ b/R/prob_model.R @@ -27,12 +27,14 @@ solve_sq <- function(Q_mat, X_vals) { diag(M) <- 2*(del[1:(n-1)] + del[2:n]) M[cbind(2:(n-1), 1:(n-2))] <- del[2:(n-1)] M[cbind(1:(n-2), 2:(n-1))] <- del[2:(n-1)] + M <- as(as(as(M, "dMatrix"), "generalMatrix"), "TsparseMatrix") MI <- solve(M) fB <- sweep(diff(t(Q_mat)),1,del,'/') fBD <- 6*diff(fB) SQ_mat <- t(MI %*% fBD) ### append the zeros SQ_mat <- cbind(0, SQ_mat, 0) + return(SQ_mat) } set_global_Q_all <- function() {