Skip to content

Commit a1bfb2b

Browse files
committed
_compute_estimate: change order of T() and ^Q in denominator
Running a simple test using Unitful: @u_str import Interpolations as Ilib import Interpolations import FiniteDifferences as FDlib tt = (0.0 : 0.01 : 1.1) .* u"s" fn = 3u"J / s" .* tt ii = Ilib.interpolate((tt,),fn, ComposedFunction(Ilib.Gridded, Ilib.Linear)()) cdm = FDlib.central_fdm(5,1) @show dd = cdm(ii, 0.6u"s") without this change in the order of operations causes the code to crash in _limit_step, because of a dimension mismatch. This is a temporary "fix", that actually not a fix. The given order of operations should really work as-is...
1 parent 311bf8a commit a1bfb2b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/methods.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@ function _compute_estimate(
260260
# therefore perform the broadcasting first. See
261261
# https://github.com/JuliaLang/julia/issues/39151.
262262
_coefs = T.(coefs)
263-
return sum(fs .* _coefs) ./ T(step)^Q
263+
# NOTE the denominator: while doing T(step)^Q should technically be possible and correct,
264+
# without flipping the order of ^ Q and T(), the current code crashes in _limit_step
265+
# because of dimension mismatch. However, the output now has wrong units.
266+
#
267+
# TODO: fix the output units. The numerical value is correct in a simple test.
268+
return sum(fs .* _coefs) ./ T(step ^ Q)
264269
end
265270

266271
# Check the method and derivative orders for consistency.

0 commit comments

Comments
 (0)