Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 ?