@@ -372,6 +372,27 @@ function rmul!(T::Tridiagonal, D::Diagonal)
372372 end
373373 return T
374374end
375+ for T in [:UpperTriangular , :UnitUpperTriangular ,
376+ :LowerTriangular , :UnitLowerTriangular ]
377+ @eval rmul! (A:: $T{<:Any, <:StridedMatrix} , D:: Diagonal ) = _rmul! (A, D)
378+ @eval lmul! (D:: Diagonal , A:: $T{<:Any, <:StridedMatrix} ) = _lmul! (D, A)
379+ end
380+ function _rmul! (A:: UpperOrLowerTriangular , D:: Diagonal )
381+ P = parent (A)
382+ isunit = A isa UnitUpperOrUnitLowerTriangular
383+ isupper = A isa UpperOrUnitUpperTriangular
384+ for col in axes (A,2 )
385+ rowstart = isupper ? firstindex (A,1 ) : col+ isunit
386+ rowstop = isupper ? col- isunit : lastindex (A,1 )
387+ for row in rowstart: rowstop
388+ P[row, col] *= D. diag[col]
389+ end
390+ if isunit
391+ A[col, col] *= D. diag[col]
392+ end
393+ end
394+ return A
395+ end
375396
376397function lmul! (D:: Diagonal , B:: AbstractVecOrMat )
377398 matmul_size_check (size (D), size (B))
@@ -395,6 +416,22 @@ function lmul!(D::Diagonal, T::Tridiagonal)
395416 end
396417 return T
397418end
419+ function _lmul! (D:: Diagonal , A:: UpperOrLowerTriangular )
420+ P = parent (A)
421+ isunit = A isa UnitUpperOrUnitLowerTriangular
422+ isupper = A isa UpperOrUnitUpperTriangular
423+ for col in axes (A,2 )
424+ rowstart = isupper ? firstindex (A,1 ) : col+ isunit
425+ rowstop = isupper ? col- isunit : lastindex (A,1 )
426+ for row in rowstart: rowstop
427+ P[row, col] = D. diag[col] * P[row, col]
428+ end
429+ if isunit
430+ A[col, col] = D. diag[col] * A[col, col]
431+ end
432+ end
433+ return A
434+ end
398435
399436@inline function __muldiag_nonzeroalpha! (out, D:: Diagonal , B, alpha:: Number , beta:: Number )
400437 @inbounds for j in axes (B, 2 )
0 commit comments