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

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

""" 

Symmetric functions defined by orthogonality and triangularity. 

 

One characterization of Schur functions is that they are upper 

triangularly related to the monomial symmetric functions and 

orthogonal with respect to the Hall scalar product. We can use the 

class SymmetricFunctionAlgebra_orthotriang to obtain the Schur 

functions from this definition. 

 

:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: s([2,1])^2 

s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2] 

 

:: 

 

sage: s2 = SymmetricFunctions(QQ).s() 

sage: s2([2,1])^2 

s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2] 

""" 

from __future__ import absolute_import 

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

# Copyright (C) 2007 Mike Hansen <mhansen@gmail.com> 

# 2012 Mike Zabrocki <mike.zabrocki@gmail.com> 

# 

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

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

 

from . import sfa 

from sage.categories.morphism import SetMorphism 

from sage.categories.homset import Hom 

 

class SymmetricFunctionAlgebra_orthotriang(sfa.SymmetricFunctionAlgebra_generic): 

 

class Element(sfa.SymmetricFunctionAlgebra_generic.Element): 

pass 

 

 

def __init__(self, Sym, base, scalar, prefix, basis_name, leading_coeff=None): 

r""" 

Initialization of the symmetric function algebra defined via orthotriangular rules. 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``Sym`` -- ring of symmetric functions 

- ``base`` -- an instance of a basis of the ring of symmetric functions 

(e.g. the Schur functions) 

- ``scalar`` -- a function ``zee`` on partitions. The function 

``zee`` determines the scalar product on the power sum basis 

with normalization `\langle p_{\mu}, p_{\mu} \rangle = 

\mathrm{zee}(\mu)`. 

- ``prefix`` -- the prefix used to display the basis 

- ``basis_name`` -- the name used for the basis 

 

.. NOTE:: 

 

The base ring is required to be a `\QQ`-algebra for this 

method to be useable, since the scalar product is defined by 

its values on the power sum basis. 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur'); s 

Symmetric Functions over Rational Field in the Schur basis 

 

TESTS:: 

 

sage: TestSuite(s).run(elements = [s[1,1]+2*s[2], s[1]+3*s[1,1]]) 

sage: TestSuite(s).run(skip = ["_test_associativity", "_test_prod"]) # long time (7s on sage.math, 2011) 

 

Note: ``s.an_element()`` is of degree 4; so we skip 

``_test_associativity`` and ``_test_prod`` which involve 

(currently?) expensive calculations up to degree 12. 

""" 

self._sym = Sym 

self._sf_base = base 

self._scalar = scalar 

self._leading_coeff = leading_coeff 

sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym, prefix=prefix, basis_name=basis_name) 

 

self._self_to_base_cache = {} 

self._base_to_self_cache = {} 

self.register_coercion(SetMorphism(Hom(base, self), self._base_to_self)) 

base.register_coercion(SetMorphism(Hom(self, base), self._self_to_base)) 

 

def _base_to_self(self, x): 

""" 

Coerce a symmetric function in base ``x`` into ``self``. 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``x`` -- an element of the basis `base` to which ``self`` is triangularly related 

 

OUTPUT: 

 

- an element of ``self`` equivalent to ``x`` 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: s._base_to_self(m([2,1])) 

-2*s[1, 1, 1] + s[2, 1] 

""" 

return self._from_cache(x, self._base_cache, self._base_to_self_cache) 

 

def _self_to_base(self, x): 

""" 

Coerce a symmetric function in ``self`` into base ``x``. 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``x`` -- an element of ``self`` as a basis of the ring of symmetric functions. 

 

OUTPUT: 

 

- the element ``x`` expressed in the basis to which ``self`` is triangularly related 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: s._self_to_base(s([2,1])) 

2*m[1, 1, 1] + m[2, 1] 

""" 

return self._sf_base._from_cache(x, self._base_cache, self._self_to_base_cache) 

 

def _base_cache(self, n): 

""" 

Computes the change of basis between ``self`` and base for the 

homogeneous component of size ``n`` 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``n`` -- a nonnegative integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: s._base_cache(2) 

sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())] 

sage: l(s._base_to_self_cache[2]) 

[([1, 1], [([1, 1], 1)]), ([2], [([1, 1], -1), ([2], 1)])] 

sage: l(s._self_to_base_cache[2]) 

[([1, 1], [([1, 1], 1)]), ([2], [([1, 1], 1), ([2], 1)])] 

""" 

if n in self._self_to_base_cache: 

return 

else: 

self._self_to_base_cache[n] = {} 

 

self._gram_schmidt(n, self._sf_base, self._scalar, self._self_to_base_cache,\ 

leading_coeff=self._leading_coeff, upper_triangular=True) 

self._invert_morphism(n, self.base_ring(), self._self_to_base_cache, \ 

self._base_to_self_cache, to_other_function = self._to_base) 

 

def _to_base(self, part): 

""" 

Returns a function which takes in a partition `\mu` and returns the 

coefficient of a partition in the expansion of ``self`` `(part)` in base. 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``part`` -- a partition 

 

.. note:: 

 

We assume that self._gram_schmidt has been called before 

self._to_base is called. 

 

OUTPUT: 

 

- a function which accepts a partition ``mu`` and returns the coefficients 

in the expansion of ``self(part)`` in the triangularly related basis. 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: m(s([2,1])) 

2*m[1, 1, 1] + m[2, 1] 

sage: f = s._to_base(Partition([2,1])) 

sage: [f(p) for p in Partitions(3)] 

[0, 1, 2] 

""" 

f = lambda mu: self._self_to_base_cache[part].get(mu, 0) 

return f 

 

def _multiply(self, left, right): 

""" 

Returns ``left`` * ``right`` by converting both to the base and then 

converting back to ``self``. 

 

INPUT: 

 

- ``self`` -- a basis determined by an orthotriangular definition 

- ``left``, ``right`` -- elements in ``self`` 

 

OUTPUT: 

 

- the expansion of the product of ``left`` and ``right`` in the basis ``self``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.sf.sfa import zee 

sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang 

sage: Sym = SymmetricFunctions(QQ) 

sage: m = Sym.m() 

sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions') 

sage: s([1])*s([2,1]) #indirect doctest 

s[2, 1, 1] + s[2, 2] + s[3, 1] 

""" 

return self( self._sf_base(left)*self._sf_base(right) ) 

 

# Backward compatibility for unpickling 

from sage.structure.sage_object import register_unpickle_override 

register_unpickle_override('sage.combinat.sf.orthotriang', 'SymmetricFunctionAlgebraElement_orthotriang', SymmetricFunctionAlgebra_orthotriang.Element)