Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up`\(::UniformScaling, ::Diagonal{T,Array{T,1}})` returns dense `Matrix` when `T` is abstract #37359
Labels
Comments
|
Fix should be as simple as: --- a/stdlib/LinearAlgebra/src/diagonal.jl
+++ b/stdlib/LinearAlgebra/src/diagonal.jl
@@ -174,6 +174,7 @@ end
(*)(x::Number, D::Diagonal) = Diagonal(x * D.diag)
(*)(D::Diagonal, x::Number) = Diagonal(D.diag * x)
(/)(D::Diagonal, x::Number) = Diagonal(D.diag / x)
+(\)(x::Number, D::Diagonal) = Diagonal(x \ D.diag)
function (*)(Da::Diagonal, Db::Diagonal)
nDa, mDb = size(Da, 2), size(Db, 1)If someone wants to try this out and make a PR out of it - go for it! |
tantei3
added a commit
to tantei3/julia
that referenced
this issue
Sep 10, 2020
…t type and a subtype of Number JuliaLang#37359
tantei3
added a commit
to tantei3/julia
that referenced
this issue
Sep 10, 2020
tantei3
added a commit
to tantei3/julia
that referenced
this issue
Sep 10, 2020
|
While @mbauman, maybe there is something else to be improved here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As stated in the title,
\(::UniformScaling, ::Diagonal{T,Array{T,1}})returns a denseMatrixwhenTis abstract. It seems that, ideally, aDiagonalmatrix should be returned (as is the case whenTis concrete). (This is for the case whenT <: Numberistrue; I haven't looked at what happens whenT <: Numberisfalse.)