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

Devel matrices #147

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Devel matrices #147

wants to merge 21 commits into from

Conversation

ratnania
Copy link
Contributor

This PR solves #145 issue.

In this PR, we introduce the objects Vector and Matrix. They are meant to be immutable and only as an API for the user.
All examples using Tuple as an element of user expressions have been updated, and we should from now on, remove the use of Tuple as it not an algebraic object.

Internally, we convert these new objects to sympy, either through the objects method to_sympy() or when evaluating symbolic expressions, for instance inside TerminalExpr or mapping evaluation operators.

@ratnania ratnania added bug Something isn't working enhancement New feature or request labels Feb 23, 2024
@ratnania ratnania requested a review from yguclu February 23, 2024 11:53
@ratnania ratnania self-assigned this Feb 23, 2024
Copy link
Member

@yguclu yguclu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great improvement!!

I have a few comments and questions.

sympde/topology/derivatives.py Outdated Show resolved Hide resolved
sympde/expr/evaluation.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/core/matrices.py Outdated Show resolved Hide resolved
sympde/expr/tests/test_expr.py Outdated Show resolved Hide resolved
@ratnania
Copy link
Contributor Author

ratnania commented Mar 2, 2024

There's still a problem with the cross operator. I'm working on it.

@ratnania
Copy link
Contributor Author

ratnania commented Mar 2, 2024

The cross problem has been fixed;

        # after simplifications, the expression can be reduced to 0 in some cases
        # here's an example;
        # if b is a Vector and u and v are scalar functions,
        # we should have the following
        # cross(b*u,b*v) = u*v*cross(b,b) = 0
        if a == b:
            return S.Zero

ready to merge.

@ratnania ratnania requested a review from yguclu March 2, 2024 13:59
Comment on lines +298 to +299
class Matrix(MatrixSymbolicExpr):
def __new__(cls, mat, *, name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code one more time, I find myself unsure about the necessity of giving a "name" to the class instances. This is not a purely symbolic class, but rather a container for symbolic objects. So why do we care about giving the objects a string name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, both Vector and Matrix should be used in two different ways;

  • as a container; like the Tuple, but allow for algebraic operations, which is not the case of Tuple. In this case, we don't need them to have the name attribute.
  • as a variable; like the Constant, in which case, we'll be able to pass it as an argument when doing the assembly. This will make our code much more readable.
    This means that the actual implementation needs improvements (add is_real or is_complex etc then update psydac).
    So I suggest that we keep it this way, then we'll open an issue to make them work as variables.

Comment on lines +1926 to +1927
b1 = Vector([1, 2, 3], name='b1')
assert not b1 == b
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment. It is quite strange that by comparing two identical vectors the equality is not satisfied, because they have different names. Then what is the meaning of equality for this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my remark on the Matrix case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants