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, 17 Sep 2013 11:11:42 +0200Generic matrixhttps://ask.sagemath.org/question/10184/generic-matrix/Does Sage provide by default a kind of generic matrix ? Maple does, for instance
matrix(2, symbol='x')
returns
a 2x2 matrix whose (i,j)-entry is the symbolic coefficient `x_{i,j}`
I can emulate a such matrix in Sage but this not very handy, for instance :
n=4
xij=var(' '.join(['x'+str(i)+'_'+str(j) for i in range(n) for j in range(n)]))
M=Matrix(SR, n, xij)
M
outputting:
[x0_0 x0_1 x0_2 x0_3]
[x1_0 x1_1 x1_2 x1_3]
[x2_0 x2_1 x2_2 x2_3]
[x3_0 x3_1 x3_2 x3_3]
Another suggestion ?
Mon, 03 Jun 2013 11:03:56 +0200https://ask.sagemath.org/question/10184/generic-matrix/Comment by Szilard SZALAY for <p>Does Sage provide by default a kind of generic matrix ? Maple does, for instance</p>
<pre><code>matrix(2, symbol='x')
</code></pre>
<p>returns </p>
<p>a 2x2 matrix whose (i,j)-entry is the symbolic coefficient <code>x_{i,j}</code></p>
<p>I can emulate a such matrix in Sage but this not very handy, for instance :</p>
<pre><code>n=4
xij=var(' '.join(['x'+str(i)+'_'+str(j) for i in range(n) for j in range(n)]))
M=Matrix(SR, n, xij)
M
</code></pre>
<p>outputting:</p>
<pre><code>[x0_0 x0_1 x0_2 x0_3]
[x1_0 x1_1 x1_2 x1_3]
[x2_0 x2_1 x2_2 x2_3]
[x3_0 x3_1 x3_2 x3_3]
</code></pre>
<p>Another suggestion ?</p>
https://ask.sagemath.org/question/10184/generic-matrix/?comment=17007#post-id-17007In maple, there is a built-in data-type for this purpose, (that is, for being an element of a symbolic matrix,) called "indexed", and it is a rather low-level thing. I'm new in python/sage, so I don't know whether it's a trouble to implement this. But that would be very very useful. Until that point, tcfisher's answer in http://ask.sagemath.org/question/152/symbolic-linear-algebra offers a workaround.Tue, 17 Sep 2013 11:11:42 +0200https://ask.sagemath.org/question/10184/generic-matrix/?comment=17007#post-id-17007Comment by kcrisman for <p>Does Sage provide by default a kind of generic matrix ? Maple does, for instance</p>
<pre><code>matrix(2, symbol='x')
</code></pre>
<p>returns </p>
<p>a 2x2 matrix whose (i,j)-entry is the symbolic coefficient <code>x_{i,j}</code></p>
<p>I can emulate a such matrix in Sage but this not very handy, for instance :</p>
<pre><code>n=4
xij=var(' '.join(['x'+str(i)+'_'+str(j) for i in range(n) for j in range(n)]))
M=Matrix(SR, n, xij)
M
</code></pre>
<p>outputting:</p>
<pre><code>[x0_0 x0_1 x0_2 x0_3]
[x1_0 x1_1 x1_2 x1_3]
[x2_0 x2_1 x2_2 x2_3]
[x3_0 x3_1 x3_2 x3_3]
</code></pre>
<p>Another suggestion ?</p>
https://ask.sagemath.org/question/10184/generic-matrix/?comment=17582#post-id-17582Though perhaps something like this could be *added* to Sage as a shortcut. We do need to decide once and for all how to do indexed variables... but this could be solved at the same time.Mon, 03 Jun 2013 11:55:12 +0200https://ask.sagemath.org/question/10184/generic-matrix/?comment=17582#post-id-17582Comment by candide for <p>Does Sage provide by default a kind of generic matrix ? Maple does, for instance</p>
<pre><code>matrix(2, symbol='x')
</code></pre>
<p>returns </p>
<p>a 2x2 matrix whose (i,j)-entry is the symbolic coefficient <code>x_{i,j}</code></p>
<p>I can emulate a such matrix in Sage but this not very handy, for instance :</p>
<pre><code>n=4
xij=var(' '.join(['x'+str(i)+'_'+str(j) for i in range(n) for j in range(n)]))
M=Matrix(SR, n, xij)
M
</code></pre>
<p>outputting:</p>
<pre><code>[x0_0 x0_1 x0_2 x0_3]
[x1_0 x1_1 x1_2 x1_3]
[x2_0 x2_1 x2_2 x2_3]
[x3_0 x3_1 x3_2 x3_3]
</code></pre>
<p>Another suggestion ?</p>
https://ask.sagemath.org/question/10184/generic-matrix/?comment=17580#post-id-17580According to the comments, I'm afraid that Sage doesn't offer any builtin feature allowing working with generic matrices without Python programming skills. From a pedagogical viewpoint this is unfortunate because generic matrices enable the learner to illustrate (or solve) easily some basic linear algebra questions such as Cayley-Hamilton theorem in low dimensions. Mon, 03 Jun 2013 13:57:07 +0200https://ask.sagemath.org/question/10184/generic-matrix/?comment=17580#post-id-17580Comment by calc314 for <p>Does Sage provide by default a kind of generic matrix ? Maple does, for instance</p>
<pre><code>matrix(2, symbol='x')
</code></pre>
<p>returns </p>
<p>a 2x2 matrix whose (i,j)-entry is the symbolic coefficient <code>x_{i,j}</code></p>
<p>I can emulate a such matrix in Sage but this not very handy, for instance :</p>
<pre><code>n=4
xij=var(' '.join(['x'+str(i)+'_'+str(j) for i in range(n) for j in range(n)]))
M=Matrix(SR, n, xij)
M
</code></pre>
<p>outputting:</p>
<pre><code>[x0_0 x0_1 x0_2 x0_3]
[x1_0 x1_1 x1_2 x1_3]
[x2_0 x2_1 x2_2 x2_3]
[x3_0 x3_1 x3_2 x3_3]
</code></pre>
<p>Another suggestion ?</p>
https://ask.sagemath.org/question/10184/generic-matrix/?comment=17583#post-id-17583Looks like this is something that you have to work around as best I can tell. See the following posts:
http://ask.sagemath.org/question/152/symbolic-linear-algebra and
http://ask.sagemath.org/question/505/symbolic-matricesMon, 03 Jun 2013 11:25:31 +0200https://ask.sagemath.org/question/10184/generic-matrix/?comment=17583#post-id-17583