diff --git a/doc/C2pyMagicDemo_nda.ipynb b/doc/C2pyMagicDemo_nda.ipynb new file mode 100644 index 0000000..13b8c3e --- /dev/null +++ b/doc/C2pyMagicDemo_nda.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "eb187f68-7c62-4561-89a4-d8f0d10c2f32", + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext clair.c2py_magic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5cdfac15-114f-423c-8caa-5ed7aa5c4faa", + "metadata": {}, + "outputs": [], + "source": [ + "import clair.compiler as C\n", + "C.compile_instructions['nda'] = C.ClangInvocation(env_preamble = \"source $HOME/nda_install/share/nda/ndavars.sh\", cpp_preamble = \"#include \")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7f1865b8-2ff3-459b-806b-58a21dbb124b", + "metadata": {}, + "outputs": [], + "source": [ + "%%c2py -C nda\n", + "int f(nda::array const & x) { \n", + "return x[0];}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2a36f64c-0a85-4d83-880e-1bcd2fe6d75d", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "a = np.array([13,2])\n", + "print(f(a))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}