Skip to content

Commit 98c113f

Browse files
committed
Add additional sikpping updating
1 parent 21ca5d5 commit 98c113f

File tree

4 files changed

+60
-28
lines changed

4 files changed

+60
-28
lines changed

R/dmat_em_base.r

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,25 @@ m.step.dmat <- function(PARAM){
212212
tmp.1 <- crossprod(B)
213213
tmp.2 <- as.matrix(tmp.1)
214214
tmp.SIGMA <- tmp.2
215-
dim(tmp.SIGMA) <- c(p, p)
216215

217-
tmp.U <- decompsigma(tmp.SIGMA)
218-
PARAM$U.check[[i.k]] <- tmp.U$check
219-
if(tmp.U$check){
220-
PARAM$U[[i.k]] <- tmp.U$value
221-
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
216+
if(!any(is.nan(tmp.SIGMA))){
217+
dim(tmp.SIGMA) <- c(p, p)
218+
219+
tmp.U <- decompsigma(tmp.SIGMA)
220+
PARAM$U.check[[i.k]] <- tmp.U$check
221+
if(tmp.U$check){
222+
PARAM$U[[i.k]] <- tmp.U$value
223+
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
224+
}
225+
} else{
226+
PARAM$U.check[[i.k]] <- FALSE
227+
if(.pmclustEnv$CONTROL$debug > 2){
228+
comm.cat(" SIGMA[[", i.k, "]] has NaN. Updating is skipped.\n", sep = "", quiet = TRUE)
229+
}
222230
}
223231
} else{
224232
if(.pmclustEnv$CONTROL$debug > 2){
225-
comm.cat(" SIGMA[[", i.k, "]] is fixed.\n", sep = "", quiet = TRUE)
233+
comm.cat(" SIGMA[[", i.k, "]] is fixed. Updating is skipped.\n", sep = "", quiet = TRUE)
226234
}
227235
}
228236
}

R/pm_aecm_base.r

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ cm.step.spmd.SIGMA <- function(PARAM){
4040
sqrt(.pmclustEnv$Z.spmd[, i.k] / .pmclustEnv$Z.colSums[i.k])
4141
tmp.SIGMA <- crossprod(B)
4242
tmp.SIGMA <- spmd.allreduce.double(tmp.SIGMA, double(p.2), op = "sum")
43-
dim(tmp.SIGMA) <- c(p, p)
4443

45-
tmp.U <- decompsigma(tmp.SIGMA)
46-
PARAM$U.check[[i.k]] <- tmp.U$check
47-
if(tmp.U$check){
48-
PARAM$U[[i.k]] <- tmp.U$value
49-
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
44+
if(!any(is.nan(tmp.SIGMA))){
45+
dim(tmp.SIGMA) <- c(p, p)
46+
47+
tmp.U <- decompsigma(tmp.SIGMA)
48+
PARAM$U.check[[i.k]] <- tmp.U$check
49+
if(tmp.U$check){
50+
PARAM$U[[i.k]] <- tmp.U$value
51+
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
52+
}
53+
} else{
54+
PARAM$U.check[[i.k]] <- FALSE
55+
if(.pmclustEnv$CONTROL$debug > 2){
56+
comm.cat(" SIGMA[[", i.k, "]] has NaN. Updating is skipped\n", sep = "", quiet = TRUE)
57+
}
5058
}
5159
} else{
5260
if(.pmclustEnv$CONTROL$debug > 2){
53-
comm.cat(" SIGMA[[", i.k, "]] is fixed.\n", sep = "")
61+
comm.cat(" SIGMA[[", i.k, "]] is fixed. Updating is skipped\n", sep = "")
5462
}
5563
}
5664
}

R/pm_apecma_base.r

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,25 @@ cm.step.spmd.MU.SIGMA.k <- function(PARAM, i.k){
3737
sqrt(.pmclustEnv$Z.spmd[, i.k] / .pmclustEnv$Z.colSums[i.k])
3838
tmp.SIGMA <- crossprod(B)
3939
tmp.SIGMA <- spmd.allreduce.double(tmp.SIGMA, double(p.2), op = "sum")
40-
dim(tmp.SIGMA) <- c(p, p)
4140

42-
tmp.U <- decompsigma(tmp.SIGMA)
43-
PARAM$U.check[[i.k]] <- tmp.U$check
44-
if(tmp.U$check){
45-
PARAM$U[[i.k]] <- tmp.U$value
46-
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
41+
if(!any(is.nan(tmp.SIGMA))){
42+
dim(tmp.SIGMA) <- c(p, p)
43+
44+
tmp.U <- decompsigma(tmp.SIGMA)
45+
PARAM$U.check[[i.k]] <- tmp.U$check
46+
if(tmp.U$check){
47+
PARAM$U[[i.k]] <- tmp.U$value
48+
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
49+
}
50+
} else{
51+
PARAM$U.check[[i.k]] <- FALSE
52+
if(.pmclustEnv$CONTROL$debug > 2){
53+
comm.cat(" SIGMA[[", i.k, "]] has NaN. Updating is skipped.\n", sep = "", quiet = TRUE)
54+
}
4755
}
4856
} else{
4957
if(.pmclustEnv$CONTROL$debug > 2){
50-
comm.cat(" SIGMA[[", i.k, "]] is fixed.\n", sep = "", quiet = TRUE)
58+
comm.cat(" SIGMA[[", i.k, "]] is fixed. Updating is skipped.\n", sep = "", quiet = TRUE)
5159
}
5260
}
5361

R/pm_em_base.r

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,25 @@ m.step.spmd <- function(PARAM){
8787
sqrt(.pmclustEnv$Z.spmd[, i.k] / .pmclustEnv$Z.colSums[i.k])
8888
tmp.SIGMA <- crossprod(B)
8989
tmp.SIGMA <- spmd.allreduce.double(tmp.SIGMA, double(p.2), op = "sum")
90-
dim(tmp.SIGMA) <- c(p, p)
9190

92-
tmp.U <- decompsigma(tmp.SIGMA)
93-
PARAM$U.check[[i.k]] <- tmp.U$check
94-
if(tmp.U$check){
95-
PARAM$U[[i.k]] <- tmp.U$value
96-
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
91+
if(!any(is.nan(tmp.SIGMA))){
92+
dim(tmp.SIGMA) <- c(p, p)
93+
94+
tmp.U <- decompsigma(tmp.SIGMA)
95+
PARAM$U.check[[i.k]] <- tmp.U$check
96+
if(tmp.U$check){
97+
PARAM$U[[i.k]] <- tmp.U$value
98+
PARAM$SIGMA[[i.k]] <- tmp.SIGMA
99+
}
100+
} else{
101+
PARAM$U.check[[i.k]] <- FALSE
102+
if(.pmclustEnv$CONTROL$debug > 2){
103+
comm.cat(" SIGMA[[", i.k, "]] has NaN. Updating is skipped.\n", sep = "", quiet = TRUE)
104+
}
97105
}
98106
} else{
99107
if(.pmclustEnv$CONTROL$debug > 2){
100-
comm.cat(" SIGMA[[", i.k, "]] is fixed.\n", sep = "", quiet = TRUE)
108+
comm.cat(" SIGMA[[", i.k, "]] is fixed. Updating is skipped.\n", sep = "", quiet = TRUE)
101109
}
102110
}
103111
}

0 commit comments

Comments
 (0)