Re: [julia-users] Re: 100 Julia exercises

2014-07-06 Thread Michiaki ARIGA
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,

Re: [julia-users] Re: 100 Julia exercises

2014-07-06 Thread John Myles White
I think anonymous function usage and list comprehensions are separate issues. Anonymous functions are not type-specialized, so they’re basically always slow. I avoid them in any code that’s not one-off. List comprehensions are type-specialized, but the inference for them isn’t super robust,

[julia-users] Re: 100 Julia exercises

2014-07-05 Thread james . dillon . delaney
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

[julia-users] Re: 100 Julia exercises

2014-07-05 Thread james . dillon . delaney
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

[julia-users] Re: 100 Julia exercises

2014-07-05 Thread Michael Prentiss
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,

[julia-users] Re: 100 Julia exercises

2014-06-27 Thread Michiaki Ariga
I solved Expert 4 by Alireza's approach like following. (I don't understand how to use TensorOperations.jl in this case) Thanks for Alireza! ``` p, n = 10, 20 M = ones(n,n,p) V = ones(n,p) S = reduce(+, [M[i,:,j]*V[i] for i = 1:n, j = 1:p])' S ``` 2014年6月27日金曜日 5時59分15秒 UTC+9 Steven G. Johnson:

[julia-users] Re: 100 Julia exercises

2014-06-26 Thread Michiaki Ariga
In original numpy version as following, matrix and vector are 3dimension arrays. Is there any way to compute tensordot like numpy? p, n = 10, 20M = np.ones((p,n,n))V = np.ones((p,n,1))S = np.tensordot(M, V, axes=[[0, 2], [0, 1]])print S# returns #[[ 15.]# [ 15.]# [ 15.]# [ 15.]# [ 15.]]

[julia-users] Re: 100 Julia exercises

2014-06-26 Thread Steven G. Johnson
On Thursday, June 26, 2014 9:54:34 AM UTC-4, Michiaki Ariga wrote: In original numpy version as following, matrix and vector are 3dimension arrays. Is there any way to compute tensordot like numpy? There is no built-in tensor contraction function at the moment

[julia-users] Re: 100 Julia exercises

2014-06-23 Thread Billou Bielour
I'm not sure and array of tuple is what you want in the meshgrid case, I mean can you use it to compute say cos(X*Y) (which is usually what you want to use meshgrid for) ? It's also linked to the problem of evaluating a Gaussian, the solution given here use meshgrid: X, Y =

[julia-users] Re: 100 Julia exercises

2014-06-23 Thread Michiaki Ariga
Thank you for your kind replies. I noticed that I'm not familiar with array comprehension style in Julia. I added your solutions to my repos. (If you have any problem to do it, please tell me) As Alireza said, this is just a translation from numpy, but I believe there are good questions

[julia-users] Re: 100 Julia exercises

2014-06-23 Thread Alireza Nejati
Actually that's not a bad idea; someone should start a Julia-specific exercise repo. About Expert.4, I'm not sure how you're running it, but matlist and veclist should obviously be lists of matrices and vectors, respectively. matlist = Matrix[rand(4,4), rand(4,4)] veclist = Vector[rand(4),

Re: [julia-users] Re: 100 Julia exercises

2014-06-23 Thread Jacob Quinn
Feel free to check out (and contribute!) to https://github.com/quinnj/Rosetta-Julia. I started it when I first got involved with julia and it's got a fair number of examples and exercises. -Jacob On Jun 23, 2014 5:52 PM, Alireza Nejati alireza@gmail.com wrote: Actually that's not a bad

[julia-users] Re: 100 Julia exercises

2014-06-23 Thread Alireza Nejati
Actually, a slight modification. The way I wrote it, it will compute the product of all matrices with all vectors (pxp mults), which is not what you want. You just want each matrix to multiply its respective vector (p mults). The solution to that is: p = length(matlist) reduce(+,

[julia-users] Re: 100 Julia exercises

2014-06-23 Thread Aerlinger
Very cool! Would be interesting to see some examples that utilize the functional aspects of the Julia language. 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

[julia-users] Re: 100 Julia exercises

2014-06-22 Thread harven
I just had a quick look. Here are some ideas for a few exercices. You can use list comprehension in some exercices e.g. Checkerboard pattern Float64[(i+j)%2 for i=1:8, j=1:8] 10x10 matrix with row values ranging from 0 to 9 Float64[j for i=0:9, j=0:9 ] It seems that what is called

[julia-users] Re: 100 Julia exercises

2014-06-22 Thread Alireza Nejati
Same with Apprentice.4 : [(x,y) for x in linspace(0,1,10), y in linspace(0,1,10)] meshgrid() isn't included in Julia because it's almost never really needed. Good work on these exercises, although I fear that the questions, being designed for numpy, may not accurately reflect typical julia