Skip to content

Commit 9836fc3

Browse files
Pick up a PreallocationTools.jl dependency
This drops LabelledArrays.jl out of the DiffEq dependency tree.
1 parent d2ca535 commit 9836fc3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1212
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
13+
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
1314

1415
[compat]
1516
ArrayInterface = "2.8, 3.0, 4, 5, 6"
1617
ArrayInterfaceStaticArrays = "0.1"
1718
ChainRulesCore = "1"
1819
MacroTools = "0.5"
20+
PreallocationTools = "0.4"
1921
StaticArrays = "0.10, 0.11, 0.12, 1.0"
2022
julia = "1.6"
2123

src/LabelledArrays.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ function ArrayInterface.ismutable(::Type{<:LArray{T, N, Syms}}) where {T, N, Sym
6363
end
6464
ArrayInterface.can_setindex(::Type{<:SLArray}) = false
6565

66+
function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache,
67+
u::LArray{T, N, D, Syms}) where {T, N, D, Syms}
68+
nelem = div(sizeof(T), sizeof(eltype(dc.dual_du))) * length(dc.du)
69+
if nelem > length(dc.dual_du)
70+
PreallocationTools.enlargedualcache!(dc, nelem)
71+
end
72+
_x = ArrayInterfaceCore.restructure(dc.du, reinterpret(T, view(dc.dual_du, 1:nelem)))
73+
LabelledArrays.LArray{T, N, D, Syms}(_x)
74+
end
75+
6676
export SLArray, LArray, SLVector, LVector, @SLVector, @LArray, @LVector, @SLArray
6777

6878
export @SLSliced, @LSliced

0 commit comments

Comments
 (0)