-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #637 from KristofferC/kc/LA_ext
make LabelledArrays an extension
- Loading branch information
Showing
3 changed files
with
34 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module SymbolicUtilsLabelledArraysExt | ||
|
||
using LabelledArrays | ||
using LabelledArrays.StaticArrays | ||
using SymbolicUtils | ||
|
||
@inline function SymbolicUtils.Code.create_array(A::Type{<:SLArray}, T, nd::Val, d::Val{dims}, elems...) where {dims} | ||
a = SymbolicUtils.Code.create_array(SArray, T, nd, d, elems...) | ||
if nfields(dims) === ndims(A) | ||
similar_type(A, eltype(a), Size(dims))(a) | ||
else | ||
a | ||
end | ||
end | ||
|
||
@inline function SymbolicUtils.Code.create_array(A::Type{<:LArray}, T, nd::Val, d::Val{dims}, elems...) where {dims} | ||
data = SymbolicUtils.Code.create_array(Array, T, nd, d, elems...) | ||
if nfields(dims) === ndims(A) | ||
LArray{eltype(data),nfields(dims),typeof(data),LabelledArrays.symnames(A)}(data) | ||
else | ||
data | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters