There's some difference in how `methods` prints the signature and how it looks
in code. The version in code is usually clearer, so let's focus on that.
The `lower::T` means `lower` has type `T`. The `{T<:Real}` means that T has to
be a real number. This could have been written
optimize(f::Function, lower::Real, upper::Real, ...)
except that, later on, there's a default value provided for `rel_tol` and
`abs_tol` which depends on the number type `T`. The intention behind that
construct is that, for example, you want to use a different tolerence for
convergence depending on whether you're optimizing a function of a Float32 or
a Float64.
The issue is that if you pass `0` and `2`, these are both Ints. And `eps(Int)`
doesn't exist.
Since you're obviously still pretty new to Julia, I'm just going to do this
for you. Here's the commit:
https://github.com/JuliaOpt/Optim.jl/commit/2c812c9cbdbca95aaf00e703289f1297844698d4
You can study how it works and see how to fix such things in the future.
(Studying how people fix bugs that bit you is a great way to learn more about
Julia.)
Best,
--Tim
On Tuesday, September 30, 2014 03:30:01 AM [email protected] wrote:
> Hi Tim,
>
> Thanks so much for your answer, indeed this was the issue here. Specifying
> the function the way you said indeed gets rid of the error (and raises a
> new one, namely
>
> `isless` has no method matching isless(::Array{Float64,1},
> ::Array{Float64,1}), I'll try to figure this one out later...). Can I
> bother you with one related but general question: How do I interpret the
> first curly brackets in the function definition? The function definition
> says optimize{T<:Real}(f::Function,
>
> lower::T<:Real,upper::T<:Real), where I understand the f::Function,
> lower::T<:Real, upper::T<:Real give the expected inputs and their
> respective types, but what exactly does the {T<:Real} tell me?
>
> You can tell I'm coming from Matlab and even though I've been doing data
> analysis in Python for a while, object oriented programming still doesn't
> come naturally to me...
>
> Best,
> Nils