Ask Your Question
1

Cannot transpose the matrix with x.transpose()

asked 2024-10-13 17:01:12 +0100

zizzelzi gravatar image

Helllo, im having a probles with matrixes that i do during my studies, i try to transpose the matrixes but it gives me the error

``` AttributeError Traceback (most recent call last) Cell In[17], line 1 ----> 1 A.transpose()

AttributeError: 'NoneType' object has no attribute 'transpose' ```

an the said matrix looks like that A = matrix(2,3,[8,-2,3,5,1,-4])

edit retag flag offensive close merge delete

Comments

Please provide more context, like any lines that might have (re)defined A. If I run consecutive commands A = matrix(2,3,[8,-2,3,5,1,-4]) and A.transpose(), it works as expected.

John Palmieri gravatar imageJohn Palmieri ( 2024-10-13 19:09:22 +0100 )edit
1

NoneType suggests that A was redefined as None at certain point.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-13 20:59:45 +0100 )edit
1

Right, perhaps by a command like A = A.swap_columns(0,2). That's why I am asking for more information.

John Palmieri gravatar imageJohn Palmieri ( 2024-10-13 23:02:41 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2024-10-15 12:13:04 +0100

Sébastien gravatar image

updated 2024-10-15 12:13:22 +0100

I don't understand the error either, but this is what one may do:

sage: A = matrix(2,3,[8,-2,3,5,1,-4])
sage: A
[ 8 -2  3]
[ 5  1 -4]
sage: A.transpose()
[ 8  5]
[-2  1]
[ 3 -4]

Notice also the shortcut:

sage: A.T
[ 8  5]
[-2  1]
[ 3 -4]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2024-10-13 17:01:12 +0100

Seen: 162 times

Last updated: Oct 15