ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Fixes and follow-ups to two-sided broadcasting in arithmethic ops

Open bluss opened this issue 4 years ago • 1 comments
trafficstars

In #898 we left the following "known issues" open that we can fix after that PR's review and merge:

  • [x] Rename BroadcastShape to DimMax - we also move the broadcast method out of the trait (it can just be a free function)
  • [ ] It is a wish that the D: Dimension + DimMax<E> bound in arith ops becomes just D: Dimension, i.e. the DimMax with associated type becomes implied by D: Dimension. At this point it is not certain how this can be done.
  • [x] Preserve the allocation of the input array in arithmetic ops in more cases (when only the left/right side needs broadcast) in array + &array and &array + array
  • [ ] Preserve the allocation of the input array in arithmetic ops in more cases (when the left side needs broadcast in Array + Array)
  • [x] Improve performance of "no-broadcasting-needed" scenario in &array + &array operation
  • [ ] Potentially provide public function or method similar to broadcast_with - that does the broadcasting of two arrays together.

bluss avatar Mar 12 '21 09:03 bluss

Specialization can solve DimMax's problems:

impl<D1: Dimension, D2: Dimension> DimMax<D2> for D1 {
    default type Output = D1;
}

But it seems that there are still many problems to be solved before stability.

SparrowLii avatar May 24 '21 02:05 SparrowLii