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

sympy.diffgeom and Add class #26478

Open
davidepittet opened this issue Apr 8, 2024 · 2 comments · May be fixed by #26499
Open

sympy.diffgeom and Add class #26478

davidepittet opened this issue Apr 8, 2024 · 2 comments · May be fixed by #26499

Comments

@davidepittet
Copy link

Following the post I wrote in the mailing list, I open this issue to discuss some problems I found in the sympy.diffgeom subclass.

As I explained there, it all started from the previous issue on the "WedgeProduct giving wrong output". I started exploring the code around WedgeProduct and TensorProduct, and I found out there is a series of problems that are all more or less related to how we sum objects (tensor products, but also simple vector fields).

For simplicity, I paste here what I wrote previously on the mailing list to explain what I think are the main points:

"I think that the main problem is that we "delegate" the sum of tensors to the Add class, allowing to sum apples with pears; e.g. we can create an object that is the sum of a vector and a covector like e_x + dx, when they really belong to different spaces, without getting an error. This reflects in cascade to the whole submodule: the sum of two tensor products is a tensor and should be treated as such, not as a generic Add instance, because there are constraints that are not taken into account; extending the previous example, we cannot sum TensorProduct(e_x, dx) with TensorProduct(dx, e_:x).

Then, we have to implement the associativity of the tensor product and the distributivity of the tensor product wrt the sum.

Once this is fixed we have to put a constraint on the number and the type of the arguments of the call method and this should solve the problems pointed out on GitHub."

As suggested, I open this issue to discuss a potential line of work to fix these problems.

@asmeurer
Copy link
Member

asmeurer commented Apr 9, 2024

We should be able to use a similar method to the one used for shape checks in the matrix expressions to add type checking for tensors in Add.

@davidepittet
Copy link
Author

Ok, I will look into it and try to come up with a solution

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 a pull request may close this issue.

2 participants