ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 06 Nov 2018 14:26:29 -0600how to get the transformation matrix for a transformation over 4x4 matrices?https://ask.sagemath.org/question/44194/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?Mon, 05 Nov 2018 14:00:31 -0600https://ask.sagemath.org/question/44194/how-to-get-the-transformation-matrix-for-a-transformation-over-4x4-matrices/Comment by eric_g for <p>I have the following transformation:</p>
<pre><code>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)
</code></pre>
<p>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?</p>
https://ask.sagemath.org/question/44194/how-to-get-the-transformation-matrix-for-a-transformation-over-4x4-matrices/?comment=44201#post-id-44201The 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`...Tue, 06 Nov 2018 06:25:30 -0600https://ask.sagemath.org/question/44194/how-to-get-the-transformation-matrix-for-a-transformation-over-4x4-matrices/?comment=44201#post-id-44201Comment by dan_fulea for <p>I have the following transformation:</p>
<pre><code>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)
</code></pre>
<p>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?</p>
https://ask.sagemath.org/question/44194/how-to-get-the-transformation-matrix-for-a-transformation-over-4x4-matrices/?comment=44210#post-id-44210Why 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 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]
Domain: Vector space of dimension 16 over Rational Field
Codomain: Vector space of dimension 16 over Rational Field
Then we can work inside the function...Tue, 06 Nov 2018 14:26:29 -0600https://ask.sagemath.org/question/44194/how-to-get-the-transformation-matrix-for-a-transformation-over-4x4-matrices/?comment=44210#post-id-44210