batched_vdot¶
- torch_sim.math.batched_vdot(x, y, batch_indices, *, n_systems=None)[source]¶
Computes batched vdot (sum of element-wise product) for groups of vectors.
- Parameters:
x (Tensor) – Tensor of shape [N_total_entities, D] (e.g., forces, velocities).
y (Tensor) – Tensor of shape [N_total_entities, D].
batch_indices (Tensor) – Tensor of shape [N_total_entities] indicating batch membership.
n_systems (int | None) – Known output size. When provided, batch_indices are assumed to lie in [0, n_systems), avoiding scalar validation and size inference that synchronize CUDA tensors with the CPU.
- Returns:
shape [n_systems] where each element is the sum(x_i * y_i)
- Return type:
Tensor
- for entities belonging to that batch,
summed over all components D and all entities in the batch.