Skip to content

Commit b5cc53c

Browse files
author
Katharine Hyatt
committed
Check that inputs are preserved for in-place batch methods
1 parent a6295d4 commit b5cc53c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • test/testsuite/decompositions

‎test/testsuite/decompositions/svd.jl‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function test_svd_compact_batched(
9999

100100
Sc = similar(diagview(S))
101101
U2, S2, V2ᴴ = @testinferred batched_svd_compact!(Ac, (U, S, Vᴴ))
102+
@test U2 === U
103+
@test S2 === S
104+
@test V2ᴴ === Vᴴ
102105
for (a, u, s, vᴴ) in zip(As, eachslice(U2, dims = 3), eachslice(S2, dims = 2), eachslice(V2ᴴ, dims = 3))
103106
@test u * Diagonal(s) * vᴴ ≈ a
104107
@test isisometric(u)
@@ -172,6 +175,9 @@ function test_svd_compact_algs_batched(
172175
end
173176

174177
U2, S2, V2ᴴ = @testinferred batched_svd_compact!(Ac, (U, S, Vᴴ); alg)
178+
@test U2 === U
179+
@test S2 === S
180+
@test V2ᴴ === Vᴴ
175181
for (a, u, s, vᴴ) in zip(As, eachslice(U2, dims = 3), eachslice(S2, dims = 2), eachslice(V2ᴴ, dims = 3))
176182
@test u * Diagonal(s) * vᴴ ≈ a
177183
@test isisometric(u)
@@ -195,7 +201,9 @@ function test_svd_compact_algs_batched(
195201
Ss = [Diagonal(similar(a, real(eltype(T)), minimum(size(a)))) for a in Ar]
196202
Vᴴs = [similar(a, minimum(size(a)), size(a, 2)) for a in Ar]
197203
U3, S3, V3ᴴ = @testinferred batched_svd_compact!(deepcopy(Ar), (Us, Ss, Vᴴs); alg)
204+
@test U3 === Us
198205
@test S3 === Ss
206+
@test V3ᴴ === Vᴴs
199207
for (a, u, s, vᴴ) in zip(Ar, U3, S3, V3ᴴ)
200208
@test u * s * vᴴ ≈ a
201209
@test isisometric(u)
@@ -282,6 +290,9 @@ function test_svd_full_batched(
282290
end
283291

284292
U2, S2, V2ᴴ = @testinferred batched_svd_full!(Ac, (U, S, Vᴴ))
293+
@test U2 === U
294+
@test S2 === S
295+
@test V2ᴴ === Vᴴ
285296
for (a, u, s, vᴴ) in zip(As, eachslice(U2, dims = 3), eachslice(S2, dims = 3), eachslice(V2ᴴ, dims = 3))
286297
@test u * s * vᴴ ≈ a
287298
@test isunitary(u)
@@ -319,6 +330,9 @@ function test_svd_full_algs(
319330
@test all(isposdef, diagview(S))
320331

321332
U2, S2, V2ᴴ = @testinferred svd_full!(Ac, (U, S, Vᴴ); alg)
333+
@test U2 === U
334+
@test S2 === S
335+
@test V2ᴴ === Vᴴ
322336
@test U2 * S2 * V2ᴴ ≈ A
323337
@test isunitary(U2)
324338
@test isunitary(V2ᴴ)

0 commit comments

Comments
 (0)