Opened 4 years ago

Closed 4 years ago

# More functionalities for bases of free modules and vector frames

Reported by: Owned by: egourgoulhon major sage-8.2 geometry basis, vector frame, manifold, free moduie tscrim Eric Gourgoulhon Travis Scrimshaw N/A da06d12 da06d12a8e041c9ee6c5f4c12a906d22bcdb02c7

This ticket provides more flexibility in the choice of symbols and indices for bases of free modules of finite rank and, consequently, for vector frames on manifolds. In particular, the labels of the basis elements are no longer necessarily integers and can be customized, for instance:

```sage: M = Manifold(3, 'M')
sage: e = M.vector_frame('e', indices=('x', 'y', 'z')); e
Vector frame (M, (e_x,e_y,e_z))
```

The symbol of each element of the basis can also be freely chosen, by providing a tuple of symbols instead of a single string; it is then mandatory to specify as well some symbols for the dual coframe:

```sage: e = M.vector_frame(('a', 'b', 'c'), symbol_dual=('A', 'B', 'C')); e
Vector frame (M, (a,b,c))
sage: e[0]
Vector field a on the 3-dimensional differentiable manifold M
sage: e.coframe()
Coframe (M, (A,B,C))
sage: e.coframe()[0]
1-form A on the 3-dimensional differentiable manifold M
```

Besides, the slice operator is introduced for bases; it is now possible to write

```sage: e[:]
(Vector field a on the 3-dimensional differentiable manifold M,
Vector field b on the 3-dimensional differentiable manifold M,
Vector field c on the 3-dimensional differentiable manifold M)
```

Internally, some refactoring of code has been performed. In particular, by renaming the `FreeModuleCoBasis`'s attribute `_form` (the tuple containing the cobasis elements) to `_vec`, so that it matches the name of the `FreeModuleBasis`'s attribute storing the basis elements, it has been possible to factor the method ` __getitem__` to the ABC `Basis_abstract`. Another improvement is getting rid of all methods `_init_dual_basis` in classes `FreeModuleBasis`, `VectorFrame` and `CoordFrame` thanks to the introduction of the class attribute `_cobasis_class`.

The functionalities introduced here provide a better user interface for #24623.

This work is part of the SageManifolds project, see #18528 for an overview.

### comment:1 Changed 4 years ago by egourgoulhon

• Branch set to public/manifolds/more_basis_flexibility
• Commit set to 01681b8f3f739e56962f1ae215a098e706a67ee7

New commits:

 ​a527e8e `First draft adding more flexibility in symbols of free module bases and vector frames` ​2d43a23 `More refactoring in vector frames` ​0840d54 `More work on vector frames` ​01681b8 `Add documentation for new options of vector frames`

### comment:2 Changed 4 years ago by egourgoulhon

• Status changed from new to needs_review

### comment:3 Changed 4 years ago by egourgoulhon

• Description modified (diff)

### comment:4 Changed 4 years ago by git

• Commit changed from 01681b8f3f739e56962f1ae215a098e706a67ee7 to 9ddc467fbfa0e1cad1410ce6ed37eba05f55c4c9

Branch pushed to git repo; I updated commit sha1. New commits:

 ​9ddc467 `Add method set_name to classes VectorFrame and CoFrame`

### comment:5 Changed 4 years ago by git

• Commit changed from 9ddc467fbfa0e1cad1410ce6ed37eba05f55c4c9 to 82c37b47ba34368a83dd7e873275a361bb0338f6

Branch pushed to git repo; I updated commit sha1. New commits:

 ​82c37b4 `Cut long lines in src/sage/manifolds/differentiable/vectorframe.py`

### comment:6 Changed 4 years ago by egourgoulhon

The above two commits add the method `set_name` to `VectorFrame` and `CoFrame` for even more flexibility (previously `set_name` was inherited from `Basis_abstract` and could not handle the domain name). This is required for #24623.

### comment:7 follow-up: ↓ 9 Changed 4 years ago by tscrim

Looks good overall. However, I do have one comment:

`VectorFrame` should process its arguments to ensure its unique representation, so this addition should not be needed (except the last bit of course):

```         """
from sage.manifolds.differentiable.vectorframe import VectorFrame
+        # Only tuples are valid entries for the unique representation of
+        # VectorFrame:
+        if isinstance(symbol, list):
+            symbol = tuple(symbol)
+        if isinstance(latex_symbol, list):
+            latex_symbol = tuple(latex_symbol)
+        if isinstance(indices, list):
+            indices = tuple(indices)
+        if isinstance(latex_indices, list):
+            latex_indices = tuple(latex_indices)
+        if isinstance(symbol_dual, list):
+            symbol_dual = tuple(symbol_dual)
+        if isinstance(latex_symbol_dual, list):
+            latex_symbol_dual = tuple(latex_symbol_dual)
return VectorFrame(self.vector_field_module(dest_map=dest_map,
force_free=True),
symbol=symbol, latex_symbol=latex_symbol,
-                           from_frame=from_frame)
+                           from_frame=from_frame, indices=indices,
+                           latex_indices=latex_indices, symbol_dual=symbol_dual,
+                           latex_symbol_dual=latex_symbol_dual)

def _set_covering_frame(self, frame):
r"""
```

This probably means you need to implement a `__classcall_private__`/`__classcall__` for that class. Note that `__classcall__` is inherited, so you could define it in a base class.

### comment:8 Changed 4 years ago by git

• Commit changed from 82c37b47ba34368a83dd7e873275a361bb0338f6 to 799066b8d4efd379fe374f1570abae6aad73a724

Branch pushed to git repo; I updated commit sha1. New commits:

 ​799066b `List entries of VectorFrame processed by __classcall_private__`

### comment:9 in reply to: ↑ 7 Changed 4 years ago by egourgoulhon

Thank you very much for looking into this and for your comments.

`VectorFrame` should process its arguments to ensure its unique representation, so this addition should not be needed (except the last bit of course): This probably means you need to implement a `__classcall_private__`/`__classcall__` for that class.

Thanks for the suggestion; this is done via `__classcall_private__` in the above commit.

### comment:10 Changed 4 years ago by git

• Commit changed from 799066b8d4efd379fe374f1570abae6aad73a724 to da06d12a8e041c9ee6c5f4c12a906d22bcdb02c7

Branch pushed to git repo; I updated commit sha1. New commits:

 ​da06d12 `Small improvement in treatment of symbol attributes of free module bases`

### comment:11 Changed 4 years ago by egourgoulhon

While working on #24623, I've noticed some issues regarding the naming of tangent space bases induced by vector frames. The above commit fixes this. It also remove unnecessary pieces of code in `FreeModuleBasis.__init__` and `FreeModuleBasis._new_instance`.

Version 0, edited 4 years ago by egourgoulhon (next)

### comment:12 follow-up: ↓ 13 Changed 4 years ago by tscrim

• Reviewers set to Travis Scrimshaw
• Status changed from needs_review to positive_review

LGTM. Thank you.

### comment:13 in reply to: ↑ 12 Changed 4 years ago by egourgoulhon

Thank you for the review!

### comment:14 Changed 4 years ago by vbraun

• Branch changed from public/manifolds/more_basis_flexibility to da06d12a8e041c9ee6c5f4c12a906d22bcdb02c7
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.