Sympy Lie Algebra extensions powered by rust.
Project description
liesym
Lie Algebras using Sympy and backend powered by Rust's pyO3 and ndarray
Overview
In an effort to supply python with the same computer algebra software (CAS)
capabilities, SymPy was written. This python
library is well written and allows an open source alternative to proprietary
choices like Mathematica/WolframLanguage and Maple. Due to the nature of
how SymPy was written, certain symbolic calculation can be extremely unoptimized
in python. Even using numpy could offer little speed ups as it is not geared
towards rational numbers (fractions). Sympy does currently offer a liealgebras
module, but due to the performance limitations, certain tradeoffs had to be
made such as locking the basis for the classic lie algebras in favor of speed.
This is a fair trade off, but would require anyone using a different basis
to hand calculate the representations of the algebra all over again.
An alternative to solve this problem would be to use a compiled
backend that supports generics (and isn't a pain to build with python).
Rust has good python binding support through py03 and allows easy communication through numpy using rust-numpy as well as numpy like api inside rust using ndarray.
Install
pip install liesym
Examples
See also example notebook
import liesym as ls
from sympy import Matrix
Cartan Matrix
A3 = ls.A(3)
print(A3.cartan_matrix)
Matrix([[2, -1, 0], [-1, 2, -1], [0, -1, 2]])
Positive Roots
A3.positive_roots
[Matrix([[1, 0, 1]]),
Matrix([[-1, 1, 1]]),
Matrix([[1, 1, -1]]),
Matrix([[-1, 2, -1]]),
Matrix([[0, -1, 2]]),
Matrix([[2, -1, 0]])]
Simple Roots
A3.simple_roots
[Matrix([[1, -1, 0, 0]]), Matrix([[0, 1, -1, 0]]), Matrix([[0, 0, 1, -1]])]
Fundamental Weights
A3.fundamental_weights # Orthogonal Basis
[Matrix([[3/4, -1/4, -1/4, -1/4]]),
Matrix([[1/2, 1/2, -1/2, -1/2]]),
Matrix([[1/4, 1/4, 1/4, -3/4]])]
Dimension of representation
print("Dim | Rep (Omega)")
print("---------")
for i in A3.fundamental_weights:
print(" ", A3.dim(i), "|", A3.to_omega(i))
Dim | Rep (Omega)
---------
4 | Matrix([[1, 0, 0]])
6 | Matrix([[0, 1, 0]])
4 | Matrix([[0, 0, 1]])
Name of rep
Commonly in literature (especially physics), names of the reps are the dimension rather than the matrix rep.
A3.dim_name(Matrix([[0, 0, 1]]))
$\displaystyle \bar{4}$
A3.irrep_lookup(r"\bar{4}")
$\displaystyle \left[\begin{matrix}0 & 0 & 1\end{matrix}\right]$
Tensor product decomps
The decomp of irreps from a product of irreps
results = A3.tensor_product_decomposition([
Matrix([[1,0,0]]),
Matrix([[1,0,0]]),
])
for i in results:
print("Rep:", A3.to_omega(i),"Dim Name:", A3.dim_name(i))
Rep: Matrix([[0, 1, 0]]) Dim Name: 6
Rep: Matrix([[2, 0, 0]]) Dim Name: \bar{10}
Repo Layout
If you are new to how python and rust are tied together with py03, below
is a simple top level layout of this repository. When the rust code is
build into a lib binary, it is put into into ./liesym
so it can be
imported in ./liesym/__init__.py
.
├── Cargo.toml # rust config file
├── README.md # you are here
├── liesym # python module
├── notebooks # jupyter notebooks
├── src # rust source code
├── tests # python tests
└── ... # other stuff
Docs
Read the documentation at https://npapapietro.github.io/liesym/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for liesym-0.5.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0edbb2cdd87dc4ca92782da0fd18c4bcc197743199bb18071aab40cb926dc9f |
|
MD5 | e043aabd52ffed83ec829293f84fc978 |
|
BLAKE2b-256 | fa0e099ef978afcabc9c52de67eedc37d1bcffa8597f86f0f40fa2522b65debd |
Hashes for liesym-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9d7d287ed400074449475ddcf945826c74d0868cb97440665e19e824d5db0ce |
|
MD5 | f3d3224ec729815ce4c1220ebf2cbae1 |
|
BLAKE2b-256 | 5261165bbfd5f9bd0482cc79f721f525726a62db502cc007c731f47dcf7d219b |
Hashes for liesym-0.5.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0b231e5c7323fbefd1b2650d0f3cf0ddd04de058bab066df379fdcf87ebf6a8 |
|
MD5 | 384920541ea8f251e51b06f041f463c1 |
|
BLAKE2b-256 | 2fe5c14e86fef03974f37d5bedbaf7ae7d8c23f359d3fd7d83a851d4fd190556 |
Hashes for liesym-0.5.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d0c2bf4218b6ff7ed5885701eec20c55fde572106856ade9449a1f7eb8e5cb9 |
|
MD5 | 4748c66bb32a95cfad3b6098117c0bdc |
|
BLAKE2b-256 | 05a74a5af3ee98557b31282f8a577d064eee2f8908ca0e4787dd935897f435d9 |
Hashes for liesym-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 270b5fa69073c1992c0b68eae41d481048a93001b10e1e0ff2cf7abeb4059370 |
|
MD5 | 4f45ba5818065e0d6934a7d5505b13e9 |
|
BLAKE2b-256 | f5231c1de87d4bb17006818e99ee2478e141b3221aeae38506ee2bf59a3fdddc |
Hashes for liesym-0.5.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de9f7e61513b26936a8ed289042912121734c3ee23875295f1370b1f7138bc4 |
|
MD5 | fa7ca24d7d42ef909f99d73bb01a8e22 |
|
BLAKE2b-256 | 825acc2a7ce0de64bb15c622750f69abf57f9704d24aa2f6253d983517498e2c |
Hashes for liesym-0.5.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f4cc6e347457367b981d9e8e9cdab3976f355338fe0dd84769ff9067d3aca3 |
|
MD5 | 4f759940bbc892ebe7a933605fdbd429 |
|
BLAKE2b-256 | e2008d0d513dceb8c3ea8ceac7bf9140ec4aef9698ba66f3e7d461af5026743f |
Hashes for liesym-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a0670ad8bfd9d412d949048b9256ed592198fbc308011f852a71d0e3df631f3 |
|
MD5 | 535106fe699ebfd4186aff4849d197e3 |
|
BLAKE2b-256 | 9378ecc59e6bbf68ec0ac2124a4fa2291da442ad2906ccc224c8c9178191e11b |
Hashes for liesym-0.5.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 295d4cf486285c6ea70282f21e2ebaa898a77bf51430bfdd5ea221e789cb2ad7 |
|
MD5 | a989c251da02652e3f7fa97a14d483e9 |
|
BLAKE2b-256 | cfea9449d9eb8a5199ff7feb7bd6838e920240c6b75b97ee25f3671540fa6430 |