Iain had a reference for wikipedia, so that wasn't an issue.

On Tuesday, August 26, 2014 11:23:48 AM UTC+2, Phillip Berndt wrote:
>
>
> It looks like i'm the only one not do be able to recognize 'the' algorithm 
>> in all 3 examples?
>>
>
> They all are variants of the method described on Wikipedia [
> https://en.wikipedia.org/wiki/Magic_square#Types_and_construction]. Sorry 
> for not pointing that out earlier.
>
>
My point was, that Iain's example and your code for the odd construction is 
basically the same, because the algorithm is residing in the div and mod 
operations and not in the construction of any intermediate value. So 
basically this is a vector/matrix algorithm and can be written as explicit 
loop over all elements or with broadcast operations (so implicit loops). 
I'm fine with both versions and i do not prefer either. I say, i do not 
recognize the algorithm, because by looking at the div and mod of row and 
column indices i do not see, what the math is here about. 

But maybe that's why it's called magic.

Oldschool julia users and developers have a tendency to discourage 
vectorized forms, but i'm still waiting for a convicing example to go for 
explicit loops in the general case. 

Reply via email to