xtensor-blas icon indicating copy to clipboard operation
xtensor-blas copied to clipboard

[Feature request] Support xt::linalg::outer for higher-dimensional objects

Open mircomarahrens opened this issue 1 year ago • 0 comments

Hello,

currently xt::linalg::outer only supports 1D vectors and is missing higher-dimensional objects. A quick workaround could be:

template<typename T>
static inline auto outer(expression_type <T> &M, expression_type <T> &W) {
    auto &&dM = M.derived_cast(); auto &&dW = W.derived_cast();
    shape_type shapeM = shape(M);
    dM = expand_dims(dM, shapeM.size());
    dW = expand_dims(dW, 0);
    return tensordot(dM, dW, {shapeM.size()}, {0});;
}

Is there a particular reason why only 1D vectors are supported in xt::linalg::outer?

Best regards, Mirco

mircomarahrens avatar Mar 29 '23 03:03 mircomarahrens