Skip to content

Commit

Permalink
Fix scale_block for constant blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
GFabien committed Dec 14, 2024
1 parent 0b1f2eb commit 1cc332e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/scale_inertia.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ scale_inertia <- function(A, sqrt_N, scale, na.rm) {
z <- A
}
fac <- 1 / sqrt_N * norm(z, type = "F")
if (fac == 0) {
return(A)
}
y <- A / fac
if (scale) {
attr(y, "scaled:scale") <- attr(A, "scaled:scale") * fac
Expand Down
3 changes: 3 additions & 0 deletions R/scale_lambda1.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ scale_lambda1 <- function(A, sqrt_N, scale, na.rm) {
symmetric = TRUE, only.values = TRUE
)$values[1]
))
if (lambda == 0) {
return(A)
}
y <- A / lambda
if (scale) {
attr(y, "scaled:scale") <- attr(A, "scaled:scale") * lambda
Expand Down

0 comments on commit 1cc332e

Please sign in to comment.