Skip to content

Commit ee446b7

Browse files
committed
add test with zero axis
1 parent 5dd808f commit ee446b7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_factorizations.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ end
147147
@test A A′
148148
@test size(U, 1) * size(U, 2) == size(U, 3) # U is unitary
149149
@test size(Vᴴ, 1) == size(Vᴴ, 2) * size(Vᴴ, 3) # V is unitary
150+
151+
U, S, Vᴴ = @constinferred svd(A, labels_A, labels_A, (); full=true)
152+
@test A == Acopy # should not have altered initial array
153+
US, labels_US = contract(U, (labels_A..., :u), S, (:u, :v))
154+
A′ = contract(labels_A, US, labels_US, Vᴴ, (:v,))
155+
@test A A′
156+
@test size(Vᴴ, 1) == 1
157+
158+
U, S, Vᴴ = @constinferred svd(A, labels_A, (), labels_A; full=true)
159+
@test A == Acopy # should not have altered initial array
160+
US, labels_US = contract(U, (:u,), S, (:u, :v))
161+
A′ = contract(labels_A, US, labels_US, Vᴴ, (:v, labels_A...))
162+
@test A A′
163+
@test size(U, 2) == 1
150164
end
151165

152166
@testset "Compact SVD ($T)" for T in elts
@@ -166,6 +180,20 @@ end
166180

167181
Svals = @constinferred svdvals(A, labels_A, labels_U, labels_Vᴴ)
168182
@test Svals diag(S)
183+
184+
U, S, Vᴴ = @constinferred svd(A, labels_A, labels_A, (); full=false)
185+
@test A == Acopy # should not have altered initial array
186+
US, labels_US = contract(U, (labels_A..., :u), S, (:u, :v))
187+
A′ = contract(labels_A, US, labels_US, Vᴴ, (:v,))
188+
@test A A′
189+
@test size(U, ndims(U)) == 1 == size(Vᴴ, 1)
190+
191+
U, S, Vᴴ = @constinferred svd(A, labels_A, (), labels_A; full=false)
192+
@test A == Acopy # should not have altered initial array
193+
US, labels_US = contract(U, (:u,), S, (:u, :v))
194+
A′ = contract(labels_A, US, labels_US, Vᴴ, (:v, labels_A...))
195+
@test A A′
196+
@test size(U, 1) == 1 == size(Vᴴ, 1)
169197
end
170198

171199
@testset "Truncated SVD ($T)" for T in elts

0 commit comments

Comments
 (0)