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 7, 2013 4:12 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message >
> The documentation states that
>
> 1) an arithmetic expression is mixed with two numerical type, the result is cast in lower type, then the operation is carried out.
>
> 2) The expression is evaluated from left to right
>


It seems that this rule does not applied for scalar expression affected with colon operator on the lhs. To avoid JIT, I put the argument as parameters of foo function.

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

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

rd = 0;
rd(:) = b + c -d;

rs = single(0);
rs(:) = b + c -d;

end % foo

% and here is the result

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

a =

0 0


rd =

1.0000e-09


rs =

1.0000e-09

>>



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.