help-octave
[Top][All Lists]
Advanced

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

Unequal results when using element-wise and broadcast power operations


From: Jose
Subject: Unequal results when using element-wise and broadcast power operations
Date: Fri, 22 Nov 2013 18:33:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

Hello.

As the subject says, have a look.
----------
clear all
r=3;
N=100;
S=rand(1,N);
C=S.^r;
C2=bsxfun(@power,S,r);
for n=1:N
  C3(n)=S(n)^r;
endfor
assert(C,C2)  %fails
assert(C,C3)  %fails
assert(C2,C3) %Does not fail
----------

The cases that fail will not if we use assert with a tolerance of say 1e-10. In case r=2, the previous test passes cleanly.

I think that they should all give bitwise identical result for any value of r. Or am I missing something?

I am using octave 3.6.4.

BR,
J.



reply via email to

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