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

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

cdef extern from 'symmetrica/def.h': 

INT mult_schubert_schubert(OP a, OP b, OP result) 

INT m_perm_sch(OP a, OP b) 

INT t_SCHUBERT_POLYNOM(OP a, OP b) 

INT t_POLYNOM_SCHUBERT(OP a, OP b) 

INT mult_schubert_variable(OP a, OP i, OP r) 

INT divdiff_perm_schubert(OP perm, OP sb, OP res) 

INT scalarproduct_schubert(OP a, OP b, OP c) 

INT divdiff_schubert(OP a, OP schub, OP res) 

  

INT t_2SCHUBERT_POLYNOM(OP a,OP b) 

INT mult_schubert_polynom(OP a,OP b,OP c) 

  

  

  

  

cdef object _check_schubert(object a, OP ca): 

if a in Permutations(): 

if isinstance(a, builtinlist): 

a = Permutation(a) 

_op_schubert_perm(a, ca) 

return max(a.reduced_word()+[0]) 

elif isinstance(a, SchubertPolynomial_class): 

br = a.parent().base_ring() 

if (br == QQ or br == ZZ): 

_op_schubert_sp(a, ca) 

return min([max(i.reduced_word()+[0]) for i in a.support()]) 

else: 

raise ValueError("a must be a Schubert polynomial over ZZ or QQ") 

else: 

raise TypeError("a must be a permutation or a Schubert polynomial") 

  

  

def mult_schubert_schubert_symmetrica(a, b): 

""" 

Multiplies the Schubert polynomials a and b. 

  

EXAMPLES: 

sage: symmetrica.mult_schubert_schubert([3,2,1], [3,2,1]) 

X[5, 3, 1, 2, 4] 

""" 

late_import() 

  

cdef OP ca = callocobject(), cb = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

max_b = _check_schubert(b, cb) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(cb); freeall(cres) 

raise err 

  

  

sig_on() 

mult_schubert_schubert(ca, cb, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca) 

freeall(cb) 

freeall(cres) 

  

return res 

  

def t_SCHUBERT_POLYNOM_symmetrica(a): 

""" 

Converts a Schubert polynomial to a 'regular' multivariate 

polynomial. 

  

EXAMPLES: 

sage: symmetrica.t_SCHUBERT_POLYNOM([3,2,1]) 

x0^2*x1 

""" 

late_import() 

  

cdef OP ca = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(cres) 

raise err 

  

sig_on() 

t_SCHUBERT_POLYNOM(ca, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca) 

freeall(cres) 

  

return res 

  

def t_POLYNOM_SCHUBERT_symmetrica(a): 

""" 

Converts a multivariate polynomial a to a Schubert polynomial. 

  

EXAMPLES: 

sage: R.<x1,x2,x3> = QQ[] 

sage: w0 = x1^2*x2 

sage: symmetrica.t_POLYNOM_SCHUBERT(w0) 

X[3, 2, 1] 

""" 

late_import() 

  

cdef OP ca = callocobject(), cres = callocobject() 

  

if not is_MPolynomial(a): 

freeall(ca); freeall(cres) 

raise TypeError("a (= %s) must be a multivariate polynomial") 

else: 

br = a.parent().base_ring() 

if br != QQ and br != ZZ: 

freeall(ca); freeall(cres) 

raise ValueError("a's base ring must be either ZZ or QQ") 

else: 

_op_polynom(a, ca) 

  

sig_on() 

t_POLYNOM_SCHUBERT(ca, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca) 

freeall(cres) 

  

return res 

  

def mult_schubert_variable_symmetrica(a, i): 

""" 

Returns the product of a and x_i. Note that indexing with i 

starts at 1. 

  

EXAMPLES: 

sage: symmetrica.mult_schubert_variable([3,2,1], 2) 

X[3, 2, 4, 1] 

sage: symmetrica.mult_schubert_variable([3,2,1], 4) 

X[3, 2, 1, 4, 6, 5] - X[3, 2, 1, 5, 4] 

""" 

late_import() 

  

cdef OP ca = callocobject(), ci = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(ci); freeall(cres) 

raise err 

  

_op_integer(i, ci) 

  

sig_on() 

mult_schubert_variable(ca, ci, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca); freeall(ci); freeall(cres) 

  

return res 

  

  

def divdiff_perm_schubert_symmetrica(perm, a): 

r""" 

Returns the result of applying the divided difference operator 

$\delta_i$ to $a$ where $a$ is either a permutation or a 

Schubert polynomial over QQ. 

  

EXAMPLES: 

sage: symmetrica.divdiff_perm_schubert([2,3,1], [3,2,1]) 

X[2, 1] 

sage: symmetrica.divdiff_perm_schubert([3,1,2], [3,2,1]) 

X[1, 3, 2] 

sage: symmetrica.divdiff_perm_schubert([3,2,4,1], [3,2,1]) 

Traceback (most recent call last): 

... 

ValueError: cannot apply \delta_{[3, 2, 4, 1]} to a (= [3, 2, 1]) 

""" 

late_import() 

  

cdef OP ca = callocobject(), cperm = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(cperm); freeall(cres) 

raise err 

  

if perm not in Permutations(): 

freeall(ca); freeall(cperm); freeall(cres) 

raise TypeError("perm must be a permutation") 

else: 

perm = Permutation(perm) 

rw = perm.reduced_word() 

max_perm = max(rw) 

_op_permutation(perm, cperm) 

  

if max_perm > max_a: 

freeall(ca); freeall(cperm); freeall(cres) 

raise ValueError(r"cannot apply \delta_{%s} to a (= %s)" % (perm, a)) 

  

sig_on() 

divdiff_perm_schubert(cperm, ca, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca); freeall(cperm); freeall(cres) 

  

return res 

  

  

def scalarproduct_schubert_symmetrica(a, b): 

""" 

EXAMPLES: 

sage: symmetrica.scalarproduct_schubert([3,2,1], [3,2,1]) 

X[1, 3, 5, 2, 4] 

sage: symmetrica.scalarproduct_schubert([3,2,1], [2,1,3]) 

X[1, 2, 4, 3] 

""" 

late_import() 

  

cdef OP ca = callocobject(), cb = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

max_b = _check_schubert(b, cb) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(cb); freeall(cres) 

raise err 

  

sig_on() 

scalarproduct_schubert(ca, cb, cres) 

sig_off() 

  

if empty_listp(cres): 

res = Integer(0) 

else: 

res = _py(cres) 

  

freeall(ca); freeall(cb); freeall(cres) 

  

return res 

  

def divdiff_schubert_symmetrica(i, a): 

r""" 

Returns the result of applying the divided difference operator 

$\delta_i$ to $a$ where $a$ is either a permutation or a 

Schubert polynomial over QQ. 

  

EXAMPLES: 

sage: symmetrica.divdiff_schubert(1, [3,2,1]) 

X[2, 3, 1] 

sage: symmetrica.divdiff_schubert(2, [3,2,1]) 

X[3, 1, 2] 

sage: symmetrica.divdiff_schubert(3, [3,2,1]) 

Traceback (most recent call last): 

... 

ValueError: cannot apply \delta_{3} to a (= [3, 2, 1]) 

""" 

late_import() 

  

cdef OP ca = callocobject(), ci = callocobject(), cres = callocobject() 

  

try: 

max_a = _check_schubert(a, ca) 

except (ValueError, TypeError), err: 

freeall(ca); freeall(ci); freeall(cres) 

raise err 

  

if not isinstance(i, (int, Integer)): 

freeall(ca); freeall(ci); freeall(cres) 

raise TypeError("i must be an integer") 

else: 

_op_integer(i, ci) 

  

if i > max_a or i <= 0: 

freeall(ca); freeall(ci); freeall(cres) 

raise ValueError(r"cannot apply \delta_{%s} to a (= %s)" % (i, a)) 

  

sig_on() 

divdiff_schubert(ci, ca, cres) 

sig_off() 

  

res = _py(cres) 

  

freeall(ca); freeall(ci); freeall(cres) 

  

return res