Skip to content

Commit 86f8f67

Browse files
committed
added test getindex AffineAdd
1 parent 8016d3c commit 86f8f67

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/syntax.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ function getindex{M,N,L,P,C,A<:VCAT{M,N,L,P,C}}(H::A, idx::Union{AbstractArray,I
8686
end
8787
end
8888

89+
getindex(H::A, idx::Union{AbstractArray,Int}) where {L <: HCAT, D, S, A<: AffineAdd{L,D,S}} =
90+
AffineAdd(getindex(H.A, idx), H.d, S)
91+
8992
# get index of scale
9093
getindex{T, L, S <:Scale{T,L}}(A::S,idx...) = Scale(A.coeff,A.coeff_conj,getindex(A.A,idx...))
9194

test/test_syntax.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ opHperm = opH[[3,1,2]]
207207
opHperm = opH[[3,1]]
208208
@test norm(opC*x3+opA*x1 - opHperm*(x3,x1)) <1e-12
209209

210+
# slicing Affine add of HCAT
211+
d = randn(n)
212+
opHA = AffineAdd(opH,d)
213+
@test norm(opHA[1]*x1-(A*x1+d)) < 1e-9
214+
@test norm(opHA[2]*x2-(B*x2+d)) < 1e-9
215+
@test norm(opHA[3]*x3-(C*x3+d)) < 1e-9
210216

211217
m4 = 9
212218
x4 = randn(m4)

0 commit comments

Comments
 (0)