5353@testset " left_orth and left_null for T = $T " for T in (Float32, Float64, ComplexF32, ComplexF64)
5454 rng = StableRNG (123 )
5555 m = 54
56- for n in (37 , m, 63 )
56+ @testset for n in (37 , m, 63 )
5757 minmn = min (m, n)
5858 A = CuArray (randn (rng, T, m, n))
5959 V, C = @constinferred left_orth (A)
115115 @test isisometric (N2)
116116 hV2 = collect (V2)
117117 hN2 = collect (N2)
118- @test hV2 * hV2' ≈ I
118+ @test hV2 * hV2' + hN2 * hN2 ' ≈ I
119119
120120 atol = eps (real (T))
121121 V2, C2 = @constinferred left_orth! (copy! (Ac, A), (V, C); trunc= (; atol= atol))
127127 @test isisometric (V2)
128128 @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
129129 @test isisometric (N2)
130- @test V2 * V2' + N2 * N2' ≈ I
130+ hV2 = collect (V2)
131+ hN2 = collect (N2)
132+ @test hV2 * hV2' + hN2 * hN2' ≈ I
131133
132134 rtol = eps (real (T))
133135 for (trunc_orth, trunc_null) in (
@@ -143,10 +145,12 @@ end
143145 @test isisometric (V2)
144146 @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
145147 @test isisometric (N2)
146- @test V2 * V2' + N2 * N2' ≈ I
148+ hV2 = collect (V2)
149+ hN2 = collect (N2)
150+ @test hV2 * hV2' + hN2 * hN2' ≈ I
147151 end
148152
149- for kind in (:qr , :polar , :svd ) # explicit kind kwarg
153+ @testset for kind in (:qr , :polar , :svd ) # explicit kind kwarg
150154 m < n && kind == :polar && continue
151155 V2, C2 = @constinferred left_orth! (copy! (Ac, A), (V, C); kind= kind)
152156 @test V2 === V
176180 @test V2' * V2 ≈ I
177181 @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
178182 @test isisometric (N2)
179- @test V2 * V2' + N2 * N2' ≈ I
183+ hV2 = collect (V2)
184+ hN2 = collect (N2)
185+ @test hV2 * hV2' + hN2 * hN2' ≈ I
180186
181187 V2, C2 = @constinferred left_orth! (copy! (Ac, A), (V, C); kind= kind,
182188 trunc= (; rtol= rtol))
189195 @test isisometric (V2)
190196 @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
191197 @test isisometric (N2)
192- @test V2 * V2' + N2 * N2' ≈ I
198+ hV2 = collect (V2)
199+ hN2 = collect (N2)
200+ @test hV2 * hV2' + hN2 * hN2' ≈ I
193201 else
194202 @test_throws ArgumentError left_orth! (copy! (Ac, A), (V, C); kind= kind,
195203 trunc= (; atol= atol))
253261 @test isisometric (Vᴴ2; side= :right )
254262 @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
255263 @test isisometric (Nᴴ; side= :right )
256- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
264+ hVᴴ2 = collect (Vᴴ2)
265+ hNᴴ2 = collect (Nᴴ2)
266+ @test hVᴴ2' * hVᴴ2 + hNᴴ2' * hNᴴ2 ≈ I
257267
258268 C2, Vᴴ2 = @constinferred right_orth! (copy! (Ac, A), (C, Vᴴ); trunc= (; rtol= rtol))
259269 Nᴴ2 = @constinferred right_null! (copy! (Ac, A), Nᴴ; trunc= (; rtol= rtol))
264274 @test isisometric (Vᴴ2; side= :right )
265275 @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
266276 @test isisometric (Nᴴ2; side= :right )
267- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
277+ hVᴴ2 = collect (Vᴴ2)
278+ hNᴴ2 = collect (Nᴴ2)
279+ @test hVᴴ2' * hVᴴ2 + hNᴴ2' * hNᴴ2 ≈ I
268280
269281 @testset " kind = $kind " for kind in (:lq , :polar , :svd )
270282 n < m && kind == :polar && continue
295307 @test isisometric (Vᴴ2; side= :right )
296308 @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
297309 @test isisometric (Nᴴ2; side= :right )
298- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
310+ hVᴴ2 = collect (Vᴴ2)
311+ hNᴴ2 = collect (Nᴴ2)
312+ @test hVᴴ2' * hVᴴ2 + hNᴴ2' * hNᴴ2 ≈ I
299313
300314 C2, Vᴴ2 = @constinferred right_orth! (copy! (Ac, A), (C, Vᴴ); kind= kind,
301315 trunc= (; rtol= rtol))
308322 @test isisometric (Vᴴ2; side= :right )
309323 @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
310324 @test isisometric (Nᴴ2; side= :right )
311- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
325+ hVᴴ2 = collect (Vᴴ2)
326+ hNᴴ2 = collect (Nᴴ2)
327+ @test hVᴴ2' * hVᴴ2 + hNᴴ2' * hNᴴ2 ≈ diagm (ones (T, size (Vᴴ2, 2 ))) atol = m* n* MatrixAlgebraKit. defaulttol (T)
312328 else
313329 @test_throws ArgumentError right_orth! (copy! (Ac, A), (C, Vᴴ); kind= kind,
314330 trunc= (; atol= atol))
0 commit comments