Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when k10 is equal to ka in one-compartment closed-form model #1197

Merged
merged 7 commits into from
Jun 28, 2024

Conversation

kylebaron
Copy link
Collaborator

@kylebaron kylebaron commented May 27, 2024

For closed-form solution to one-compartment model, error when KA and CL/V are too close together.

  • Write test
  • Decide on eps

@kylebaron kylebaron linked an issue May 27, 2024 that may be closed by this pull request
@kylebaron kylebaron added this to the Future Version milestone May 27, 2024
@kylebaron kylebaron marked this pull request as draft May 27, 2024 05:09
@kylebaron kylebaron requested a review from kyleam June 22, 2024 03:06
@kylebaron kylebaron marked this pull request as ready for review June 22, 2024 03:06
@@ -380,6 +380,12 @@ void odeproblem::advan2(const double& tfrom, const double& tto) {

if(k10 <= 0) Rcpp::stop("k10 has a 0 or negative value");

// Going for the simpler method; using epsilon of ~ 100 * DBL_EPSILON
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
if(std::fabs(ka-k10) < 2.22e-14) {
Copy link
Contributor

@kyleam kyleam Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach makes sense here.


Just a note:isSymmetric.matrix uses 100 * DBL_EPSILON as its default value too.

https://github.com/wch/r-source/blob/9d01d16b4cda7b53b9a2c94a1e3f078faf1b9eaa/src/library/base/R/eigen.R#L22

@kylebaron kylebaron merged commit 96dfac6 into main Jun 28, 2024
7 checks passed
@kylebaron kylebaron deleted the clv-ka-gh119 branch June 28, 2024 15:43
@kylebaron kylebaron modified the milestones: Future Version, 1.4.3 Jul 3, 2024
@kylebaron kylebaron mentioned this pull request Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined behavior in pk1 when KA=CL/V
2 participants