Skip to content

Implement a fixed size UniformScaling #1444

@albertomercurio

Description

@albertomercurio

UniformScaling is very useful in LinearAlgebra operations, because it optimizes the performances due to the fact that the compiler knows that it behaves like an identity matrix (possibly multiplied by some factor).

I'm aware that I(N) creates a Diagonal matrix of type Bool with all true in the diagonal. This constructor basically stores a vector inside, which stores all the values of the Diagonal.

In my opinion, it would be very useful to have another construction (let's say SizedUniformScaling), which behaves like a UniformScaling but additionally stores also the dimension. This is very useful in contexts like Kronecker's product. For example, one can define a method like

kron(A::Matrix, I::SizedUniformScaling)

which would be impossible with UniformScaling.

I'm currently using the method kron(A::Matrix, I::UniformScaling), but I basically only need to multiply it by an identity, and converting it into a Diagonal matrix seems an overkill.

Moreover, this would also be useful for defining methods for other AbstractMatrixs, for example for CUDA, Metal, DistributedArrays, and many others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]featureIndicates new feature / enhancement requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions