Skip to content

Commit 09347d1

Browse files
committed
Use Testsuite for Schur
1 parent 4212b74 commit 09347d1

File tree

5 files changed

+65
-144
lines changed

5 files changed

+65
-144
lines changed

test/genericschur/eig.jl

Lines changed: 0 additions & 116 deletions
This file was deleted.

test/runtests.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ if !is_buildkite
2222
@safetestset "Generalized Eigenvalue Decomposition" begin
2323
include("gen_eig.jl")
2424
end
25-
@safetestset "Schur Decomposition" begin
26-
include("schur.jl")
27-
end
2825
@safetestset "Image and Null Space" begin
2926
include("orthnull.jl")
3027
end
@@ -55,10 +52,6 @@ if !is_buildkite
5552
include("genericlinearalgebra/eigh.jl")
5653
end
5754

58-
using GenericSchur
59-
@safetestset "General Eigenvalue Decomposition" begin
60-
include("genericschur/eig.jl")
61-
end
6255
end
6356

6457
@safetestset "QR / LQ Decomposition" begin
@@ -71,6 +64,9 @@ end
7164
@safetestset "Projections" begin
7265
include("projections.jl")
7366
end
67+
@safetestset "Schur Decomposition" begin
68+
include("schur.jl")
69+
end
7470

7571
using CUDA
7672
if CUDA.functional()

test/schur.jl

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@ using MatrixAlgebraKit
22
using Test
33
using TestExtras
44
using StableRNGs
5-
using LinearAlgebra: I
5+
using LinearAlgebra: I, Diagonal
66

7-
@testset "schur_full! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64)
8-
rng = StableRNG(123)
9-
m = 54
10-
for alg in (LAPACK_Simple(), LAPACK_Expert())
11-
A = randn(rng, T, m, m)
12-
Tc = complex(T)
7+
BLASFloats = (Float32, Float64, ComplexF32, ComplexF64)
8+
GenericFloats = (Float16, BigFloat, Complex{BigFloat})
139

14-
TA, Z, vals = @constinferred schur_full(A; alg)
15-
@test eltype(TA) == eltype(Z) == T
16-
@test eltype(vals) == Tc
17-
@test isisometric(Z)
18-
@test A * Z Z * TA
10+
@isdefined(TestSuite) || include("testsuite/TestSuite.jl")
11+
using .TestSuite
1912

20-
Ac = similar(A)
21-
TA2, Z2, vals2 = @constinferred schur_full!(copy!(Ac, A), (TA, Z, vals), alg)
22-
@test TA2 === TA
23-
@test Z2 === Z
24-
@test vals2 === vals
25-
@test A * Z Z * TA
13+
is_buildkite = get(ENV, "BUILDKITE", "false") == "true"
2614

27-
valsc = @constinferred schur_vals(A, alg)
28-
@test eltype(valsc) == Tc
29-
@test valsc eig_vals(A, alg)
15+
m = 54
16+
for T in (BLASFloats..., GenericFloats...)
17+
TestSuite.seed_rng!(123)
18+
if T BLASFloats
19+
#=if CUDA.functional()
20+
TestSuite.test_schur(CuMatrix{T}, (m, m); test_blocksize = false)
21+
TestSuite.test_schur(Diagonal{T, CuVector{T}}, m; test_blocksize = false)
22+
end
23+
if AMDGPU.functional()
24+
TestSuite.test_schur(ROCMatrix{T}, (m, m); test_blocksize = false)
25+
TestSuite.test_schur(Diagonal{T, ROCVector{T}}, m; test_blocksize = false)
26+
end=# # not yet supported
27+
end
28+
if !is_buildkite
29+
TestSuite.test_schur(T, (m, m))
30+
AT = Diagonal{T, Vector{T}}
31+
TestSuite.test_schur(AT, m)
3032
end
3133
end

test/testsuite/TestSuite.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ include("qr.jl")
7373
include("lq.jl")
7474
include("polar.jl")
7575
include("projections.jl")
76+
include("schur.jl")
7677

7778
end

test/testsuite/schur.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using TestExtras
2+
using GenericSchur
3+
4+
function test_schur(T::Type, sz; kwargs...)
5+
summary_str = testargs_summary(T, sz)
6+
return @testset "schur $summary_str" begin
7+
test_schur_full(T, sz; kwargs...)
8+
end
9+
end
10+
11+
function test_schur_full(
12+
T::Type, sz;
13+
atol::Real = 0, rtol::Real = precision(T),
14+
kwargs...
15+
)
16+
summary_str = testargs_summary(T, sz)
17+
return @testset "eig_full! $summary_str" begin
18+
A = instantiate_matrix(T, sz)
19+
Ac = deepcopy(A)
20+
Tc = isa(A, Diagonal) ? eltype(T) : complex(eltype(T))
21+
22+
TA, Z, vals = @testinferred schur_full(A)
23+
@test eltype(TA) == eltype(Z) == eltype(T)
24+
@test eltype(vals) == Tc
25+
@test isisometric(Z)
26+
@test A * Z Z * TA
27+
28+
TA2, Z2, vals2 = @testinferred schur_full!(Ac, (TA, Z, vals))
29+
@test TA2 === TA
30+
@test Z2 === Z
31+
@test vals2 === vals
32+
@test A * Z Z * TA
33+
34+
valsc = @testinferred schur_vals(A)
35+
@test eltype(valsc) == Tc
36+
@test valsc eig_vals(A)
37+
end
38+
end

0 commit comments

Comments
 (0)