Skip to content

Commit

Permalink
Add type to the last argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Aug 20, 2024
1 parent 093b565 commit 8c1b942
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,24 +661,24 @@ _pushzero(A) = (B = similar(A, length(A)+1); @inbounds B[begin:end-1] .= A; @inb
_droplast!(A) = deleteat!(A, lastindex(A))

# destination type for matmul
matprod_dest(A::StructuredMatrix, B::StructuredMatrix, TS) = similar(B, TS, size(B))
matprod_dest(A::AbstractArray, B::StructuredMatrix, TS) = similar(A, TS, size(A))
matprod_dest(A::StructuredMatrix, B::AbstractArray, TS) = similar(B, TS, size(B))
matprod_dest(A::StructuredMatrix, B::StructuredMatrix, TS::Type) = similar(B, TS, size(B))
matprod_dest(A::AbstractArray, B::StructuredMatrix, TS::Type) = similar(A, TS, size(A))
matprod_dest(A::StructuredMatrix, B::AbstractArray, TS::Type) = similar(B, TS, size(B))
# diagonal is special, as it does not change the structure of the other matrix
# we call similar without a size to preserve the type of the matrix wherever possible
# reroute through _matprod_dest_diag to allow speicalizing on the type of the StructuredMatrix
# without defining methods for both the orderings
matprod_dest(A::StructuredMatrix, B::Diagonal, TS) = _matprod_dest_diag(A, TS)
matprod_dest(A::Diagonal, B::StructuredMatrix, TS) = _matprod_dest_diag(B, TS)
matprod_dest(A::Diagonal, B::Diagonal, TS) = _matprod_dest_diag(B, TS)
matprod_dest(A::StructuredMatrix, B::Diagonal, TS::Type) = _matprod_dest_diag(A, TS)
matprod_dest(A::Diagonal, B::StructuredMatrix, TS::Type) = _matprod_dest_diag(B, TS)
matprod_dest(A::Diagonal, B::Diagonal, TS::Type) = _matprod_dest_diag(B, TS)
_matprod_dest_diag(A, TS) = similar(A, TS)
function _matprod_dest_diag(A::SymTridiagonal, TS)
n = size(A, 1)
Tridiagonal(similar(A, TS, n-1), similar(A, TS, n), similar(A, TS, n-1))
end

# Special handling for adj/trans vec
matprod_dest(A::Diagonal, B::AdjOrTransAbsVec, TS) = similar(B, TS)
matprod_dest(A::Diagonal, B::AdjOrTransAbsVec, TS::Type) = similar(B, TS)

# General fallback definition for handling under- and overdetermined system as well as square problems
# While this definition is pretty general, it does e.g. promote to common element type of lhs and rhs
Expand Down

0 comments on commit 8c1b942

Please sign in to comment.