Skip to content

[Feature request] compatible_multiplicative_operand interface #261

Open
@GiggleLiu

Description

@GiggleLiu

In the discussion under this PR: SciML/ExponentialUtilities.jl#84 . We meet a using case of multipling a linear operator of certain type to a dense matrix. We think it would be fantastic if there is an API called compatible_multiplicative_operand(target, source) in ArrayInterface. That is,

  • compatible_multiplicative_operand(::CuArray, dense::Matrix) = CuArray(dense)
  • compatible_multiplicative_operand(::Matrix, cuarray::CuArray) = Matrix(cuarray)
  • compatible_multiplicative_operand(::SparseMatrixCSC, dense::Matrix) = dense
  • compatible_multiplicative_operand(::Matrix, sparse::SparseMatrixCSC) = sparse

Similarly, we can define them for Transpose, Adjoint, SubArray, and ReshapedArray, DistributedArray et al.

The key point is, we want two arrays can have compatible array types for multiplication, which is quite different from Base.convert.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions