schubmult 2.0.3__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 (32) hide show
  1. schubmult/__init__.py +1 -1
  2. schubmult/_base_argparse.py +11 -6
  3. schubmult/_tests.py +19 -4
  4. schubmult/perm_lib.py +52 -112
  5. schubmult/sage_integration/__init__.py +13 -14
  6. schubmult/sage_integration/_fast_double_schubert_polynomial_ring.py +92 -128
  7. schubmult/sage_integration/_fast_schubert_polynomial_ring.py +55 -54
  8. schubmult/sage_integration/_indexing.py +35 -39
  9. schubmult/schubmult_double/__init__.py +5 -15
  10. schubmult/schubmult_double/__main__.py +1 -0
  11. schubmult/schubmult_double/_funcs.py +140 -256
  12. schubmult/schubmult_double/_script.py +41 -41
  13. schubmult/schubmult_py/__init__.py +3 -4
  14. schubmult/schubmult_py/__main__.py +1 -0
  15. schubmult/schubmult_py/_funcs.py +18 -18
  16. schubmult/schubmult_py/_script.py +12 -11
  17. schubmult/schubmult_q/__init__.py +2 -7
  18. schubmult/schubmult_q/__main__.py +1 -0
  19. schubmult/schubmult_q/_funcs.py +24 -27
  20. schubmult/schubmult_q/_script.py +27 -21
  21. schubmult/schubmult_q_double/__init__.py +4 -11
  22. schubmult/schubmult_q_double/__main__.py +1 -0
  23. schubmult/schubmult_q_double/_funcs.py +48 -48
  24. schubmult/schubmult_q_double/_script.py +39 -41
  25. schubmult-2.0.4.dist-info/METADATA +542 -0
  26. schubmult-2.0.4.dist-info/RECORD +30 -0
  27. {schubmult-2.0.3.dist-info → schubmult-2.0.4.dist-info}/WHEEL +1 -1
  28. schubmult-2.0.3.dist-info/METADATA +0 -455
  29. schubmult-2.0.3.dist-info/RECORD +0 -30
  30. {schubmult-2.0.3.dist-info → schubmult-2.0.4.dist-info}/entry_points.txt +0 -0
  31. {schubmult-2.0.3.dist-info → schubmult-2.0.4.dist-info}/licenses/LICENSE +0 -0
  32. {schubmult-2.0.3.dist-info → schubmult-2.0.4.dist-info}/top_level.txt +0 -0
@@ -5,27 +5,29 @@
5
5
  # var3,
6
6
  # q_var2,
7
7
  # )
8
- import schubmult.schubmult_double as norm_yz
8
+ from functools import cached_property
9
9
 
10
10
  from symengine import Add, Mul, Pow, expand, symarray
11
+
12
+ import schubmult.schubmult_double as norm_yz
11
13
  from schubmult.perm_lib import (
12
- elem_sym_perms_q,
13
14
  add_perm_dict,
15
+ call_zvars,
14
16
  compute_vpathdicts,
17
+ double_elem_sym_q,
18
+ elem_sym_func_q,
19
+ elem_sym_perms_q,
20
+ elem_sym_perms_q_op,
21
+ elem_sym_poly_q,
22
+ inv,
15
23
  inverse,
16
- strict_theta,
17
24
  medium_theta,
18
- permtrim,
19
- inv,
20
25
  mulperm,
26
+ permtrim,
27
+ strict_theta,
21
28
  uncode,
22
- double_elem_sym_q,
23
- elem_sym_poly_q,
24
- elem_sym_perms_q_op,
25
- elem_sym_func_q,
26
- call_zvars,
27
29
  )
28
- from functools import cached_property
30
+
29
31
 
30
32
  class _gvars:
31
33
  @cached_property
@@ -47,7 +49,7 @@ class _gvars:
47
49
  @cached_property
48
50
  def var3(self):
49
51
  return tuple(symarray("z", self.n).tolist())
50
-
52
+
51
53
  @cached_property
52
54
  def q_var(self):
53
55
  return tuple(symarray("q", self.n).tolist())
@@ -60,7 +62,7 @@ class _gvars:
60
62
  _vars = _gvars()
61
63
 
62
64
 
63
- def E(p, k, varl=_vars.var2[1:],var_x=_vars.var1):
65
+ def E(p, k, varl=_vars.var2[1:], var_x=_vars.var1):
64
66
  return elem_sym_poly_q(p, k, var_x[1:], varl)
65
67
 
66
68
 
@@ -87,28 +89,27 @@ def single_variable(coeff_dict, varnum, var2=_vars.var2, q_var=_vars.q_var):
87
89
  def mult_poly(coeff_dict, poly, var_x=_vars.var1, var_y=_vars.var2, q_var=_vars.q_var):
88
90
  if poly in var_x:
89
91
  return single_variable(coeff_dict, var_x.index(poly), var_y, q_var)
90
- elif isinstance(poly, Mul):
92
+ if isinstance(poly, Mul):
91
93
  ret = coeff_dict
92
94
  for a in poly.args:
93
95
  ret = mult_poly(ret, a, var_x, var_y, q_var)
94
96
  return ret
95
- elif isinstance(poly, Pow):
97
+ if isinstance(poly, Pow):
96
98
  base = poly.args[0]
97
99
  exponent = int(poly.args[1])
98
100
  ret = coeff_dict
99
101
  for i in range(int(exponent)):
100
102
  ret = mult_poly(ret, base, var_x, var_y, q_var)
101
103
  return ret
102
- elif isinstance(poly, Add):
104
+ if isinstance(poly, Add):
103
105
  ret = {}
104
106
  for a in poly.args:
105
107
  ret = add_perm_dict(ret, mult_poly(coeff_dict, a, var_x, var_y, q_var))
106
108
  return ret
107
- else:
108
- ret = {}
109
- for perm in coeff_dict:
110
- ret[perm] = poly * coeff_dict[perm]
111
- return ret
109
+ ret = {}
110
+ for perm in coeff_dict:
111
+ ret[perm] = poly * coeff_dict[perm]
112
+ return ret
112
113
 
113
114
 
114
115
  def nil_hecke(perm_dict, v, n, var2=_vars.var2, var3=_vars.var3):
@@ -129,8 +130,7 @@ def nil_hecke(perm_dict, v, n, var2=_vars.var2, var3=_vars.var3):
129
130
  mx_th = 0
130
131
  for vp in vpathdicts[index]:
131
132
  for v2, vdiff, s in vpathdicts[index][vp]:
132
- if th[index] - vdiff > mx_th:
133
- mx_th = th[index] - vdiff
133
+ mx_th = max(mx_th, th[index] - vdiff)
134
134
  newpathsums = {}
135
135
  for up in vpathsums:
136
136
  newperms = elem_sym_perms_q_op(up, mx_th, th[index], n)
@@ -143,7 +143,8 @@ def nil_hecke(perm_dict, v, n, var2=_vars.var2, var3=_vars.var3):
143
143
  continue
144
144
  for v2, vdiff, s in vpathdicts[index][v]:
145
145
  newpathsums[up2][v2] = newpathsums[up2].get(
146
- v2, 0
146
+ v2,
147
+ 0,
147
148
  ) + s * sumval * elem_sym_func_q(
148
149
  th[index],
149
150
  index + 1,
@@ -202,13 +203,15 @@ def schubpoly_quantum(v, var_x=_vars.var1, var_y=_vars.var2, q_var=_vars.q_var,
202
203
  mx_th = 0
203
204
  for vp in vpathdicts[index]:
204
205
  for v2, vdiff, s in vpathdicts[index][vp]:
205
- if th[index] - vdiff > mx_th:
206
- mx_th = th[index] - vdiff
206
+ mx_th = max(mx_th, th[index] - vdiff)
207
207
  newpathsums = {}
208
208
  for up in vpathsums:
209
209
  inv_up = inv(up)
210
210
  newperms = elem_sym_perms_q(
211
- up, min(mx_th, (inv_mu - (inv_up - inv_u)) - inv_vmu), th[index], q_var
211
+ up,
212
+ min(mx_th, (inv_mu - (inv_up - inv_u)) - inv_vmu),
213
+ th[index],
214
+ q_var,
212
215
  )
213
216
  for up2, udiff, mul_val in newperms:
214
217
  if up2 not in newpathsums:
@@ -219,7 +222,8 @@ def schubpoly_quantum(v, var_x=_vars.var1, var_y=_vars.var2, q_var=_vars.q_var,
219
222
  continue
220
223
  for v2, vdiff, s in vpathdicts[index][v]:
221
224
  newpathsums[up2][v2] = newpathsums[up2].get(
222
- v2, 0
225
+ v2,
226
+ 0,
223
227
  ) + s * sumval * elem_sym_func_q_q(
224
228
  th[index],
225
229
  index + 1,
@@ -261,8 +265,7 @@ def schubmult(perm_dict, v, var2=_vars.var2, var3=_vars.var3, q_var=_vars.q_var)
261
265
  mx_th = 0
262
266
  for vp in vpathdicts[index]:
263
267
  for v2, vdiff, s in vpathdicts[index][vp]:
264
- if th[index] - vdiff > mx_th:
265
- mx_th = th[index] - vdiff
268
+ mx_th = max(mx_th, th[index] - vdiff)
266
269
  newpathsums = {}
267
270
  for up in vpathsums:
268
271
  inv_up = inv(up)
@@ -281,7 +284,8 @@ def schubmult(perm_dict, v, var2=_vars.var2, var3=_vars.var3, q_var=_vars.q_var)
281
284
  continue
282
285
  for v2, vdiff, s in vpathdicts[index][v]:
283
286
  newpathsums[up2][v2] = newpathsums[up2].get(
284
- v2, 0
287
+ v2,
288
+ 0,
285
289
  ) + s * sumval * elem_sym_func_q(
286
290
  th[index],
287
291
  index + 1,
@@ -325,14 +329,12 @@ def schubmult_db(perm_dict, v, var2=_vars.var2, var3=_vars.var3, q_var=_vars.q_v
325
329
  mx_th = 0
326
330
  for vp in vpathdicts[index]:
327
331
  for v2, vdiff, s in vpathdicts[index][vp]:
328
- if th[index] - vdiff > mx_th:
329
- mx_th = th[index] - vdiff
332
+ mx_th = max(mx_th, th[index] - vdiff)
330
333
  if index < len(th) - 1 and th[index] == th[index + 1]:
331
334
  mx_th1 = 0
332
335
  for vp in vpathdicts[index + 1]:
333
336
  for v2, vdiff, s in vpathdicts[index + 1][vp]:
334
- if th[index + 1] - vdiff > mx_th1:
335
- mx_th1 = th[index + 1] - vdiff
337
+ mx_th1 = max(mx_th1, th[index + 1] - vdiff)
336
338
  newpathsums = {}
337
339
  for up in vpathsums:
338
340
  newpathsums0 = {}
@@ -364,9 +366,7 @@ def schubmult_db(perm_dict, v, var2=_vars.var2, var3=_vars.var3, q_var=_vars.q_v
364
366
  if (up1, udiff1, mul_val1) not in newpathsums0:
365
367
  newpathsums0[(up1, udiff1, mul_val1)] = {}
366
368
  # newpathsums0[(up1, udiff1, mul_val1
367
- newpathsums0[(up1, udiff1, mul_val1)][v2] = (
368
- newpathsums0[(up1, udiff1, mul_val1)].get(v2, 0) + mulfac
369
- )
369
+ newpathsums0[(up1, udiff1, mul_val1)][v2] = newpathsums0[(up1, udiff1, mul_val1)].get(v2, 0) + mulfac
370
370
 
371
371
  for up1, udiff1, mul_val1 in newpathsums0:
372
372
  for v in vpathdicts[index + 1]:
@@ -414,7 +414,8 @@ def schubmult_db(perm_dict, v, var2=_vars.var2, var3=_vars.var3, q_var=_vars.q_v
414
414
  continue
415
415
  for v2, vdiff, s in vpathdicts[index][v]:
416
416
  newpathsums[up2][v2] = newpathsums[up2].get(
417
- v2, 0
417
+ v2,
418
+ 0,
418
419
  ) + s * sumval * elem_sym_func_q(
419
420
  th[index],
420
421
  index + 1,
@@ -460,28 +461,28 @@ def factor_out_q_keep_factored(poly):
460
461
  if str(poly).find("q") == -1:
461
462
  ret[1] = poly
462
463
  return ret
463
- elif poly in _vars.q_var:
464
+ if poly in _vars.q_var:
464
465
  ret[poly] = 1
465
466
  return ret
466
- elif isinstance(poly, Add):
467
+ if isinstance(poly, Add):
467
468
  ag = poly.args
468
469
  ret = factor_out_q_keep_factored(ag[0])
469
470
  for i in range(1, len(ag)):
470
471
  ret = sum_q_dict(ret, factor_out_q_keep_factored(ag[i]))
471
472
  return ret
472
- elif isinstance(poly, Mul):
473
+ if isinstance(poly, Mul):
473
474
  ag = poly.args
474
475
  ret = factor_out_q_keep_factored(ag[0])
475
476
  for i in range(1, len(ag)):
476
477
  ret = mul_q_dict(ret, factor_out_q_keep_factored(ag[i]))
477
478
  return ret
478
- elif isinstance(poly, Pow):
479
+ if isinstance(poly, Pow):
479
480
  base = poly.args[0]
480
481
  exponent = int(poly.args[1])
481
482
 
482
483
  ret = factor_out_q_keep_factored(base)
483
484
  ret0 = dict(ret)
484
- for i in range(exponent - 1):
485
+ for _ in range(exponent - 1):
485
486
  ret = mul_q_dict(ret, ret0)
486
487
 
487
488
  # print(f"exponent {exponent}")
@@ -530,11 +531,10 @@ def factor_out_q(poly):
530
531
  q_part *= key
531
532
  else:
532
533
  yz_part *= key
534
+ elif key in _vars.q_var:
535
+ q_part *= key
533
536
  else:
534
- if key in _vars.q_var:
535
- q_part *= key
536
- else:
537
- yz_part *= key
537
+ yz_part *= key
538
538
 
539
539
  ret[q_part] = ret.get(q_part, 0) + yz_part
540
540
  return ret
@@ -1,34 +1,36 @@
1
1
  import sys
2
+ from functools import cached_property
3
+
2
4
  import numpy as np
3
- from schubmult.schubmult_q_double._funcs import (
4
- schubmult,
5
- schubmult_db,
6
- # mult_poly,
7
- nil_hecke,
8
- factor_out_q_keep_factored,
9
- )
10
- from schubmult.schubmult_double import compute_positive_rep, posify, div_diff
11
- from symengine import expand, sympify, symarray
5
+ from symengine import expand, symarray, sympify
6
+
7
+ from schubmult._base_argparse import schub_argparse
12
8
  from schubmult.perm_lib import (
9
+ check_blocks,
10
+ code,
11
+ count_less_than,
12
+ inv,
13
13
  inverse,
14
+ is_parabolic,
15
+ longest_element,
14
16
  medium_theta,
15
- permtrim,
16
- inv,
17
17
  mulperm,
18
- uncode,
18
+ omega,
19
+ permtrim,
19
20
  q_var,
20
21
  q_vector,
21
22
  reduce_q_coeff,
22
- code,
23
23
  trimcode,
24
- longest_element,
25
- check_blocks,
26
- is_parabolic,
27
- count_less_than,
28
- omega,
24
+ uncode,
25
+ )
26
+ from schubmult.schubmult_double import compute_positive_rep, div_diff, posify
27
+ from schubmult.schubmult_q_double._funcs import (
28
+ factor_out_q_keep_factored,
29
+ # mult_poly,
30
+ nil_hecke,
31
+ schubmult,
32
+ schubmult_db,
29
33
  )
30
- from schubmult._base_argparse import schub_argparse
31
- from functools import cached_property
32
34
 
33
35
 
34
36
  class _gvars:
@@ -122,7 +124,7 @@ def _display_full(coeff_dict, args, formatter, posified=None, var2=_vars.var2, v
122
124
  while did_one:
123
125
  u2, v2, w2, qv, did_one = reduce_q_coeff(u2, v2, w2, qv)
124
126
  q_part2 = np.prod(
125
- [q_var[i + 1] ** qv[i] for i in range(len(qv))]
127
+ [q_var[i + 1] ** qv[i] for i in range(len(qv))],
126
128
  )
127
129
  if q_part2 == 1:
128
130
  # reduced to classical coefficient
@@ -160,21 +162,20 @@ def _display_full(coeff_dict, args, formatter, posified=None, var2=_vars.var2, v
160
162
  )
161
163
  val2 = val
162
164
  break
163
- else:
164
- print(
165
- f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {coeff_dict.get(perm,0)=}"
166
- )
167
- print(f"Exception: {e}")
168
- import traceback
165
+ print(
166
+ f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {val=} {coeff_dict.get(perm,0)=}",
167
+ )
168
+ print(f"Exception: {e}")
169
+ import traceback
169
170
 
170
- traceback.print_exc()
171
- exit(1)
171
+ traceback.print_exc()
172
+ exit(1)
172
173
  if not same and check and expand(val - val2) != 0:
173
174
  if mult:
174
175
  val2 = val
175
176
  else:
176
177
  print(
177
- f"error: value not equal; write to schubmult@gmail.com with the case {perms=} {perm=} {val2=} {coeff_dict.get(perm,0)=}"
178
+ f"error: value not equal; write to schubmult@gmail.com with the case {perms=} {perm=} {val2=} {coeff_dict.get(perm,0)=}",
178
179
  )
179
180
  exit(1)
180
181
  val = val2
@@ -184,11 +185,11 @@ def _display_full(coeff_dict, args, formatter, posified=None, var2=_vars.var2, v
184
185
  if ascode:
185
186
  raw_result_dict[tuple(trimcode(perm))] = val
186
187
  if formatter:
187
- print(f"{str(trimcode(perm))} {formatter(val)}")
188
+ print(f"{trimcode(perm)!s} {formatter(val)}")
188
189
  else:
189
190
  raw_result_dict[tuple(perm)] = val
190
191
  if formatter:
191
- print(f"{str(perm)} {formatter(val)}")
192
+ print(f"{perm!s} {formatter(val)}")
192
193
  return raw_result_dict
193
194
 
194
195
 
@@ -310,11 +311,10 @@ def main(argv=None):
310
311
 
311
312
  new_q_part = np.prod(
312
313
  [
313
- q_var[index + 1 - count_less_than(parabolic_index, index + 1)]
314
- ** qv[index]
314
+ q_var[index + 1 - count_less_than(parabolic_index, index + 1)] ** qv[index]
315
315
  for index in range(len(qv))
316
316
  if index + 1 not in parabolic_index
317
- ]
317
+ ],
318
318
  )
319
319
 
320
320
  try:
@@ -350,7 +350,7 @@ def main(argv=None):
350
350
  while did_one:
351
351
  u2, v2, w2, qv, did_one = reduce_q_coeff(u2, v2, w2, qv)
352
352
  q_part2 = np.prod(
353
- [q_var[i + 1] ** qv[i] for i in range(len(qv))]
353
+ [q_var[i + 1] ** qv[i] for i in range(len(qv))],
354
354
  )
355
355
  if q_part2 == 1:
356
356
  q_val_part = posify(
@@ -373,13 +373,11 @@ def main(argv=None):
373
373
  )
374
374
  except Exception as e:
375
375
  print(
376
- f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {q_part*q_val_part=} {coeff_dict.get(w_1,0)=}"
376
+ f"error; write to schubmult@gmail.com with the case {perms=} {perm=} {q_part*q_val_part=} {coeff_dict.get(w_1,0)=}",
377
377
  )
378
378
  print(f"Exception: {e}")
379
379
  exit(1)
380
- coeff_dict_update[w] = (
381
- coeff_dict_update.get(w, 0) + new_q_part * q_val_part
382
- )
380
+ coeff_dict_update[w] = coeff_dict_update.get(w, 0) + new_q_part * q_val_part
383
381
 
384
382
  coeff_dict = coeff_dict_update
385
383
 
@@ -395,4 +393,4 @@ def main(argv=None):
395
393
  if __name__ == "__main__":
396
394
  import sys
397
395
 
398
- main(sys.argv)
396
+ sys.exit(main(sys.argv))