Add methods .cell_view() and .into_cell_view() #877
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
ArrayBase::cell_view(similar to methods.view()and.view_mut()) and the conversion methodArrayViewMut::into_cell_view()We've wanted to add these methods since we added
.cast::<T>()to the raw views.The translation of
ArrayViewMut<'a, T, D>->ArrayView<'a, MathCell<T>, D>works under the same principleas the method
Cell:from_mutin the standard library.These methods should give a lot of flexibility - suddenly the same array view can be traversed multiple times
in the same
Zipand mutated while being traversed in a different way than before. The price to pay for thisis using the Cell methods to manipulate the elements.
We use a new cell type -
MathCell- which is just a transparent wrapper aroundCell. This is so thatwe can implement arithmetic ops for cells. However, finding the right implementations requires more design
work so that will be in a later PR.
This fixes #478 - the use case is fixed by using
Zip::from(a).and_broadcast(b.cell_view())- i.e composingcell_viewwith the existing broadcasting method.