Skip to content

Commit

Permalink
fixing issues with Matrix class
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Enamorado committed Nov 17, 2023
1 parent ef316f0 commit ce7f42b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
8 changes: 7 additions & 1 deletion R/gammaCK2par.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ gammaCK2par <- function(matAp, matBp, n.cores = NULL, cut.a = 0.92, method = "jw
t <- Matrix(t, sparse = T)
}

t@x[t@x >= cut] <- 2; gc()
if(is(t, "ddiMatrix")) {
t <- t * 2
} else {
t@x[t@x >= cut] <- 2
}
gc()

slice.1 <- m[[2]]
slice.2 <- y[[2]]
indexes.2 <- which(t == 2, arr.ind = T)
Expand Down
10 changes: 8 additions & 2 deletions R/gammaCKpar.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ gammaCKpar <- function(matAp, matBp, n.cores = NULL, cut.a = 0.92, cut.p = 0.88,
t <- Matrix(t, sparse = T)
}

t@x[t@x >= cut[1]] <- 2
t@x[t@x >= cut[2] & t@x < cut[1]] <- 1; gc()
if(is(t, "ddiMatrix")) {
t <- t * 2
} else {
t@x[t@x >= cut[1]] <- 2
t@x[t@x >= cut[2] & t@x < cut[1]] <- 1
}
gc()

slice.1 <- m[[2]]
slice.2 <- y[[2]]
indexes.2 <- which(t == 2, arr.ind = T)
Expand Down
8 changes: 7 additions & 1 deletion R/gammaNUMCK2par.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ gammaNUMCK2par <- function(matAp, matBp, n.cores = NULL, cut.a = 1) {
t[ t > cut ] <- 0
t <- Matrix(t, sparse = T)

t@x[t@x <= cut] <- 2; gc()
if(is(t, "ddiMatrix")) {
t <- t * 2
} else {
t@x[t@x <= cut] <- 2
}
gc()

slice.1 <- m[[2]]
slice.2 <- y[[2]]
indexes.2 <- which(t == 2, arr.ind = T)
Expand Down
10 changes: 7 additions & 3 deletions R/gammaNUMCKpar.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ gammaNUMCKpar <- function(matAp, matBp, n.cores = NULL, cut.a = 1, cut.p = 2) {
t[ t > cut[2] ] <- 0
t <- Matrix(t, sparse = T)

t@x[t@x <= cut[1]] <- cut[2] + 1; gc()
t@x[t@x > cut[1] & t@x <= cut[2]] <- 1; gc()

if(is(t, "ddiMatrix")) {
t <- t * (cut[2] + 1)
} else {
t@x[t@x <= cut[1]] <- cut[2] + 1; gc()
t@x[t@x > cut[1] & t@x <= cut[2]] <- 1; gc()
}

slice.1 <- m[[2]]
slice.2 <- y[[2]]
indexes.2 <- which(t == cut[2] + 1, arr.ind = T)
Expand Down

0 comments on commit ce7f42b

Please sign in to comment.