Well, if memory is really an issue, you can avoid the creation of the intermediate tensor fields uR and dR by writing
gc = g.components() igc = g.inverse().components() Rc = R.components() kr = 0 for a in M.irange(): for b in M.irange(): for c in M.irange(): for d in M.irange(): for i in M.irange(): for j in M.irange(): for k in M.irange(): for l in M.irange(): kr += gc[[a, i]]*igc[[b, j]]*igc[[c, k]]*igc [[d, l]] \ *Rc[[i, b, c, d]]*Rc[[a, j, k, l]] kr.expr() It is certainly more efficient in term of memory, but less efficient in term of CPU time, since the symmetries of the Riemann tensor are not taken into account in the above writing. Best wishes, Eric. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/9b401de7-166e-4471-9aa3-362c94cae3af%40googlegroups.com.