Skip to content

Commit

Permalink
Merge pull request #119 from gongyh:unimod
Browse files Browse the repository at this point in the history
fix bugs in constraintUnimod
  • Loading branch information
svkucheryavski authored Aug 1, 2024
2 parents 2e3d262 + 1f12b81 commit bfd7aca
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions R/constraints.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ constraintUnimod <- function(x, d, tol = 0) {
# process each component separately
for (a in seq_len(ncol(x))) {

# flatten peaks to the left of maximum
left_part <- (peak.ind[a] - 1):1
x[, a] <- f(x[, a], max = x[peak.ind[a], a], indseq = left_part, step = +1)
if (peak.ind[a] != 1) {
# flatten peaks to the left of maximum
left_part <- (peak.ind[a] - 1):1
x[, a] <- f(x[, a], max = x[peak.ind[a], a], indseq = left_part, step = +1)
}

if (peak.ind[a] != nvar) {
# flatten peaks to the right of maximum
right_part <- (peak.ind[a] + 1):nvar
x[, a] <- f(x[, a], max = x[peak.ind[a], a], indseq = right_part, step = -1)
}

# flatten peaks to the right of maximum
right_part <- (peak.ind[a] + 1):nvar
x[, a] <- f(x[, a], max = x[peak.ind[a], a], indseq = right_part, step = -1)
}

return(x)
Expand Down

0 comments on commit bfd7aca

Please sign in to comment.