The docstring for UniformScaling describes it as an "identity operator"
yet the support multiplication works only for a Vector or Matrix,
not for a general Array, as illustrated by this MWE:
using LinearAlgebra: I
5I * ones(2,3) # works of course
5I * ones(2,3,4) # fails with MethodError
The culprit is this one line of source code:
*(J::UniformScaling, A::AbstractVecOrMat) = J.λ*A
|
*(J::UniformScaling, A::AbstractVecOrMat) = J.λ*A |
that limits
A to be a matrix or vector.
My feature request is to generalize this to
*(J::UniformScaling, A::AbstractArray) = J.λ*A
With this tiny change, I really become an "identity operator" rather than merely an identity "matrix."
For context, I've put this more general method in one of my packages for years, but Aqua.jl tells me that it is type piracy, so it would be better to have this generality here in LinearAlgebra.
I will make a PR.
The docstring for
UniformScalingdescribes it as an "identity operator"yet the support multiplication works only for a
VectororMatrix,not for a general
Array, as illustrated by this MWE:The culprit is this one line of source code:
LinearAlgebra.jl/src/uniformscaling.jl
Line 279 in 27b0f13
that limits
Ato be a matrix or vector.My feature request is to generalize this to
With this tiny change,
Ireally become an "identity operator" rather than merely an identity "matrix."For context, I've put this more general method in one of my packages for years, but Aqua.jl tells me that it is type piracy, so it would be better to have this generality here in
LinearAlgebra.I will make a PR.