Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to define multiple objects with a for loop?

While this question can be answered in greater generality, I'm specifically writing a program in which I need to systematically define and label a bunch of differential forms.
Suppose I have the set up

M = manifold(2, 'M')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
eU = c_xy.frame()

Now I want to have a bunch of differential forms indexed by 2 numbers (as they will be going into a matrix).
Instead of writing them all out by hand as

a_00 = M.diff_form(1, name='a_00')
a_01 = M.diff_form(1, name='a_01')
a_33 = M.diff_form(1, name='a_33')

Is there any way I can write a for loop to build these for me? I've seen a similar question asked here: but I'm not sure how to extend to the 2-index case. Also, the linked example works for symbols, but I don't know if this can be made to work for defining a list of objects like differential forms.