schubmult 2.0.3__py3-none-any.whl → 3.0.0__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.
- schubmult/__init__.py +94 -1
- schubmult/perm_lib.py +233 -880
- schubmult/poly_lib/__init__.py +31 -0
- schubmult/poly_lib/poly_lib.py +244 -0
- schubmult/poly_lib/schub_poly.py +148 -0
- schubmult/poly_lib/variables.py +204 -0
- schubmult/rings/__init__.py +17 -0
- schubmult/rings/_quantum_schubert_polynomial_ring.py +788 -0
- schubmult/rings/_schubert_polynomial_ring.py +1006 -0
- schubmult/rings/_tensor_schub_ring.py +128 -0
- schubmult/rings/_utils.py +55 -0
- schubmult/{sage_integration → sage}/__init__.py +17 -15
- schubmult/{sage_integration → sage}/_fast_double_schubert_polynomial_ring.py +142 -220
- schubmult/{sage_integration → sage}/_fast_schubert_polynomial_ring.py +78 -72
- schubmult/sage/_indexing.py +51 -0
- schubmult/schub_lib/__init__.py +51 -0
- schubmult/{schubmult_double/_funcs.py → schub_lib/double.py} +618 -798
- schubmult/{schubmult_q/_funcs.py → schub_lib/quantum.py} +70 -72
- schubmult/schub_lib/quantum_double.py +954 -0
- schubmult/schub_lib/schub_lib.py +659 -0
- schubmult/{schubmult_py/_funcs.py → schub_lib/single.py} +58 -48
- schubmult/schub_lib/tests/__init__.py +0 -0
- schubmult/schub_lib/tests/legacy_perm_lib.py +946 -0
- schubmult/schub_lib/tests/test_vs_old.py +109 -0
- schubmult/scripts/__init__.py +0 -0
- schubmult/scripts/schubmult_double.py +378 -0
- schubmult/scripts/schubmult_py.py +84 -0
- schubmult/scripts/schubmult_q.py +109 -0
- schubmult/scripts/schubmult_q_double.py +207 -0
- schubmult/utils/__init__.py +0 -0
- schubmult/{_base_argparse.py → utils/argparse.py} +40 -11
- schubmult/utils/logging.py +16 -0
- schubmult/utils/parsing.py +20 -0
- schubmult/utils/perm_utils.py +135 -0
- schubmult/utils/test_utils.py +65 -0
- schubmult-3.0.0.dist-info/METADATA +1234 -0
- schubmult-3.0.0.dist-info/RECORD +41 -0
- {schubmult-2.0.3.dist-info → schubmult-3.0.0.dist-info}/WHEEL +1 -1
- schubmult-3.0.0.dist-info/entry_points.txt +5 -0
- schubmult/_tests.py +0 -9
- schubmult/sage_integration/_indexing.py +0 -51
- schubmult/schubmult_double/__init__.py +0 -22
- schubmult/schubmult_double/__main__.py +0 -5
- schubmult/schubmult_double/_script.py +0 -474
- schubmult/schubmult_py/__init__.py +0 -13
- schubmult/schubmult_py/__main__.py +0 -5
- schubmult/schubmult_py/_script.py +0 -96
- schubmult/schubmult_q/__init__.py +0 -13
- schubmult/schubmult_q/__main__.py +0 -5
- schubmult/schubmult_q/_script.py +0 -160
- schubmult/schubmult_q_double/__init__.py +0 -17
- schubmult/schubmult_q_double/__main__.py +0 -5
- schubmult/schubmult_q_double/_funcs.py +0 -540
- schubmult/schubmult_q_double/_script.py +0 -398
- schubmult-2.0.3.dist-info/METADATA +0 -455
- schubmult-2.0.3.dist-info/RECORD +0 -30
- schubmult-2.0.3.dist-info/entry_points.txt +0 -5
- {schubmult-2.0.3.dist-info → schubmult-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {schubmult-2.0.3.dist-info → schubmult-3.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
from functools import cache
|
2
|
+
|
3
|
+
import symengine
|
4
|
+
from symengine import expand
|
5
|
+
from sympy import Add, Basic, Dict, Expr, Mul, sympify
|
6
|
+
|
7
|
+
import schubmult.perm_lib as pl
|
8
|
+
|
9
|
+
|
10
|
+
def _tensor_product_of_dicts(d1, d2):
|
11
|
+
ret_dict = {}
|
12
|
+
for k1, v1 in d1.items():
|
13
|
+
this_dict = {}
|
14
|
+
for k2, v2 in d2.items():
|
15
|
+
this_dict[(k1, k2)] = v1 * v2
|
16
|
+
ret_dict = pl.add_perm_dict(ret_dict, this_dict)
|
17
|
+
return Dict(ret_dict)
|
18
|
+
|
19
|
+
|
20
|
+
class TensorBasisElement(Expr):
|
21
|
+
is_commutative = False
|
22
|
+
|
23
|
+
def __new__(cls, k1, k2, basis, tensor_symbol=" # "):
|
24
|
+
obj = Expr.__new__(cls, k1, k2, basis)
|
25
|
+
obj._elem1 = basis.basis1._from_dict({k1: 1})
|
26
|
+
obj._elem2 = basis.basis2._from_dict({k2: 1})
|
27
|
+
obj._tensor_symbol = tensor_symbol
|
28
|
+
return obj
|
29
|
+
|
30
|
+
def _sympystr(self, printer):
|
31
|
+
return f"{printer.doprint(self._elem1)}{self._tensor_symbol}{printer.doprint(self._elem2)}"
|
32
|
+
|
33
|
+
|
34
|
+
class TensorAlgebraElement(Expr):
|
35
|
+
# tensor ring
|
36
|
+
def __new__(cls, _dict, basis):
|
37
|
+
return TensorAlgebraElement.__xnew_cached__(cls, Dict(_dict), basis)
|
38
|
+
|
39
|
+
@staticmethod
|
40
|
+
def __xnew__(_class, _dict, basis):
|
41
|
+
_dict = Dict({k: v for k, v in _dict.items() if expand(v) != 0})
|
42
|
+
return Expr.__new__(_class, _dict, basis)
|
43
|
+
|
44
|
+
@property
|
45
|
+
def coeff_dict(self):
|
46
|
+
return self.args[0]
|
47
|
+
|
48
|
+
@staticmethod
|
49
|
+
@cache
|
50
|
+
def __xnew_cached__(_class, _dict, basis):
|
51
|
+
return TensorAlgebraElement.__xnew__(_class, _dict, basis)
|
52
|
+
|
53
|
+
@property
|
54
|
+
def basis(self):
|
55
|
+
return self.args[1]
|
56
|
+
|
57
|
+
def __mul__(self, other):
|
58
|
+
ret_dict = {}
|
59
|
+
for k1, v1 in self.coeff_dict.items():
|
60
|
+
for k2, v2 in other.coeff_dict.items():
|
61
|
+
dict1 = self.basis.basis1._from_dict({k1[0]: v1 * v2}) * self.basis.basis1._from_dict({k2[0]: 1})
|
62
|
+
dict2 = self.basis.basis2._from_dict({k1[1]: 1}) * self.basis.basis2._from_dict({k2[1]: 1})
|
63
|
+
ret_dict = pl.add_perm_dict(ret_dict, _tensor_product_of_dicts(dict1.coeff_dict, dict2.coeff_dict))
|
64
|
+
return self.basis._from_dict(ret_dict)
|
65
|
+
|
66
|
+
def __add__(self, other):
|
67
|
+
return self.basis._from_dict(pl.add_perm_dict(self.coeff_dict, other.coeff_dict))
|
68
|
+
|
69
|
+
def __sub__(self, other):
|
70
|
+
return self.basis._from_dict(pl.add_perm_dict(self.coeff_dict, {k: -v for k, v in other.coeff_dict.items()}))
|
71
|
+
|
72
|
+
@cache
|
73
|
+
def cached_sympystr(self, printer):
|
74
|
+
ret_list = [Mul(v, TensorBasisElement(k[0], k[1], self.basis)) for k, v in self.coeff_dict.items()]
|
75
|
+
return printer.doprint(Add(*ret_list))
|
76
|
+
|
77
|
+
def _sympystr(self, printer):
|
78
|
+
return self.cached_sympystr(printer)
|
79
|
+
|
80
|
+
def expand(self, **_):
|
81
|
+
return sympify(
|
82
|
+
symengine.Add(
|
83
|
+
*[v * symengine.sympify(self.basis.basis1._from_dict({k[0]: 1}).expand()) * symengine.sympify(self.basis.basis2._from_dict({k[1]: 1}).expand()) for k, v in self.coeff_dict.items()],
|
84
|
+
),
|
85
|
+
)
|
86
|
+
|
87
|
+
|
88
|
+
class TensorAlgebraBasis(Basic):
|
89
|
+
# tensor ring
|
90
|
+
def __new__(cls, basis1, basis2):
|
91
|
+
return TensorAlgebraBasis.__xnew_cached__(cls, basis1, basis2)
|
92
|
+
|
93
|
+
@staticmethod
|
94
|
+
def __xnew__(_class, basis1, basis2):
|
95
|
+
return Basic.__new__(_class, basis1, basis2)
|
96
|
+
|
97
|
+
@property
|
98
|
+
def basis1(self):
|
99
|
+
return self.args[0]
|
100
|
+
|
101
|
+
@property
|
102
|
+
def basis2(self):
|
103
|
+
return self.args[1]
|
104
|
+
|
105
|
+
@property
|
106
|
+
def coeff_dict(self):
|
107
|
+
return self.args[0]
|
108
|
+
|
109
|
+
def _from_dict(self, _dict):
|
110
|
+
return TensorAlgebraElement(_dict, self)
|
111
|
+
|
112
|
+
@staticmethod
|
113
|
+
@cache
|
114
|
+
def __xnew_cached__(_class, basis1, basis2):
|
115
|
+
return TensorAlgebraBasis.__xnew__(_class, basis1, basis2)
|
116
|
+
|
117
|
+
def call2(self, *args):
|
118
|
+
def calla(*a):
|
119
|
+
return TensorAlgebraElement._from_dict(_tensor_product_of_dicts(self.basis1(*args).coeff_dict, self.basis2(*a).coeff_dict))
|
120
|
+
|
121
|
+
return calla
|
122
|
+
|
123
|
+
def __call__(self, *args):
|
124
|
+
return self.call2(args)
|
125
|
+
|
126
|
+
|
127
|
+
# def TensorAlgebra_basis(Basic):
|
128
|
+
# pass
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from functools import cache
|
2
|
+
|
3
|
+
from symengine import sympify
|
4
|
+
|
5
|
+
from schubmult.poly_lib.variables import GeneratingSet
|
6
|
+
|
7
|
+
NoneVar = 1e10
|
8
|
+
ZeroVar = 0
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
@cache
|
15
|
+
def poly_ring(v: str):
|
16
|
+
if v == ZeroVar:
|
17
|
+
return tuple([sympify(0) for i in range(100)])
|
18
|
+
if v == NoneVar:
|
19
|
+
return tuple([sympify(0) for i in range(100)])
|
20
|
+
return GeneratingSet(str(v))
|
21
|
+
|
22
|
+
# def _schubifyit(func):
|
23
|
+
# @wraps(func)
|
24
|
+
# def wrapper(f, g):
|
25
|
+
# g = _sympify(g)
|
26
|
+
# if isinstance(g, Poly):
|
27
|
+
# return func(f, g)
|
28
|
+
# elif isinstance(g, Integer):
|
29
|
+
# g = f.from_expr(g, *f.gens, domain=f.domain)
|
30
|
+
# return func(f, g)
|
31
|
+
# elif isinstance(g, Expr):
|
32
|
+
# try:
|
33
|
+
# g = f.from_expr(g, *f.gens)
|
34
|
+
# except PolynomialError:
|
35
|
+
# if g.is_Matrix:
|
36
|
+
# return NotImplemented
|
37
|
+
# expr_method = getattr(f.as_expr(), func.__name__)
|
38
|
+
# result = expr_method(g)
|
39
|
+
# if result is not NotImplemented:
|
40
|
+
# sympy_deprecation_warning(
|
41
|
+
# """
|
42
|
+
# Mixing Poly with non-polynomial expressions in binary
|
43
|
+
# operations is deprecated. Either explicitly convert
|
44
|
+
# the non-Poly operand to a Poly with as_poly() or
|
45
|
+
# convert the Poly to an Expr with as_expr().
|
46
|
+
# """,
|
47
|
+
# deprecated_since_version="1.6",
|
48
|
+
# active_deprecations_target="deprecated-poly-nonpoly-binary-operations",
|
49
|
+
# )
|
50
|
+
# return result
|
51
|
+
# else:
|
52
|
+
# return func(f, g)
|
53
|
+
# else:
|
54
|
+
# return NotImplemented
|
55
|
+
# return wrapper
|
@@ -1,26 +1,28 @@
|
|
1
|
-
|
1
|
+
try:
|
2
|
+
import sage # noqa: F401
|
3
|
+
except ImportError:
|
4
|
+
raise ImportError("SageMath is not installed. Please install SageMath to use this module.")
|
2
5
|
|
3
|
-
|
4
|
-
from ._fast_schubert_polynomial_ring import (
|
5
|
-
FastSchubertPolynomialRing,
|
6
|
-
FastSchubertPolynomial,
|
7
|
-
FastSchubertPolynomialRing_base,
|
8
|
-
FastQuantumSchubertPolynomialRing,
|
9
|
-
)
|
10
6
|
from ._fast_double_schubert_polynomial_ring import (
|
11
|
-
FastDoubleSchubertPolynomialRing,
|
12
7
|
FastDoubleSchubertPolynomial,
|
8
|
+
FastDoubleSchubertPolynomialRing,
|
13
9
|
FastDoubleSchubertPolynomialRing_base,
|
14
|
-
FastQuantumDoubleSchubertPolynomialRing,
|
10
|
+
FastQuantumDoubleSchubertPolynomialRing,
|
11
|
+
)
|
12
|
+
from ._fast_schubert_polynomial_ring import (
|
13
|
+
FastQuantumSchubertPolynomialRing,
|
14
|
+
FastSchubertPolynomial,
|
15
|
+
FastSchubertPolynomialRing,
|
16
|
+
FastSchubertPolynomialRing_base,
|
15
17
|
)
|
16
18
|
|
17
19
|
__all__ = [
|
18
|
-
"FastSchubertPolynomialRing",
|
19
|
-
"FastSchubertPolynomial",
|
20
|
-
"FastSchubertPolynomialRing_base",
|
21
|
-
"FastDoubleSchubertPolynomialRing",
|
22
20
|
"FastDoubleSchubertPolynomial",
|
21
|
+
"FastDoubleSchubertPolynomialRing",
|
23
22
|
"FastDoubleSchubertPolynomialRing_base",
|
23
|
+
"FastQuantumDoubleSchubertPolynomialRing",
|
24
24
|
"FastQuantumSchubertPolynomialRing",
|
25
|
-
"
|
25
|
+
"FastSchubertPolynomial",
|
26
|
+
"FastSchubertPolynomialRing",
|
27
|
+
"FastSchubertPolynomialRing_base",
|
26
28
|
]
|