Skip to content

Commit fa97d9c

Browse files
committed
Rewrite A[ct]_(mul|ldiv|rdiv)_B[ct][!] calls in test/sparse/sparsevector.jl as *, /, \, mul!, ldiv!, or rdiv!.
1 parent 2b91b2f commit fa97d9c

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

test/sparse/sparsevector.jl

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
using Base.LinAlg: mul!, ldiv!, Adjoint, Transpose
4+
35
### Data
46

57
spv_x1 = SparseVector(8, [2, 5, 6], [1.25, -0.75, 3.5])
@@ -816,7 +818,7 @@ end
816818
for α in [0.0, 1.0, 2.0], β in [0.0, 0.5, 1.0]
817819
y = rand(9)
818820
rr = α*A*xf + β*y
819-
@test A_mul_B!(α, A, x, β, y) === y
821+
@test mul!(α, A, x, β, y) === y
820822
@test y rr
821823
end
822824
y = A*x
@@ -829,12 +831,12 @@ end
829831
for α in [0.0, 1.0, 2.0], β in [0.0, 0.5, 1.0]
830832
y = rand(9)
831833
rr = α*A'xf + β*y
832-
@test At_mul_B!(α, A, x, β, y) === y
834+
@test mul!(α, Transpose(A), x, β, y) === y
833835
@test y rr
834836
end
835-
y = At_mul_B(A, x)
837+
y = *(Transpose(A), x)
836838
@test isa(y, Vector{Float64})
837-
@test y At_mul_B(A, xf)
839+
@test y *(Transpose(A), xf)
838840
end
839841
end
840842
@testset "sparse A * sparse x -> dense y" begin
@@ -844,7 +846,7 @@ end
844846
for α in [0.0, 1.0, 2.0], β in [0.0, 0.5, 1.0]
845847
y = rand(9)
846848
rr = α*Af*xf + β*y
847-
@test A_mul_B!(α, A, x, β, y) === y
849+
@test mul!(α, A, x, β, y) === y
848850
@test y rr
849851
end
850852
y = SparseArrays.densemv(A, x)
@@ -858,12 +860,12 @@ end
858860
for α in [0.0, 1.0, 2.0], β in [0.0, 0.5, 1.0]
859861
y = rand(9)
860862
rr = α*Af'xf + β*y
861-
@test At_mul_B!(α, A, x, β, y) === y
863+
@test mul!(α, Transpose(A), x, β, y) === y
862864
@test y rr
863865
end
864866
y = SparseArrays.densemv(A, x; trans='T')
865867
@test isa(y, Vector{Float64})
866-
@test y At_mul_B(Af, xf)
868+
@test y *(Transpose(Af), xf)
867869
end
868870

869871
let A = complex.(sprandn(7, 8, 0.5), sprandn(7, 8, 0.5)),
@@ -889,7 +891,7 @@ end
889891
@test all(nonzeros(y) .!= 0.0)
890892
@test Array(y) Af * xf
891893

892-
y = At_mul_B(A, x2)
894+
y = *(Transpose(A), x2)
893895
@test isa(y, SparseVector{Float64,Int})
894896
@test all(nonzeros(y) .!= 0.0)
895897
@test Array(y) Af'x2f
@@ -906,11 +908,11 @@ end
906908
@test isa(y, SparseVector{Complex128,Int})
907909
@test Array(y) Af * xf
908910

909-
y = At_mul_B(A, x2)
911+
y = *(Transpose(A), x2)
910912
@test isa(y, SparseVector{Complex128,Int})
911913
@test Array(y) Af.' * x2f
912914

913-
y = Ac_mul_B(A, x2)
915+
y = *(Adjoint(A), x2)
914916
@test isa(y, SparseVector{Complex128,Int})
915917
@test Array(y) Af'x2f
916918
end
@@ -955,19 +957,25 @@ end
955957
for spvec in spvecs
956958
fspvec = convert(Array, spvec)
957959
# test out-of-place left-division methods
958-
for mat in (trimats..., unittrimats...), func in (\, At_ldiv_B, Ac_ldiv_B)
959-
@test func(mat, spvec) func(mat, fspvec)
960+
for mat in (trimats..., unittrimats...)
961+
@test \(mat, spvec) \(mat, fspvec)
962+
@test \(Adjoint(mat), spvec) \(Adjoint(mat), fspvec)
963+
@test \(Transpose(mat), spvec) \(Transpose(mat), fspvec)
960964
end
961965
# test in-place left-division methods not involving quotients
962966
if eltypevec == typeof(zero(eltypemat)*zero(eltypevec) + zero(eltypemat)*zero(eltypevec))
963-
for mat in unittrimats, func in (A_ldiv_B!, Base.LinAlg.At_ldiv_B!, Base.LinAlg.Ac_ldiv_B!)
964-
@test func(mat, copy(spvec)) func(mat, copy(fspvec))
967+
for mat in unittrimats
968+
@test ldiv!(mat, copy(spvec)) ldiv!(mat, copy(fspvec))
969+
@test ldiv!(Adjoint(mat), copy(spvec)) ldiv!(Adjoint(mat), copy(fspvec))
970+
@test ldiv!(Transpose(mat), copy(spvec)) ldiv!(Transpose(mat), copy(fspvec))
965971
end
966972
end
967973
# test in-place left-division methods involving quotients
968974
if eltypevec == typeof((zero(eltypemat)*zero(eltypevec) + zero(eltypemat)*zero(eltypevec))/one(eltypemat))
969-
for mat in trimats, func in (A_ldiv_B!, Base.LinAlg.At_ldiv_B!, Base.LinAlg.Ac_ldiv_B!)
970-
@test func(mat, copy(spvec)) func(mat, copy(fspvec))
975+
for mat in trimats
976+
@test ldiv!(mat, copy(spvec)) ldiv!(mat, copy(fspvec))
977+
@test ldiv!(Adjoint(mat), copy(spvec)) ldiv!(Adjoint(mat), copy(fspvec))
978+
@test ldiv!(Transpose(mat), copy(spvec)) ldiv!(Transpose(mat), copy(fspvec))
971979
end
972980
end
973981
end
@@ -987,12 +995,12 @@ end
987995
zerodvec = zeros(Float64, 2)
988996

989997
for mat in (utmat, ltmat, uutmat, ultmat)
990-
for func in (\, At_ldiv_B, Ac_ldiv_B)
991-
@test isequal((func)(mat, zerospvec), zerodvec)
992-
end
993-
for ipfunc in (A_ldiv_B!, Base.LinAlg.At_ldiv_B!, Base.LinAlg.Ac_ldiv_B!)
994-
@test isequal((ipfunc)(mat, copy(zerospvec)), zerospvec)
995-
end
998+
@test isequal(\(mat, zerospvec), zerodvec)
999+
@test isequal(\(Adjoint(mat), zerospvec), zerodvec)
1000+
@test isequal(\(Transpose(mat), zerospvec), zerodvec)
1001+
@test isequal(ldiv!(mat, copy(zerospvec)), zerospvec)
1002+
@test isequal(ldiv!(Adjoint(mat), copy(zerospvec)), zerospvec)
1003+
@test isequal(ldiv!(Transpose(mat), copy(zerospvec)), zerospvec)
9961004
end
9971005
end
9981006
end

0 commit comments

Comments
 (0)