Mercurial > hg > octave-nkf
comparison libinterp/parse-tree/pt-eval.cc @ 19410:0279c601b49c stable
compute for loop indices consistently with range element results
* pt-eval.cc (tree_evaluator::visit_simple_for_command): Use
Range::elem instead of compuiting elements directly. This change
appears to fix obscure test failures in eig.cc-tst on 64-bit Windows
systems. See also task #13313.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Oct 2014 10:41:51 -0400 |
parents | 175b392e91fe |
children | 3978a5509f40 |
comparison
equal
deleted
inserted
replaced
19409:3ffb8f53e940 | 19410:0279c601b49c |
---|---|
334 if (rhs.is_range ()) | 334 if (rhs.is_range ()) |
335 { | 335 { |
336 Range rng = rhs.range_value (); | 336 Range rng = rhs.range_value (); |
337 | 337 |
338 octave_idx_type steps = rng.nelem (); | 338 octave_idx_type steps = rng.nelem (); |
339 double b = rng.base (); | |
340 double increment = rng.inc (); | |
341 | 339 |
342 for (octave_idx_type i = 0; i < steps; i++) | 340 for (octave_idx_type i = 0; i < steps; i++) |
343 { | 341 { |
344 // Use multiplication here rather than declaring a | 342 octave_value val (rng.elem (i)); |
345 // temporary variable outside the loop and using | |
346 // | |
347 // tmp_val += increment | |
348 // | |
349 // to avoid problems with limited precision. Also, this | |
350 // is consistent with the way Range::matrix_value is | |
351 // implemented. | |
352 | |
353 octave_value val (b + i * increment); | |
354 | 343 |
355 ult.assign (octave_value::op_asn_eq, val); | 344 ult.assign (octave_value::op_asn_eq, val); |
356 | 345 |
357 if (! error_state && loop_body) | 346 if (! error_state && loop_body) |
358 loop_body->accept (*this); | 347 loop_body->accept (*this); |