Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

""" 

Examples of manifolds 

""" 

#***************************************************************************** 

# Copyright (C) 2015 Travis Scrimshaw <tscrim at ucdavis.edu> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# http://www.gnu.org/licenses/ 

#****************************************************************************** 

 

from sage.structure.parent import Parent 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.element_wrapper import ElementWrapper 

from sage.categories.manifolds import Manifolds 

from sage.rings.all import QQ 

 

class Plane(UniqueRepresentation, Parent): 

r""" 

An example of a manifold: the `n`-dimensional plane. 

 

This class illustrates a minimal implementation of a manifold. 

 

EXAMPLES:: 

 

sage: from sage.categories.manifolds import Manifolds 

sage: M = Manifolds(QQ).example(); M 

An example of a Rational Field manifold: the 3-dimensional plane 

 

sage: M.category() 

Category of manifolds over Rational Field 

 

We conclude by running systematic tests on this manifold:: 

 

sage: TestSuite(M).run() 

""" 

 

def __init__(self, n=3, base_ring=None): 

r""" 

EXAMPLES:: 

 

sage: from sage.categories.manifolds import Manifolds 

sage: M = Manifolds(QQ).example(6); M 

An example of a Rational Field manifold: the 6-dimensional plane 

 

TESTS:: 

 

sage: TestSuite(M).run() 

""" 

self._n = n 

Parent.__init__(self, base=base_ring, category=Manifolds(base_ring)) 

 

def _repr_(self): 

r""" 

TESTS:: 

 

sage: from sage.categories.manifolds import Manifolds 

sage: Manifolds(QQ).example() 

An example of a Rational Field manifold: the 3-dimensional plane 

""" 

return "An example of a {} manifold: the {}-dimensional plane".format( 

self.base_ring(), self._n) 

 

def dimension(self): 

""" 

Return the dimension of ``self``. 

 

EXAMPLES:: 

 

sage: from sage.categories.manifolds import Manifolds 

sage: M = Manifolds(QQ).example() 

sage: M.dimension() 

3 

""" 

return self._n 

 

def an_element(self): 

r""" 

Return an element of the manifold, as per 

:meth:`Sets.ParentMethods.an_element`. 

 

EXAMPLES:: 

 

sage: from sage.categories.manifolds import Manifolds 

sage: M = Manifolds(QQ).example() 

sage: M.an_element() 

(0, 0, 0) 

""" 

zero = self.base_ring().zero() 

return self(tuple([zero]*self._n)) 

 

Element = ElementWrapper 

 

Example = Plane