Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Chart._codomain_set: Add option periodic_extension, use it to constru…
Browse files Browse the repository at this point in the history
…ct the domain of the ChartInverse
  • Loading branch information
mkoeppe committed Jul 13, 2021
1 parent b76ddd7 commit c21f884
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/sage/manifolds/chart.py
Expand Up @@ -289,7 +289,7 @@ class Chart(Map, WithEqualityById, metaclass=InheritComparisonClasscallMetaclass
sage: X.valid_coordinates(i, 1)
False
A chart is a map, so it has domain::
A chart is a map, so it has domain and codomain::
sage: M = Manifold(2, 'M', structure='topological')
sage: X.<x,y> = M.chart()
Expand All @@ -299,14 +299,19 @@ class Chart(Map, WithEqualityById, metaclass=InheritComparisonClasscallMetaclass
sage: Y.<u,v> = U.chart()
sage: Y.domain()
Open subset U of the 2-dimensional topological manifold M
... and a codomain::
sage: Y.codomain()
Vector space of dimension 2 over Real Field with 53 bits of precision
sage: M = Manifold(2, 'M', field='complex', structure='topological')
sage: X.<x,y> = M.chart()
sage: X.codomain()
Vector space of dimension 2 over Complex Field with 53 bits of precision
sage: N = Manifold(2, 'N', field='complex', structure='topological')
sage: XN.<Z1,Z2> = N.chart('Z1:period=1+2*I Z2')
sage: XN.codomain()
Vector space of dimension 2 over Complex Field with 53 bits of precision
.. SEEALSO::
:class:`sage.manifolds.chart.RealChart` for charts on topological
Expand Down Expand Up @@ -407,7 +412,8 @@ def __init__(self, domain, coordinates, calc_method=None, **coordinate_options):

codomain = self._codomain_set()
Map.__init__(self, Hom(domain, codomain, cat))
self._inverse = ChartInverse(Hom(codomain, domain, inverse_cat), self)
ext_codomain = self._codomain_set(periodic_extension=True)
self._inverse = ChartInverse(Hom(ext_codomain, domain, inverse_cat), self)

#
# The chart is added to the domain's atlas, as well as to all the
Expand Down Expand Up @@ -444,7 +450,7 @@ def __init__(self, domain, coordinates, calc_method=None, **coordinate_options):
dom._zero_scalar_field._express[self] = self.function_ring().zero()
dom._one_scalar_field._express[self] = self.function_ring().one()

def _init_coordinates(self, coordinates, *, periods, coord_restrictions):
def _init_coordinates(self, coordinates, *, periods=None, coord_restrictions):
# Treatment of the coordinates:
if periods is None:
self._periods = {}
Expand Down Expand Up @@ -1040,7 +1046,7 @@ def _check_restrictions(self, restrict, substitutions):
# Case of a single condition:
return bool(restrict.subs(substitutions))

def _codomain_set(self):
def _codomain_set(self, periodic_extension=False):
r"""
Return the codomain of ``self`` as a set.
Expand All @@ -1054,6 +1060,7 @@ def _codomain_set(self):
"""
from sage.modules.free_module import VectorSpace
ambient = VectorSpace(self.manifold().base_field(), self.manifold().dimension())
# TODO: Handle complex periodic coordinates (with periodic_extension=False)
if self._restrictions:
return self._restrict_set(ambient, self._restrictions)
else:
Expand Down Expand Up @@ -2087,7 +2094,7 @@ def coord_bounds(self, i=None):
else:
return self._bounds[i-self._sindex]

def _codomain_set(self):
def _codomain_set(self, periodic_extension=False):
"""
Return the codomain of ``self`` as a set.
Expand Down Expand Up @@ -2116,10 +2123,15 @@ def _codomain_set(self):
from sage.sets.real_set import RealSet
from sage.modules.free_module import VectorSpace
from sage.categories.cartesian_product import cartesian_product
intervals = tuple(RealSet.interval(xmin, xmax,
lower_closed=(min_included == 'periodic' or min_included),
upper_closed=(max_included != 'periodic' and max_included))
for ((xmin, min_included), (xmax, max_included)) in self._bounds)
def interval_from_bounds(bounds):
((xmin, min_included), (xmax, max_included)) = bounds
if min_included == 'periodic' and periodic_extension:
return RealSet(-Infinity, Infinity)
return RealSet.interval(xmin, xmax,
lower_closed=(min_included == 'periodic' or min_included),
upper_closed=(max_included != 'periodic' and max_included))
intervals = tuple(interval_from_bounds(bounds)
for bounds in self._bounds)
if all(interval.is_universe()
for interval in intervals):
ambient = VectorSpace(self.manifold().base_field(), self.manifold().dimension())
Expand Down

0 comments on commit c21f884

Please sign in to comment.