Skip to content

Commit

Permalink
Fix sign
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Dec 5, 2023
1 parent 7e3bb53 commit d8e140c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/amici/forwardproblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ class ForwardProblem {
* @brief Array of flags indicating which root has been found.
*
* Array of length nr (ne) with the indices of the user functions gi found
* to have a root. For i = 0, . . . ,nr 1 if gi has a root, and = 0 if not.
* to have a root. For i = 0, . . . ,nr 1 or -1 if gi has a root, and = 0
* if not. See CVodeGetRootInfo for details.
*/
std::vector<int> roots_found_;

Expand Down
5 changes: 3 additions & 2 deletions src/forwardproblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace amici {
* @return True if too close, false otherwise.
*/
bool is_next_t_too_close(realtype cur_t, realtype t_next) {
// Based on cvHin
auto tdiff = t_next - cur_t;
if(tdiff == 0.0)
return true;
Expand Down Expand Up @@ -181,7 +180,9 @@ void ForwardProblem::workForwardProblem() {
// if so, set the root-found flag
if (t_ == next_t_event) {
for (auto ie : model->state_independent_events_[t_]) {
roots_found_[ie] = 1;
// determine direction of root crossing from
// root function value at the previous event
roots_found_[ie] = std::copysign(1, -rootvals_[ie]);
}
++it_trigger_timepoints;
}
Expand Down

0 comments on commit d8e140c

Please sign in to comment.