Skip to content

Commit

Permalink
Fix variable name in scaling an AbstractTriangular with zero alpha (#…
Browse files Browse the repository at this point in the history
…52855)

There is no `C` defined in these methods, so this branch used to error.
  • Loading branch information
jishnub authored Jan 11, 2024
1 parent 73cdfd8 commit c5d7b87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 8 additions & 8 deletions stdlib/LinearAlgebra/src/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ end

function _triscale!(A::UpperTriangular, B::UpperTriangular, c::Number, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
for i = 1:j
@inbounds _modify!(_add, B.data[i,j] * c, A.data, (i,j))
Expand All @@ -555,7 +555,7 @@ function _triscale!(A::UpperTriangular, B::UpperTriangular, c::Number, _add)
end
function _triscale!(A::UpperTriangular, c::Number, B::UpperTriangular, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
for i = 1:j
@inbounds _modify!(_add, c * B.data[i,j], A.data, (i,j))
Expand All @@ -565,7 +565,7 @@ function _triscale!(A::UpperTriangular, c::Number, B::UpperTriangular, _add)
end
function _triscale!(A::UpperOrUnitUpperTriangular, B::UnitUpperTriangular, c::Number, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
@inbounds _modify!(_add, c, A, (j,j))
for i = 1:(j - 1)
Expand All @@ -576,7 +576,7 @@ function _triscale!(A::UpperOrUnitUpperTriangular, B::UnitUpperTriangular, c::Nu
end
function _triscale!(A::UpperOrUnitUpperTriangular, c::Number, B::UnitUpperTriangular, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
@inbounds _modify!(_add, c, A, (j,j))
for i = 1:(j - 1)
Expand All @@ -587,7 +587,7 @@ function _triscale!(A::UpperOrUnitUpperTriangular, c::Number, B::UnitUpperTriang
end
function _triscale!(A::LowerTriangular, B::LowerTriangular, c::Number, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
for i = j:n
@inbounds _modify!(_add, B.data[i,j] * c, A.data, (i,j))
Expand All @@ -597,7 +597,7 @@ function _triscale!(A::LowerTriangular, B::LowerTriangular, c::Number, _add)
end
function _triscale!(A::LowerTriangular, c::Number, B::LowerTriangular, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
for i = j:n
@inbounds _modify!(_add, c * B.data[i,j], A.data, (i,j))
Expand All @@ -607,7 +607,7 @@ function _triscale!(A::LowerTriangular, c::Number, B::LowerTriangular, _add)
end
function _triscale!(A::LowerOrUnitLowerTriangular, B::UnitLowerTriangular, c::Number, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
@inbounds _modify!(_add, c, A, (j,j))
for i = (j + 1):n
Expand All @@ -618,7 +618,7 @@ function _triscale!(A::LowerOrUnitLowerTriangular, B::UnitLowerTriangular, c::Nu
end
function _triscale!(A::LowerOrUnitLowerTriangular, c::Number, B::UnitLowerTriangular, _add)
n = checksize1(A, B)
iszero(_add.alpha) && return _rmul_or_fill!(C, _add.beta)
iszero(_add.alpha) && return _rmul_or_fill!(A, _add.beta)
for j = 1:n
@inbounds _modify!(_add, c, A, (j,j))
for i = (j + 1):n
Expand Down
5 changes: 5 additions & 0 deletions stdlib/LinearAlgebra/test/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ for elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFlo
A2tmp = unitt(A1)
mul!(A1tmp, cr, A2tmp)
@test A1tmp == cr * A2tmp

A1tmp .= A1
@test mul!(A1tmp, A2tmp, cr, 0, 2) == 2A1
A1tmp .= A1
@test mul!(A1tmp, cr, A2tmp, 0, 2) == 2A1
else
A1tmp = copy(A1)
rmul!(A1tmp, ci)
Expand Down

0 comments on commit c5d7b87

Please sign in to comment.