Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arsenovic/279f46d84dd28bc371c0e941180839b8 to your computer and use it in GitHub Desktop.
Save arsenovic/279f46d84dd28bc371c0e941180839b8 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",
" "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"code_folding": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(1^e14) \n",
" [[5. 0. 0.]\n",
" [0. 1. 0.]\n",
" [0. 0. 1.]]\n",
"(1^e24) \n",
" [[1. 0. 0.]\n",
" [0. 5. 0.]\n",
" [0. 0. 1.]]\n",
"(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 = 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 = arccosh(5) \n",
" rho = 1/sqrt(cosh(r))\n",
" R = e**(r* B/2.)\n",
" S = rho*R\n",
" f = lambda x: down(S*up(x)*~S)\n",
" print(B,'\\n',f2Mat(f = f, I = I))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.3169578969248166"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arccosh(2)\n"
]
}
],
"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