schubmult 1.2.4__tar.gz → 1.2.5__tar.gz

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 (28) hide show
  1. {schubmult-1.2.4 → schubmult-1.2.5}/PKG-INFO +1 -1
  2. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/perm_lib.py +13 -13
  3. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/schubmult_yz.py +64 -20
  4. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/PKG-INFO +1 -1
  5. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/requires.txt +1 -0
  6. {schubmult-1.2.4 → schubmult-1.2.5}/setup.py +3 -2
  7. {schubmult-1.2.4 → schubmult-1.2.5}/LICENSE +0 -0
  8. {schubmult-1.2.4 → schubmult-1.2.5}/README.md +0 -0
  9. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/__init__.py +0 -0
  10. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_double/__init__.py +0 -0
  11. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_double/__main__.py +0 -0
  12. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_double/schubmult_double.py +0 -0
  13. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_py/__init__.py +0 -0
  14. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_py/__main__.py +0 -0
  15. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_py/schubmult_py.py +0 -0
  16. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_py/schubmult_py_bak.py +0 -0
  17. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_py/schubmult_py_parallel.py +0 -0
  18. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/__init__.py +0 -0
  19. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/__main__.py +0 -0
  20. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/schubmult_yz_test.py +0 -0
  21. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/schubmult_yz_test2.py +0 -0
  22. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/schubmult_yz_test3.py +0 -0
  23. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult/schubmult_yz/schubmult_yz_try.py +0 -0
  24. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/SOURCES.txt +0 -0
  25. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/dependency_links.txt +0 -0
  26. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/entry_points.txt +0 -0
  27. {schubmult-1.2.4 → schubmult-1.2.5}/schubmult.egg-info/top_level.txt +0 -0
  28. {schubmult-1.2.4 → schubmult-1.2.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: schubmult
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: Computing Littlewood-Richardson coefficients of Schubert polynomials
5
5
  Home-page: https://github.com/matthematics/schubmult
6
6
  Author: Matt Samuel
@@ -13,6 +13,17 @@ def inv(perm):
13
13
  v = v[:itr] + v[itr + 1 :]
14
14
  return ans
15
15
 
16
+ def code(perm):
17
+ L = len(perm)
18
+ ret = []
19
+ v = [i for i in range(1,L+1)]
20
+ for i in range(L-1):
21
+ itr = bisect_left(v, perm[i])
22
+ ret += [itr]
23
+ v = v[:itr] + v[itr + 1 :]
24
+ return ret
25
+
26
+
16
27
  def mulperm(perm1,perm2):
17
28
  if len(perm1)<len(perm2):
18
29
  return [perm1[perm2[i]-1] if perm2[i]<=len(perm1) else perm2[i] for i in range(len(perm2))]
@@ -20,7 +31,7 @@ def mulperm(perm1,perm2):
20
31
  return [perm1[perm2[i]-1] for i in range(len(perm2))]+perm1[len(perm2):]
21
32
 
22
33
  def uncode(cd):
23
- cd2 = list(cd)
34
+ cd2 = [*cd]
24
35
  if cd2 == []:
25
36
  return [1,2]
26
37
  max_required = max([cd2[i]+i for i in range(len(cd2))])
@@ -28,20 +39,9 @@ def uncode(cd):
28
39
  fullperm = [i+1 for i in range(len(cd2)+1)]
29
40
  perm = []
30
41
  for i in range(len(cd2)):
31
- perm += [fullperm[cd2[i]]]
32
- fullperm.pop(cd2[i])
42
+ perm += [fullperm.pop(cd2[i])]
33
43
  perm += [fullperm[0]]
34
44
  return perm
35
-
36
-
37
- def code(perm):
38
- ret = []
39
- for i in range(len(perm)-1):
40
- ret += [0]
41
- for j in range(i+1,len(perm)):
42
- if perm[i]>perm[j]:
43
- ret[-1] += 1
44
- return ret
45
45
 
46
46
  def reversecode(perm):
47
47
  ret = []
@@ -2,6 +2,8 @@ from symengine import *
2
2
  import sys
3
3
  from functools import cache
4
4
  from itertools import chain
5
+ from cachetools import cached
6
+ from cachetools.keys import hashkey
5
7
  from schubmult.perm_lib import *
6
8
  import numpy as np
7
9
  import pulp as pu
@@ -10,9 +12,9 @@ import sympy
10
12
 
11
13
  n = 100
12
14
 
13
- var = symarray('x',n)
14
- var2 = symarray('y',n)
15
- var3 = symarray('z',n)
15
+ var = tuple(symarray('x',n).tolist())
16
+ var2 = tuple(symarray('y',n).tolist())
17
+ var3 = tuple(symarray('z',n).tolist())
16
18
 
17
19
 
18
20
  def forwardcoeff(u,v,perm,var2=var2,var3=var3):
@@ -22,8 +24,8 @@ def forwardcoeff(u,v,perm,var2=var2,var3=var3):
22
24
 
23
25
  w = mulperm(list(perm),vmun1)
24
26
  if inv(w) == inv(vmun1) + inv(perm):
25
- coeff_dict = {tuple(permtrim([*u])): 1}
26
- coeff_dict = schubmult(coeff_dict,muv,var2,var3)
27
+ #coeff_dict = {tuple(permtrim([*u])): 1}
28
+ coeff_dict = schubmult_one(tuple(permtrim([*u])),tuple(muv),var2,var3)
27
29
  return coeff_dict.get(tuple(permtrim(w)),0)
28
30
  return 0
29
31
 
@@ -110,6 +112,9 @@ def dualpieri(mu,v,w):
110
112
  dimen = 0
111
113
  monom_to_vec = {}
112
114
 
115
+ @cache
116
+ def schubmult_one(perm1,perm2,var2=var2,var3=var3):
117
+ return schubmult({perm1: 1},perm2,var2,var3)
113
118
 
114
119
  def schubmult(perm_dict,v,var2=var2,var3=var3):
115
120
  vn1 = inverse(v)
@@ -360,8 +365,8 @@ def compute_positive_rep(val,var2=var2,var3=var3,msg=False):
360
365
  notint = True
361
366
  if notint:
362
367
  frees = val.free_symbols
363
- var2list = var2.tolist()
364
- var3list = var3.tolist()
368
+ var2list = [*var2]
369
+ var3list = [*var3]
365
370
 
366
371
  for i in range(len(var2list)):
367
372
  symset = var2list[i].free_symbols
@@ -480,11 +485,34 @@ def is_split_two(u,v,w):
480
485
  return False, []
481
486
 
482
487
  def is_coeff_irreducible(u,v,w):
483
- return not will_formula_work(u,v) and not will_formula_work(v,u) and not one_dominates(u,w) and not is_reducible(v) and inv(w) - inv(u)>1 and not is_split_two(u,v,w)[0]
488
+ return not will_formula_work(u,v) and not will_formula_work(v,u) and not one_dominates(u,w) and not is_reducible(v) and inv(w) - inv(u)>1 and not is_split_two(u,v,w)[0] and len([i for i in code(v) if i !=0]) > 1
484
489
 
490
+ def is_hook(cd):
491
+ started = False
492
+ done = False
493
+ found_zero_after = False
494
+ for i in range(len(cd)):
495
+ if (done or found_zero_after) and cd[i]!=0:
496
+ return False
497
+ if cd[i] == 1 and not started:
498
+ started = True
499
+ if cd[i] > 1:
500
+ done = True
501
+ if started and cd[i] == 0:
502
+ found_zero_after = True
503
+ if started or done:
504
+ return True
505
+ return False
506
+
507
+ @cached(cache={}, key=lambda val, u2,v2,w2,var2=var2,var3=var3,msg=False: hashkey(u2,v2,w2,var2,var3,msg))
485
508
  def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
486
509
  if inv(u2)+inv(v2) - inv(w2)<=1:
487
510
  return expand(val)
511
+ cdv = code(v2)
512
+ if set(cdv) == set([0,1]):
513
+ return val
514
+ #if is_hook(cdv):
515
+ # print(f"Could've {cdv}")
488
516
  if expand(val) == 0:
489
517
  return 0
490
518
 
@@ -517,7 +545,21 @@ def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
517
545
  if not is_coeff_irreducible(u3,v3,w3):
518
546
  u, v, w = u3, v3, w3
519
547
  split_two_b, split_two = is_split_two(u,v,w)
520
- if (will_formula_work(v,u) or dominates(u,w)):
548
+
549
+ if len([i for i in code(v) if i !=0]) == 1:
550
+ cv = code(v)
551
+ for i in range(len(cv)):
552
+ if cv[i]!=0:
553
+ k = i+1
554
+ p = cv[i]
555
+ break
556
+ inv_u = inv(u)
557
+ r = inv(w) - inv_u
558
+ val = 0
559
+ w2 = w
560
+ hvarset = [w2[i] for i in range(min(len(w2),k))]+[i+1 for i in range(len(w2),k)] + [w2[b] for b in range(k,len(u)) if u[b]!=w2[b]]+[w2[b] for b in range(len(u),len(w2))]
561
+ val = elem_sym_poly(p-r,k+p-1,[-var3[i] for i in range(1,n)],[-var2[i] for i in hvarset])
562
+ elif (will_formula_work(v,u) or dominates(u,w)):
521
563
  val = dualcoeff(u,v,w,var2,var3)
522
564
  elif inv(w) - inv(u) == 1:
523
565
  a, b = -1, -1
@@ -701,9 +743,9 @@ def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
701
743
  if len(v3)<=3:
702
744
  v3 += [4]
703
745
  v3[2], v3[3] = v3[3], v3[2]
704
- coeff = permy(posify(schubmult({(1,3,2): 1},tuple(permtrim([*v3]))).get((2,4,3,1),0),(1,3,2),tuple(permtrim([*v3])),(2,4,3,1),var2,var3,msg),2)
746
+ coeff = permy(posify(schubmult_one((1,3,2),tuple(permtrim([*v3]))).get((2,4,3,1),0),(1,3,2),tuple(permtrim([*v3])),(2,4,3,1),var2,var3,msg),2)
705
747
  else:
706
- coeff = permy(schubmult({(1,3,2): 1},tuple(permtrim([*v3]))).get((2,4,1,3),0),2)
748
+ coeff = permy(schubmult_one((1,3,2),tuple(permtrim([*v3]))).get((2,4,1,3),0),2)
707
749
  tomul = sympify(coeff)
708
750
  toadd = 1
709
751
  for i in range(len(L[0])):
@@ -725,6 +767,8 @@ def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
725
767
  subs_dict3 = {var2[i]: varo[i] for i in range(len(varo))}
726
768
  toadd*=tomul.subs(subs_dict3)
727
769
  val += toadd
770
+ elif will_formula_work(u,v):
771
+ val = forwardcoeff(u,v,w,var2,var3)
728
772
  else:
729
773
  c01 = code(u)
730
774
  c02 = code(w)
@@ -757,26 +801,26 @@ def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
757
801
  else:
758
802
  break
759
803
  v3 = uncode(newc)
760
- coeff_dict = schubmult({u: 1},tuple(permtrim(uncode(elemc))),var2,var3)
804
+ coeff_dict = schubmult_one(u,tuple(permtrim(uncode(elemc))),var2,var3)
761
805
  val = 0
762
806
  for new_w in coeff_dict:
763
807
  tomul = coeff_dict[new_w]
764
- newval = schubmult({new_w: 1},tuple(permtrim(uncode(newc))),var2,var3).get(tuple(permtrim(list(w))),0)
765
- newval = posify(newval,new_w,permtrim(uncode(newc)),w,var2,var3,msg)
808
+ newval = schubmult_one(new_w,tuple(permtrim(uncode(newc))),var2,var3).get(tuple(permtrim(list(w))),0)
809
+ newval = posify(newval,new_w,tuple(permtrim(uncode(newc))),w,var2,var3,msg)
766
810
  val += tomul*shiftsubz(newval)
767
811
  elif c01[0] == c02[0] and c01[0] != 0:
768
812
  varl = c01[0]
769
813
  u3 = uncode([0] + c01[1:])
770
814
  w3 = uncode([0] + c02[1:])
771
815
  val = 0
772
- val = schubmult({tuple(permtrim(u3)): 1},tuple(permtrim(list(v))),var2,var3).get(tuple(permtrim(w3)),0)
773
- val = posify(val,u3,v,w3,var2,var3,msg)
816
+ val = schubmult_one(tuple(permtrim(u3)),tuple(permtrim(list(v))),var2,var3).get(tuple(permtrim(w3)),0)
817
+ val = posify(val,tuple(permtrim(u3)),tuple(permtrim(list(v))),tuple(permtrim(w3)),var2,var3,msg)
774
818
  for i in range(varl):
775
819
  val = permy(val,i+1)
776
820
  elif c1[0] == c2[0]:
777
821
  vp = pull_out_var(c1[0]+1,list(v))
778
- u3 = phi1(u)
779
- w3 = phi1(w)
822
+ u3 = tuple(permtrim(phi1(u)))
823
+ w3 = tuple(permtrim(phi1(w)))
780
824
  c3 = code(inverse(u3))
781
825
  c4 = code(inverse(w3))
782
826
  val = 0
@@ -785,8 +829,8 @@ def posify(val,u2,v2,w2,var2=var2,var3=var3,msg=False):
785
829
  for i in range(len(arr)):
786
830
  tomul*=var2[1] - var3[arr[i]]
787
831
 
788
- val2 = schubmult({tuple(permtrim(u3)): 1},tuple(permtrim(v3)),var2,var3).get(tuple(permtrim(w3)),0)
789
- val2 = posify(val2,u3,v3,w3,var2,var3,msg)
832
+ val2 = schubmult_one(tuple(permtrim(u3)),tuple(permtrim(v3)),var2,var3).get(tuple(permtrim(w3)),0)
833
+ val2 = posify(val2,u3,tuple(permtrim(v3)),w3,var2,var3,msg)
790
834
  val += tomul*shiftsub(val2)
791
835
  else:
792
836
  val2 = compute_positive_rep(val,var2,var3,msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: schubmult
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: Computing Littlewood-Richardson coefficients of Schubert polynomials
5
5
  Home-page: https://github.com/matthematics/schubmult
6
6
  Author: Matt Samuel
@@ -1,4 +1,5 @@
1
1
  PuLP>=2.7.0
2
+ cachetools
2
3
  numpy
3
4
  psutil
4
5
  symengine>=0.11.0
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text()
6
6
 
7
7
  setup(
8
8
  name="schubmult",
9
- version="1.2.4",
9
+ version="1.2.5",
10
10
  description="Computing Littlewood-Richardson coefficients of Schubert polynomials",
11
11
  long_description=long_description,
12
12
  long_description_content_type='text/markdown',
@@ -24,7 +24,8 @@ setup(
24
24
  "PuLP>=2.7.0",
25
25
  "symengine>=0.11.0",
26
26
  "sympy>=1.12",
27
- "psutil"
27
+ "psutil",
28
+ "cachetools"
28
29
  ],
29
30
  entry_points={"console_scripts": ["schubmult_py=schubmult.schubmult_py.__main__:main",
30
31
  "schubmult_double=schubmult.schubmult_double.__main__:main",
File without changes
File without changes
File without changes