File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[deps ]
2+ BenchmarkTools = " 6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
23CairoMakie = " 13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
4+ FastInterpolations = " 9ea80cae-fc13-4c00-8066-6eaedb12f34b"
5+ ForwardDiff = " f6369f11-7733-5829-9624-2563aa707210"
36GraphMakie = " 1ecd5474-83a3-4783-bb4f-06765db800d2"
47Graphs = " 86223c79-3864-5bf0-83f7-82e725a168b6"
58LayeredLayouts = " f4a74d36-062a-4d48-97cd-1356bad1de4e"
69NetworkLayout = " 46757867-2c16-5918-afeb-47bfcb05e46a"
710NonlinearSolve = " 8913a72c-1f9b-4ce2-8d82-65094dcecaec"
811ODEProblemLibrary = " fdc4e326-1af4-4b90-96e7-779fcce2daa5"
912OrdinaryDiffEq = " 1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
13+ StaticArrays = " 90137ffa-7385-5640-81b9-e52037218182"
1014SymbolicUtils = " d1185830-fcd6-423d-90d6-eec64667417b"
1115Symbolics = " 0c5d862f-8b57-4792-8d23-62f2024744c7"
1216TaylorDiff = " b36ab563-344f-407b-a36a-4f200bebf99c"
Original file line number Diff line number Diff line change 1+ using FastInterpolations
2+ import ForwardDiff, TaylorDiff
3+ using BenchmarkTools
4+
5+ x = 0.0 : 0.1 : 1.0
6+ y = sin .(π * x)
7+ itp = cubic_interp (x, y)
8+
9+ x0 = 0.45
10+
11+ function analytic (itp, x0)
12+ return itp (x0; deriv = DerivOp (2 ))
13+ end
14+ @btime analytic ($ itp, $ x0)
15+
16+ function td (itp, x0)
17+ t = TaylorDiff. TaylorScalar {2} (x0, one (x0))
18+ v = itp (t)
19+ return v. partials[2 ] * 2
20+ end
21+ @btime td ($ itp, $ x0)
22+
23+ @code_typed analytic (itp, x0)
24+ @code_typed td (itp, x0)
25+
26+ z = [sin (xi) * sin (yi) for xi in x, yi in x]
27+ itp2d = cubic_interp ((x, x), z)
28+
29+ function analytic2 (itp2d, x0)
30+ return itp2d ((x0, x0); deriv = DerivOp (2 , 0 ))
31+ end
32+ @btime analytic2 ($ itp2d, $ x0)
33+
34+ @code_native analytic2 (itp2d, x0)
35+
36+ function td2 (itp2d, x0)
37+ t = TaylorDiff. TaylorScalar {2} (x0, one (x0))
38+ v = itp2d ((t, x0))
39+ return v. partials[2 ] * 2
40+ end
41+ @code_native td2 (itp2d, x0)
You can’t perform that action at this time.
0 commit comments