|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
2 | 2 |
|
| 3 | +function rand_except(elty2_list, elty1) |
| 4 | + v = copy(elty2_list) |
| 5 | + ind_match = findfirst(==(elty1), v) |
| 6 | + if !isnothing(ind_match) |
| 7 | + deleteat!(v, ind_match) |
| 8 | + end |
| 9 | + rand(v) |
| 10 | +end |
| 11 | + |
3 | 12 | # 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. |
4 | 13 | function test_triangular(elty1_types) |
5 | 14 | n = 9 |
@@ -314,12 +323,10 @@ function test_triangular(elty1_types) |
314 | 323 | @test ((A1 \ A1)::t1) ≈ M1 \ M1 |
315 | 324 |
|
316 | 325 | # Begin loop for second Triangular matrix |
317 | | - @testset for elty2 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int) |
318 | | - # Only test methods for the same element type and a single combination of mixed element types |
319 | | - # to avoid too much compilation |
320 | | - if !(elty1 == elty2 || elty1 ∈ (ComplexF32, Int) || elty2 ∈ (ComplexF32, Int)) |
321 | | - continue |
322 | | - end |
| 326 | + # Only test methods for the same element type and a single combination of mixed element types |
| 327 | + # to avoid too much compilation |
| 328 | + elty2_list = [Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int] |
| 329 | + @testset for elty2 in (elty1, rand_except(elty2_list, elty1)) |
323 | 330 | @testset for (t2, uplo2) in ((UpperTriangular, :U), |
324 | 331 | (UnitUpperTriangular, :U), |
325 | 332 | (LowerTriangular, :L), |
@@ -409,13 +416,10 @@ function test_triangular(elty1_types) |
409 | 416 | end |
410 | 417 | end |
411 | 418 |
|
412 | | - @testset for eltyB in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}) |
413 | | - # Only test methods for the same element type and a single combination of mixed element types |
414 | | - # to avoid too much compilation |
415 | | - if !(elty1 == eltyB || elty1 ∈ (ComplexF32, Int) || eltyB ∈ (ComplexF32, Int)) |
416 | | - continue |
417 | | - end |
418 | | - |
| 419 | + # Only test methods for the same element type and a single combination of mixed element types |
| 420 | + # to avoid too much compilation |
| 421 | + eltyB_list = [Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}] |
| 422 | + @testset for eltyB in (elty1, rand_except(eltyB_list, elty1)) |
419 | 423 | B = convert(Matrix{eltyB}, (elty1 <: Complex ? real(A1) : A1) * fill(1.0, n, n)) |
420 | 424 |
|
421 | 425 | Tri = Tridiagonal(rand(eltyB, n - 1), rand(eltyB, n), rand(eltyB, n - 1)) |
|
0 commit comments