Skip to content

Commit 59d031f

Browse files
committed
Redirect mul to _mul
1 parent e4e8c19 commit 59d031f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/bidiag.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,26 +1215,22 @@ function _dibimul!(C::Bidiagonal, A::Diagonal, B::Bidiagonal, _add)
12151215
end
12161216

12171217
function mul(A::UpperOrUnitUpperTriangular, B::Bidiagonal)
1218-
TS = promote_op(matprod, eltype(A), eltype(B))
1219-
C = mul!(similar(A, TS, size(A)), A, B)
1218+
C = _mul(A, B)
12201219
return B.uplo == 'U' ? UpperTriangular(C) : C
12211220
end
12221221

12231222
function mul(A::LowerOrUnitLowerTriangular, B::Bidiagonal)
1224-
TS = promote_op(matprod, eltype(A), eltype(B))
1225-
C = mul!(similar(A, TS, size(A)), A, B)
1223+
C = _mul(A, B)
12261224
return B.uplo == 'L' ? LowerTriangular(C) : C
12271225
end
12281226

12291227
function mul(A::Bidiagonal, B::UpperOrUnitUpperTriangular)
1230-
TS = promote_op(matprod, eltype(A), eltype(B))
1231-
C = mul!(similar(B, TS, size(B)), A, B)
1228+
C = _mul(A, B)
12321229
return A.uplo == 'U' ? UpperTriangular(C) : C
12331230
end
12341231

12351232
function mul(A::Bidiagonal, B::LowerOrUnitLowerTriangular)
1236-
TS = promote_op(matprod, eltype(A), eltype(B))
1237-
C = mul!(similar(B, TS, size(B)), A, B)
1233+
C = _mul(A, B)
12381234
return A.uplo == 'L' ? LowerTriangular(C) : C
12391235
end
12401236

src/matmul.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ julia> [1 1; 0 1] * [1 0; 1 1]
113113
"""
114114
(*)(A::AbstractMatrix, B::AbstractMatrix) = mul(A, B)
115115
# we add an extra level of indirection to avoid ambiguities in *
116-
function mul(A::AbstractMatrix, B::AbstractMatrix)
116+
# We also define the core functionality within _mul to reuse the code elsewhere
117+
mul(A::AbstractMatrix, B::AbstractMatrix) = _mul(A, B)
118+
function _mul(A::AbstractMatrix, B::AbstractMatrix)
117119
TS = promote_op(matprod, eltype(A), eltype(B))
118120
mul!(matprod_dest(A, B, TS), A, B)
119121
end

0 commit comments

Comments
 (0)