# how to get the transformation matrix for a transformation over 4x4 matrices?

I have the following transformation:

M = MatrixSpace(QQ,4,4)
def f(m):
return matrix([
[m[0][0], m[0][1], m[0][2], m[0][3]],
[m[1][3], m[1][0], m[1][1], m[1][2]],
[m[2][2], m[2][3], m[2][0], m[2][1]],
[m[3][1], m[3][2], m[3][3], m[3][0]]
])
print linear_transformation(M, M, f)


This is not working - but I can't figure out what linear_transformation is expecting. How can I get this to work? Is this even possible?

edit retag close merge delete

1

The error message

TypeError: first argument must be a matrix or a vector space, not Full MatrixSpace of 4 by 4 dense matrices over Rational Field


is triggered by

sage: from sage.modules.module import is_VectorSpace
sage: is_VectorSpace(M)
False


which is quite weird, because M is indeed a vector space and moreover Sage recognizes it as such:

sage: M in VectorSpaces(QQ)
True
sage: dim(M)
16


So I would say it is a bug in linear_transformation...

( 2018-11-06 06:25:30 -0600 )edit
1

Why not explicitly using vector spaces, as in the doc string of the method? For instance:

sage: M = QQ^16
sage: L = linear_transformation( M, M, lambda A: A )
sage: L
Vector space morphism represented by the matrix:
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]

::: many other lines

[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 1 ...
(more)
( 2018-11-06 14:26:29 -0600 )edit