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.Sun, 04 Feb 2024 07:59:01 +0100Variable Matrices on Sagehttps://ask.sagemath.org/question/75778/variable-matrices-on-sage/I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, `R = PolynomialRing(QQ, 100, 'x'); R.gens()` is what I am trying). I create a `matrix.zero(n,n)` for reasonable `n` (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.
So I tried to provide the ring above as an argument by writing `matrix.zero(R, n,n)`, but this generated the error
`TypeError: unbound method Parent.category() needs an argument`
I have also tried using `M=MatrixSpace(R,n,n); M(L)` where `L` is a list of appropriate design. It still complains about getting non-constant polynomial entries.
How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!Sat, 03 Feb 2024 12:34:40 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/Comment by yeetcode for <p>I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, <code>R = PolynomialRing(QQ, 100, 'x'); R.gens()</code> is what I am trying). I create a <code>matrix.zero(n,n)</code> for reasonable <code>n</code> (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.</p>
<p>So I tried to provide the ring above as an argument by writing <code>matrix.zero(R, n,n)</code>, but this generated the error</p>
<p><code>TypeError: unbound method Parent.category() needs an argument</code></p>
<p>I have also tried using <code>M=MatrixSpace(R,n,n); M(L)</code> where <code>L</code> is a list of appropriate design. It still complains about getting non-constant polynomial entries.</p>
<p>How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!</p>
https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75797#post-id-75797Okay, I am not sure what happened. The command `matrix(R,n,n)` seemed to be yielding this error. But when I ran the notebook today, stuff seems to be fine. As of this moment, I am unable to recover the original code I wrote which was causing issues. There is a small chance I just did not run the appropriate cells. Apologies.Sun, 04 Feb 2024 07:59:01 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75797#post-id-75797Comment by John Palmieri for <p>I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, <code>R = PolynomialRing(QQ, 100, 'x'); R.gens()</code> is what I am trying). I create a <code>matrix.zero(n,n)</code> for reasonable <code>n</code> (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.</p>
<p>So I tried to provide the ring above as an argument by writing <code>matrix.zero(R, n,n)</code>, but this generated the error</p>
<p><code>TypeError: unbound method Parent.category() needs an argument</code></p>
<p>I have also tried using <code>M=MatrixSpace(R,n,n); M(L)</code> where <code>L</code> is a list of appropriate design. It still complains about getting non-constant polynomial entries.</p>
<p>How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!</p>
https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75791#post-id-75791You say "it complains". What command yields the complaint? The comment from @FrédéricC was intended (I believe) to address your first question: how to create a zero matrix that can be modified one entry at a time.Sat, 03 Feb 2024 21:42:43 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75791#post-id-75791Comment by yeetcode for <p>I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, <code>R = PolynomialRing(QQ, 100, 'x'); R.gens()</code> is what I am trying). I create a <code>matrix.zero(n,n)</code> for reasonable <code>n</code> (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.</p>
<p>So I tried to provide the ring above as an argument by writing <code>matrix.zero(R, n,n)</code>, but this generated the error</p>
<p><code>TypeError: unbound method Parent.category() needs an argument</code></p>
<p>I have also tried using <code>M=MatrixSpace(R,n,n); M(L)</code> where <code>L</code> is a list of appropriate design. It still complains about getting non-constant polynomial entries.</p>
<p>How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!</p>
https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75788#post-id-75788Before that, I must remark that it didn't resolve the issue. It complains about getting too many arguments. Which makes sense, because as far as I recall, `matrix()` takes in a list of lists and returns the corresponding matrix.Sat, 03 Feb 2024 19:47:33 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75788#post-id-75788Comment by Emmanuel Charpentier for <p>I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, <code>R = PolynomialRing(QQ, 100, 'x'); R.gens()</code> is what I am trying). I create a <code>matrix.zero(n,n)</code> for reasonable <code>n</code> (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.</p>
<p>So I tried to provide the ring above as an argument by writing <code>matrix.zero(R, n,n)</code>, but this generated the error</p>
<p><code>TypeError: unbound method Parent.category() needs an argument</code></p>
<p>I have also tried using <code>M=MatrixSpace(R,n,n); M(L)</code> where <code>L</code> is a list of appropriate design. It still complains about getting non-constant polynomial entries.</p>
<p>How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!</p>
https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75782#post-id-75782@FrédéricC : could you resend your comment as an answer (possibly with amplification/explanations ? This would be useful for the edification of future generations of [this site](https://ask.sagemath.org/) users ;-)...Sat, 03 Feb 2024 14:19:14 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75782#post-id-75782Comment by FrédéricC for <p>I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, <code>R = PolynomialRing(QQ, 100, 'x'); R.gens()</code> is what I am trying). I create a <code>matrix.zero(n,n)</code> for reasonable <code>n</code> (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.</p>
<p>So I tried to provide the ring above as an argument by writing <code>matrix.zero(R, n,n)</code>, but this generated the error</p>
<p><code>TypeError: unbound method Parent.category() needs an argument</code></p>
<p>I have also tried using <code>M=MatrixSpace(R,n,n); M(L)</code> where <code>L</code> is a list of appropriate design. It still complains about getting non-constant polynomial entries.</p>
<p>How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!</p>
https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75780#post-id-75780like this
sage: R = PolynomialRing(QQ, 'x', 2)
sage: matrix(R, 5, 5)
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]Sat, 03 Feb 2024 14:06:40 +0100https://ask.sagemath.org/question/75778/variable-matrices-on-sage/?comment=75780#post-id-75780