Skip to content

Commit 4fc4ec2

Browse files
jagotdlfivefifty
authored andcommitted
Added copy{,to!}(::MulQuasiArray) and similar(::QuasiArrayMulArray) (#12)
* Added copy/copyto!(::MulQuasiArray) * Added similar(::QuasiArrayMulArray)
1 parent f3d3673 commit 4fc4ec2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/QuasiArrays/QuasiArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module QuasiArrays
22
using Base, LinearAlgebra, LazyArrays
33
import Base: getindex, size, axes, length, ==, isequal, iterate, CartesianIndices, LinearIndices,
4-
Indices, IndexStyle, getindex, setindex!, parent, vec, convert, similar, zero,
4+
Indices, IndexStyle, getindex, setindex!, parent, vec, convert, similar, copy, copyto!, zero,
55
map, eachindex, eltype, first, last, firstindex, lastindex, in
66
import Base: @_inline_meta, DimOrInd, OneTo, @_propagate_inbounds_meta, @_noinline_meta,
77
DimsInteger, error_if_canonical_getindex, @propagate_inbounds, _return_type,

src/QuasiArrays/matmul.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ function similar(A::MulQuasiArray)
200200
B*similar(a)
201201
end
202202

203+
function similar(A::QuasiArrayMulArray)
204+
B,a = A.args
205+
applied(*, B, similar(a))
206+
end
207+
208+
function copy(a::MulQuasiArray)
209+
@_propagate_inbounds_meta
210+
copymutable(a)
211+
end
212+
213+
function copyto!(dest::MulQuasiArray, src::MulQuasiArray)
214+
d = last(dest.applied.args)
215+
s = last(src.applied.args)
216+
copyto!(IndexStyle(d), d, IndexStyle(s), s)
217+
dest
218+
end
219+
203220

204221
MemoryLayout(M::MulQuasiArray) = MulLayout(MemoryLayout.(M.applied.args))
205222

0 commit comments

Comments
 (0)