ndarray
ndarray copied to clipboard
Fixes and follow-ups to two-sided broadcasting in arithmethic ops
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 justD: Dimension, i.e. the DimMax with associated type becomes implied byD: 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.
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.