Skip to content

Commit

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

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 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)

# 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 0e8d954

Please sign in to comment.