Metric Spaces

class sage.categories.metric_spaces.MetricSpaces(category, *args)

Bases: sage.categories.metric_spaces.MetricSpacesCategory

The category of metric spaces.

A metric on a set \(S\) is a function \(d : S \times S \to \RR\) such that:

  • \(d(a, b) \geq 0\),
  • \(d(a, b) = 0\) if and only if \(a = b\).

A metric space is a set \(S\) with a distinguished metric.

Implementation

Objects in this category must implement either a dist on the parent or the elements or metric on the parent; otherwise this will cause an infinite recursion.

Todo

  • Implement a general geodesics class.
  • Implement a category for metric additive groups and move the generic distance \(d(a, b) = |a - b|\) there.
  • Incorperate the length of a geodesic as part of the default distance cycle.

EXAMPLES:

sage: from sage.categories.metric_spaces import MetricSpaces
sage: C = MetricSpaces()
sage: C
Category of metric spaces
sage: TestSuite(C).run()
class Complete(base_category)

Bases: sage.categories.category_with_axiom.CategoryWithAxiom

The category of complete metric spaces.

class MetricSpaces.ElementMethods
abs()

Return the absolute value of self.

EXAMPLES:

sage: CC(I).abs()
1.00000000000000
dist(b)

Return the distance between self and other.

EXAMPLES:

sage: UHP = HyperbolicPlane().UHP()
sage: p1 = UHP.get_point(5 + 7*I)
sage: p2 = UHP.get_point(1 + I)
sage: p1.dist(p2)
arccosh(33/7)
class MetricSpaces.ParentMethods
dist(a, b)

Return the distance between a and b in self.

EXAMPLES:

sage: UHP = HyperbolicPlane().UHP()
sage: p1 = UHP.get_point(5 + 7*I)
sage: p2 = UHP.get_point(1.0 + I)
sage: UHP.dist(p1, p2)
2.23230104635820

sage: PD = HyperbolicPlane().PD()
sage: PD.dist(PD.get_point(0), PD.get_point(I/2))
arccosh(5/3)

TESTS:

sage: RR.dist(-1, pi)
4.14159265358979
sage: RDF.dist(1, -1/2)
1.5
sage: CC.dist(3, 2)
1.00000000000000
sage: CC.dist(-1, I)
1.41421356237310
sage: CDF.dist(-1, I)
1.4142135623730951
metric()

Return the metric of self.

EXAMPLES:

sage: UHP = HyperbolicPlane().UHP()
sage: m = UHP.metric()
sage: p1 = UHP.get_point(5 + 7*I)
sage: p2 = UHP.get_point(1.0 + I)
sage: m(p1, p2)
2.23230104635820
class MetricSpaces.SubcategoryMethods
Complete()

Return the full subcategory of the complete objects of self.

EXAMPLES:

sage: Sets().Metric().Complete()
Category of complete metric spaces

TESTS:

sage: TestSuite(Sets().Metric().Complete()).run()
sage: Sets().Metric().Complete.__module__
'sage.categories.metric_spaces'
class MetricSpaces.WithRealizations(category, *args)

Bases: sage.categories.with_realizations.WithRealizationsCategory

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
....:     _functor_category = "FooBars"
....:     _base_category_class = (Category,)
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
class ParentMethods
dist(a, b)

Return the distance between a and b by converting them to a realization of self and doing the computation.

EXAMPLES:

sage: H = HyperbolicPlane()
sage: PD = H.PD()
sage: p1 = PD.get_point(0)
sage: p2 = PD.get_point(I/2)
sage: H.dist(p1, p2)
arccosh(5/3)
class sage.categories.metric_spaces.MetricSpacesCategory(category, *args)

Bases: sage.categories.covariant_functorial_construction.RegressiveCovariantConstructionCategory

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
....:     _functor_category = "FooBars"
....:     _base_category_class = (Category,)
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
classmethod default_super_categories(category)

Return the default super categories of category.Metric().

Mathematical meaning: if \(A\) is a metric space in the category \(C\), then \(A\) is also a topological space.

INPUT:

  • cls – the class MetricSpaces
  • category – a category \(Cat\)

OUTPUT:

A (join) category

In practice, this returns category.Metric(), joined together with the result of the method RegressiveCovariantConstructionCategory.default_super_categories() (that is the join of category and cat.Metric() for each cat in the super categories of category).

EXAMPLES:

Consider category=Groups(). Then, a group \(G\) with a metric is simultaneously a topological group by itself, and a metric space:

sage: Groups().Metric().super_categories()
[Category of topological groups, Category of metric spaces]

This resulted from the following call:

sage: sage.categories.metric_spaces.MetricSpacesCategory.default_super_categories(Groups())
Join of Category of topological groups and Category of metric spaces