Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Displaying a matrix with scalar fields

I have some scalar fields and a matrix whose elements are these scalar fields. A sample code is the following:

reset()
M=Manifold(4, 'M', r'\mathcal{M}')
BL.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
f=M.scalar_field(function('f')(*BL))
g=M.scalar_field(function('g')(*BL))
h=M.scalar_field(function('h')(*BL))
h=0
mymatrix=matrix([[f+g,g,h],[f,h,g],[h,g,f]])

f, g, or h can be zero or nonzero (according to some calculations).

When I try to display my matrix with show(mymatrix) or print(mymatrix), I see Scalar field on the 4-dimensional differentiable manifold M instead of the non-zero elements.

What should I do to display my matrix as

[f+g g 0]
[f 0 g]
[0 g f]

preferably without using loops, etc?