yep, x never changes...

On Monday, April 28, 2014 12:25:14 AM UTC+8, Jason Merrill wrote:
>
> On Sunday, April 27, 2014 12:04:26 AM UTC-7, Elliot Saba wrote:
>>
>> Since we have made sure that our for loops have the right boundaries, we 
>> can assure the compiler that we're not going to step out of the bounds of 
>> an array, and surround our code in the @inbounds macro.  This is not 
>> something you should do unless you're certain that you'll never try to 
>> access memory out of bounds, but it does get the runtime down to 0.23 
>> seconds, which is on the same order as Java.  Here's the full 
>> code<https://gist.github.com/staticfloat/11339342>with all the modifications 
>> made.
>> -E
>>
>
> I made this comment on the gist, and then figured I should just copy it 
> here:
>
> Lifting the computation of the scaling constant out of the loop shaves 
> another 13% off the runtime. So change lines 28-30 to
>
>     c = rate*(y[n] - y_hat)    for k=1:K
>         w[k] += c * x[k,n]    end
>  
>
> Ideally, the compiler might do that for you.
>
> BTW, is x really supposed to remain the same between iterations?
>  
>

Reply via email to