ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 12 Dec 2023 04:44:12 +0100How to rearrange matrix entries from another matrix entrieshttps://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/Suppose i have $m\times m$ matrix $D$ which is known, i have to re arrange entries of $D$ to a new $m\times m$ matrix $M$ such that $M_{i,j}=D_{j-i%m, -i%m}$. How to do it in SageMath?Mon, 11 Dec 2023 10:10:11 +0100https://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/Answer by rburing for <p>Suppose i have $m\times m$ matrix $D$ which is known, i have to re arrange entries of $D$ to a new $m\times m$ matrix $M$ such that $M_{i,j}=D_{j-i%m, -i%m}$. How to do it in SageMath?</p>
https://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/?answer=74786#post-id-74786 sage: D = matrix(QQ, 2, [[1, 2], [3, 4]]); D
[1 2]
[3 4]
sage: m = D.nrows()
sage: M = matrix(QQ, m, lambda i, j: D[(j-i)%m, (-i)%m]); M
[1 3]
[4 2]Mon, 11 Dec 2023 14:03:32 +0100https://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/?answer=74786#post-id-74786Comment by Akhilesh for <pre><code>sage: D = matrix(QQ, 2, [[1, 2], [3, 4]]); D
[1 2]
[3 4]
sage: m = D.nrows()
sage: M = matrix(QQ, m, lambda i, j: D[(j-i)%m, (-i)%m]); M
[1 3]
[4 2]
</code></pre>
https://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/?comment=74799#post-id-74799It worked. Thanks for the helpTue, 12 Dec 2023 04:44:12 +0100https://ask.sagemath.org/question/74780/how-to-rearrange-matrix-entries-from-another-matrix-entries/?comment=74799#post-id-74799