Skip to content

Commit daed7ee

Browse files
authored
Merge pull request #286 from RafaelArutjunjan/patch-1
Allow for MArrays
2 parents cde48fa + f0fed56 commit daed7ee

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/code.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,15 @@ end
464464
SArray{Tuple{dims...}, T}(elems...)
465465
end
466466

467+
## MArray
468+
@inline function create_array(::Type{<:MArray}, ::Nothing, nd::Val, ::Val{dims}, elems...) where dims
469+
MArray{Tuple{dims...}}(elems...)
470+
end
471+
472+
@inline function create_array(::Type{<:MArray}, T, nd::Val, ::Val{dims}, elems...) where dims
473+
MArray{Tuple{dims...}, T}(elems...)
474+
end
475+
467476
## LabelledArrays
468477
@inline function create_array(A::Type{<:SLArray}, T, nd::Val, d::Val{dims}, elems...) where {dims}
469478
a = create_array(SArray, T, nd, d, elems...)

test/code.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
119119

120120
@test eval(toexpr(Let([a 1, b 2, arr @SLVector((:a, :b))(@SVector[1,2])],
121121
MakeArray([a+b,a/b], arr)))) === @SLVector((:a, :b))(@SVector [3, 1/2])
122+
123+
R1 = eval(toexpr(Let([a 1, b 2, arr @MVector([1,2])],MakeArray([a,b,a+b,a/b], arr))))
124+
@test R1 == (@MVector [1, 2, 3, 1/2]) && R1 isa MVector
125+
126+
R2 = eval(toexpr(Let([a 1, b 2, arr @MVector([1,2])],MakeArray([a b;a+b a/b], arr))))
127+
@test R2 == (@MArray [1 2; 3 1/2]) && R2 isa MMatrix
122128

123129
mksp = MakeSparseArray(sparse([1,2,31,32,2],
124130
[1,2,31,32,2],

0 commit comments

Comments
 (0)