Skip to content

Commit f61c04c

Browse files
committed
Fix scaling diagonals for unit triangular matrices
1 parent e5f345c commit f61c04c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/diagonal.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,10 @@ function _rmul!(A::UpperOrLowerTriangular, D::Diagonal)
387387
for row in rowstart:rowstop
388388
P[row, col] *= D.diag[col]
389389
end
390-
if isunit
391-
A[col, col] *= D.diag[col]
392-
end
393390
end
394-
return A
391+
isupper && _setdiag!(P, identity, D.diag)
392+
TriWrapper = isupper ? UpperTriangular : LowerTriangular
393+
return TriWrapper(P)
395394
end
396395

397396
function lmul!(D::Diagonal, B::AbstractVecOrMat)
@@ -426,11 +425,10 @@ function _lmul!(D::Diagonal, A::UpperOrLowerTriangular)
426425
for row in rowstart:rowstop
427426
P[row, col] = D.diag[col] * P[row, col]
428427
end
429-
if isunit
430-
A[col, col] = D.diag[col] * A[col, col]
431-
end
432428
end
433-
return A
429+
isupper && _setdiag!(P, identity, D.diag)
430+
TriWrapper = isupper ? UpperTriangular : LowerTriangular
431+
return TriWrapper(P)
434432
end
435433

436434
@inline function __muldiag_nonzeroalpha!(out, D::Diagonal, B, alpha::Number, beta::Number)

0 commit comments

Comments
 (0)