1
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2
2
3
+ using Base. LinAlg: mul!, ldiv!, Adjoint, Transpose
4
+
3
5
# ## Data
4
6
5
7
spv_x1 = SparseVector (8 , [2 , 5 , 6 ], [1.25 , - 0.75 , 3.5 ])
816
818
for α in [0.0 , 1.0 , 2.0 ], β in [0.0 , 0.5 , 1.0 ]
817
819
y = rand (9 )
818
820
rr = α* A* xf + β* y
819
- @test A_mul_B ! (α, A, x, β, y) === y
821
+ @test mul ! (α, A, x, β, y) === y
820
822
@test y ≈ rr
821
823
end
822
824
y = A* x
@@ -829,12 +831,12 @@ end
829
831
for α in [0.0 , 1.0 , 2.0 ], β in [0.0 , 0.5 , 1.0 ]
830
832
y = rand (9 )
831
833
rr = α* A' xf + β* y
832
- @test At_mul_B ! (α, A , x, β, y) === y
834
+ @test mul ! (α, Transpose (A) , x, β, y) === y
833
835
@test y ≈ rr
834
836
end
835
- y = At_mul_B (A , x)
837
+ y = * ( Transpose (A) , x)
836
838
@test isa (y, Vector{Float64})
837
- @test y ≈ At_mul_B (A , xf)
839
+ @test y ≈ * ( Transpose (A) , xf)
838
840
end
839
841
end
840
842
@testset " sparse A * sparse x -> dense y" begin
844
846
for α in [0.0 , 1.0 , 2.0 ], β in [0.0 , 0.5 , 1.0 ]
845
847
y = rand (9 )
846
848
rr = α* Af* xf + β* y
847
- @test A_mul_B ! (α, A, x, β, y) === y
849
+ @test mul ! (α, A, x, β, y) === y
848
850
@test y ≈ rr
849
851
end
850
852
y = SparseArrays. densemv (A, x)
@@ -858,12 +860,12 @@ end
858
860
for α in [0.0 , 1.0 , 2.0 ], β in [0.0 , 0.5 , 1.0 ]
859
861
y = rand (9 )
860
862
rr = α* Af' xf + β* y
861
- @test At_mul_B ! (α, A , x, β, y) === y
863
+ @test mul ! (α, Transpose (A) , x, β, y) === y
862
864
@test y ≈ rr
863
865
end
864
866
y = SparseArrays. densemv (A, x; trans= ' T' )
865
867
@test isa (y, Vector{Float64})
866
- @test y ≈ At_mul_B (Af , xf)
868
+ @test y ≈ * ( Transpose (Af) , xf)
867
869
end
868
870
869
871
let A = complex .(sprandn (7 , 8 , 0.5 ), sprandn (7 , 8 , 0.5 )),
889
891
@test all (nonzeros (y) .!= 0.0 )
890
892
@test Array (y) ≈ Af * xf
891
893
892
- y = At_mul_B (A , x2)
894
+ y = * ( Transpose (A) , x2)
893
895
@test isa (y, SparseVector{Float64,Int})
894
896
@test all (nonzeros (y) .!= 0.0 )
895
897
@test Array (y) ≈ Af' x2f
@@ -906,11 +908,11 @@ end
906
908
@test isa (y, SparseVector{Complex128,Int})
907
909
@test Array (y) ≈ Af * xf
908
910
909
- y = At_mul_B (A , x2)
911
+ y = * ( Transpose (A) , x2)
910
912
@test isa (y, SparseVector{Complex128,Int})
911
913
@test Array (y) ≈ Af.' * x2f
912
914
913
- y = Ac_mul_B (A , x2)
915
+ y = * ( Adjoint (A) , x2)
914
916
@test isa (y, SparseVector{Complex128,Int})
915
917
@test Array (y) ≈ Af' x2f
916
918
end
@@ -955,19 +957,25 @@ end
955
957
for spvec in spvecs
956
958
fspvec = convert (Array, spvec)
957
959
# 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)
960
964
end
961
965
# test in-place left-division methods not involving quotients
962
966
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))
965
971
end
966
972
end
967
973
# test in-place left-division methods involving quotients
968
974
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))
971
979
end
972
980
end
973
981
end
@@ -987,12 +995,12 @@ end
987
995
zerodvec = zeros (Float64, 2 )
988
996
989
997
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)
996
1004
end
997
1005
end
998
1006
end
0 commit comments