Opened 23 months ago

# Tensor Arithmetics on Minimal Amount of Domains

Reported by: Owned by: gh-mjungmath major sage-9.7 manifolds egourgoulhon, tscrim, mkoeppe N/A

### Description

If I get the code correctly, operations between two tensor fields on non-parallelizable manifolds are performed as follows:

1. get common domains from the `_restrictions` dictionary,
2. perform the corresponding operation on each of those domains.

However, in most cases not all domains are necessary to fully determine the result. It is enough to find a minimal set of common domains which cover the manifold and perform the computation on those. The wanted restrictions of the result can then be computed on demand.

Allow me an example:

```sage: M = Manifold(2, 'S^2') # the 2-dimensional sphere S^2
sage: U = M.open_subset('U') # complement of the North pole
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
sage: V = M.open_subset('V') # complement of the South pole
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
sage: M.declare_union(U,V)   # S^2 is the union of U and V
sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
....:                                intersection_name='W',
....:                                restrictions1=x^2+y^2!=0,
....:                                restrictions2=u^2+v^2!=0)
sage: uv_to_xy = xy_to_uv.inverse()
sage: W = U.intersection(V)
sage: eU = c_xy.frame()
sage: eV = c_uv.frame()
sage: v = M.vector_field(name='v')
sage: v[eU,:] = [1, -2]
sage: v._restrictions
{Open subset U of the 2-dimensional differentiable manifold S^2: Vector field v on the Open subset U of the 2-dimensional differentiable manifold S^2,
Open subset W of the 2-dimensional differentiable manifold S^2: Vector field v on the Open subset W of the 2-dimensional differentiable manifold S^2,
Open subset V of the 2-dimensional differentiable manifold S^2: Vector field v on the Open subset V of the 2-dimensional differentiable manifold S^2}
```

Now, if you add `v` and another vector field defined similarly, the addition would be performed on `U`, `V` and `W`. Even though the computation on `W` is not necessary.

### comment:1 follow-up: ↓ 3 Changed 23 months ago by mkoeppe

This is an NP-hard optimization problem.

### comment:2 follow-ups: ↓ 4 ↓ 5 Changed 23 months ago by egourgoulhon

Maybe one shall introduce the concept of "top restrictions", i.e. restrictions that are not restrictions of a larger restriction on a parallelizable domain (there are already similar concepts in `TopologicalManifold._top_charts` and `DifferentiableManifold._top_frames`). Then the method `TensorField._common_subdomains()`, which is invoked by `_add_()`, could deal only with these top restrictions.

### comment:3 in reply to: ↑ 1 Changed 23 months ago by gh-mjungmath

This is an NP-hard optimization problem.

I'm sorry, I don't know what you mean. Can you explain please?

### comment:4 in reply to: ↑ 2 Changed 23 months ago by gh-mjungmath

Just for the records, I have introduced a method called `_get_min_covering` for characteristic forms and orientations (you can find it in `manifold.py`), which returns the minimal amount of objects necessary to cover the manifold. Maybe this is something we can use? I don't know how speedy it is compared to the computational cost we might save.

Last edited 23 months ago by gh-mjungmath (previous) (diff)

### comment:5 in reply to: ↑ 2 Changed 23 months ago by gh-mjungmath

Maybe one shall introduce the concept of "top restrictions", i.e. restrictions that are not restrictions of a larger restriction on a parallelizable domain (there are already similar concepts in `TopologicalManifold._top_charts` and `DifferentiableManifold._top_frames`). Then the method `TensorField._common_subdomains()`, which is invoked by `_add_()`, could deal only with these top restrictions.

This sounds like a great idea to me. I'm eager to hear what Matthias and Travis think about it.

### comment:6 Changed 22 months ago by mkoeppe

• Milestone changed from sage-9.2 to sage-9.3

### comment:7 Changed 18 months ago by mkoeppe

• Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

### comment:8 Changed 16 months ago by gh-mjungmath

Possibly related: #31740, #31703.

### comment:10 Changed 16 months ago by mkoeppe

A first step in line with #31740 could be to introduce methods `TensorField.restriction_digraph`, `.restriction_poset` etc. in analogy to `ManifoldSubset.subset_{digraph,subset}` (most recent version in #31736). A generator of the top elements of the poset then comes for free - see #31766.

### comment:11 Changed 16 months ago by gh-mjungmath

Perhaps it is a good idea to implement that behavior into sheaves (#31703) first and then wrap this over tensors and vb sections etc.

### comment:12 Changed 13 months ago by mkoeppe

• Milestone changed from sage-9.4 to sage-9.5

### comment:13 Changed 8 months ago by mkoeppe

• Milestone changed from sage-9.5 to sage-9.6

### comment:14 Changed 5 months ago by mkoeppe

• Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.