I have not heard it explicitly from the developers, but it seems obvious to 
me that implementing slicing as a view into the original array, is hard to 
do right, while a copy is simple. They probably wanted to do the simple 
thing first, and then solve the harder problem when things settle down. 
This behaviour will likely change soon and be included in the 0.4 release.

Ivar

kl. 09:57:12 UTC+2 torsdag 14. august 2014 skrev Andrew Wrigley følgende:
>
> Excellent, thanks. Replacing `@inbounds a = dot(W[:,n], state)` with the 
> following gave a ~5x improvement:
>
>             a::Float64 = 0
>             for k in 1:N
>                 @inbounds a += W[k, n] * state[k]
>             end
>
> The ::Float64 annotation was necessary or it was really slow. Why does 
> Julia copy the column before using it in the expression?
>
> Andrew
>
> On Thursday, August 14, 2014 2:40:54 PM UTC+10, John Myles White wrote:
>>
>> Here are some things you might try: 
>>
>> (1) Don’t use a global const. Pass N as an argument to all functions. 
>>
>> (2) Use in-place multiplication via functions like A_mul_B! in lines like 
>> `@inbounds a = dot(W[:,n], state)`. In Julia 0.3, W[:,n] creates a copy of 
>> that column of W on every iteration. 
>>
>> (3) Don’t make full copies of state in lines like `@inbounds samples[:,i] 
>> = copy(state)`. Do explicit elementwise copying, which is much cheaper. 
>>
>>  — John 
>>
>> On Aug 13, 2014, at 9:14 PM, Andrew Wrigley <[email protected]> wrote: 
>>
>> > <gibbstiming.jl> 
>>
>>

Reply via email to