11module Code
22
3- using StaticArrays, LabelledArrays, SparseArrays
3+ using StaticArrays, LabelledArrays, SparseArrays, LinearAlgebra
44
55export toexpr, Assignment, (← ), Let, Func, DestructuredArgs, LiteralExpr,
66 SetArray, MakeArray, MakeSparseArray, MakeTuple, AtIndex,
@@ -375,7 +375,7 @@ function toexpr(a::MakeArray, st)
375375end
376376
377377# # Array
378- @inline function _create_array (:: Union{ Type{<:Array},Type{<:SubArray} } , T, :: Val{dims} , elems... ) where dims
378+ @inline function _create_array (:: Type{<:Array} , T, :: Val{dims} , elems... ) where dims
379379 arr = Array {T} (undef, dims)
380380 @assert prod (dims) == nfields (elems)
381381 @inbounds for i= 1 : prod (dims)
@@ -384,15 +384,23 @@ end
384384 arr
385385end
386386
387- @inline function create_array (A:: Union{ Type{<:Array},Type{<:SubArray} } , T, d:: Val , elems... )
387+ @inline function create_array (A:: Type{<:Array} , T, d:: Val , elems... )
388388 _create_array (A, T, d, elems... )
389389end
390390
391- @inline function create_array (A:: Union{ Type{<:Array},Type{<:SubArray} } , :: Nothing , d:: Val{dims} , elems... ) where dims
391+ @inline function create_array (A:: Type{<:Array} , :: Nothing , d:: Val{dims} , elems... ) where dims
392392 T = promote_type (map (typeof, elems)... )
393393 _create_array (A, T, d, elems... )
394394end
395395
396+ @inline function create_array (A:: Type{<:SubArray{T,N,P,I,L}} , S, d:: Val , elems... ) where {T,N,P,I,L}
397+ create_array (P, S, d, elems... )
398+ end
399+
400+ @inline function create_array (A:: Type{<:PermutedDimsArray{T,N,perm,iperm,P}} , S, d:: Val , elems... ) where {T,N,perm,iperm,P}
401+ create_array (P, S, d, elems... )
402+ end
403+
396404# # Matrix
397405
398406@inline function create_array (:: Type{<:Matrix} , :: Nothing , :: Val{dims} , elems... ) where dims
403411 Base. typed_hvcat (T, dims, elems... )
404412end
405413
414+ @inline function create_array (A:: Type{<:Transpose{T,P}} , S, d:: Val , elems... ) where {T,P}
415+ create_array (P, S, d, elems... )
416+ end
417+
418+ @inline function create_array (A:: Type{<:UpperTriangular{T,P}} , S, d:: Val , elems... ) where {T,P}
419+ create_array (P, S, d, elems... )
420+ end
421+
406422# # SArray
407423@inline function create_array (:: Type{<:SArray} , :: Nothing , :: Val{dims} , elems... ) where dims
408424 SArray {Tuple{dims...}} (elems... )
0 commit comments