Merge pull request #1129 from mkborregaard/fix-function-vector

Apply automatic limits for vectors of functions
This commit is contained in:
Michael Krabbe Borregaard 2017-10-05 12:26:04 +02:00 committed by GitHub
commit 0cd382a1ce

View File

@ -371,6 +371,13 @@ end
end end
# try some intervals over which the function may be defined # try some intervals over which the function may be defined
function tryrange(F::AbstractArray, vec)
rets = [tryrange(f, vec) for f in F] # get the preferred for each
maxind = maximum(indexin(rets, vec)) # get the last attempt that succeeded (most likely to fit all)
rets .= [tryrange(f, vec[maxind:maxind]) for f in F] # ensure that all functions compute there
rets[1]
end
function tryrange(F, vec) function tryrange(F, vec)
for v in vec for v in vec
try try
@ -379,7 +386,7 @@ function tryrange(F, vec)
catch catch
end end
end end
error("Function not defined over the given interval, $vec") error("$F is not a Function, or is not defined at any of the values $vec")
end end
# #
# # -------------------------------------------------------------------- # # --------------------------------------------------------------------