Skip to content

Commit 61ffd27

Browse files
committed
Fix deprecations in linalg/triangular.jl
1 parent 64ac638 commit 61ffd27

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

base/linalg/triangular.jl

+12-9
Original file line numberDiff line numberDiff line change
@@ -1547,12 +1547,11 @@ for (f, g) in ((:A_mul_Bc, :A_mul_Bc!), (:A_mul_Bt, :A_mul_Bt!))
15471547
end
15481548
end
15491549

1550-
for mat in (:AbstractVector, :AbstractMatrix)
1551-
15521550
### Multiplication with triangle to the left and hence rhs cannot be transposed.
15531551
for (f, g) in ((:*, :A_mul_B!), (:Ac_mul_B, :Ac_mul_B!), (:At_mul_B, :At_mul_B!))
15541552
@eval begin
1555-
function ($f)(A::AbstractTriangular, B::$mat)
1553+
($f)(A::AbstractTriangular, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
1554+
function ($f)(A::AbstractTriangular, B::AbstractMatrix)
15561555
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
15571556
BB = similar(B, TAB, size(B))
15581557
copy!(BB, B)
@@ -1563,7 +1562,8 @@ end
15631562
### Left division with triangle to the left hence rhs cannot be transposed. No quotients.
15641563
for (f, g) in ((:\, :A_ldiv_B!), (:Ac_ldiv_B, :Ac_ldiv_B!), (:At_ldiv_B, :At_ldiv_B!))
15651564
@eval begin
1566-
function ($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::$mat)
1565+
($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
1566+
function ($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::AbstractMatrix)
15671567
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
15681568
BB = similar(B, TAB, size(B))
15691569
copy!(BB, B)
@@ -1574,7 +1574,8 @@ end
15741574
### Left division with triangle to the left hence rhs cannot be transposed. Quotients.
15751575
for (f, g) in ((:\, :A_ldiv_B!), (:Ac_ldiv_B, :Ac_ldiv_B!), (:At_ldiv_B, :At_ldiv_B!))
15761576
@eval begin
1577-
function ($f)(A::Union{UpperTriangular,LowerTriangular}, B::$mat)
1577+
($f)(A::Union{UpperTriangular,LowerTriangular}, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
1578+
function ($f)(A::Union{UpperTriangular,LowerTriangular}, B::AbstractMatrix)
15781579
TAB = typeof((zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))/one(eltype(A)))
15791580
BB = similar(B, TAB, size(B))
15801581
copy!(BB, B)
@@ -1585,7 +1586,8 @@ end
15851586
### Multiplication with triangle to the rigth and hence lhs cannot be transposed.
15861587
for (f, g) in ((:*, :A_mul_B!), (:A_mul_Bc, :A_mul_Bc!), (:A_mul_Bt, :A_mul_Bt!))
15871588
@eval begin
1588-
function ($f)(A::$mat, B::AbstractTriangular)
1589+
($f)(A::AbstractVector, B::AbstractTriangular) = ($f)(reshape(A, Val{2}), B)
1590+
function ($f)(A::AbstractMatrix, B::AbstractTriangular)
15891591
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
15901592
AA = similar(A, TAB, size(A))
15911593
copy!(AA, A)
@@ -1596,7 +1598,8 @@ end
15961598
### Right division with triangle to the right hence lhs cannot be transposed. No quotients.
15971599
for (f, g) in ((:/, :A_rdiv_B!), (:A_rdiv_Bc, :A_rdiv_Bc!), (:A_rdiv_Bt, :A_rdiv_Bt!))
15981600
@eval begin
1599-
function ($f)(A::$mat, B::Union{UnitUpperTriangular, UnitLowerTriangular})
1601+
($f)(A::AbstractVector, B::Union{UnitUpperTriangular, UnitLowerTriangular}) = ($f)(reshape(A, Val{2}), B)
1602+
function ($f)(A::AbstractMatrix, B::Union{UnitUpperTriangular, UnitLowerTriangular})
16001603
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
16011604
AA = similar(A, TAB, size(A))
16021605
copy!(AA, A)
@@ -1608,15 +1611,15 @@ end
16081611
### Right division with triangle to the right hence lhs cannot be transposed. Quotients.
16091612
for (f, g) in ((:/, :A_rdiv_B!), (:A_rdiv_Bc, :A_rdiv_Bc!), (:A_rdiv_Bt, :A_rdiv_Bt!))
16101613
@eval begin
1611-
function ($f)(A::$mat, B::Union{UpperTriangular,LowerTriangular})
1614+
($f)(A::AbstractVector, B::Union{UpperTriangular,LowerTriangular}) = ($f)(reshape(A, Val{2}), B)
1615+
function ($f)(A::AbstractMatrix, B::Union{UpperTriangular,LowerTriangular})
16121616
TAB = typeof((zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))/one(eltype(A)))
16131617
AA = similar(A, TAB, size(A))
16141618
copy!(AA, A)
16151619
($g)(AA, convert(AbstractArray{TAB}, B))
16161620
end
16171621
end
16181622
end
1619-
end
16201623

16211624
# If these are not defined, they will fallback to the versions in matmul.jl
16221625
# and dispatch to generic_matmatmul! which is very costly to compile. The methods

0 commit comments

Comments
 (0)