Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Matrices
New issue 4107 by [email protected]: Equality of unequal
matrices does not reduce to False
http://code.google.com/p/sympy/issues/detail?id=4107
Putting two equal matrices into an Equality correctly reduces to True:
In [1]: Equality(Matrix([1, 2]), Matrix([1, 2]))
Out[1]: True
If the two matrices are definitely unequal, the Equality should likewise
reduce to False. But it doesn't:
In [2]: Equality(Matrix([1, 2]), Matrix([3, 4]))
Out[2]:
[1] = [3]
[ ] [ ]
[2] [4]
Well, Matrix isn't a subclass of Basic, so maybe this is just one case
where that distinction must be considered. But if we try the same thing
with ImmutableMatrix, it still doesn't reduce:
In [3]: Equality(ImmutableMatrix([1, 2]), ImmutableMatrix([3, 4]))
Out[3]:
[1] = [3]
[ ] [ ]
[2] [4]
I think the issue derives from the fact that Relational specially handles
instances of Expr, but ImmutableMatrix is not a subclass of Expr.
Confusingly, ImmutableMatrix subclasses MatrixExpr, which claims in its
docstring to subclass Expr, but actually subclasses Basic. Its definition
begins:
class MatrixExpr(Basic):
""" Matrix Expression Class
Matrix Expressions subclass SymPy Expr's so that
MatAdd inherits from Add
MatMul inherits from Mul
MatPow inherits from Pow
[...]
But none of these statements are true. Oh, and then ImmutableSparseMatrix
subclasses Basic instead of MatrixExpr, so it's not an Expr either.
How can this be handled? Should MatrixExpr actually subclass Expr, or is
there a reason it doesn't? Or should Relational be somehow modified to
handle all matrices?
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.