Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arsenovic/5c87152f2393809dcc7dc4d3ef5a4708 to your computer and use it in GitHub Desktop.
Save arsenovic/5c87152f2393809dcc7dc4d3ef5a4708 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Directional Scaling"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The code below is a dumb trial-and-error way to determine a mapping which implements directional scaling through spinors. This is done by \n",
" \n",
" 1. create a algebra and a representation (higher) algebra \n",
" 1. guess a map `up()` and map `down()` \n",
" 2. Take a orthonormal frame map it up\n",
" 3. take each bivectors in repr space and spin the frame \n",
" 4. map the resultant frame down and convert frame into matrices\n",
" 5. repeat for all bivectors\n",
" \n",
" \n",
" \n",
" So far this seems to work, \n",
" \n",
" Given $G(n,0)$, create $G(n,1)$ with added dimenion given by $e_0$\n",
" \n",
" \n",
" $$\n",
" \\text{up(x)} = e_0/x\\\\\n",
" \\text{down}(X) = -e_0^2 /(X\\cdot e_0)\n",
" $$\n",
" \n",
" a directional scaling of amount $r$ along $e_i$ is given by the spinor, \n",
" \n",
" $$S = \\sqrt{r}e^{\\frac{\\text{arccosh}{(r)}}{2}\\quad e_i\\wedge e_0}$$ \n",
" \n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"code_folding": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"generator= (1^e14) \n",
" [[5. 0. 0.]\n",
" [0. 1. 0.]\n",
" [0. 0. 1.]]\n",
"generator= (1^e24) \n",
" [[1. 0. 0.]\n",
" [0. 5. 0.]\n",
" [0. 0. 1.]]\n",
"generator= (1^e34) \n",
" [[1. 0. 0.]\n",
" [0. 1. 0.]\n",
" [0. 0. 5.]]\n"
]
}
],
"source": [
"from clifford import Cl\n",
"from clifford.tools import mat2Frame, frame2Mat\n",
"from pylab import * \n",
"\n",
"\n",
"N = 3\n",
"l,b = Cl(N,1)\n",
"locals().update(b)\n",
"\n",
"I_ = l.pseudoScalar # projection space\n",
"e_ = I_.basis()[-1] # the projection vector\n",
"I = I_/e_ # the original space\n",
"\n",
"###### up/down projections ################### \n",
"up = lambda x: e_/x \n",
"down = lambda X: -(e_**2)/(X|e_)\n",
" \n",
"# sanity test of up/down \n",
"x = I.layout.randomV()(I)\n",
"assert(down(up(x)) ==x)\n",
"\n",
"def f2Mat(f,I):\n",
" '''\n",
" convert a geometric function to a matrix. \n",
" b = f(a) for a = ortho-normal frame of I.\n",
" return matrix version of b\n",
" '''\n",
" A = I.basis()\n",
" B = [f(x) for x in A]\n",
" mat, dum = frame2Mat(B=B, I=I)\n",
" return mat \n",
" \n",
"# sort bivectors by those in/out of I\n",
"Bin = [k for k in l.blades_of_grade(2) if k|I != 0]\n",
"Bout = [k for k in l.blades_of_grade(2) if k|I == 0 ]\n",
"\n",
"for B in Bout: # (we know what Bin do already)\n",
" ############ construct the spinor ###############\n",
" r =5\n",
" rho = 1/sqrt(r)\n",
" R = e**(arccosh(r)* B/2.)\n",
" S = rho*R\n",
" f = lambda x: down(S*up(x)*~S)\n",
" print('generator =',B,'\\n',f2Mat(f = f, I = I))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"toc_cell": false,
"toc_position": {},
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment