Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lib/python3.12/site-packages/sympy/core/benchmarks/__init__.py +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_arit.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_assumptions.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_basic.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_expand.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_numbers.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_sympify.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_arit.py +43 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_assumptions.py +12 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_basic.py +15 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_expand.py +23 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_numbers.py +92 -0
- lib/python3.12/site-packages/sympy/core/benchmarks/bench_sympify.py +11 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_assumptions.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_basic.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_cache.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_compatibility.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_complex.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_constructor_postprocessor.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_containers.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_count_ops.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_diff.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_equal.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_eval.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_expand.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_exprtools.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_facts.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_kind.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_logic.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_match.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_multidimensional.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_operations.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_parameters.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_power.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_priority.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_random.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_rules.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_singleton.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_sorting.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_subs.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_symbol.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_sympify.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_traversal.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_truediv.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_var.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/physics/quantum/__pycache__/operatorordering.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/physics/quantum/__pycache__/qft.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sympy/physics/quantum/anticommutator.py +149 -0
lib/python3.12/site-packages/sympy/core/benchmarks/__init__.py
ADDED
|
File without changes
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (200 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_arit.cpython-312.pyc
ADDED
|
Binary file (1.77 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_assumptions.cpython-312.pyc
ADDED
|
Binary file (682 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_basic.cpython-312.pyc
ADDED
|
Binary file (770 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_expand.cpython-312.pyc
ADDED
|
Binary file (1.43 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_numbers.cpython-312.pyc
ADDED
|
Binary file (3.69 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/__pycache__/bench_sympify.cpython-312.pyc
ADDED
|
Binary file (596 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_arit.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core import Add, Mul, symbols
|
| 2 |
+
|
| 3 |
+
x, y, z = symbols('x,y,z')
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def timeit_neg():
|
| 7 |
+
-x
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def timeit_Add_x1():
|
| 11 |
+
x + 1
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def timeit_Add_1x():
|
| 15 |
+
1 + x
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def timeit_Add_x05():
|
| 19 |
+
x + 0.5
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def timeit_Add_xy():
|
| 23 |
+
x + y
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def timeit_Add_xyz():
|
| 27 |
+
Add(*[x, y, z])
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def timeit_Mul_xy():
|
| 31 |
+
x*y
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def timeit_Mul_xyz():
|
| 35 |
+
Mul(*[x, y, z])
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def timeit_Div_xy():
|
| 39 |
+
x/y
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def timeit_Div_2y():
|
| 43 |
+
2/y
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_assumptions.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core import Symbol, Integer
|
| 2 |
+
|
| 3 |
+
x = Symbol('x')
|
| 4 |
+
i3 = Integer(3)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def timeit_x_is_integer():
|
| 8 |
+
x.is_integer
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def timeit_Integer_is_irrational():
|
| 12 |
+
i3.is_irrational
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_basic.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core import symbols, S
|
| 2 |
+
|
| 3 |
+
x, y = symbols('x,y')
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def timeit_Symbol_meth_lookup():
|
| 7 |
+
x.diff # no call, just method lookup
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def timeit_S_lookup():
|
| 11 |
+
S.Exp1
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def timeit_Symbol_eq_xy():
|
| 15 |
+
x == y
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_expand.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core import symbols, I
|
| 2 |
+
|
| 3 |
+
x, y, z = symbols('x,y,z')
|
| 4 |
+
|
| 5 |
+
p = 3*x**2*y*z**7 + 7*x*y*z**2 + 4*x + x*y**4
|
| 6 |
+
e = (x + y + z + 1)**32
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def timeit_expand_nothing_todo():
|
| 10 |
+
p.expand()
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def bench_expand_32():
|
| 14 |
+
"""(x+y+z+1)**32 -> expand"""
|
| 15 |
+
e.expand()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def timeit_expand_complex_number_1():
|
| 19 |
+
((2 + 3*I)**1000).expand(complex=True)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def timeit_expand_complex_number_2():
|
| 23 |
+
((2 + 3*I/4)**1000).expand(complex=True)
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_numbers.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.numbers import Integer, Rational, pi, oo
|
| 2 |
+
from sympy.core.intfunc import integer_nthroot, igcd
|
| 3 |
+
from sympy.core.singleton import S
|
| 4 |
+
|
| 5 |
+
i3 = Integer(3)
|
| 6 |
+
i4 = Integer(4)
|
| 7 |
+
r34 = Rational(3, 4)
|
| 8 |
+
q45 = Rational(4, 5)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def timeit_Integer_create():
|
| 12 |
+
Integer(2)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def timeit_Integer_int():
|
| 16 |
+
int(i3)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def timeit_neg_one():
|
| 20 |
+
-S.One
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def timeit_Integer_neg():
|
| 24 |
+
-i3
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def timeit_Integer_abs():
|
| 28 |
+
abs(i3)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def timeit_Integer_sub():
|
| 32 |
+
i3 - i3
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def timeit_abs_pi():
|
| 36 |
+
abs(pi)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def timeit_neg_oo():
|
| 40 |
+
-oo
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def timeit_Integer_add_i1():
|
| 44 |
+
i3 + 1
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def timeit_Integer_add_ij():
|
| 48 |
+
i3 + i4
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def timeit_Integer_add_Rational():
|
| 52 |
+
i3 + r34
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def timeit_Integer_mul_i4():
|
| 56 |
+
i3*4
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def timeit_Integer_mul_ij():
|
| 60 |
+
i3*i4
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def timeit_Integer_mul_Rational():
|
| 64 |
+
i3*r34
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def timeit_Integer_eq_i3():
|
| 68 |
+
i3 == 3
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def timeit_Integer_ed_Rational():
|
| 72 |
+
i3 == r34
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def timeit_integer_nthroot():
|
| 76 |
+
integer_nthroot(100, 2)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def timeit_number_igcd_23_17():
|
| 80 |
+
igcd(23, 17)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def timeit_number_igcd_60_3600():
|
| 84 |
+
igcd(60, 3600)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def timeit_Rational_add_r1():
|
| 88 |
+
r34 + 1
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def timeit_Rational_add_rq():
|
| 92 |
+
r34 + q45
|
lib/python3.12/site-packages/sympy/core/benchmarks/bench_sympify.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core import sympify, Symbol
|
| 2 |
+
|
| 3 |
+
x = Symbol('x')
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def timeit_sympify_1():
|
| 7 |
+
sympify(1)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def timeit_sympify_x():
|
| 11 |
+
sympify(x)
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (195 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_assumptions.cpython-312.pyc
ADDED
|
Binary file (68.2 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_basic.cpython-312.pyc
ADDED
|
Binary file (22.4 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_cache.cpython-312.pyc
ADDED
|
Binary file (4.8 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_compatibility.cpython-312.pyc
ADDED
|
Binary file (532 Bytes). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_complex.cpython-312.pyc
ADDED
|
Binary file (24.8 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_constructor_postprocessor.cpython-312.pyc
ADDED
|
Binary file (4.87 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_containers.cpython-312.pyc
ADDED
|
Binary file (18.3 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_count_ops.cpython-312.pyc
ADDED
|
Binary file (13 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_diff.cpython-312.pyc
ADDED
|
Binary file (14.7 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_equal.cpython-312.pyc
ADDED
|
Binary file (3.59 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_eval.cpython-312.pyc
ADDED
|
Binary file (5.51 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_expand.cpython-312.pyc
ADDED
|
Binary file (35 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_exprtools.cpython-312.pyc
ADDED
|
Binary file (44.2 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_facts.cpython-312.pyc
ADDED
|
Binary file (17.4 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_kind.cpython-312.pyc
ADDED
|
Binary file (4.47 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_logic.cpython-312.pyc
ADDED
|
Binary file (15.2 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_match.cpython-312.pyc
ADDED
|
Binary file (53.8 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_multidimensional.cpython-312.pyc
ADDED
|
Binary file (2.51 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_operations.cpython-312.pyc
ADDED
|
Binary file (7 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_parameters.cpython-312.pyc
ADDED
|
Binary file (9.09 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_power.cpython-312.pyc
ADDED
|
Binary file (57.4 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_priority.cpython-312.pyc
ADDED
|
Binary file (7.95 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_random.cpython-312.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_rules.cpython-312.pyc
ADDED
|
Binary file (1.17 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_singleton.cpython-312.pyc
ADDED
|
Binary file (3.07 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_sorting.cpython-312.pyc
ADDED
|
Binary file (2.2 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_subs.cpython-312.pyc
ADDED
|
Binary file (77.8 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_symbol.cpython-312.pyc
ADDED
|
Binary file (27.1 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_sympify.cpython-312.pyc
ADDED
|
Binary file (57.6 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_traversal.cpython-312.pyc
ADDED
|
Binary file (8.09 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_truediv.cpython-312.pyc
ADDED
|
Binary file (1.74 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/core/tests/__pycache__/test_var.cpython-312.pyc
ADDED
|
Binary file (3.03 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/physics/quantum/__pycache__/operatorordering.cpython-312.pyc
ADDED
|
Binary file (10.8 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/physics/quantum/__pycache__/qft.cpython-312.pyc
ADDED
|
Binary file (10.2 kB). View file
|
|
|
lib/python3.12/site-packages/sympy/physics/quantum/anticommutator.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The anti-commutator: ``{A,B} = A*B + B*A``."""
|
| 2 |
+
|
| 3 |
+
from sympy.core.expr import Expr
|
| 4 |
+
from sympy.core.mul import Mul
|
| 5 |
+
from sympy.core.numbers import Integer
|
| 6 |
+
from sympy.core.singleton import S
|
| 7 |
+
from sympy.printing.pretty.stringpict import prettyForm
|
| 8 |
+
|
| 9 |
+
from sympy.physics.quantum.operator import Operator
|
| 10 |
+
from sympy.physics.quantum.dagger import Dagger
|
| 11 |
+
|
| 12 |
+
__all__ = [
|
| 13 |
+
'AntiCommutator'
|
| 14 |
+
]
|
| 15 |
+
|
| 16 |
+
#-----------------------------------------------------------------------------
|
| 17 |
+
# Anti-commutator
|
| 18 |
+
#-----------------------------------------------------------------------------
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class AntiCommutator(Expr):
|
| 22 |
+
"""The standard anticommutator, in an unevaluated state.
|
| 23 |
+
|
| 24 |
+
Explanation
|
| 25 |
+
===========
|
| 26 |
+
|
| 27 |
+
Evaluating an anticommutator is defined [1]_ as: ``{A, B} = A*B + B*A``.
|
| 28 |
+
This class returns the anticommutator in an unevaluated form. To evaluate
|
| 29 |
+
the anticommutator, use the ``.doit()`` method.
|
| 30 |
+
|
| 31 |
+
Canonical ordering of an anticommutator is ``{A, B}`` for ``A < B``. The
|
| 32 |
+
arguments of the anticommutator are put into canonical order using
|
| 33 |
+
``__cmp__``. If ``B < A``, then ``{A, B}`` is returned as ``{B, A}``.
|
| 34 |
+
|
| 35 |
+
Parameters
|
| 36 |
+
==========
|
| 37 |
+
|
| 38 |
+
A : Expr
|
| 39 |
+
The first argument of the anticommutator {A,B}.
|
| 40 |
+
B : Expr
|
| 41 |
+
The second argument of the anticommutator {A,B}.
|
| 42 |
+
|
| 43 |
+
Examples
|
| 44 |
+
========
|
| 45 |
+
|
| 46 |
+
>>> from sympy import symbols
|
| 47 |
+
>>> from sympy.physics.quantum import AntiCommutator
|
| 48 |
+
>>> from sympy.physics.quantum import Operator, Dagger
|
| 49 |
+
>>> x, y = symbols('x,y')
|
| 50 |
+
>>> A = Operator('A')
|
| 51 |
+
>>> B = Operator('B')
|
| 52 |
+
|
| 53 |
+
Create an anticommutator and use ``doit()`` to multiply them out.
|
| 54 |
+
|
| 55 |
+
>>> ac = AntiCommutator(A,B); ac
|
| 56 |
+
{A,B}
|
| 57 |
+
>>> ac.doit()
|
| 58 |
+
A*B + B*A
|
| 59 |
+
|
| 60 |
+
The commutator orders it arguments in canonical order:
|
| 61 |
+
|
| 62 |
+
>>> ac = AntiCommutator(B,A); ac
|
| 63 |
+
{A,B}
|
| 64 |
+
|
| 65 |
+
Commutative constants are factored out:
|
| 66 |
+
|
| 67 |
+
>>> AntiCommutator(3*x*A,x*y*B)
|
| 68 |
+
3*x**2*y*{A,B}
|
| 69 |
+
|
| 70 |
+
Adjoint operations applied to the anticommutator are properly applied to
|
| 71 |
+
the arguments:
|
| 72 |
+
|
| 73 |
+
>>> Dagger(AntiCommutator(A,B))
|
| 74 |
+
{Dagger(A),Dagger(B)}
|
| 75 |
+
|
| 76 |
+
References
|
| 77 |
+
==========
|
| 78 |
+
|
| 79 |
+
.. [1] https://en.wikipedia.org/wiki/Commutator
|
| 80 |
+
"""
|
| 81 |
+
is_commutative = False
|
| 82 |
+
|
| 83 |
+
def __new__(cls, A, B):
|
| 84 |
+
r = cls.eval(A, B)
|
| 85 |
+
if r is not None:
|
| 86 |
+
return r
|
| 87 |
+
obj = Expr.__new__(cls, A, B)
|
| 88 |
+
return obj
|
| 89 |
+
|
| 90 |
+
@classmethod
|
| 91 |
+
def eval(cls, a, b):
|
| 92 |
+
if not (a and b):
|
| 93 |
+
return S.Zero
|
| 94 |
+
if a == b:
|
| 95 |
+
return Integer(2)*a**2
|
| 96 |
+
if a.is_commutative or b.is_commutative:
|
| 97 |
+
return Integer(2)*a*b
|
| 98 |
+
|
| 99 |
+
# [xA,yB] -> xy*[A,B]
|
| 100 |
+
ca, nca = a.args_cnc()
|
| 101 |
+
cb, ncb = b.args_cnc()
|
| 102 |
+
c_part = ca + cb
|
| 103 |
+
if c_part:
|
| 104 |
+
return Mul(Mul(*c_part), cls(Mul._from_args(nca), Mul._from_args(ncb)))
|
| 105 |
+
|
| 106 |
+
# Canonical ordering of arguments
|
| 107 |
+
#The Commutator [A,B] is on canonical form if A < B.
|
| 108 |
+
if a.compare(b) == 1:
|
| 109 |
+
return cls(b, a)
|
| 110 |
+
|
| 111 |
+
def doit(self, **hints):
|
| 112 |
+
""" Evaluate anticommutator """
|
| 113 |
+
A = self.args[0]
|
| 114 |
+
B = self.args[1]
|
| 115 |
+
if isinstance(A, Operator) and isinstance(B, Operator):
|
| 116 |
+
try:
|
| 117 |
+
comm = A._eval_anticommutator(B, **hints)
|
| 118 |
+
except NotImplementedError:
|
| 119 |
+
try:
|
| 120 |
+
comm = B._eval_anticommutator(A, **hints)
|
| 121 |
+
except NotImplementedError:
|
| 122 |
+
comm = None
|
| 123 |
+
if comm is not None:
|
| 124 |
+
return comm.doit(**hints)
|
| 125 |
+
return (A*B + B*A).doit(**hints)
|
| 126 |
+
|
| 127 |
+
def _eval_adjoint(self):
|
| 128 |
+
return AntiCommutator(Dagger(self.args[0]), Dagger(self.args[1]))
|
| 129 |
+
|
| 130 |
+
def _sympyrepr(self, printer, *args):
|
| 131 |
+
return "%s(%s,%s)" % (
|
| 132 |
+
self.__class__.__name__, printer._print(
|
| 133 |
+
self.args[0]), printer._print(self.args[1])
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
def _sympystr(self, printer, *args):
|
| 137 |
+
return "{%s,%s}" % (
|
| 138 |
+
printer._print(self.args[0]), printer._print(self.args[1]))
|
| 139 |
+
|
| 140 |
+
def _pretty(self, printer, *args):
|
| 141 |
+
pform = printer._print(self.args[0], *args)
|
| 142 |
+
pform = prettyForm(*pform.right(prettyForm(',')))
|
| 143 |
+
pform = prettyForm(*pform.right(printer._print(self.args[1], *args)))
|
| 144 |
+
pform = prettyForm(*pform.parens(left='{', right='}'))
|
| 145 |
+
return pform
|
| 146 |
+
|
| 147 |
+
def _latex(self, printer, *args):
|
| 148 |
+
return "\\left\\{%s,%s\\right\\}" % tuple([
|
| 149 |
+
printer._print(arg, *args) for arg in self.args])
|