Skip to content

Commit

Permalink
get/setindex methods for mixed tuple/integer args
Browse files Browse the repository at this point in the history
  • Loading branch information
jebej committed Feb 22, 2023
1 parent 1f49c1c commit 3868d3e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/quobj/basicmethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ dimsmatch(A::QuObject,Bs::AbstractVecOrTuple{QuObject}) = dimsmatch((A,),Bs)
getindex(A.data,tensored_sub2ind(dims(A),t))
@propagate_inbounds getindex(A::QuMatrix,ti::Tuple,tj::Tuple) =
getindex(A.data,tensored_sub2ind(dims(A),ti),tensored_sub2ind(dims(A),tj))
@propagate_inbounds getindex(A::QuMatrix,ti::Tuple,j::Integer) =
getindex(A.data,tensored_sub2ind(dims(A),ti),j)
@propagate_inbounds getindex(A::QuMatrix,i::Integer,tj::Tuple) =
getindex(A.data,i,tensored_sub2ind(dims(A),tj))
@propagate_inbounds setindex!(A::QuVector,v,t::Tuple) =
setindex!(A.data,v,tensored_sub2ind(dims(A),t))
@propagate_inbounds setindex!(A::QuMatrix,v,ti::Tuple,tj::Tuple) =
setindex!(A.data,v,tensored_sub2ind(dims(A),ti),tensored_sub2ind(dims(A),tj))
@propagate_inbounds setindex!(A::QuMatrix,v,ti::Tuple,j::Integer) =
setindex!(A.data,v,tensored_sub2ind(dims(A),ti),j)
@propagate_inbounds setindex!(A::QuMatrix,v,i::Integer,tj::Tuple) =
setindex!(A.data,v,i,tensored_sub2ind(dims(A),tj))

# Translate basic Base array methods to QuObjects
@propagate_inbounds getindex(A::QuObject,idx...) = getindex(A.data,idx...)
Expand Down

0 comments on commit 3868d3e

Please sign in to comment.