You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A 4D tensor can have index configuration ulll, and can be changed to lulu with the help of a metric tensor, here u denotes contravariant index and l denotes covariant index.
Reproducing code example:
importnumpyasnpT=np.zeros(shape=(4,4,4,4), dtype=float)
# substitute some values in TM=np.zeros(shape=(4,4), dtype=float)
# substitute some values in M(Metric Tensor)T_=np.change_config(T, metric=M, old='ulll', new='lulu')
print(T_)
# Example snippet
The text was updated successfully, but these errors were encountered:
Yes moveaxis is required, and it also requires tensorproduct and tensorcontraction which is provided einsum in np, I guess. I couldn't understand the @ metric thing. Sorry for the trouble!
@ here is matrix multiplication, which I believe that when combined with moveaxis, subsumes contraction and product for the cases that matter here - assuming that a metric tensor is always 2D, which your links seem to suggest is so.
I'm not sure this is a good fit for numpy - on the one hand, we don't really have a true concept of tensors - but on the other, we do provide einsum and tensordot...
Indices raising and lowering are a very crucial part of differential geometry and particularly important in relativistic physics.
See https://en.wikipedia.org/wiki/Raising_and_lowering_indices
Example :
ulll
, and can be changed tolulu
with the help of a metric tensor, hereu
denotes contravariant index andl
denotes covariant index.Reproducing code example:
The text was updated successfully, but these errors were encountered: