[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-21 Thread francois . fayard
Hi Hans, There was a huge slowdown in your code with : local i::Int. If you change it to i = 0 (therefore i::Int64), the return type is always Int64. Therefore, Julia can generate efficient code. Use @time to check it. This change makes your code 10 time faster on my machine. On Wednesday,

[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-21 Thread francois . fayard
Good catch. I have no idea the reason behind this behaviour. It would be interesting to know why. On Wednesday, May 21, 2014 7:58:02 PM UTC+2, Peter Simon wrote: I don't think this slowness is because of type instability, as I understand the concept. On a 64-bit machine `Int === Int64` is

[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-20 Thread francois . fayard
Hi, I would do a while as the loop is a conditional loop : function test(x::Vector{Float64}) i = 1 while i = length(x) x[i] != 0.0 i += 1 end return i - 1 end or I would use a return inside the for loop even though I prefer to avoid a return in the middle of a

[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-20 Thread francois . fayard
Hi, I would do a while as the loop is a conditional loop : function test(x::Vector{Float64}) i = 1 while i = length(x) x[i] != 0.0 i += 1 end return i - 1 end or I would use a return inside the for loop even though I prefer to avoid a return in the middle of a

[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-20 Thread francois . fayard
This method is also a bit faster as you can check with @time. I guess that it's because there is only one if per loop as opposed to 2 if per loop in your design (Are we at the end of the array ? Is it a 0.0 ?). François On Wednesday, May 21, 2014 12:09:02 AM UTC+2, francoi...@gmail.com wrote:

[julia-users] Re: Accessing the loop variable (and pi as float)

2014-05-20 Thread francois . fayard
Also, your program is weird. My guess is that you want to give the largest k such that x[1],..., x[k] are not equal to 0. If you want that, your program is wrong when x does not contain any 0. The fact that if x does not contain any 0, your program return length(x) - 1 is very weird to me. On

[julia-users] Design patterns for an API

2014-05-16 Thread francois . fayard
Hi, I am starting to use Julia, and I would like to learn and contribute a bit. As I have some experience in numerics I am thinking of contributing to the ODE package. I've read the ideas for the API, and I believe that we can still improve it. Usually, for this kind of solver, we could

[julia-users] Re: Design patterns for an API

2014-05-16 Thread francois . fayard
I am new to GitHub. Is there some kind of forum, or do you mean to create a new file with my thoughts on it ? On Friday, May 16, 2014 11:26:21 PM UTC+2, Alex wrote: so if you have a github account it might be good to post your thoughts there as well.

[julia-users] Translate Julia into another language

2014-05-11 Thread francois . fayard
Hi Julia users, As a newcomer, let me first introduce myself. I have some experience in numeric code, written mostly in Fortran 2008, C++, C#, Delphi and Mathematica. As a consultant, I have to write some numerical codes but those need to be written in languages that are different from clients

[julia-users] Re: readcsv returns Array{T, 1}

2014-05-11 Thread francois . fayard
It would be a bad idea to return Array{T, 1} in the special case of a file with a single column. The return type would be dependent upon the csv file which is a really bad design. On Sunday, May 11, 2014 8:29:57 PM UTC+2, Ethan Anderes wrote: Does it make sense to have readcsv return an

Re: [julia-users] Translate Julia into another language

2014-05-11 Thread francois . fayard
On the whole I think that just sucking it up and using the different languages clients require is on the whole the least trouble Unfortunately, that's less time spending with Julia :-(. Still, it will be an amazing tool for prototyping, and it might be worth it to translate the code manually