From 190a5a3a6e457a7c1cf14f8dd122bc647542ede9 Mon Sep 17 00:00:00 2001 From: maximusron Date: Fri, 29 Sep 2023 14:15:21 +0530 Subject: [PATCH] Update eigen_demo --- notebooks/eigen_demo/eigen_demo.ipynb | 134 ++++++++++++++++---------- notebooks/eigen_demo/test.jpg | Bin 0 -> 13287 bytes 2 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 notebooks/eigen_demo/test.jpg diff --git a/notebooks/eigen_demo/eigen_demo.ipynb b/notebooks/eigen_demo/eigen_demo.ipynb index 0df61ead..e36c9665 100644 --- a/notebooks/eigen_demo/eigen_demo.ipynb +++ b/notebooks/eigen_demo/eigen_demo.ipynb @@ -11,16 +11,46 @@ { "cell_type": "code", "execution_count": 1, - "id": "610a5fef-82f3-487e-8ec7-53f3c5276505", + "id": "b172dcbe-7a72-4d1a-8e70-5955dec48735", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting package metadata (current_repodata.json): ...working... done\n", + "Solving environment: ...working... done\n", + "\n", + "\n", + "==> WARNING: A newer version of conda exists. <==\n", + " current version: 22.9.0\n", + " latest version: 23.7.4\n", + "\n", + "Please update conda by running\n", + "\n", + " $ conda update -n base -c conda-forge conda\n", + "\n", + "\n", + "\n", + "# All requested packages already installed.\n", + "\n", + "Retrieving notices: ...working... done\n" + ] + } + ], + "source": [ + "!conda install -y -c conda-forge eigen" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "01d6e223-c6bc-4255-bd2f-a2deb68ea06d", "metadata": {}, "outputs": [], "source": [ - "%%python\n", - "\n", - "import py, os, sys\n", - "from pytest import mark, raises\n", - "\n", - "cppyy.include('/opt/conda/envs/.venv/include/eigen3/Eigen/Dense')" + "#include \n", + "Cpp::AddIncludePath(\"/opt/conda/envs/.venv/include\");" ] }, { @@ -33,11 +63,13 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "815bd42b-024a-49c7-9557-fa5bfd8b4496", "metadata": {}, "outputs": [], "source": [ + "#include \"/opt/conda/envs/.venv/include/eigen3/Eigen/Dense\"\n", + "\n", "typedef Eigen::Matrix MatrixXd;\n", "\n", "Eigen::Vector2d a;\n", @@ -55,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "bca71004-dec4-4571-8a89-c9c9a54aaeee", "metadata": {}, "outputs": [], @@ -95,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "9b7e7fee-1edd-427c-a738-0cdf941200c1", "metadata": {}, "outputs": [], @@ -124,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "3775e315-652d-4dea-8729-e36549524b62", "metadata": {}, "outputs": [], @@ -132,7 +164,7 @@ "%%python\n", "\n", "for i in range(len(a)):\n", - " a[i] = i -1\n", + " a[i] = i - 1\n", "\n", "for i in range(len(b)):\n", " b[i] = i + 1\n", @@ -143,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "ca77d6ff-3428-4977-9072-9f2f2a904973", "metadata": {}, "outputs": [ @@ -184,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "a01b4c6d-88ea-4cb1-a17e-716e1d813b1b", "metadata": {}, "outputs": [], @@ -196,42 +228,44 @@ "res4d = cppyy.gbl.EigenOperations[\"Eigen::Vector4d\"].PerformOperations(c)" ] }, - { - "cell_type": "code", - "execution_count": 8, - "id": "239c40e4-7b92-40be-bd86-336779f88946", - "metadata": {}, - "outputs": [], - "source": [ - "// fig = plt.figure()\n", - "// ax = fig.add_subplot(111, projection='3d')\n", - "// ax.quiver(X, Y)\n", - "// ax.set_xlim([-1, 0.5])\n", - "// ax.set_ylim([-1, 1.5])\n", - "// ax.set_zlim([-1, 8])\n", - "// plt.show()" - ] - }, { "cell_type": "code", "execution_count": 9, - "id": "876beb2f-113e-4889-bd10-3e460d17181e", + "id": "680cc0d4-3d7b-441c-8f71-3acdf1b9b3e2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(1.0, 2.0, 3.0, 4.0)\n", - "(1.0, 1.0, 2.0, 0.5)\n" + "Requirement already satisfied: matplotlib in /opt/conda/envs/.venv/lib/python3.10/site-packages (3.8.0)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (1.1.1)\n", + "Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (0.11.0)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (4.42.1)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (1.4.5)\n", + "Requirement already satisfied: numpy<2,>=1.21 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (1.26.0)\n", + "Requirement already satisfied: packaging>=20.0 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (23.1)\n", + "Requirement already satisfied: pillow>=6.2.0 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (10.0.1)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (3.1.1)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from matplotlib) (2.8.2)\n", + "Requirement already satisfied: six>=1.5 in /opt/conda/envs/.venv/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n" ] } ], + "source": [ + "!pip install matplotlib" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "876beb2f-113e-4889-bd10-3e460d17181e", + "metadata": {}, + "outputs": [], "source": [ "%%python\n", "\n", "import matplotlib.pyplot as plt\n", - "from mpl_toolkits.mplot3d import Axes3D\n", "import numpy as np\n", "\n", "origin = [0, 0]\n", @@ -240,23 +274,25 @@ "np_res3 = np.array(list(res3d)) \n", "np_res4 = np.array(list(res4d)) \n", "\n", - "X, Y = np_res2, np_res3\n", - "\n", + "plt.quiver(*origin, *np_res2, color=['r'], scale=5)\n", + "plt.quiver(*origin, *np_res3, color=['b'], scale=5)\n", "\n", - " \n", - "ax.quiver(X, Y, Z, U, V, W)\n", - "ax.set_xlim([-1, 0.5])\n", - "ax.set_ylim([-1, 1.5])\n", - "ax.set_zlim([-1, 8])\n", "\n", - "plt.show()\n", - "\n", - " \n" + "plt.savefig(\"test.jpg\")\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "fc77ec01-bd62-4a87-b2e1-76141623fc5c", + "metadata": {}, + "source": [ + "" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "id": "4078ec69-0b4d-4350-8e6b-2d793bc27491", "metadata": {}, "outputs": [ @@ -286,14 +322,6 @@ "display_eigen(res3d, \"B\")\n", "display_eigen(res4d, \"C\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "65bb897c-8251-4898-a6ac-725f4dce8c07", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/notebooks/eigen_demo/test.jpg b/notebooks/eigen_demo/test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ff7a942273c7788c744632721e8d8be3c4009f33 GIT binary patch literal 13287 zcmeHN2Ut^Cx4j`i=m>@?9h53cFM@zb69GXw0tx~`q)Cw?0v1Z72q-FuK^N}bg0h-200M!4 z>$pDvI}9iSM1+J8LINTP1VT(qL_!87CnF^#W1v1t31wzvWnpGyVq)VGC|LEhH)`%E~PzD=91^C?YES^&%i*Vq!8 zfJX%aQ-QDz04o512ymnQI^h3)f$+fi1cVSGViHoEL-7#+4+I9|;e!bX@bPipKDgrm zJ{18qyO09mQSECG4ri#ae?%e?=edHnG&)_&Tp|{??h%vF($O<89zVg&!^S0Y_2g;vv*#~j z5J|}?scGpMnT4;5ic3n%$}8&X8ycIM-@R|??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