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.
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) = densecompatible_multiplicative_operand(::Matrix, sparse::SparseMatrixCSC) = sparseSimilarly, we can define them for Transpose, Adjoint, SubArray, and ReshapedArray,
DistributedArrayet al.The key point is, we want two arrays can have compatible array types for multiplication, which is quite different from
Base.convert.