Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Computation precision on command line and in scripts
Replies: 8   Last Post: Feb 11, 2013 6:59 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,727
Registered: 7/26/08
Re: Computation precision on command line and in scripts
Posted: Feb 9, 2013 5:10 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Update. I'm now pretty sure the JIT accelerator does something when the lhs is a scalar (:).

What I did is force calling the built-in function by a wrap functions, so JIT is not kicked in, and the result is different only when the scalar LHS is indexed by (:).

Here is the code that shows what is going on:

function [a rd_colon rd] = foo(b, c, d, bsxflag)

if nargin >= 4 && bsxflag
% http://www.mathworks.com/matlabcentral/fileexchange/23821-bsxops
bsxops(1);
end

a = zeros(1,2,'double');
bar = b + c - d;
a(1) = b + c - d; % always 0
a(2) = bar; % always 0

rd_colon = double(0); % <= zeros(1,1,'double');
rd_colon(:) = b + c - d; % 1.0000e-09 when bsxflag is FALSE

rd = b + c - d; % always 0

bsxops(0);

end % foo

% Test on command line (2012B, WIN7-64):

>> [a rd_colon rd] = foo(single(1),double(1e-9),double(1), 0)

a =

0 0


rd_colon =

1.0000e-09


rd =

0

>> [a rd_colon rd] = foo(single(1),double(1e-9),double(1), 1)

a =

0 0


rd_colon =

0


rd =

0

% Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.