ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Aug 2018 06:29:33 -0500Convert a matrix to a list of equationshttp://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/Hi there, I have a matrix A with entries depending linearly on a number of parameters a1,...,an, and would like to solve the equation A=0. It seems I need to convert A to a list of equations of the form "entry=0" and then use solve(eqns, a1,...,an); but how do I convert A to such a list?
Any help appreciated!Wed, 29 Aug 2018 14:24:30 -0500http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/Answer by tmonteil for <p>Hi there, I have a matrix A with entries depending linearly on a number of parameters a1,...,an, and would like to solve the equation A=0. It seems I need to convert A to a list of equations of the form "entry=0" and then use solve(eqns, a1,...,an); but how do I convert A to such a list?</p>
<p>Any help appreciated!</p>
http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?answer=43521#post-id-43521Given a matrix M, say:
sage: M = matrix(ZZ, [[4, 27, -3], [-3, 2, -1], [-177, 45, 5]])
sage: M
[ 4 27 -3]
[ -3 2 -1]
[-177 45 5]
You can get its entries by doing:
sage: M.coefficients()
[4, 27, -3, -3, 2, -1, -177, 45, 5]
Wed, 29 Aug 2018 15:41:04 -0500http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?answer=43521#post-id-43521Comment by eric_g for <p>Given a matrix M, say:</p>
<pre><code>sage: M = matrix(ZZ, [[4, 27, -3], [-3, 2, -1], [-177, 45, 5]])
sage: M
[ 4 27 -3]
[ -3 2 -1]
[-177 45 5]
</code></pre>
<p>You can get its entries by doing:</p>
<pre><code>sage: M.coefficients()
[4, 27, -3, -3, 2, -1, -177, 45, 5]
</code></pre>
http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?comment=43530#post-id-43530yes, like this:
[c == 0 for c in M.coefficients()]Thu, 30 Aug 2018 06:29:33 -0500http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?comment=43530#post-id-43530Comment by matrixman for <p>Given a matrix M, say:</p>
<pre><code>sage: M = matrix(ZZ, [[4, 27, -3], [-3, 2, -1], [-177, 45, 5]])
sage: M
[ 4 27 -3]
[ -3 2 -1]
[-177 45 5]
</code></pre>
<p>You can get its entries by doing:</p>
<pre><code>sage: M.coefficients()
[4, 27, -3, -3, 2, -1, -177, 45, 5]
</code></pre>
http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?comment=43522#post-id-43522Thanks tmonteil, that's good to know! Is there also a way to convert the list of coefficients to a list of equations, setting each coefficient == 0?Wed, 29 Aug 2018 16:33:47 -0500http://ask.sagemath.org/question/43520/convert-a-matrix-to-a-list-of-equations/?comment=43522#post-id-43522