Skip to content

Commit

Permalink
FIX: converting sparse matrix to a dense vector leads to memory error…
Browse files Browse the repository at this point in the history
…s for large sparse matrices and slow down program. While converting dense matrix to a sparse matrix have at worst the same time as previous method, works faster sparse matrices and doesn't lead to memory issues.
  • Loading branch information
MatveevDaniil committed Jan 29, 2024
1 parent 8396e84 commit e8f62e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/argchecks_mid.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
(is.matrix(x) || inherits(x, "sparseMatrix")) &&
isTRUE(dim(x)[[1]] == dim(x)[[2]]) &&
Matrix::isSymmetric(x, check.attributes = FALSE) &&
all(unique(as.vector(x)) %in% c(0, 1))
all(Matrix::Matrix(x, sparse = TRUE)@x %in% c(0, 1))
}
.MUST.isAdjacencyMatrix <- function(x, name = NULL) {
if (is.null(name)) { name <- deparse(substitute(x)) }
Expand Down

0 comments on commit e8f62e8

Please sign in to comment.