Skip to content

Commit

Permalink
Merge pull request #24382 from Sacha0/evileye
Browse files Browse the repository at this point in the history
rewrite a few eye calls
  • Loading branch information
fredrikekre authored Oct 30, 2017
2 parents f8c503a + 3f9a8b5 commit fb46fe8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
20 changes: 10 additions & 10 deletions test/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,16 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa
@test A1'A2' Matrix(A1)'Matrix(A2)'
@test A1/A2 Matrix(A1)/Matrix(A2)
@test A1\A2 Matrix(A1)\Matrix(A2)
@test_throws DimensionMismatch eye(n+1)/A2
@test_throws DimensionMismatch eye(n+1)/A2.'
@test_throws DimensionMismatch eye(n+1)/A2'
@test_throws DimensionMismatch eye(n+1)*A2
@test_throws DimensionMismatch eye(n+1)*A2.'
@test_throws DimensionMismatch eye(n+1)*A2'
@test_throws DimensionMismatch A2.'*eye(n+1)
@test_throws DimensionMismatch A2'*eye(n+1)
@test_throws DimensionMismatch A2*eye(n+1)
@test_throws DimensionMismatch A2*ones(n+1) # redundant with immediately preceding test?
offsizeA = Matrix{Float64}(n+1, n+1)
@test_throws DimensionMismatch offsizeA / A2
@test_throws DimensionMismatch offsizeA / A2.'
@test_throws DimensionMismatch offsizeA / A2'
@test_throws DimensionMismatch offsizeA * A2
@test_throws DimensionMismatch offsizeA * A2.'
@test_throws DimensionMismatch offsizeA * A2'
@test_throws DimensionMismatch A2.' * offsizeA
@test_throws DimensionMismatch A2' * offsizeA
@test_throws DimensionMismatch A2 * offsizeA
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ guardsrand(123) do
@test Array(A/α) Array(A)/α

@testset "Matmul with Triangular types" begin
@test A*Base.LinAlg.UnitUpperTriangular(eye(n)) fA*eye(n)
@test A*Base.LinAlg.UnitLowerTriangular(eye(n)) fA*eye(n)
@test A*UpperTriangular(eye(n)) fA*eye(n)
@test A*LowerTriangular(eye(n)) fA*eye(n)
@test A*Base.LinAlg.UnitUpperTriangular(eye(n)) fA
@test A*Base.LinAlg.UnitLowerTriangular(eye(n)) fA
@test A*UpperTriangular(eye(n)) fA
@test A*LowerTriangular(eye(n)) fA
end
@testset "A_mul_B! errors" begin
@test_throws DimensionMismatch Base.LinAlg.A_mul_B!(zeros(fA),A,ones(elty,n,n+1))
Expand Down
6 changes: 3 additions & 3 deletions test/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,9 @@ end
sparsecomplexmat = speye(m) + SparseMatrixCSC(m, m, sprmat.colptr, sprmat.rowval, complex.(sprmat.nzval, sprmat.nzval)/(4m))
sparseintmat = speye(Int, m)*10m + SparseMatrixCSC(m, m, sprmat.colptr, sprmat.rowval, round.(Int, sprmat.nzval*10))

denseintmat = eye(Int, m)*10m + rand(1:m, m, m)
densefloatmat = eye(m) + randn(m, m)/(2m)
densecomplexmat = eye(m) + complex.(randn(m, m), randn(m, m))/(4m)
denseintmat = I*10m + rand(1:m, m, m)
densefloatmat = I + randn(m, m)/(2m)
densecomplexmat = I + randn(Complex{Float64}, m, m)/(4m)

inttypes = (Int32, Int64, BigInt)
floattypes = (Float32, Float64, BigFloat)
Expand Down
11 changes: 6 additions & 5 deletions test/sparse/spqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ nn = 100
@test R0[1:n, :] F[:R]
@test norm(R0[n + 1:end, :], 1) < 1e-12

@test_throws DimensionMismatch A_mul_B!(Q, eye(m + 1))
@test_throws DimensionMismatch Ac_mul_B!(Q, eye(m + 1))
@test_throws DimensionMismatch A_mul_B!(eye(m + 1), Q)
@test_throws DimensionMismatch A_mul_Bc!(eye(m + 1), Q)
offsizeA = Matrix{Float64}(m+1, m+1)
@test_throws DimensionMismatch A_mul_B!(Q, offsizeA)
@test_throws DimensionMismatch Ac_mul_B!(Q, offsizeA)
@test_throws DimensionMismatch A_mul_B!(offsizeA, Q)
@test_throws DimensionMismatch A_mul_Bc!(offsizeA, Q)
end

@testset "element type of B: $eltyB" for eltyB in (Int, Float64, Complex{Float64})
Expand All @@ -63,7 +64,7 @@ nn = 100
end

# Make sure that conversion to Sparse doesn't use SuiteSparse's symmetric flag
@test qrfact(sparse(eye(eltyA, 5)))\ones(eltyA, 5) == ones(5)
@test qrfact(sparse(one(eltyA)I, 5))\ones(eltyA, 5) == ones(5)
end

@testset "basic solution of rank deficient ls" begin
Expand Down

0 comments on commit fb46fe8

Please sign in to comment.