Hi,
This is how I’m defining the function.
function unrestricted_search(f::Function, δ::T, x0::T) where T# Maximization algorithm
f0 = f(x0)
Data = DataFrame(f=f0, x=x0)
diff = f(x0+δ) - f(x0)
if diff < 0
δ = -δ
end
x1 = x0 + δ
push!(Data, (f=f(x1), x=x1))
n=2
while Data.f[end-1] < Data.f[end]
x = x0 + n*δ
push!(Data, (f=f(x), x=x))
n += 1
end
Optima = Data[n-1, :]
return Data, n, Optima
end
When I call the function with unmatching data types,
unrestricted_search(f, 0.1, 0)
It results in the following error.
LoadError: InexactError: Int64(0.1)
InexactError: Int64(0.1)
Is there a way to automatically read the input as Float64 if one of them is float?
PS:
Also, as a side note. I created the following function for testing
function addition(x1::T, x2::T) where T
x3 = x1 + x2
return
end
addition(1.,2)
which results in the following error
LoadError: MethodError: no method matching addition(::Float64, ::Int64)
e[0mClosest candidates are:
e[0m addition(::T, e[91m::Te[39m) where T at In[57]:1
MethodError: no method matching addition(::Float64, ::Int64)
Closest candidates are:
addition(::T, ::T) where T at In[57]:1
Why are the errors different ?