Commit e9526087 authored by Jerome Benoit's avatar Jerome Benoit

RC #793998 - eg/test_updating - fix (hardden)

parent cd2f5874
......@@ -6,7 +6,7 @@ apophenia (0.999e+ds-3) UNRELEASED; urgency=medium
- tests/distribution_tests FAILURE on some 32bit architectures: double
comparison issue, fix via a numerical approach (based on GSL_DBL_EPSILN).
-- Jerome Benoit <calculus@rezozer.net> Sat, 29 Aug 2015 01:56:36 +0000
-- Jerome Benoit <calculus@rezozer.net> Sun, 30 Aug 2015 17:58:03 +0000
apophenia (0.999e+ds-2) unstable; urgency=medium
......
Description: upstream -- RC bug fix 793998 -- eg/test_updating
Fix a type conversion bug that failed the eg/test_updating test on some
architectures (e.g., arm64 and ppc64el).
architectures (e.g., arm64 and ppc64el). The initial fix has been harden
as it raised new issues on the 32bit i386 architecture.
The patch was designed with 'gcc (Debian 5.2.1-15) 5.2.1 20150808' on
i386, arm64, and ppc64el Debian porters (sid).
The raised issue is likely due to some unexpected (broken ?) optimization
at compile time: the use of the function modf appeared to break the
faulty optimization.
Origin: debian
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2015-08-29
Last-Update: 2015-08-30
--- a/apop_mcmc.c
+++ b/apop_mcmc.c
@@ -196,13 +196,13 @@
@@ -196,13 +196,14 @@
}
-void main_mcmc_loop(apop_data *d, apop_model *m, apop_data *out, gsl_vector *draw,
+void main_mcmc_loop(apop_data *d, apop_model *m, apop_data *out, gsl_vector *draw,
apop_mcmc_settings *s, gsl_rng *rng, int *constraint_fails){
+ double integerpart_periods_burnin = GSL_NAN; modf((double)(s->periods)*s->burnin,&integerpart_periods_burnin);
s->accept_count = 0;
+ int out_row = - s->periods*s->burnin;
+ int out_row = -lround(integerpart_periods_burnin);
int block = 0;
- for (s->proposal_count=1; s->proposal_count< s->periods+1; s->proposal_count++){
- one_step(d, draw, m, s, rng, constraint_fails, out, block
......@@ -25,3 +32,21 @@ Last-Update: 2015-08-29
block = (block+1) % s->block_count;
s->proposals[block].adapt_fn(s->proposals+block, s);
//if (constraint_fails>10000) break;
@@ -300,11 +301,14 @@
apop_prep(d, m); //typically a no-op
s->last_ll = GSL_NEGINF;
gsl_vector * drawv = apop_data_pack(m->parameters);
- Apop_stopif(s->burnin > 1, s->burnin/=(s->periods + 0.0),
+ const double double_periods = (double)(s->periods);
+ Apop_stopif(s->burnin > 1, s->burnin/=double_periods,
1, "Burn-in should be a fraction of the number of periods, "
"not a whole number of periods. Rescaling to burnin=%g."
- , s->burnin/(s->periods+0.0));
- apop_data *out = apop_data_alloc(s->periods*(1-s->burnin), drawv->size);
+ , s->burnin/double_periods);
+ double integerpart_periods_cburnin = GSL_NAN; modf(double_periods*(1.0-s->burnin),&integerpart_periods_cburnin);
+ const size_t data_size1 = llround(integerpart_periods_cburnin);
+ apop_data *out = apop_data_alloc(data_size1, drawv->size);
if (!s->proposals){
set_block_count_and_block_starts(m->parameters, s, drawv->size);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment