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

make solve understand matrix equations #5201

Open
jasongrout opened this issue Feb 7, 2009 · 4 comments
Open

make solve understand matrix equations #5201

jasongrout opened this issue Feb 7, 2009 · 4 comments

Comments

@jasongrout
Copy link
Member

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 :).

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/5201

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Feb 7, 2009

comment:1

Which part of no non-ReST tickets against 3.4 is hard to understand? :p

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.4, sage-3.4.1 Feb 7, 2009
@jasongrout
Copy link
Member Author

comment:2

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.

@sagetrac-ryan
Copy link
Mannequin

sagetrac-ryan mannequin commented Apr 14, 2011

comment:4

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

@jasongrout
Copy link
Member Author

comment:5

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.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@rwst rwst removed this from the sage-6.4 milestone Feb 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants