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}
Lie Groups
from liesym import SO, SU
so10 = SO(10)
so10.product(Matrix([[1,0,0,0,0]]),Matrix([[1,0,0,0,0]]))
[Matrix([[0, 0, 0, 0, 0]]),
Matrix([[0, 1, 0, 0, 0]]),
Matrix([[2, 0, 0, 0, 0]])]
so10.sym_product("10","45")
[120, 10, 320]
su3 = SU(3)
su.sym_product('3', '\\bar{3}')
[1, 8]
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
Formatt
.
├── Cargo.toml # rust config file
├── README.md # you are here
├── liesym # python module
├── notebooks # jupyter notebooks
├── rootsystem # native rust lie algebra root system
├── src # rust binding 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.6.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfce6121c113eb4ca37055b7ed8a12abbb2d6afcf415e1b1bc9e73d452f56cc9 |
|
MD5 | 75851d57202d24905d86df23feb57745 |
|
BLAKE2b-256 | 7034911273f3aacc25740b9d6e5fd9376917afad295cf8196b85bcf127cc0095 |
Hashes for liesym-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69746c07082cbbbbe815d3f08474447373dbb7e2f6f437faf18c3b969e99b8c6 |
|
MD5 | 9859ea2cb49d5147969d92387f35dc9a |
|
BLAKE2b-256 | 625f4626b03bf6d5b97fc60b4cc2b53428fd3c616efa02d02e871f51ddfc67b0 |
Hashes for liesym-0.6.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5998262c2a723d4bfc73f28b50954cb913a7f68ce536bec4c4efbd411047144b |
|
MD5 | f405f5cbe979e84c8ea76f7802b7ba04 |
|
BLAKE2b-256 | 695eb404d1681709eeb6728b0d17f40dbb7f33d33921aa0968fa76298d245a54 |
Hashes for liesym-0.6.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bd0054dcf2264089d3f3d2d472616b8c6eb846a3b6149e0c301aaa4f81e4994 |
|
MD5 | f9ad2854e0501746cda1db7b690e26f5 |
|
BLAKE2b-256 | 0820919b6c6cea4f3cf7086e31f9ef152ae766fe9e17767fdeb80e763205f2d6 |
Hashes for liesym-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a94a6b37a23f7a71a0e0495aab097c1be5bfe43879f3bd7fd0310529980b56b2 |
|
MD5 | 55ee22b91daa42c7b5e6aa7b336a2bcb |
|
BLAKE2b-256 | f3a8975046e85828e61b65ccfcdb14d0d7d60d8c836bc728025c346e2bdd582a |
Hashes for liesym-0.6.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c997c1d0c585de5d2996e887d2516bb9d653c8b9ef7b488f4f4c98e26b30c3e1 |
|
MD5 | e53158182bff268fec3d74685454c410 |
|
BLAKE2b-256 | 853e9fd9118f9fcb0573b85e352f126cf13d56a38d957264eae754c508733e9f |
Hashes for liesym-0.6.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bcb33a20a64a2e8c7b7682d5dda2205299f5dce9e78cad25583bc32faef5a83 |
|
MD5 | c6674f9c94482ef5752a0e8b75eded42 |
|
BLAKE2b-256 | cc9d191afe13c6f282e6cdd76282460679e625d7a5f468995b70092800142809 |
Hashes for liesym-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a3d1facae12581dacc1f76d16480cf528a40d078287f3dbf25ff958eaf5bcd |
|
MD5 | 9c102c9ccdbbedd4d28a730906e9f36a |
|
BLAKE2b-256 | 27aab840a9132f36d5a1465c349b8195595ff95f7ee8756daa2d90c44955dfd7 |
Hashes for liesym-0.6.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6378d47e8dc790ea87f1dfefa3594234d8c05e6a38be6a461f79784b4b8afaf |
|
MD5 | 0d257011c8cfdf988e5fd527cb3d223b |
|
BLAKE2b-256 | 54837001a61f9a26c547613bf9d7218539ac7ca13a37befac08790f5c69d4100 |