Created
November 18, 2017 14:13
-
-
Save hugohadfield/c3d044c1aeb0d9922e4da690151c0611 to your computer and use it in GitHub Desktop.
Added jitting of layout comparison, small but easy gains
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": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import clifford as cf\n", | |
"import numpy as np\n", | |
"import timeit\n", | |
"layout,blades = cf.Cl(5)\n", | |
"n_dims = len(layout.blades)+1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def setup(n_dims):\n", | |
" a = cf.MultiVector(layout,value=np.random.rand(n_dims))\n", | |
" b = cf.MultiVector(layout,value=np.random.rand(n_dims))\n", | |
" return (a, b)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"5.86 µs ± 243 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%%timeit a,b = setup(n_dims)\n", | |
"a*b" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"layout,blades = cf.Cl(4,1)\n", | |
"n_dims = len(layout.blades)+1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def setup(n_dims):\n", | |
" a = cf.MultiVector(layout,value=np.random.rand(n_dims))\n", | |
" b = cf.MultiVector(layout,value=np.random.rand(n_dims))\n", | |
" return (a, b)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"5.85 µs ± 104 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%%timeit a,b = setup(n_dims)\n", | |
"a*b" | |
] | |
}, | |
{ | |
"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.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment