ndarray
ndarray copied to clipboard
Give MathCell arithmetic ops implementations when MathCell is left value
Update #969
Four functions are implemented for ArrayView<MathCell, _> in impl_methods.rs:
zip_cell_with, zip_cell_with_elem, zip_cell_with_same_shape, zip_cell_with_by_rows.
Operator overloading is implemented in impl_ops.rs for the following situations:
ArrayView<MathCell, _> binary_op &ArrayBase
ArrayView<MathCell, _> binary_op Scalar
ArrayView<MathCell, _> assign_op &ArrayBase
ArrayView<MathCell, _> assign_op Scalar
The unresolved problems are:
-
Currently
MathCellcan only be left value. The main reason are: (1) Conflicts occur when compilingMathCell<A> op MathCell<B>(2) Rust's orphan rules. We can't write code like this:impl<T> Add<MathCell<T>> for T. This will cause E0210 error -
The value in
MathCellmust beCopyThis is because the value in MathCell needs to be retrieved using theget()method. We cannot get&Tfrom&MathCell<T>unless we create a new structureMathRefCell(RefCell<T>)
We don't implement ArrayViewMut + x (only ArrayViewMut += x), and this should be the same way IMO. I.e we want the += and similar ops. I hope we can do with without adding new copies like all the new .zip* methods.