differential_geometry.dense_utils.dense_transform_tensor_field#

differential_geometry.dense_utils.dense_transform_tensor_field(tensor_field: ndarray, indices: List[int], tensor_signature: ndarray, jacobian: ndarray | None = None, inverse_jacobian: ndarray | None = None, out=None, **kwargs) ndarray[source]#

Apply a coordinate transformation to a tensor field based on its signature and selected indices.

This function transforms selected indices of a tensor field using the Jacobian or its inverse, depending on the variance (contravariant/covariant) of each index as specified by tensor_signature.

Parameters:
  • tensor_field (numpy.ndarray) – Tensor field of shape (…, I₁, …, I_r), where the last r axes are tensor indices.

  • indices (List[int]) – Indices to be transformed (among the last rank axes). Each must be in [0, rank).

  • tensor_signature (numpy.ndarray) – Array of +1 (contravariant) or -1 (covariant) values of shape (rank,).

  • jacobian (numpy.ndarray, optional) – Jacobian matrix ∂x_old/∂x_new with shape (…, N, N), required for transforming contravariant indices.

  • inverse_jacobian (numpy.ndarray, optional) – Inverse Jacobian ∂x_new/∂x_old with shape (…, N, N), required for covariant indices.

  • out (numpy.ndarray, optional) – Optional output array to store the result. If provided, must have the same shape and dtype as the expected output, and will be used for in-place storage.

  • **kwargs – Additional arguments passed to the underlying einsum transformation.

Returns:

The transformed tensor field.

Return type:

numpy.ndarray

Raises:

ValueError – If tensor signature or Jacobians are incompatible with input dimensions.

See also

adjust_tensor_signature, _transform_tensor_signature