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

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

r""" 

Super modules with basis 

""" 

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

# 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.categories.super_modules import SuperModulesCategory 

 

class SuperModulesWithBasis(SuperModulesCategory): 

""" 

The category of super modules with a distinguished basis. 

 

An `R`-*super module with a distinguished basis* is an 

`R`-super module equipped with an `R`-module basis whose elements are 

homogeneous. 

 

EXAMPLES:: 

 

sage: C = GradedModulesWithBasis(ZZ); C 

Category of graded modules with basis over Integer Ring 

sage: sorted(C.super_categories(), key=str) 

[Category of filtered modules with basis over Integer Ring, 

Category of graded modules over Integer Ring] 

sage: C is ModulesWithBasis(ZZ).Graded() 

True 

 

TESTS:: 

 

sage: TestSuite(C).run() 

""" 

class ParentMethods: 

def _even_odd_on_basis(self, m): 

""" 

Return the parity of the basis element indexed by ``m``. 

 

OUTPUT: 

 

``0`` if ``m`` is for an even element or ``1`` if ``m`` 

is for an odd element. 

 

.. NOTE:: 

 

The default implementation assumes that the even/odd is 

determined by the parity of :meth:`degree`. 

 

Overwrite this method if the even/odd behavior is desired 

to be independent. 

 

EXAMPLES:: 

 

sage: Q = QuadraticForm(QQ, 2, [1,2,3]) 

sage: C.<x,y> = CliffordAlgebra(Q) 

sage: C._even_odd_on_basis((0,)) 

1 

sage: C._even_odd_on_basis((0,1)) 

0 

""" 

return self.degree_on_basis(m) % 2 

 

class ElementMethods: 

def is_super_homogeneous(self): 

r""" 

Return whether this element is homogeneous, in the sense 

of a super module (i.e., is even or odd). 

 

EXAMPLES:: 

 

sage: Q = QuadraticForm(QQ, 2, [1,2,3]) 

sage: C.<x,y> = CliffordAlgebra(Q) 

sage: a = x + y 

sage: a.is_super_homogeneous() 

True 

sage: a = x*y + 4 

sage: a.is_super_homogeneous() 

True 

sage: a = x*y + x - 3*y + 4 

sage: a.is_super_homogeneous() 

False 

 

The exterior algebra has a `\ZZ` grading, which induces the 

`\ZZ / 2\ZZ` grading. However the definition of homogeneous 

elements differs because of the different gradings:: 

 

sage: E.<x,y> = ExteriorAlgebra(QQ) 

sage: a = x*y + 4 

sage: a.is_super_homogeneous() 

True 

sage: a.is_homogeneous() 

False 

""" 

even_odd = self.parent()._even_odd_on_basis 

degree = None 

for m in self.support(): 

if degree is None: 

degree = even_odd(m) 

else: 

if degree != even_odd(m): 

return False 

return True 

 

def is_even_odd(self): 

""" 

Return ``0`` if ``self`` is an even element and ``1`` if 

``self`` is an odd element. 

 

EXAMPLES:: 

 

sage: Q = QuadraticForm(QQ, 2, [1,2,3]) 

sage: C.<x,y> = CliffordAlgebra(Q) 

sage: a = x + y 

sage: a.is_even_odd() 

1 

sage: a = x*y + 4 

sage: a.is_even_odd() 

0 

sage: a = x + 4 

sage: a.is_even_odd() 

Traceback (most recent call last): 

... 

ValueError: element is not homogeneous 

 

sage: E.<x,y> = ExteriorAlgebra(QQ) 

sage: (x*y).is_even_odd() 

0 

""" 

if not self.support(): 

raise ValueError("the zero element does not have a well-defined degree") 

if not self.is_super_homogeneous(): 

raise ValueError("element is not homogeneous") 

return self.parent()._even_odd_on_basis(self.leading_support()) 

 

def even_component(self): 

""" 

Return the even component of ``self``. 

 

EXAMPLES:: 

 

sage: Q = QuadraticForm(QQ, 2, [1,2,3]) 

sage: C.<x,y> = CliffordAlgebra(Q) 

sage: a = x*y + x - 3*y + 4 

sage: a.even_component() 

x*y + 4 

 

TESTS: 

 

Check that this really return ``A.zero()`` and not a plain ``0``:: 

 

sage: a = x + y 

sage: a.even_component().parent() is C 

True 

""" 

even_odd = self.parent()._even_odd_on_basis 

return self.parent().sum_of_terms((i, c) 

for (i, c) in self 

if even_odd(i) == 0) 

 

def odd_component(self): 

""" 

Return the odd component of ``self``. 

 

EXAMPLES:: 

 

sage: Q = QuadraticForm(QQ, 2, [1,2,3]) 

sage: C.<x,y> = CliffordAlgebra(Q) 

sage: a = x*y + x - 3*y + 4 

sage: a.odd_component() 

x - 3*y 

 

TESTS: 

 

Check that this really return ``A.zero()`` and not a plain ``0``:: 

 

sage: a = x*y 

sage: a.odd_component().parent() is C 

True 

""" 

even_odd = self.parent()._even_odd_on_basis 

return self.parent().sum_of_terms((i, c) 

for (i, c) in self 

if even_odd(i) == 1)