Skip to content

Commit 3b4e12d

Browse files
authored
Fix cblas error for models without solver states in combination with forward sensitivities (#2108)
1 parent f4252b9 commit 3b4e12d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/model.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,15 +1069,17 @@ void Model::getObservableSensitivity(
10691069
// dydx A[ny,nx_solver] * sx B[nx_solver,nplist] = sy C[ny,nplist]
10701070
// M K K N M N
10711071
// lda ldb ldc
1072-
setNaNtoZero(derived_state_.dydx_);
1073-
setNaNtoZero(derived_state_.sx_);
1074-
amici_dgemm(
1075-
BLASLayout::colMajor, BLASTranspose::noTrans, BLASTranspose::noTrans,
1076-
ny, nplist(), nx_solver, 1.0, derived_state_.dydx_.data(), ny,
1077-
derived_state_.sx_.data(), nx_solver, 1.0, derived_state_.dydp_.data(),
1078-
ny
1079-
);
10801072

1073+
if (nx_solver) {
1074+
setNaNtoZero(derived_state_.dydx_);
1075+
setNaNtoZero(derived_state_.sx_);
1076+
amici_dgemm(
1077+
BLASLayout::colMajor, BLASTranspose::noTrans,
1078+
BLASTranspose::noTrans, ny, nplist(), nx_solver, 1.0,
1079+
derived_state_.dydx_.data(), ny, derived_state_.sx_.data(),
1080+
nx_solver, 1.0, derived_state_.dydp_.data(), ny
1081+
);
1082+
}
10811083
writeSlice(derived_state_.dydp_, sy);
10821084

10831085
if (always_check_finite_)

0 commit comments

Comments
 (0)