Skip to content

Instantly share code, notes, and snippets.

@arsenovic
Created December 28, 2020 15:01
Show Gist options
  • Save arsenovic/607a9e785a97af03df0d23def742cc64 to your computer and use it in GitHub Desktop.
Save arsenovic/607a9e785a97af03df0d23def742cc64 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from clifford.cga import CGA\n",
"N=2\n",
"cga = CGA(N)\n",
"locals().update(cga.blades)\n",
"\n",
"v2c = lambda x: float(x|e1)+ float(x|e2)*1j\n",
"c2v = lambda x: x.real*e1+ x.imag*e2\n",
"cr = lambda a,b,c,d: (a-b)*(c-d)/\\\n",
" ((a-d)*(c-b))"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-0.4436773975341889-0.03838763391718519j)"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w = np.random.rand(4)+ np.random.rand(4)*1j \n",
"cr(*w)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.44368 + (0.03839^e1234)"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a,b,c,d = map(cga.up, map(c2v, w))\n",
"1 + (a*c*d*b)(0,4)/\\\n",
" (a*d*c*b)(0,4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pretty close, but would be nice to remove the conj(), and make sense of expression"
]
}
],
"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