Re: [julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-20 Thread Mauro
On Mon, 2016-06-20 at 10:32, Chris Rackauckas wrote: > I agree rationals don't make sense in most cases (I did it once just for > fun), but how would it work with other defined numbers as they come? Will > the promotions "just work?" No. It is the duty of the type-creator to embed their new type

Re: [julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-20 Thread Chris Rackauckas
I agree rationals don't make sense in most cases (I did it once just for fun), but how would it work with other defined numbers as they come? Will the promotions "just work?" But as mentioned, applying f once and using the types from there would catch most cases. On Monday, June 20, 2016 at 9

Re: [julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-20 Thread Mauro
I'd say this is a bug. `sin(5)` works, so `ode23(f, 0, [0,1])` should work too by promoting `y0=0` and `tspan=[0,1]` to appropriate types. Note that `eltype(tspan)` needs to be promoted to some kind of floating point number; I don't think rationals make sense for differential-equations. I pushed

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Joungmin Lee
Thank you all for the discussion! I have recently moved from Python to Julia, so I didn't know that. :) Joungmin 2016년 6월 20일 월요일 오전 3시 49분 55초 UTC+9, Joungmin Lee 님의 말: > Hi, > > I am making simple examples of the ODE package in Julia, but I cannot make > a code without error for 1st order OD

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Gabriel Gellner
Fair enough. I guess if the urge is to support strangely generic code then the inputs should never be expected to be promoted. But I just don't see what you are describing as being a "standard" in Julia. ODE.jl and your project maybe try to attain this level of genericity, but most of Base seem

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Chris Rackauckas
But I gave an example where the output type can change depending on the chosen timespan (eltype(y0)==Rational{Int}), so "eltype(f(y0))" can really only be what the time integration algorithm actually produces, which means you have to just run it and see what happens. It becomes a type-stability

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Gabriel Gellner
I will admit my understanding of type stability in a jit compiler is shakey, but I don't see 0.5//2 as a type instability, rather it is a method error (the issues is a float does not convert to an int, but having a int become a float is a fair promotion, so I can't see why requiring y0 to be a

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Chris Rackauckas
I mean, it's the same type instability that you get if you try things like .5//2. Many Julia function work with ints that give a float, but not all do. If any function doesn't work (like convert will always fail if you somehow got a float but initialized an array to be similar(arrInt)), then yo

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Gabriel Gellner
Is this truly a type instability? The function f has no type stability issues from my understanding of the concept. No matter the input types you always get a Float output so there is no type instability. Many of Julia's functions work this way, including division 1/2 -> float even though the i

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Chris Rackauckas
I wouldn't call this a bug, it's a standard Julia thing for a reason. You get an InexactError() because you start with an Int and you do an operation which turns the Int into a Float so the program gets mad at the type instability. You can just change everything to floats, but then you're getti

[julia-users] Re: Unexpected error on 1st order ODE using ODE package

2016-06-19 Thread Gabriel Gellner
You are passing in the initial condition `start` as an integer, but ode23 needs this to be a float. Change it to `const start = 3.0` and you are golden. This does feel like a bug you should file an issue at the github page. On Sunday, June 19, 2016 at 11:49:55 AM UTC-7, Joungmin Lee wrote: > >