Skip to content

Commit c8e2827

Browse files
committed
Check uplo using dispatch
1 parent 3c22a01 commit c8e2827

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/testtriag.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ using Test, LinearAlgebra
44
using LinearAlgebra: BlasFloat, errorbounds, full!, transpose!,
55
UpperOrUnitUpperTriangular, LowerOrUnitLowerTriangular, UnitUpperOrUnitLowerTriangular
66

7+
check_uplo(::Any, A1, A2) = false
8+
check_uplo(::typeof{==}, A1::UpperOrUnitUpperTriangular, A2::UpperOrUnitUpperTriangular) = true
9+
check_uplo(::typeof{==}, A1::LowerOrUnitLowerTriangular, A2::LowerOrUnitLowerTriangular) = true
10+
check_uplo(::typeof{!=}, A1::UpperOrUnitUpperTriangular, A2::LowerOrUnitLowerTriangular) = true
11+
check_uplo(::typeof{!=}, A1::LowerOrUnitLowerTriangular, A2::UpperOrUnitUpperTriangular) = true
12+
713
# The following test block tries to call all methods in base/linalg/triangular.jl in order for a combination of input element types. Keep the ordering when adding code.
814
function test_triangular(elty1_types)
915
n = 9
@@ -394,17 +400,17 @@ function test_triangular(elty1_types)
394400
@test_throws DimensionMismatch transpose(A2) * offsizeA
395401
@test_throws DimensionMismatch A2' * offsizeA
396402
@test_throws DimensionMismatch A2 * offsizeA
397-
if (uplo1 == uplo2 && eltype(A1) == elty2 != Int && !(A1 isa UnitUpperOrUnitLowerTriangular))
403+
if (check_uplo(==, A1, A2) && eltype(A1) == eltype(A2) != Int && !(A1 isa UnitUpperOrUnitLowerTriangular))
398404
@test rdiv!(copy(A1), A2)::t1 A1 / A2 M1 / M2
399405
@test ldiv!(A2, copy(A1))::t1 A2 \ A1 M2 \ M1
400406
end
401-
if (uplo1 != uplo2 && eltype(A1) == elty2 != Int && !(A2 isa UnitUpperOrUnitLowerTriangular))
407+
if (check_uplo(!=, A1, A2) && eltype(A1) == eltype(A2) != Int && !(A2 isa UnitUpperOrUnitLowerTriangular))
402408
@test lmul!(adjoint(A1), copy(A2)) A1' * A2 M1' * M2
403409
@test lmul!(transpose(A1), copy(A2)) transpose(A1) * A2 transpose(M1) * M2
404410
@test ldiv!(adjoint(A1), copy(A2)) A1' \ A2 M1' \ M2
405411
@test ldiv!(transpose(A1), copy(A2)) transpose(A1) \ A2 transpose(M1) \ M2
406412
end
407-
if (uplo1 != uplo2 && eltype(A1) == elty2 != Int && !(A1 isa UnitUpperOrUnitLowerTriangular))
413+
if (check_uplo(!=, A1, A2) && eltype(A1) == eltype(A2) != Int && !(A1 isa UnitUpperOrUnitLowerTriangular))
408414
@test rmul!(copy(A1), adjoint(A2)) A1 * A2' M1 * M2'
409415
@test rmul!(copy(A1), transpose(A2)) A1 * transpose(A2) M1 * transpose(M2)
410416
@test rdiv!(copy(A1), adjoint(A2)) A1 / A2' M1 / M2'

0 commit comments

Comments
 (0)