@@ -39,7 +39,7 @@ function test_left_orthnull(
3939 VM, CM = left_orth (M; alg = :svd )
4040 @test parent (VM) * parent (CM) ≈ A
4141
42- if m > n
42+ if m > n && (T <: Number || T <: Diagonal{<:Number, <:Vector} )
4343 nullity = 5
4444 V, C = @testinferred left_orth (A)
4545 N = @testinferred left_null (A; trunc = (; maxnullity = nullity))
@@ -98,18 +98,20 @@ function test_left_orthnull(
9898 @test isisometric (N2)
9999 @test V2 * V2' + N2 * N2' ≈ I
100100
101- rtol = eps (real (eltype (T)))
102- for (trunc_orth, trunc_null) in (
103- ((; rtol = rtol), (; rtol = rtol)),
104- (trunctol (; rtol), trunctol (; rtol, keep_below = true )),
105- )
106- V2, C2 = @testinferred left_orth! (copy! (Ac, A), (V, C); trunc = trunc_orth)
107- N2 = @testinferred left_null! (copy! (Ac, A), N; trunc = trunc_null)
108- @test V2 * C2 ≈ A
109- @test isisometric (V2)
110- @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
111- @test isisometric (N2)
112- @test V2 * V2' + N2 * N2' ≈ I
101+ if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
102+ rtol = eps (real (eltype (T)))
103+ for (trunc_orth, trunc_null) in (
104+ ((; rtol = rtol), (; rtol = rtol)),
105+ (trunctol (; rtol), trunctol (; rtol, keep_below = true )),
106+ )
107+ V2, C2 = @testinferred left_orth! (copy! (Ac, A), (V, C); trunc = trunc_orth)
108+ N2 = @testinferred left_null! (copy! (Ac, A), N; trunc = trunc_null)
109+ @test V2 * C2 ≈ A
110+ @test isisometric (V2)
111+ @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
112+ @test isisometric (N2)
113+ @test V2 * V2' + N2 * N2' ≈ I
114+ end
113115 end
114116
115117 for alg in (:qr , :polar , :svd ) # explicit kind kwarg
@@ -128,25 +130,27 @@ function test_left_orthnull(
128130
129131 # with kind and tol kwargs
130132 if alg == :svd
131- # broken
132- # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; atol))
133- V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; atol))
134- N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; atol))
135- @test V2 * C2 ≈ A
136- @test isisometric (V2)
137- @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
138- @test isisometric (N2)
139- @test V2 * V2' + N2 * N2' ≈ I
133+ if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
134+ # broken
135+ # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; atol))
136+ V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; atol))
137+ N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; atol))
138+ @test V2 * C2 ≈ A
139+ @test isisometric (V2)
140+ @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
141+ @test isisometric (N2)
142+ @test V2 * V2' + N2 * N2' ≈ I
140143
141- # broken
142- # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; rtol))
143- V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; rtol))
144- N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; rtol))
145- @test V2 * C2 ≈ A
146- @test isisometric (V2)
147- @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
148- @test isisometric (N2)
149- @test V2 * V2' + N2 * N2' ≈ I
144+ # broken
145+ # V2, C2 = @testinferred left_orth!(copy!(Ac, A), (V, C); alg = alg, trunc = (; rtol))
146+ V2, C2 = left_orth! (copy! (Ac, A), (V, C); alg = alg, trunc = (; rtol))
147+ N2 = @testinferred left_null! (copy! (Ac, A), N; alg, trunc = (; rtol))
148+ @test V2 * C2 ≈ A
149+ @test isisometric (V2)
150+ @test LinearAlgebra. norm (A' * N2) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
151+ @test isisometric (N2)
152+ @test V2 * V2' + N2 * N2' ≈ I
153+ end
150154 else
151155 @test_throws ArgumentError left_orth! (copy! (Ac, A), (V, C); alg, trunc = (; atol))
152156 @test_throws ArgumentError left_orth! (copy! (Ac, A), (V, C); alg, trunc = (; rtol))
@@ -195,23 +199,25 @@ function test_right_orthnull(
195199 @test isisometric (Nᴴ; side = :right )
196200 @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
197201
198- atol = eps (real (eltype (T)))
199- C2, Vᴴ2 = @testinferred right_orth! (copy! (Ac, A), (C, Vᴴ); trunc = (; atol))
200- Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; trunc = (; atol))
201- @test C2 * Vᴴ2 ≈ A
202- @test isisometric (Vᴴ2; side = :right )
203- @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
204- @test isisometric (Nᴴ; side = :right )
205- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
202+ if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
203+ atol = eps (real (eltype (T)))
204+ C2, Vᴴ2 = @testinferred right_orth! (copy! (Ac, A), (C, Vᴴ); trunc = (; atol))
205+ Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; trunc = (; atol))
206+ @test C2 * Vᴴ2 ≈ A
207+ @test isisometric (Vᴴ2; side = :right )
208+ @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
209+ @test isisometric (Nᴴ; side = :right )
210+ @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
206211
207- rtol = eps (real (eltype (T)))
208- C2, Vᴴ2 = @testinferred right_orth! (copy! (Ac, A), (C, Vᴴ); trunc = (; rtol))
209- Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; trunc = (; rtol))
210- @test C2 * Vᴴ2 ≈ A
211- @test isisometric (Vᴴ2; side = :right )
212- @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
213- @test isisometric (Nᴴ2; side = :right )
214- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
212+ rtol = eps (real (eltype (T)))
213+ C2, Vᴴ2 = @testinferred right_orth! (copy! (Ac, A), (C, Vᴴ); trunc = (; rtol))
214+ Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; trunc = (; rtol))
215+ @test C2 * Vᴴ2 ≈ A
216+ @test isisometric (Vᴴ2; side = :right )
217+ @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
218+ @test isisometric (Nᴴ2; side = :right )
219+ @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
220+ end
215221
216222 for alg in (:lq , :polar , :svd )
217223 n < m && alg == :polar && continue
@@ -228,25 +234,27 @@ function test_right_orthnull(
228234 end
229235
230236 if alg == :svd
231- # broken
232- # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
233- C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
234- Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; atol))
235- @test C2 * Vᴴ2 ≈ A
236- @test isisometric (Vᴴ2; side = :right )
237- @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
238- @test isisometric (Nᴴ2; side = :right )
239- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
237+ if (T <: Number || T <: Diagonal{<:Number, <:Vector} )
238+ # broken
239+ # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
240+ C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; atol))
241+ Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; atol))
242+ @test C2 * Vᴴ2 ≈ A
243+ @test isisometric (Vᴴ2; side = :right )
244+ @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
245+ @test isisometric (Nᴴ2; side = :right )
246+ @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
240247
241- # broken
242- # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
243- C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
244- Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; rtol))
245- @test C2 * Vᴴ2 ≈ A
246- @test isisometric (Vᴴ2; side = :right )
247- @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
248- @test isisometric (Nᴴ2; side = :right )
249- @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
248+ # broken
249+ # C2, Vᴴ2 = @testinferred right_orth!(copy!(Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
250+ C2, Vᴴ2 = right_orth! (copy! (Ac, A), (C, Vᴴ); alg = alg, trunc = (; rtol))
251+ Nᴴ2 = @testinferred right_null! (copy! (Ac, A), Nᴴ; alg = alg, trunc = (; rtol))
252+ @test C2 * Vᴴ2 ≈ A
253+ @test isisometric (Vᴴ2; side = :right )
254+ @test LinearAlgebra. norm (A * adjoint (Nᴴ2)) ≈ 0 atol = MatrixAlgebraKit. defaulttol (T)
255+ @test isisometric (Nᴴ2; side = :right )
256+ @test Vᴴ2' * Vᴴ2 + Nᴴ2' * Nᴴ2 ≈ I
257+ end
250258 else
251259 @test_throws ArgumentError right_orth! (copy! (Ac, A), (C, Vᴴ); alg, trunc = (; atol))
252260 @test_throws ArgumentError right_orth! (copy! (Ac, A), (C, Vᴴ); alg, trunc = (; rtol))
0 commit comments