No big deal, just now noticed it, is all.  FWIW, I like the comprehension 
order better (inner = faster).  Although I also see François' point about 
the for loop nesting.

Thanks,
--Peter

On Friday, May 16, 2014 2:10:19 PM UTC-7, Stefan Karpinski wrote:
>
> It's less about the array ordering and more about the fact that 
> mathematically the row index comes before the column index and doing it the 
> other way would be very confusing. It's a shame these don't match, but 
> there's not much to do about it.
>
> On May 16, 2014, at 4:57 PM, francoi...@gmail.com <javascript:> wrote:
>
> I am very new to Julia, but here is my guess :
> - for i = , j =
>   should be the same as
>   for i =
>     for j =
>   It would be awkward to have something else.
> - For comprehensions, the order is the other way around because matrices 
> are stored in Julia in column order as in Fortran (and maybe Matlab) as 
> opposed to C. Therefore, ordering the comprehension that way make the 
> filling of the array cache-friendly.
>
> François
>
> On Friday, May 16, 2014 10:52:22 PM UTC+2, Peter Simon wrote:
>>
>> Comprehensions and for loops do not perform nested looping in the same 
>> order:
>>
>> julia> [begin println((i,j)); (i,j) end  for i = 1:3, j = 1:4]
>> (1,1)
>> (2,1)
>> (3,1)
>> (1,2)
>> (2,2)
>> (3,2)
>> (1,3)
>> (2,3)
>> (3,3)
>> (1,4)
>> (2,4)
>> (3,4)
>> 3x4 Array{(Int64,Int64),2}:
>>  (1,1)  (1,2)  (1,3)  (1,4)
>>  (2,1)  (2,2)  (2,3)  (2,4)
>>  (3,1)  (3,2)  (3,3)  (3,4)
>>
>>
>> julia> for i = 1:3, j=1:4
>>            println((i,j))
>>        end
>> (1,1)
>> (1,2)
>> (1,3)
>> (1,4)
>> (2,1)
>> (2,2)
>> (2,3)
>> (2,4)
>> (3,1)
>> (3,2)
>> (3,3)
>> (3,4)
>>
>>
>>
>> Just wondering what the rationale is for this difference.
>>
>> --Peter
>>
>

Reply via email to