schubmult 2.0.2__py3-none-any.whl → 2.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. schubmult/__init__.py +1 -1
  2. schubmult/_base_argparse.py +42 -8
  3. schubmult/_tests.py +24 -0
  4. schubmult/perm_lib.py +52 -112
  5. schubmult/sage_integration/__init__.py +13 -13
  6. schubmult/sage_integration/_fast_double_schubert_polynomial_ring.py +139 -118
  7. schubmult/sage_integration/_fast_schubert_polynomial_ring.py +88 -49
  8. schubmult/sage_integration/_indexing.py +35 -32
  9. schubmult/schubmult_double/__init__.py +6 -12
  10. schubmult/schubmult_double/__main__.py +2 -1
  11. schubmult/schubmult_double/_funcs.py +245 -281
  12. schubmult/schubmult_double/_script.py +128 -70
  13. schubmult/schubmult_py/__init__.py +5 -3
  14. schubmult/schubmult_py/__main__.py +2 -1
  15. schubmult/schubmult_py/_funcs.py +68 -23
  16. schubmult/schubmult_py/_script.py +40 -58
  17. schubmult/schubmult_q/__init__.py +3 -7
  18. schubmult/schubmult_q/__main__.py +2 -1
  19. schubmult/schubmult_q/_funcs.py +41 -60
  20. schubmult/schubmult_q/_script.py +39 -30
  21. schubmult/schubmult_q_double/__init__.py +5 -11
  22. schubmult/schubmult_q_double/__main__.py +2 -1
  23. schubmult/schubmult_q_double/_funcs.py +99 -66
  24. schubmult/schubmult_q_double/_script.py +209 -150
  25. schubmult-2.0.4.dist-info/METADATA +542 -0
  26. schubmult-2.0.4.dist-info/RECORD +30 -0
  27. {schubmult-2.0.2.dist-info → schubmult-2.0.4.dist-info}/WHEEL +1 -1
  28. schubmult-2.0.4.dist-info/entry_points.txt +5 -0
  29. {schubmult-2.0.2.dist-info → schubmult-2.0.4.dist-info}/top_level.txt +0 -1
  30. schubmult/schubmult_double/_vars.py +0 -18
  31. schubmult/schubmult_py/_vars.py +0 -3
  32. schubmult/schubmult_q/_vars.py +0 -18
  33. schubmult/schubmult_q_double/_vars.py +0 -21
  34. schubmult-2.0.2.dist-info/METADATA +0 -455
  35. schubmult-2.0.2.dist-info/RECORD +0 -36
  36. schubmult-2.0.2.dist-info/entry_points.txt +0 -5
  37. tests/__init__.py +0 -0
  38. tests/test_fast_double_schubert.py +0 -145
  39. tests/test_fast_schubert.py +0 -38
  40. {schubmult-2.0.2.dist-info → schubmult-2.0.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,38 +1,65 @@
1
+ import sys
2
+ from functools import cached_property
3
+
1
4
  import numpy as np
2
5
  import sympy
3
- import sys
4
- from ._vars import (
5
- var2,
6
- var3,
7
- var_x,
8
- var,
9
- var_r
10
- )
11
- from ._funcs import (
12
- mult_poly,
13
- mult_poly_down,
14
- schubmult,
15
- schubmult_down,
16
- compute_positive_rep,
17
- posify,
18
- split_perms,
19
- )
20
- from symengine import expand, sympify
6
+ from symengine import expand, symarray, sympify
7
+
21
8
  from schubmult._base_argparse import schub_argparse
22
9
  from schubmult.perm_lib import (
23
10
  add_perm_dict,
24
- inverse,
25
- theta,
26
- permtrim,
11
+ code,
27
12
  inv,
13
+ inverse,
14
+ mu_A,
28
15
  mulperm,
29
- code,
16
+ permtrim,
17
+ theta,
18
+ trimcode,
30
19
  uncode,
31
20
  will_formula_work,
32
- mu_A,
33
- trimcode,
34
21
  )
35
22
 
23
+ # from schubmult.schubmult_double._vars import var_x, var, var_r
24
+ from schubmult.schubmult_double._funcs import (
25
+ compute_positive_rep,
26
+ mult_poly,
27
+ mult_poly_down,
28
+ posify,
29
+ schubmult,
30
+ schubmult_down,
31
+ split_perms,
32
+ )
33
+
34
+
35
+ class _gvars:
36
+ @cached_property
37
+ def n(self):
38
+ return 100
39
+
40
+ # @cached_property
41
+ # def fvar(self):
42
+ # return 100
43
+
44
+ @cached_property
45
+ def var1(self):
46
+ return tuple(symarray("x", self.n).tolist())
47
+
48
+ @cached_property
49
+ def var2(self):
50
+ return tuple(symarray("y", self.n).tolist())
51
+
52
+ @cached_property
53
+ def var3(self):
54
+ return tuple(symarray("z", self.n).tolist())
55
+
56
+ @cached_property
57
+ def var_r(self):
58
+ return symarray("r", 100)
59
+
60
+
61
+ _vars = _gvars()
62
+
36
63
 
37
64
  def _display(val):
38
65
  print(val)
@@ -42,13 +69,20 @@ def _display_full(
42
69
  coeff_dict,
43
70
  args,
44
71
  formatter,
72
+ var2,
73
+ var3,
45
74
  posified=None,
46
75
  check_coeff_dict=None,
47
76
  kperm=None,
48
- var2=var2,
49
- var3=var3,
50
77
  N=None,
51
78
  ):
79
+ subs_dict2 = {}
80
+ for i in range(1, 100):
81
+ sm = var2[1]
82
+ for j in range(1, i):
83
+ sm += _vars.var_r[j]
84
+ subs_dict2[var2[i]] = sm
85
+ raw_result_dict = {}
52
86
  perms = args.perms
53
87
  mult = args.mult
54
88
  ascode = args.ascode
@@ -88,9 +122,9 @@ def _display_full(
88
122
 
89
123
  for i in range(1, 100):
90
124
  if i <= N:
91
- subs_dict[var[i]] = var2[i]
125
+ subs_dict[_vars.var1[i]] = var2[i]
92
126
  else:
93
- subs_dict[var[i]] = var3[i - N]
127
+ subs_dict[_vars.var1[i]] = var3[i - N]
94
128
 
95
129
  coeff_perms.sort(key=lambda x: (inv(x), *x))
96
130
 
@@ -112,11 +146,12 @@ def _display_full(
112
146
 
113
147
  if ascode:
114
148
  width = max(
115
- [len(str(trimcode(perm[0])) + " " + str(trimcode(perm[1]))) for perm in perm_pairs]
149
+ [len(str(trimcode(perm[0])) + " " + str(trimcode(perm[1]))) for perm in perm_pairs],
116
150
  )
117
151
  else:
118
152
  width = max([len(str(perm[0]) + " " + str(perm[1])) for perm in perm_pairs])
119
153
 
154
+
120
155
  for perm in coeff_perms:
121
156
  val = coeff_dict[perm]
122
157
  downperm = mulperm(list(perm), inverse_kperm)
@@ -133,13 +168,7 @@ def _display_full(
133
168
  val = sympify(val).subs(subs_dict)
134
169
 
135
170
  if same and display_positive:
136
- subs_dict2 = {}
137
- for i in range(1, 100):
138
- sm = var2[1]
139
- for j in range(1, i):
140
- sm += var_r[j]
141
- subs_dict2[var2[i]] = sm
142
- val = expand(sympify(val).xreplace(subs_dict2))
171
+ val = expand(sympify(val).subs(subs_dict2))
143
172
 
144
173
  if val != 0:
145
174
  if display_positive and not same:
@@ -156,15 +185,15 @@ def _display_full(
156
185
  )
157
186
  if expand(val - val2) != 0:
158
187
  _display(
159
- f"error; write to schubmult@gmail.com with the case {perms=}\n{code(firstperm)=} {code(secondperm)=}\n{val2=}\n{val=}"
188
+ f"error; write to schubmult@gmail.com with the case {perms=}\n{code(firstperm)=} {code(secondperm)=}\n{val2=}\n{val=}",
160
189
  )
161
190
  _display(
162
- f"{code(tuple(permtrim(mulperm(firstperm,muA))))=},{code(tuple(permtrim(mulperm(secondperm,muB))))=},{code(the_top_perm)=}\n{expand(val-val2)=}"
191
+ f"{code(tuple(permtrim(mulperm(firstperm,muA))))=},{code(tuple(permtrim(mulperm(secondperm,muB))))=},{code(the_top_perm)=}\n{expand(val-val2)=}",
163
192
  )
164
193
  exit(1)
165
194
  val = val2
166
195
  else:
167
- val = 0
196
+ val = 0
168
197
  if val != 0:
169
198
  if not ascode:
170
199
  width2 = (
@@ -172,18 +201,26 @@ def _display_full(
172
201
  - len(str(permtrim(firstperm)))
173
202
  - len(str(permtrim(secondperm)))
174
203
  )
175
- _display(
176
- f"{tuple(permtrim(firstperm))}{' ':>{width2}}{tuple(permtrim(secondperm))} {formatter(val)}"
177
- )
204
+ raw_result_dict[
205
+ (tuple(permtrim(firstperm)), tuple(permtrim(secondperm)))
206
+ ] = val
207
+ if formatter:
208
+ _display(
209
+ f"{tuple(permtrim(firstperm))}{' ':>{width2}}{tuple(permtrim(secondperm))} {formatter(val)}",
210
+ )
178
211
  else:
179
212
  width2 = (
180
213
  width
181
214
  - len(str(trimcode(firstperm)))
182
215
  - len(str(trimcode(secondperm)))
183
216
  )
184
- _display(
185
- f"{trimcode(firstperm)}{' ':>{width2}}{trimcode(secondperm)} {formatter(val)}"
186
- )
217
+ raw_result_dict[
218
+ (tuple(trimcode(firstperm)), tuple(trimcode(secondperm)))
219
+ ] = val
220
+ if formatter:
221
+ _display(
222
+ f"{trimcode(firstperm)}{' ':>{width2}}{trimcode(secondperm)} {formatter(val)}",
223
+ )
187
224
  else:
188
225
  if ascode:
189
226
  width = max([len(str(trimcode(perm))) for perm in coeff_dict.keys()])
@@ -192,7 +229,7 @@ def _display_full(
192
229
 
193
230
  coeff_perms = list(coeff_dict.keys())
194
231
  coeff_perms.sort(key=lambda x: (inv(x), *x))
195
-
232
+
196
233
  for perm in coeff_perms:
197
234
  val = coeff_dict[perm]
198
235
  if val != 0:
@@ -207,7 +244,7 @@ def _display_full(
207
244
  for i in range(1, 100):
208
245
  sm = var2[1]
209
246
  for j in range(1, i):
210
- sm += var_r[j]
247
+ sm += _vars.var_r[j]
211
248
  subs_dict[var2[i]] = sm
212
249
  val = expand(sympify(coeff_dict[perm]).xreplace(subs_dict))
213
250
  else:
@@ -245,24 +282,33 @@ def _display_full(
245
282
  )
246
283
  else:
247
284
  _display(
248
- f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {check_coeff_dict.get(perm,0)=}"
285
+ f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {check_coeff_dict.get(perm,0)=}",
249
286
  )
250
287
  exit(1)
251
288
  if check and expand(val - check_coeff_dict.get(perm, 0)) != 0:
252
289
  _display(
253
- f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {check_coeff_dict.get(perm,0)=}"
290
+ f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {check_coeff_dict.get(perm,0)=}",
254
291
  )
255
292
  exit(1)
256
293
  if val != 0:
257
294
  if ascode:
258
- _display(f"{str(trimcode(perm)):>{width}} {formatter(val)}")
295
+ raw_result_dict[tuple(trimcode(perm))] = val
296
+ if formatter:
297
+ _display(f"{trimcode(perm)!s:>{width}} {formatter(val)}")
259
298
  else:
260
- _display(f"{str(perm):>{width}} {formatter(val)}")
299
+ raw_result_dict[tuple(perm)] = val
300
+ if formatter:
301
+ _display(f"{perm!s:>{width}} {formatter(val)}")
302
+ return raw_result_dict
303
+
261
304
 
305
+ def main(argv=None):
306
+ if argv is None:
307
+ argv = sys.argv
262
308
 
263
- def main():
264
- global var2, var3
265
309
  try:
310
+ var2 = tuple(symarray("y", 100).tolist())
311
+ var3 = tuple(symarray("z", 100).tolist())
266
312
  sys.setrecursionlimit(1000000)
267
313
 
268
314
  # TEMP
@@ -271,6 +317,7 @@ def main():
271
317
  args, formatter = schub_argparse(
272
318
  "schubmult_double",
273
319
  "Compute coefficients of product of double Schubert polynomials in the same or different sets of coefficient variables",
320
+ argv=argv[1:],
274
321
  yz=True,
275
322
  )
276
323
 
@@ -287,9 +334,11 @@ def main():
287
334
  display_positive = args.display_positive
288
335
  pr = args.pr
289
336
 
337
+ # logger.log(logging.DEBUG, f"main boing 1 {var2=}{var3=}{same=}")
290
338
  if same:
339
+ # logger.log(logging.DEBUG, f"main OOO {same=}")
291
340
  var3 = var2
292
-
341
+ # logger.log(logging.DEBUG, f"main boing 2 {var2=}{var3=}{same=}")
293
342
  posified = False
294
343
  if coprod:
295
344
  if ascode:
@@ -307,10 +356,11 @@ def main():
307
356
 
308
357
  kperm = inverse(uncode(kcd))
309
358
  coeff_dict = {tuple(kperm): 1}
310
- coeff_dict = schubmult(coeff_dict, perms[0], var, var2)
359
+ coeff_dict = schubmult(coeff_dict, perms[0], _vars.var1, var2)
311
360
 
312
- if pr:
313
- _display_full(
361
+ if pr or formatter is None:
362
+ # logger.log(logging.DEBUG, f"main {var2=}{var3=}{same=}")
363
+ raw_result_dict = _display_full(
314
364
  coeff_dict,
315
365
  args,
316
366
  formatter,
@@ -320,6 +370,8 @@ def main():
320
370
  var3=var3,
321
371
  N=N,
322
372
  )
373
+ if formatter is None:
374
+ return raw_result_dict
323
375
  else:
324
376
  if ascode:
325
377
  for i in range(len(perms)):
@@ -339,13 +391,13 @@ def main():
339
391
  coeff_dict = {perms[0]: 1}
340
392
  check_coeff_dict = {perms[0]: 1}
341
393
 
342
- if mult:
343
- for v in var2:
344
- globals()[str(v)] = v
345
- for v in var3:
346
- globals()[str(v)] = v
347
- for v in var_x:
348
- globals()[str(v)] = v
394
+ # if mult:
395
+ # for v in var2:
396
+ # ()[str(v)] = v
397
+ # for v in var3:
398
+ # globals()[str(v)] = v
399
+ # for v in _vars.var1:
400
+ # globals()[str(v)] = v
349
401
 
350
402
  if down:
351
403
  for perm in orig_perms[1:]:
@@ -356,6 +408,7 @@ def main():
356
408
  else:
357
409
  for perm in orig_perms[1:]:
358
410
  check_coeff_dict = schubmult(check_coeff_dict, perm, var2, var3)
411
+ # coeff_dict = check_coeff_dict
359
412
  if mult:
360
413
  mul_exp = eval(mulstring)
361
414
  check_coeff_dict = mult_poly(check_coeff_dict, mul_exp)
@@ -389,7 +442,7 @@ def main():
389
442
  coeff_dict4 = schubmult(coeff_dict4, perm, var2, var3)
390
443
  for w in coeff_dict4:
391
444
  coeff_dict4[w] = coeff_dict2[u] * posify(
392
- coeff_dict4[w], u, perm, w, var2, var3, msg
445
+ coeff_dict4[w], u, perm, w, var2, var3, msg,
393
446
  )
394
447
  coeff_dict3 = add_perm_dict(coeff_dict4, coeff_dict3)
395
448
  coeff_dict2 = coeff_dict3
@@ -398,19 +451,24 @@ def main():
398
451
  elif not posified:
399
452
  coeff_dict = check_coeff_dict
400
453
 
401
- if pr:
402
- _display_full(
454
+
455
+ if pr or formatter is None:
456
+ raw_result_dict = _display_full(
403
457
  coeff_dict,
404
458
  args,
405
459
  formatter,
460
+ var2,
461
+ var3,
406
462
  posified=posified,
407
463
  check_coeff_dict=check_coeff_dict,
408
- var2=var2,
409
- var3=var3,
410
464
  )
465
+
466
+ if formatter is None:
467
+ return raw_result_dict
411
468
  except BrokenPipeError:
412
469
  pass
470
+ return 0
413
471
 
414
472
 
415
473
  if __name__ == "__main__":
416
- main()
474
+ sys.exit(main(sys.argv))
@@ -1,10 +1,12 @@
1
1
  from ._funcs import (
2
+ mult_poly,
3
+ schub_coprod,
2
4
  schubmult,
3
- mult_poly
4
5
  )
5
6
 
6
-
7
7
  __all__ = [
8
+ "mult_poly",
9
+ "schub_coprod",
8
10
  "schubmult",
9
- "mult_poly"
10
11
  ]
12
+
@@ -1,5 +1,6 @@
1
1
  import sys
2
+
2
3
  from ._script import main
3
4
 
4
5
  if __name__ == "__main__":
5
- sys.exit(main())
6
+ sys.exit(main(sys.argv))
@@ -1,16 +1,31 @@
1
- from ._vars import var_x
1
+ from functools import cached_property
2
+
3
+ from symengine import Add, Mul, Pow, symarray
4
+
2
5
  from schubmult.perm_lib import (
3
- elem_sym_perms,
4
6
  add_perm_dict,
5
7
  compute_vpathdicts,
6
- inverse,
7
- theta,
8
- permtrim,
8
+ elem_sym_perms,
9
9
  inv,
10
+ inverse,
10
11
  mulperm,
12
+ permtrim,
13
+ theta,
11
14
  uncode,
12
15
  )
13
- from symengine import Add, Mul, Pow
16
+
17
+
18
+ class _gvars:
19
+ @cached_property
20
+ def n(self):
21
+ return 100
22
+
23
+ @cached_property
24
+ def var_x(self):
25
+ return tuple(symarray("x", self.n).tolist())
26
+
27
+
28
+ _vars = _gvars()
14
29
 
15
30
 
16
31
  def single_variable(coeff_dict, varnum):
@@ -29,31 +44,30 @@ def single_variable(coeff_dict, varnum):
29
44
  return ret
30
45
 
31
46
 
32
- def mult_poly(coeff_dict, poly, var_x=var_x):
47
+ def mult_poly(coeff_dict, poly, var_x=_vars.var_x):
33
48
  if poly in var_x:
34
49
  return single_variable(coeff_dict, var_x.index(poly))
35
- elif isinstance(poly, Mul):
50
+ if isinstance(poly, Mul):
36
51
  ret = coeff_dict
37
52
  for a in poly.args:
38
53
  ret = mult_poly(ret, a, var_x)
39
54
  return ret
40
- elif isinstance(poly, Pow):
55
+ if isinstance(poly, Pow):
41
56
  base = poly.args[0]
42
57
  exponent = int(poly.args[1])
43
58
  ret = coeff_dict
44
59
  for i in range(int(exponent)):
45
60
  ret = mult_poly(ret, base, var_x)
46
61
  return ret
47
- elif isinstance(poly, Add):
62
+ if isinstance(poly, Add):
48
63
  ret = {}
49
64
  for a in poly.args:
50
65
  ret = add_perm_dict(ret, mult_poly(coeff_dict, a, var_x))
51
66
  return ret
52
- else:
53
- ret = {}
54
- for perm in coeff_dict:
55
- ret[perm] = poly * coeff_dict[perm]
56
- return ret
67
+ ret = {}
68
+ for perm in coeff_dict:
69
+ ret[perm] = poly * coeff_dict[perm]
70
+ return ret
57
71
 
58
72
 
59
73
  def schubmult(perm_dict, v):
@@ -74,8 +88,7 @@ def schubmult(perm_dict, v):
74
88
  for index in range(len(th)):
75
89
  for vp in vpathdicts[index]:
76
90
  for v2, vdiff, s in vpathdicts[index][vp]:
77
- if th[index] - vdiff > mx_th[index]:
78
- mx_th[index] = th[index] - vdiff
91
+ mx_th[index] = max(mx_th[index], th[index] - vdiff)
79
92
 
80
93
  for u, val in perm_dict.items():
81
94
  inv_u = inv(u)
@@ -100,12 +113,44 @@ def schubmult(perm_dict, v):
100
113
  if vdiff + udiff == th[index]:
101
114
  if up2 not in newpathsums:
102
115
  newpathsums[up2] = {}
103
- newpathsums[up2][v2] = (
104
- newpathsums[up2].get(v2, 0) + addsumval
105
- )
116
+ newpathsums[up2][v2] = newpathsums[up2].get(v2, 0) + addsumval
106
117
  vpathsums = newpathsums
107
118
  toget = tuple(vmu)
108
- ret_dict = add_perm_dict(
109
- {ep: vpathsums[ep].get(toget, 0) for ep in vpathsums}, ret_dict
110
- )
119
+ ret_dict = add_perm_dict({ep: vpathsums[ep].get(toget, 0) for ep in vpathsums}, ret_dict)
120
+ return ret_dict
121
+
122
+
123
+ def schub_coprod(perm, indices):
124
+ mperm = tuple(perm)
125
+ indices = sorted(indices)
126
+ ret_dict = {}
127
+ k = len(indices)
128
+ n = len(mperm)
129
+ kcd = [indices[i] - i - 1 for i in range(len(indices))] + [n + 1 - k for i in range(k, n)]
130
+ max_required = max([kcd[i] + i for i in range(len(kcd))])
131
+ kcd2 = kcd + [0 for i in range(len(kcd), max_required)] + [0]
132
+ N = len(kcd)
133
+ kperm = permtrim(inverse(uncode(kcd2)))
134
+ coeff_dict = {tuple(kperm): 1}
135
+ coeff_dict = schubmult(coeff_dict, tuple(mperm))
136
+
137
+ inv_kperm = inv(kperm)
138
+ inverse_kperm = inverse(kperm)
139
+ # total_sum = 0
140
+ for perm, val in coeff_dict.items():
141
+ if val == 0:
142
+ continue
143
+ pperm = [*perm]
144
+ downperm = mulperm(pperm, inverse_kperm)
145
+ if inv(downperm) == inv(pperm) - inv_kperm:
146
+ flag = True
147
+ for i in range(N):
148
+ if downperm[i] > N:
149
+ flag = False
150
+ break
151
+ if not flag:
152
+ continue
153
+ firstperm = tuple(permtrim(list(downperm[0:N])))
154
+ secondperm = tuple(permtrim([downperm[i] - N for i in range(N, len(downperm))]))
155
+ ret_dict[(firstperm, secondperm)] = val
111
156
  return ret_dict
@@ -1,24 +1,26 @@
1
- from ._funcs import (
2
- mult_poly,
3
- schubmult,
4
- )
1
+ import sys
2
+
5
3
  from symengine import sympify
4
+
6
5
  from schubmult._base_argparse import schub_argparse
7
6
  from schubmult.perm_lib import (
7
+ inv,
8
8
  inverse,
9
- theta,
10
9
  permtrim,
11
- inv,
12
- mulperm,
13
- code,
14
- uncode,
10
+ theta,
15
11
  trimcode,
12
+ uncode,
16
13
  )
14
+ from schubmult.schubmult_py._funcs import mult_poly, schub_coprod, schubmult
17
15
 
18
16
 
19
- def main():
17
+ def main(argv=None):
18
+ if argv is None:
19
+ argv = sys.argv
20
20
  try:
21
- args, formatter = schub_argparse("schubmult_py", "Compute products of ordinary Schubert polynomials")
21
+ args, formatter = schub_argparse(
22
+ "schubmult_py", "Compute products of ordinary Schubert polynomials", argv=argv[1:],
23
+ )
22
24
 
23
25
  mult = args.mult
24
26
  mulstring = args.mulstring
@@ -36,55 +38,29 @@ def main():
36
38
  ascode = args.ascode
37
39
  pr = args.pr
38
40
  coprod = args.coprod
39
-
41
+ raw_result_dict = {}
40
42
  if coprod:
41
43
  if ascode:
42
44
  perms[0] = tuple(permtrim(uncode(perms[0])))
43
45
  pos = [*perms[1]]
44
46
  pos.sort()
45
- mperm = perms[0]
46
-
47
- cd = code(mperm)
48
- perms[0] = mperm
49
-
50
- while cd[-1] == 0:
51
- cd.pop()
52
- k = len(pos)
53
- n = len(perms[0])
54
- kcd = [pos[i] - i - 1 for i in range(len(pos))] + [n + 1 - k for i in range(k, n)]
55
- N = len(kcd)
56
- kperm = inverse(uncode(kcd))
57
- coeff_dict = {tuple(permtrim(kperm)): 1}
58
- coeff_dict = schubmult(coeff_dict, tuple(permtrim([*perms[0]])))
59
-
60
- inv_kperm = inv(kperm)
61
- inverse_kperm = inverse(kperm)
62
- if pr:
63
- for perm, val in coeff_dict.items():
64
- downperm = mulperm(list(perm), inverse_kperm)
65
- if inv(downperm) == inv(perm) - inv_kperm:
66
- flag = True
67
- for i in range(N):
68
- if downperm[i] > N:
69
- flag = False
70
- break
71
- if not flag:
72
- continue
73
- firstperm = downperm[0:N]
74
- secondperm = [downperm[i] - N for i in range(N, len(downperm))]
75
- if val != 0:
76
- # firstcode = code(firstperm)
77
- # while len(firstcode)>0 and firstcode[-1] == 0:
78
- # firstcode.pop()
79
- # secondcode = code(secondperm)
80
- # while len(secondcode)>0 and secondcode[-1] == 0:
81
- # secondcode.pop()
82
- if ascode:
83
- print(f"{val} {trimcode(firstperm)} {trimcode(secondperm)}")
47
+ mperm = tuple(permtrim(perms[0]))
48
+
49
+ coeff_dict = schub_coprod(mperm, pos)
50
+
51
+ if pr or formatter is None:
52
+ for firstperm, secondperm in coeff_dict:
53
+ val = coeff_dict[(firstperm, secondperm)]
54
+ if val != 0:
55
+ if ascode:
56
+ if formatter is None:
57
+ raw_result_dict[(tuple(trimcode(firstperm)), tuple(trimcode(secondperm)))] = val
84
58
  else:
85
- print(
86
- f"{val} {tuple(permtrim(firstperm))} {tuple(permtrim(secondperm))}"
87
- )
59
+ print(f"{val} {trimcode(firstperm)} {trimcode(secondperm)}")
60
+ elif formatter is None:
61
+ raw_result_dict[(firstperm, secondperm)] = val
62
+ else:
63
+ print(f"{val} {firstperm} {secondperm}")
88
64
  else:
89
65
  if ascode:
90
66
  for i in range(len(perms)):
@@ -100,16 +76,22 @@ def main():
100
76
  mul_exp = sympify(mulstring)
101
77
  coeff_dict = mult_poly(coeff_dict, mul_exp)
102
78
 
103
- if pr:
79
+ if pr or formatter is None:
104
80
  for perm, val in coeff_dict.items():
105
81
  if val != 0:
106
82
  if ascode:
107
- print(f"{val} {trimcode(perm)}")
83
+ raw_result_dict[tuple(trimcode(perm))] = val
84
+ if formatter:
85
+ print(f"{val} {trimcode(perm)}")
108
86
  else:
109
- print(f"{val} {perm}")
87
+ raw_result_dict[tuple(perm)] = val
88
+ if formatter:
89
+ print(f"{val} {perm}")
90
+ if formatter is None:
91
+ return raw_result_dict
110
92
  except BrokenPipeError:
111
93
  pass
112
94
 
113
95
 
114
96
  if __name__ == "__main__":
115
- main()
97
+ sys.exit(main(sys.argv))
@@ -1,12 +1,8 @@
1
- from ._funcs import (
2
- schubmult,
3
- schubmult_db,
4
- mult_poly
5
- )
6
-
1
+ from ._funcs import mult_poly, schubmult, schubmult_db
7
2
 
8
3
  __all__ = [
4
+ "mult_poly",
9
5
  "schubmult",
10
6
  "schubmult_db",
11
- "mult_poly"
12
7
  ]
8
+