help-octave
[Top][All Lists]
Advanced

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

Re: Unequal results when using element-wise and broadcast power operatio


From: Mike Miller
Subject: Re: Unequal results when using element-wise and broadcast power operations
Date: Fri, 22 Nov 2013 12:31:18 -0500

On Fri, Nov 22, 2013 at 18:33:14 +0200, Jose wrote:
> 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.

Works for me, I get identical results for all 3 in version 3.6.4 and
in the current development version.

-- 
mike


reply via email to

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