Skip to content

Commit c9f1e0c

Browse files
committed
bug: fix bug while computing the objective function for the mm algorithm
1 parent d443ed8 commit c9f1e0c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

R/graphLaplacianEstimation.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ learn_laplacian_gle_mm <- function(S, A_mask = NULL, alpha = 0, maxiter = 10000,
6060
R <- t(E) %*% K %*% E
6161
r <- nrow(R)
6262
G <- cbind(E, rep(1, p))
63-
if (record_objective)
64-
fun <- vanilla.objective(L(wk), K)
63+
if (record_objective) {
64+
z <- rep(0, .5 * p * (p - 1))
65+
z[mask] <- wk
66+
fun <- vanilla.objective(L(z), K)
67+
}
6568
if (verbose)
6669
pb <- progress::progress_bar$new(format = "<:bar> :current/:total eta: :eta",
6770
total = maxiter, clear = FALSE, width = 80)
@@ -72,8 +75,11 @@ learn_laplacian_gle_mm <- function(S, A_mask = NULL, alpha = 0, maxiter = 10000,
7275
Q <- G_aug_t %*% solve(G_aug %*% t(G), G_aug)
7376
Q <- Q[1:m, 1:m]
7477
wk <- sqrt(diag(Q) / diag(R))
75-
if (record_objective)
76-
fun <- c(fun, vanilla.objective(L(wk), K))
78+
if (record_objective) {
79+
z <- rep(0, .5 * p * (p - 1))
80+
z[mask] <- wk
81+
fun <- c(fun, vanilla.objective(L(z), K))
82+
}
7783
if (verbose)
7884
pb$tick()
7985
has_converged <- norm(w - wk, "2") / norm(w, "2") < reltol

vignettes/SpectralGraphTopology.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)