octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51178] publish() sometimes removes last eleme


From: Rik
Subject: [Octave-bug-tracker] [bug #51178] publish() sometimes removes last element from vector after section break
Date: Tue, 6 Jun 2017 12:34:44 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0

Follow-up Comment #2, bug #51178 (project octave):

The root cause of this bug is round-off error in a series of calculations. 
The way the publish.m script works is to execute a block of code, checkpoint
the current workspace by saving all the variables to a temporary file, format
the resulting output for presentation, and then move to the next block of
code.  For the next block of code it restores the current workspace by loading
the variables from the temporary file.

Before my patch, publish.m was just using save/load to restore context. 
Because there were no options, the file format used was that set by the
'save_default_options" command.  The default for this is '-text' which uses
Octave's text format.  Unfortunately, it appears that this format does not
always accurately store range variables.  To see this, I created the file
tst_save_range.m which is attached.  The code is


tm = 29.43357091;
ta = 31 + (8/24);
tb = 31 + ((19+(45/60))/24);
dt = (5 / 60) / 24;
ts = ta:dt:tb;

numel(ts)

Mm = 1;
nm = 2;

save -text tmp.var
clear all
load tmp.var

############################################################
Ms = Mm + 2 * pi * nm * (ts - tm);
numel(Ms)

save -text tmp2.var
clear all
load tmp2.var

############################################################
numel (Ms)


The output is


ans =  142
ans =  142
ans =  141


By using a different format, such as '-binary' or '-v7', the code will work. 
My immediate fix for publish.m was to switch to always using '-binary' format
for saving intermediate variables.



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51178>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]