def metric_to_Ricci_components(expr):
 riemann = metric_to_Riemann_components(expr)
 coord_sys = expr.atoms(CoordSystem).pop()
 indices = list(range(coord_sys.dim))
 ricci = [[Add(*[riemann[(k, i, k, j)] for k in indices]) for j in indices] for i in indices]
 return ImmutableDenseNDimArray(ricci)

def metric_to_Ricci_components ( expr ) : riemann = metric_to_Riemann_components ( expr ) coord_sys = expr . atoms ( CoordSystem ) . pop ( ) indices = list ( range ( coord_sys . dim ) ) ricci = [ [ Add ( * [ riemann [ ( k , i , k , j ) ] for k in indices ] ) for j in indices ] for i in indices ] return ImmutableDenseNDimArray ( ricci )
return the components of the ricci tensor expressed in a given basis .