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

Matrix morphism addition ignores bases #18520

Open
rbeezer mannequin opened this issue May 26, 2015 · 5 comments
Open

Matrix morphism addition ignores bases #18520

rbeezer mannequin opened this issue May 26, 2015 · 5 comments

Comments

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented May 26, 2015

When two module or vector space morphisms are added, the matrix_morphism module simply adds their matrix representations, even if the representations have wildly different bases. To wit,

S, T, R are all versions of the identity linear transformation, so S+T, S+R should just be 2I.

sage: u = vector([1,2])
sage: S = linear_transformation(QQ^2, QQ^2, [[1,0],[0,1]])
sage: T = linear_transformation(QQ^2, QQ^2, [[1,0],[0,1]])
sage: good = ((S+T)(u) == S(u) + T(u))
sage: B  = [vector([0,1]), vector([1,0])]
sage: V = (QQ^2).subspace_with_basis(B)
sage: R = T.restrict_domain(V)
sage: bad = ((S+R)(u) == S(u) + R(u))
sage: ugly = (S+R).matrix()
sage: good, bad, ugly
(
             [1 1]
True, False, [1 1]
)

CC: @toadrush @roed314

Component: linear algebra

Keywords: matrix morphism sum addition

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

@rbeezer rbeezer mannequin added this to the sage-6.8 milestone May 26, 2015
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 26, 2015

comment:1

Packaging up a fix now. The result (sum) will have the bases from self, meaning that the matrix representation of right will need to change.

@mkoeppe
Copy link
Member

mkoeppe commented May 10, 2021

comment:3

Moving to 9.4, as 9.3 has been released.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 May 10, 2021
@roed314
Copy link
Contributor

roed314 commented Aug 3, 2021

comment:5

I think the issue is that S and R don't have the same domain. We should either raise an error in this case, or compose with the coercion map V -> QQ^2.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mjungmath
Copy link

comment:8

Replying to @roed314:

I think the issue is that S and R don't have the same domain. We should either raise an error in this case, or compose with the coercion map V -> QQ^2.

The problem I see here is that there is really no preferred coercion:

sage: S = linear_transformation(QQ^2, QQ^2, [[1,0],[0,1]])
sage: T = linear_transformation(QQ^2, QQ^2, [[1,0],[0,1]])
sage: B  = [vector([0,1]), vector([1,0])]
sage: V = (QQ^2).subspace_with_basis(B)
sage: R = T.restrict_domain(V)
sage: S+R
Free module morphism defined by the matrix
[1 1]
[1 1]
Domain: Vector space of dimension 2 over Rational Field
Codomain: Vector space of dimension 2 over Rational Field
sage: R+S
Free module morphism defined by the matrix
[1 1]
[1 1]
Domain: Vector space of degree 2 and dimension 2 over Rational Field
User basis matrix:
[0 1]
[1 0]

I'd opt for an error message.

@mjungmath
Copy link

comment:9

But in any case, the coercion needs to be fixed. In fact, nothing happens to R or S when coerced.

@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 7, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
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

3 participants