|
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 | | - |
12 | 3 | # 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. |
13 | 4 | function test_triangular(elty1_types) |
14 | 5 | n = 9 |
@@ -323,10 +314,12 @@ function test_triangular(elty1_types) |
323 | 314 | @test ((A1 \ A1)::t1) ≈ M1 \ M1 |
324 | 315 |
|
325 | 316 | # Begin loop for second Triangular matrix |
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)) |
| 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 |
330 | 323 | @testset for (t2, uplo2) in ((UpperTriangular, :U), |
331 | 324 | (UnitUpperTriangular, :U), |
332 | 325 | (LowerTriangular, :L), |
@@ -416,10 +409,13 @@ function test_triangular(elty1_types) |
416 | 409 | end |
417 | 410 | end |
418 | 411 |
|
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)) |
| 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 | + |
423 | 419 | B = convert(Matrix{eltyB}, (elty1 <: Complex ? real(A1) : A1) * fill(1.0, n, n)) |
424 | 420 |
|
425 | 421 | Tri = Tridiagonal(rand(eltyB, n - 1), rand(eltyB, n), rand(eltyB, n - 1)) |
|
0 commit comments