Skip to content

Commit

Permalink
Added SubArray tests for linalg/givens.jl.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod committed Mar 4, 2016
1 parent 81ded47 commit 34e51b6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/linalg/givens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ for elty in (Float32, Float64, Complex64, Complex128)
else
A = convert(Matrix{elty}, complex(randn(10,10),randn(10,10)))
end
for Atype in ("Array", "SubArray")
if Atype == "Array"
A = A
else
A = sub(A, 1:10, 1:10)
end

Ac = copy(A)
R = Base.LinAlg.Rotation(Base.LinAlg.Givens{elty}[])
for j = 1:8
Expand Down Expand Up @@ -47,12 +54,15 @@ for elty in (Float32, Float64, Complex64, Complex128)
@test_approx_eq ctranspose(K*eye(elty,10))*(K*eye(elty,10)) eye(elty, 10)

# test that Givens * work for vectors
x = A[:,1]
if Atype == "Array"
x = A[:, 1]
else
x = sub(A, 1:10, 1)
end
G, r = givens(x[2], x[4], 2, 4)
@test (G*x)[2] r
@test abs((G*x)[4]) < eps(real(elty))

x = A[:,1]
G, r = givens(x, 2, 4)
@test (G*x)[2] r
@test abs((G*x)[4]) < eps(real(elty))
Expand All @@ -61,4 +71,5 @@ for elty in (Float32, Float64, Complex64, Complex128)
@test (G*x)[4] r
@test abs((G*x)[2]) < eps(real(elty))
end
end
end #let

0 comments on commit 34e51b6

Please sign in to comment.