Created
December 27, 2020 14:07
-
-
Save arsenovic/fbfcc9b1a12a668061657f8e7db3ed4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## An procedure to map matrices into spinors " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": { | |
"code_folding": [] | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-(1.0^e13)" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from clifford import Cl,Frame,eps\n", | |
"from clifford.tools import mat2Frame\n", | |
"from clifford.tools import orthoFrames2Versor as of2v\n", | |
"from numpy.random import rand\n", | |
"import numpy as np \n", | |
"\n", | |
"\n", | |
"## all of these are inputs\n", | |
"mat = np.array([[1,2],[0,1]]) # matrix of interest\n", | |
"\n", | |
"l,b = Cl(2,1)\n", | |
"locals().update(b)\n", | |
"I = e12 # ps for base space \n", | |
"up = lambda x: (x^e3) # map into repr space\n", | |
"###\n", | |
"\n", | |
"b,na = mat2Frame(mat, I=I)\n", | |
"a,na = mat2Frame(np.eye(len(mat)),I=I)\n", | |
"B = list(map(up,b))\n", | |
"A = list(map(up,a))\n", | |
"# test for orthogonality between A,B in repr space. \n", | |
"#assert(Frame(A).is_innermorphic_to(Frame(B))) # might need omoh\n", | |
"V,rs = of2v(B=B, A=A)\n", | |
"V" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Test and troubleshoot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"fails\n", | |
"(1.0^e13) --> -(1.0^e13)\n", | |
"(2.0^e13) + (1.0^e23) --> (1.0^e23)\n" | |
] | |
} | |
], | |
"source": [ | |
"from clifford import eps \n", | |
"if max([abs((V*k*~V) - l) for k,l in zip(A,B)]) < eps():\n", | |
" print('works')\n", | |
"else:\n", | |
" print('fails')\n", | |
" for k,l in zip(A,B):\n", | |
" print(l,'-->', V*k*~V)\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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