Opened 12 years ago
Last modified 6 years ago
#5201 new enhancement
make solve understand matrix equations
Reported by: | jason | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-wishlist |
Component: | calculus | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
I think it would be a great thing if solve could recognize matrices and that two matrices are equal if each entry is equal. I believe MMA does this (but it's easier there; matrices are nothing more than nested lists). It'd certainly make certain things I do more natural if I could do:
solve(matrixA==matrixB)
and that was equivalent to:
solve([i==j for i,j in zip(matrixA.list(), matrixB.list())])
Okay, so now that I've written my piece, I suppose the next step is to open a trac ticket, write a patch to implement it, and post it for review :).
Change History (10)
comment:1 Changed 12 years ago by
- Milestone changed from sage-3.4 to sage-3.4.1
comment:2 Changed 12 years ago by
argh! I looked at the list and thought "the first item is the ReST transition, so I have to pick the second item". Apparently I was thinking that the next release was already out and 3.3 was the ReST transition.
comment:3 Changed 11 years ago by
- Keywords beginner added
- Report Upstream set to N/A
comment:4 Changed 10 years ago by
Could this be accomplished by overriding the comparison operator for the matrix class?
for example
def __richcmp__(self, other_matrix, cmptype): if cmptype == 2: #this is the '==' operator if is_Matrix(other_matrix): if False in [i==j for i,j in zip(self.list(), other_matrix.list())]: return False else: return True
I'm just not sure where the 'matrix class' is. This would allow comparisons like
sage: matrixA == matrixB True
comment:5 Changed 10 years ago by
- Keywords beginner removed
You bring up a good point, and make me doubt whether the feature request is even feasible. Certainly it's probably not a beginner ticket after all. The problem is that we already have an == operator:
sage: a=matrix(SR,2,[x,x^2,x+1,x+4]) sage: b=matrix(SR,2,[4,3,2,1]) sage: a==b False
That means that all solve will see is False. Instead, we want something like:
sage: SR(a)==SR(b) ([ x x^2] [x + 1 x + 4]) == ([4 3] [2 1])
(i.e., we want the == in the solve to construct an equation, which it does for symbolic objects. One of the issues at heart here is that a symbolic object wrapping a Sage matrix is different from a Sage matrix containing symbolic objects.
So I'm going to take off beginner status for this ticket here. It would still be nice if solve(SR(a)==SR(b)) worked in the above example.
comment:6 Changed 7 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:7 Changed 7 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:8 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:9 Changed 6 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:10 Changed 6 years ago by
- Milestone changed from sage-6.4 to sage-wishlist
Which part of no non-ReST tickets against 3.4 is hard to understand? :p
Cheers,
Michael