Skip to content

Commit 607c9a1

Browse files
authored
Fix indexing errors for adjoint quadratures during event updates (#2796)
* Fix indexing error in xQB (related to #18) Now this is in line with the indexing in ReturnData https://github.com/AMICI-dev/AMICI/blob/ce28017159c9172a93b3b5ad6c602ebd3c0cd9d3/src/rdata.cpp#L497 * Fix incorrect documentation of dimensions * Fix error message for finiteness check for deltaqB
1 parent 62e1557 commit 607c9a1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/amici/backwardproblem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ struct BwdSimWorkspace {
3131
/** The model. */
3232
Model* model_;
3333

34-
/** adjoint state vector */
34+
/** adjoint state vector (size: nx_solver) */
3535
AmiVector xB_;
36-
/** differential adjoint state vector */
36+
/** differential adjoint state vector (size: nx_solver) */
3737
AmiVector dxB_;
38-
/** quadrature state vector */
38+
/** quadrature state vector (size: nJ x nplist, col-major) */
3939
AmiVector xQB_;
4040

4141
/** array of number of found roots for a certain event type */

include/amici/model_state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct ModelStateDerived {
336336
std::vector<realtype> dJzdx_;
337337

338338
/** parameter derivative of event likelihood for current timepoint
339-
* (dimension: nJ x nplist x, row-major)
339+
* (dimension: nJ x nplist, col-major)
340340
*/
341341
std::vector<realtype> dJzdp_;
342342

@@ -433,7 +433,7 @@ struct ModelStateDerived {
433433
std::vector<realtype> deltaxB_;
434434

435435
/** temporary storage for change in qB after event
436-
* (dimension: nJ x nplist, row-major)
436+
* (dimension: nJ)
437437
*/
438438
std::vector<realtype> deltaqB_;
439439

src/model.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,11 @@ void Model::addAdjointQuadratureEventUpdate(
15391539
);
15401540

15411541
for (int iJ = 0; iJ < nJ; ++iJ)
1542-
xQB.at(iJ) += derived_state_.deltaqB_.at(iJ);
1542+
xQB.at(ip * nJ + iJ) += derived_state_.deltaqB_.at(iJ);
15431543
}
15441544

15451545
if (always_check_finite_) {
1546-
checkFinite(derived_state_.deltaqB_, ModelQuantity::deltaqB, nplist());
1546+
checkFinite(derived_state_.deltaqB_, ModelQuantity::deltaqB, t);
15471547
}
15481548
}
15491549

0 commit comments

Comments
 (0)