Skip to content

Instantly share code, notes, and snippets.

@mariogeiger
Created November 11, 2022 02:23
Show Gist options
  • Save mariogeiger/2bae912a87256b3e382e40b53eba9731 to your computer and use it in GitHub Desktop.
Save mariogeiger/2bae912a87256b3e382e40b53eba9731 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The algebra is\n",
"[[[ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 1. 0. 0. 0.]\n",
" [ 0. -1. -0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 1.]\n",
" [ 0. 0. 0. 0. -1. 0.]]\n",
"\n",
" [[ 0. 0. -1. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 1. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. -1.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 1. 0. 0.]]\n",
"\n",
" [[ 0. 1. 0. 0. 0. 0.]\n",
" [-1. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 1. 0.]\n",
" [ 0. 0. 0. -1. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]]\n",
"\n",
" [[ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 1.]\n",
" [ 0. 0. 0. 0. -1. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]]\n",
"\n",
" [[ 0. 0. 0. 0. 0. -1.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 1. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]]\n",
"\n",
" [[ 0. 0. 0. 0. 1. 0.]\n",
" [ 0. 0. 0. -1. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0.]]]\n",
"Found 1 solutions for vector x vector -> scalar\n",
"[[[0.577 0. 0. 0. ]\n",
" [0. 0.577 0. 0. ]\n",
" [0. 0. 0.577 0. ]\n",
" [0. 0. 0. 0. ]]]\n",
"Found 1 solutions for vector x vector -> vector\n",
"[[[0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]]\n",
"\n",
" [[0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]]\n",
"\n",
" [[0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]\n",
" [0. 0. 0. 0. ]]\n",
"\n",
" [[1.155 0. 0. 0. ]\n",
" [0. 1.155 0. 0. ]\n",
" [0. 0. 1.155 0. ]\n",
" [0. 0. 0. 0. ]]]\n"
]
}
],
"source": [
"import numpy as np\n",
"from lie_nn import GenericRep\n",
"from lie_nn.irreps import SO3Rep\n",
"from lie_nn.util import round_to_sqrt_rational\n",
"np.set_printoptions(precision=3, suppress=True)\n",
"\n",
"# Generators of rotations\n",
"r = SO3Rep(1).continuous_generators()\n",
"r = np.pad(r, ((0, 0), (0, 1), (0, 1))) # pad with zeros to make it 4 dimensional\n",
"\n",
"# Generators of translations\n",
"t = np.array(\n",
" [\n",
" [\n",
" [0, 0, 0, 1],\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 0.0],\n",
" ],\n",
" [\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 1],\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 0.0],\n",
" ],\n",
" [\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 0],\n",
" [0, 0, 0, 1],\n",
" [0, 0, 0, 0.0],\n",
" ],\n",
" ]\n",
")\n",
"\n",
"# Generators of rotations and translations\n",
"X = np.concatenate([r, t], axis=0)\n",
"\n",
"\n",
"# Create generic representations (this will automatically compute the algebra and test it)\n",
"vector = GenericRep.from_generators(X, round_fn=round_to_sqrt_rational)\n",
"if vector is not None:\n",
" print(\"The algebra is\")\n",
" print(vector.algebra())\n",
"\n",
"scalar = GenericRep(\n",
" A=vector.algebra(),\n",
" X=np.zeros((6, 1, 1)),\n",
" H=np.zeros((0, 1, 1)),\n",
")\n",
"\n",
"# Compute Clebsch-Gordan coefficients to go from vector x vector -> scalar\n",
"cg = GenericRep.clebsch_gordan(vector, vector, scalar, round_fn=round_to_sqrt_rational)\n",
"print(f\"Found {cg.shape[0]} solutions for vector x vector -> scalar\")\n",
"for c in cg:\n",
" print(np.moveaxis(c, -1, 0))\n",
"\n",
"cg = GenericRep.clebsch_gordan(vector, vector, vector, round_fn=round_to_sqrt_rational)\n",
"print(f\"Found {cg.shape[0]} solutions for vector x vector -> vector\")\n",
"for c in cg:\n",
" print(np.moveaxis(c, -1, 0))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There is no cross-product $x \\wedge y$ in the Euclidean group !! Weird, isn't it ??"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.8 ('base')",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "f26faf9d33dc8b83cd077f62f5d9010e5bc51611e479f12b96223e2da63ba699"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment