-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Devel matrices #147
Conversation
…e. Update all examples and remove the use of Tuple as an input
There was a problem hiding this 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.
There's still a problem with the |
The # 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. |
class Matrix(MatrixSymbolicExpr): | ||
def __new__(cls, mat, *, name): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ofTuple
. In this case, we don't need them to have thename
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 (addis_real
oris_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.
b1 = Vector([1, 2, 3], name='b1') | ||
assert not b1 == b |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
This PR solves #145 issue.
In this PR, we introduce the objects
Vector
andMatrix
. 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 ofTuple
as it not an algebraic object.Internally, we convert these new objects to
sympy
, either through the objects methodto_sympy()
or when evaluating symbolic expressions, for instance insideTerminalExpr
or mapping evaluation operators.