Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give MathCell arithmetic ops implementations when MathCell is left value #1011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SparrowLii
Copy link
Contributor

@SparrowLii SparrowLii commented May 21, 2021

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:

  1. Currently MathCell can only be left value. The main reason are:
    (1) Conflicts occur when compiling MathCell<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

  2. The value in MathCell must be Copy
    This is because the value in MathCell needs to be retrieved using the get() method. We cannot get &T from &MathCell<T> unless we create a new structure MathRefCell(RefCell<T>)

@bluss
Copy link
Member

bluss commented May 21, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants