Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few operations from linear symplectic geometry #35354

Merged
merged 17 commits into from
May 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/sage/tensor/modules/free_module_tensor.py
Original file line number Diff line number Diff line change
@@ -2844,6 +2844,25 @@ def contract(self, *args):
if self._tensor_rank + other._tensor_rank - 2*ncontr == 0:
# Case of scalar output:
return cmp_res
#
# Reordering of the indices to have all contravariant indices first:
#
nb_cov_s = 0 # Number of covariant indices of self not involved in the
# contraction
for pos in range(k1,k1+l1):
if pos not in pos1:
nb_cov_s += 1
nb_con_o = 0 # Number of contravariant indices of other not involved
# in the contraction
for pos in range(0,k2):
if pos not in pos2:
nb_con_o += 1
if nb_cov_s != 0 and nb_con_o != 0:
# some reordering is necessary:
p2 = k1 + l1 - ncontr
p1 = p2 - nb_cov_s
p3 = p2 + nb_con_o
cmp_res = cmp_res.swap_adjacent_indices(p1, p2, p3)
type_res = (k1+k2-ncontr, l1+l2-ncontr)
return self._fmodule.tensor_from_comp(type_res, cmp_res)