def __init__(self, parent, coord_expression=None, name=None, latex_name=None, is_isomorphism=False, is_identity=False): r""" Construct a curve. TESTS:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: I = R.open_interval(0, 2*pi) sage: c = Hom(I,M)({X: (cos(t), sin(2*t))}, name='c') ; c Curve c in the 2-dimensional differentiable manifold M sage: TestSuite(c).run() The identity of interval ``I``:: sage: c = Hom(I,I)({}, is_identity=True) ; c Identity map Id_(0, 2*pi) of the Real interval (0, 2*pi) sage: TestSuite(c).run() """ domain = parent.domain() codomain = parent.codomain() if coord_expression is None: coord_functions = None else: if not isinstance(coord_expression, dict): raise TypeError( "{} is not a dictionary".format(coord_expression)) param_chart = domain.canonical_chart() codom_atlas = codomain.atlas() n = codomain.manifold().dim() coord_functions = {} for chart, expr in coord_expression.items(): if isinstance(chart, tuple): # a pair of charts is passed: coord_functions[chart] = expr else: coord_functions[(param_chart, chart)] = expr DiffMap.__init__(self, parent, coord_functions=coord_functions, name=name, latex_name=latex_name, is_isomorphism=is_isomorphism, is_identity=is_identity)
def __init__(self, parent, coord_expression=None, name=None, latex_name=None, is_isomorphism=False, is_identity=False): r""" Construct a curve. TESTS:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: I = R.open_interval(0, 2*pi) sage: c = Hom(I,M)({X: (cos(t), sin(2*t))}, name='c') ; c Curve c in the 2-dimensional differentiable manifold M sage: TestSuite(c).run() The identity of interval ``I``:: sage: c = Hom(I,I)({}, is_identity=True) ; c Identity map Id_(0, 2*pi) of the Real interval (0, 2*pi) sage: TestSuite(c).run() """ domain = parent.domain() codomain = parent.codomain() if coord_expression is None: coord_functions = None else: if not isinstance(coord_expression, dict): raise TypeError("{} is not a dictionary".format( coord_expression)) param_chart = domain.canonical_chart() codom_atlas = codomain.atlas() n = codomain.manifold().dim() coord_functions = {} for chart, expr in coord_expression.items(): if isinstance(chart, tuple): # a pair of charts is passed: coord_functions[chart] = expr else: coord_functions[(param_chart, chart)] = expr DiffMap.__init__(self, parent, coord_functions=coord_functions, name=name, latex_name=latex_name, is_isomorphism=is_isomorphism, is_identity=is_identity)
def _repr_(self): r""" Return a string representation of ``self``. TESTS:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: M.curve([cos(t), sin(2*t)], (t, 0, 2*pi)) Curve in the 2-dimensional differentiable manifold M sage: M.curve([cos(t), sin(2*t)], (t, 0, 2*pi), name='c') Curve c in the 2-dimensional differentiable manifold M """ if self._codomain._dim == 1: return DiffMap._repr_(self) description = "Curve " if self._name is not None: description += self._name + " " description += "in the {}".format(self._codomain) return description
def _repr_(self): r""" Return a string representation of ``self``. TESTS:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: M.curve([cos(t), sin(2*t)], (t, 0, 2*pi)) Curve in the 2-dimensional differentiable manifold M sage: M.curve([cos(t), sin(2*t)], (t, 0, 2*pi), name='c') Curve c in the 2-dimensional differentiable manifold M """ if self._codomain._dim == 1: return DiffMap._repr_(self) description = "Curve " if self._name is not None: description += self._name + " " description += "in the {}".format(self._codomain) return description
def __call__(self, t, simplify=True): r""" Image for a given value of the curve parameter. This is a redefinition of :meth:`sage.categories.map.Map.__call__` to allow for the direct call with some value of the parameter (numerical value or symbolic expression) instead of the element (ManifoldPoint) of the domain corresponding to that value. EXAMPLES: Points on circle in the Euclidean plane:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: c = M.curve([cos(t), sin(t)], (t, 0, 2*pi), name='c') sage: c(0) Point c(0) on the 2-dimensional differentiable manifold M sage: c(0) in M True sage: c(0).coord(X) (1, 0) sage: c(pi/4).coord(X) (1/2*sqrt(2), 1/2*sqrt(2)) sage: c(t) Point c(t) on the 2-dimensional differentiable manifold M sage: c(t).coord(X) (cos(t), sin(t)) """ # Case of a point in the domain: if isinstance(t, ManifoldPoint): return DiffMap.__call__(self, t) # Case of a value of the canonical coordinate in the domain: codom = self._codomain canon_chart = self._domain._canon_chart canon_coord = canon_chart._xx[0] if (canon_chart, codom._def_chart) in self._coord_expression: chart_pair = (canon_chart, codom._def_chart) else: chart_pair = next(iter(self._coord_expression.keys())) # a chart is picked at random coord_functions = self._coord_expression[chart_pair]._functions n = codom._dim dict_subs = {canon_coord: t} coords = [coord_functions[i].expr().substitute(dict_subs) for i in range(n)] if simplify: coords = [chart_pair[0].simplify(coords[i]) for i in range(n)] if self._name is not None: name = "{}({})".format(self._name, t) else: name = None if self._latex_name is not None: latex_name = r"{}\left({}\right)".format(self._latex_name, latex(t)) else: latex_name = None return codom.element_class(codom, coords=coords, chart=chart_pair[1], name=name, latex_name=latex_name, check_coords=False)
def __call__(self, t, simplify=True): r""" Image for a given value of the curve parameter. This is a redefinition of :meth:`sage.categories.map.Map.__call__` to allow for the direct call with some value of the parameter (numerical value or symbolic expression) instead of the element (ManifoldPoint) of the domain corresponding to that value. EXAMPLES: Points on circle in the Euclidean plane:: sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: R.<t> = RealLine() sage: c = M.curve([cos(t), sin(t)], (t, 0, 2*pi), name='c') sage: c(0) Point c(0) on the 2-dimensional differentiable manifold M sage: c(0) in M True sage: c(0).coord(X) (1, 0) sage: c(pi/4).coord(X) (1/2*sqrt(2), 1/2*sqrt(2)) sage: c(t) Point c(t) on the 2-dimensional differentiable manifold M sage: c(t).coord(X) (cos(t), sin(t)) """ # Case of a point in the domain: if isinstance(t, ManifoldPoint): return DiffMap.__call__(self, t) # Case of a value of the canonical coordinate in the domain: codom = self._codomain canon_chart = self._domain._canon_chart canon_coord = canon_chart._xx[0] if (canon_chart, codom._def_chart) in self._coord_expression: chart_pair = (canon_chart, codom._def_chart) else: chart_pair = self._coord_expression.keys()[0] # a chart is picked # at random coord_functions = self._coord_expression[chart_pair]._functions n = codom._dim dict_subs = {canon_coord: t} coords = [coord_functions[i].expr().substitute(dict_subs) for i in range(n)] if simplify: coords = [simplify_chain_real(coords[i]) for i in range(n)] if self._name is not None: name = "{}({})".format(self._name, t) else: name = None if self._latex_name is not None: latex_name = r"{}\left({}\right)".format(self._latex_name, latex(t)) else: latex_name = None return codom.element_class(codom, coords=coords, chart=chart_pair[1], name=name, latex_name=latex_name, check_coords=False)