Created
October 15, 2019 13:15
-
-
Save hugohadfield/86f4ecce95084304f190f4740c17247e to your computer and use it in GitHub Desktop.
basic_cga_benchmarkipynb
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": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "from clifford import MVArray\nfrom clifford.g3c import *\nimport numpy as np\nimport itertools\n\ndef chunk(it, n):\n try:\n while True:\n xs = [] # The buffer to hold the next n items\n for _ in range(n):\n xs.append(next(it))\n yield xs\n except StopIteration:\n yield xs", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%prun -s cumulative\n\n# Generate 9999 random conformal points\nP = MVArray([up(np.random.randn()*e1 + np.random.randn()*e2 + np.random.randn()*e3) for _ in range(9999)])\n\n# Translate them with a rotor\nt = np.random.randn()*e1 + np.random.randn()*e2 + np.random.randn()*e3\nR = (1 - 0.5*t*einf).normal()\nP2 = R*P*~R\n\n# Wedge them together\nP2 = MVArray([MVArray(X).op()(3).normal() for X in chunk(P2.__iter__(), 3) if len(X) > 0])\nP2", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"version": 3, | |
"name": "ipython" | |
}, | |
"nbconvert_exporter": "python", | |
"name": "python", | |
"pygments_lexer": "ipython3", | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"version": "3.5.2" | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "basic_cga_benchmarkipynb", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment