Thank you for your correction, Jim. In Apprentice.2, same approach with numpy version, I fixed as following.
``` Z = rand(100,2) X, Y = Z[:,1], Z[:,2] R = sqrt(X.^2 + Y.^2) T = atan2(Y,X) ``` Also in Apprentice. 7, I fixed . position. I understand Julia works well without anonymous function, so when should I use array comprehension? Do I have to make function to use array comprehension? Many people advised to use array comprehension in this thread, but I don't understand when to use it... che...@gmail.com 2014-07-06 10:58 GMT+09:00 Michael Prentiss <mcprent...@gmail.com>: > Julia is not as performant with anonymous functions, and list > comprehension. > The compiler has a harder time with the optimization step. This is not a > surprise and is > known to the language designers. This is not a surprise. > > > On Saturday, July 5, 2014 8:01:46 PM UTC-5, james.dill...@gmail.com wrote: >> >> >> In Apprentice.6, I don't think you want to use the sqrtm(). sqrt() is >> already vectorized over the matrix. Also a couple of '.'s are misplaced, >> so perhaps instead: >> >> Z =rand(10,2) >> >> D = sqrt((Z[:,1].-Z[:,1]').^2+(Z[:,2].-Z[:,2]').^2) >> >> As a newbie myself, what surprised me is that this is faster and >> allocates less memory than the comprehension: >> >> D = [norm(Z[i,:]-Z[j,:],2) for i = 1:10, j = 1:10] >> >> I am sure someone else here can explain why. >> >> Jim >> On Sunday, June 22, 2014 10:43:32 AM UTC-4, Michiaki Ariga wrote: >>> >>> Hi all, >>> >>> I'm a Julia newbee, and I'm trying to learn Julia and wrote Julia >>> version of rougier's 100 numpy exercises(http://www.loria.fr/ >>> ~rougier/teaching/numpy.100/index.html). >>> >>> https://github.com/chezou/julia-100-exercises >>> >>> I'd like you to tell me more "julia way" or something wrong with. >>> >>> Best regards, >>> Michiaki >>> >>