# How to convert a list to components of a PseudoRiemannian metric

Good afternoon. I work with theoretical physics, and I build Einstein's Tensor from an extensive metric. So I decided to use list comprehension in order to make the construction of curvature tensors simpler. However, after finding the Einstein tensor, I need to work with some components separately, but I am not able to return the list in components of a PseudoRiemannian metric. Is there any possibility to do this conversion?

Thank you in advance for your attention.

edit retag close merge delete

1

Please give us some implementation details, else there is no chance to give a pointed answer. If the issue is just an issue of using a list comprehension, then please try to isolate the issue in a minimal framework, then give the related details only. Also a bigger example is welcome, but please arrange that it comes best with minimal code, possibly with simplified geometric data (making everything "flat and boring" in the physical world), if sage special libraries and/or classes and/or function are used, especially when the results are rather involved in the typed used. Best, provide some lines of code, this makes it simpler for potential answerers to react.

( 2022-05-22 19:36:40 +0200 )edit

Sort by » oldest newest most voted

I am not sure to fully understand what you are looking for (as @dan_fulea pointed out, you should provide some simple example), but could it be the operator [:]? The later can be used either to initialize the components of a tensor field from a given list or to get all the components as a list. Here is some example:

sage: M = Manifold(2, 'M', structure='Riemannian')
sage: X.<x,y> = M.chart()
sage: g = M.metric()
sage: g[:] = [[1+x^2, x*y], [x*y, 1+y^2]]  # set components to the values in the r.h.s. list
sage: g.display()
g = (x^2 + 1) dx⊗dx + x*y dx⊗dy + x*y dy⊗dx + (y^2 + 1) dy⊗dy
sage: g[:]  # returns all components as a matrix
[x^2 + 1     x*y]
[    x*y y^2 + 1]
sage: list(g[:])  # returns all components as a list
[(x^2 + 1, x*y), (x*y, y^2 + 1)]

more