bachrathyd / MDBM.jl

Multi-Dimensional Bisection Method: Julia package to determine the set of roots for 'any' parameter dimension and 'any' codimension
MIT License
33 stars 5 forks source link

Passing SVectors to MDBM_Problem #15

Closed BeastyBlacksmith closed 5 years ago

BeastyBlacksmith commented 5 years ago

What is the reason that you can't allow AbstractArays here?

I naively expected it to work with StaticArrays.

bachrathyd commented 5 years ago

Your question is not clear for me. Did you try to pass a StaticArryas as an 'axis' parameter? Did you try to use a single variable problem?

Note, that this method is basically designed for multi-variable problem, so variable axes must be provided in a Vector. Even if a single-variable problem is used, then that single axis should be passed in a vector form.

Try to use this form:

a = SVector{7}([-3,-2,-1,0,1, 2, 3])
mymdbm=MDBM_Problem((x)->x^2-2,[a])
solve!(mymdbm,5)
println(getinterpolatedsolution(mymdbm))
BeastyBlacksmith commented 5 years ago

my code was more like

a = Axis([-3,-2,-1,0,1, 2, 3])
b = Axis([-3,-2,-1,0,1, 2, 3])
ax = @SVector [a,b]
mymdbm=MDBM_Problem((x...)->x.^2.-2,ax)
solve!(mymdbm,5)
println(getinterpolatedsolution(mymdbm))
bachrathyd commented 5 years ago

Thank your for the comment! I did not considered this type of calling. You are right, Vector is updated to AbstractVector and it solved the problem. See the commit However, this type of calling will not effect any performance, because the axes is used in a different format (struct), so there is no need to use this form

ax = @SVector [a,b]

it is sufficient to use:

ax = [a,b]