@@ -3,6 +3,20 @@ using LinearAlgebra
33
44include (" ../linearmap.jl" )
55
6+ _left_orth_svd (x; kwargs... ) = left_orth (x; alg = :svd ; kwargs... )
7+ _left_orth_svd! (x, VC; kwargs... ) = left_orth! (x, VC; alg = :svd , kwargs... )
8+ _left_orth_qr (x; kwargs... ) = left_orth (x; alg = :qr , kwargs... )
9+ _left_orth_qr! (x, VC; kwargs... ) = left_orth! (x, VC; alg = :qr , kwargs... )
10+ _left_orth_polar (x; kwargs... ) = left_orth (x; alg = :polar , kwargs... )
11+ _left_orth_polar! (x, VC; kwargs... ) = left_orth! (x, VC; alg = :polar , kwargs... )
12+
13+ _right_orth_svd (x; kwargs... ) = right_orth (x; alg = :svd ; kwargs... )
14+ _right_orth_svd! (x, CVᴴ; kwargs... ) = right_orth! (x, CVᴴ; alg = :svd , kwargs... )
15+ _right_orth_lq (x; kwargs... ) = right_orth (x; alg = :lq , kwargs... )
16+ _right_orth_lq! (x, CVᴴ; kwargs... ) = right_orth! (x, CVᴴ; alg = :lq , kwargs... )
17+ _right_orth_polar (x; kwargs... ) = right_orth (x; alg = :polar , kwargs... )
18+ _right_orth_polar! (x, CVᴴ; kwargs... ) = right_orth! (x, CVᴴ; alg = :polar , kwargs... )
19+
620function test_orthnull (T:: Type , sz; kwargs... )
721 summary_str = testargs_summary (T, sz)
822 return @testset " orthnull $summary_str " begin
@@ -34,9 +48,7 @@ function test_left_orthnull(
3448 @test collect (V) * collect (V)' + collect (N) * collect (N)' ≈ I
3549
3650 M = LinearMap (A)
37- # broken
38- # VM, CM = @testinferred left_orth(M; alg = :svd)
39- VM, CM = left_orth (M; alg = :svd )
51+ VM, CM = @testinferred _left_orth_svd (M)
4052 @test parent (VM) * parent (CM) ≈ A
4153
4254 if m > n && (T <: Number || T <: Diagonal{<:Number, <:Vector} )
@@ -53,9 +65,7 @@ function test_left_orthnull(
5365 end
5466
5567 # passing a kind and some kwargs
56- # broken
57- # V, C = @testinferred left_orth(A; alg = :qr, positive = true)
58- V, C = left_orth (A; alg = :qr , positive = true )
68+ V, C = @testinferred _left_orth_qr (A; positive = true )
5969 N = @testinferred left_null (A; alg = :qr , positive = true )
6070 @test V isa typeof (A) && size (V) == (m, minmn)
6171 @test C isa typeof (A) && size (C) == (minmn, n)
@@ -117,9 +127,13 @@ function test_left_orthnull(
117127
118128 for alg in (:qr , :polar , :svd ) # explicit kind kwarg
119129 m < n && alg === :polar && continue
120- # broken
121- # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg)
122- V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg)
130+ if alg == :svd
131+ V2, C2 = @testinferred _left_orth_svd! (copy! (Ac, A), (V, C))
132+ elseif alg == :qr
133+ V2, C2 = @testinferred _left_orth_qr! (copy! (Ac, A), (V, C))
134+ elseif alg == :polar
135+ V2, C2 = @testinferred _left_orth_polar! (copy! (Ac, A), (V, C))
136+ end
123137 @test V2 * C2 ≈ A
124138 @test isisometric (V2)
125139 if alg != :polar
@@ -132,19 +146,15 @@ function test_left_orthnull(
132146 # with kind and tol kwargs
133147 if alg == :svd
134148 if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
135- # broken
136- # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; atol))
137- V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; atol))
149+ V2, C2 = @testinferred _left_orth_svd! (copy! (Ac, A), (V, C); trunc = (; atol))
138150 N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; atol))
139151 @test V2 * C2 ≈ A
140152 @test isisometric (V2)
141153 @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
142154 @test isisometric (N2)
143155 @test collect (V2) * collect (V2)' + collect (N2) * collect (N2)' ≈ I
144156
145- # broken
146- # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; rtol))
147- V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; rtol))
157+ V2, C2 = @testinferred _left_orth_svd! (copy! (Ac, A), (V, C); trunc = (; rtol))
148158 N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; rtol))
149159 @test V2 * C2 ≈ A
150160 @test isisometric (V2)
@@ -186,9 +196,7 @@ function test_right_orthnull(
186196 @test collect (Vᴴ)' * collect (Vᴴ) + collect (Nᴴ)' * collect (Nᴴ) ≈ I
187197
188198 M = LinearMap (A)
189- # broken
190- # CM, VMᴴ = @testinferred right_orth(M; alg = :svd)
191- CM, VMᴴ = right_orth (M; alg = :svd )
199+ CM, VMᴴ = @testinferred _right_orth_svd (M)
192200 @test parent (CM) * parent (VMᴴ) ≈ A
193201
194202 Ac = similar (A)
@@ -222,9 +230,13 @@ function test_right_orthnull(
222230
223231 for alg in (:lq , :polar , :svd )
224232 n < m && alg == :polar && continue
225- # broken
226- # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg)
227- C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg)
233+ if alg == :lq
234+ C2, Vᴴ2 = @testinferred _right_orth_lq! (copy! (Ac, A), (C, Vᴴ))
235+ elseif alg == :polar
236+ C2, Vᴴ2 = @testinferred _right_orth_polar! (copy! (Ac, A), (C, Vᴴ))
237+ elseif alg == :svd
238+ C2, Vᴴ2 = @testinferred _right_orth_svd! (copy! (Ac, A), (C, Vᴴ))
239+ end
228240 @test C2 * Vᴴ2 ≈ A
229241 @test isisometric (Vᴴ2; side = :right )
230242 if alg != :polar
@@ -236,19 +248,15 @@ function test_right_orthnull(
236248
237249 if alg == :svd
238250 if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
239- # broken
240- # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
241- C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
251+ C2, Vᴴ2 = @testinferred _right_orth_svd! (copy! (Ac, A), (C, Vᴴ); trunc = (; atol))
242252 Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; atol))
243253 @test C2 * Vᴴ2 ≈ A
244254 @test isisometric (Vᴴ2; side = :right )
245255 @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
246256 @test isisometric (Nᴴ2; side = :right )
247257 @test collect (Vᴴ2)' * collect (Vᴴ2) + collect (Nᴴ2)' * collect (Nᴴ2) ≈ I
248258
249- # broken
250- # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
251- C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
259+ C2, Vᴴ2 = @testinferred _right_orth_svd! (copy! (Ac, A), (C, Vᴴ); trunc = (; rtol))
252260 Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; rtol))
253261 @test C2 * Vᴴ2 ≈ A
254262 @test isisometric (Vᴴ2; side = :right )
0 commit comments