{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Using Julia from python\n", "\n", "This notebook provides a quick demonstration, how to use Julia's `eigen` function from python.\n", "\n", "First you need to install the Julia package from python. For this, for example, do the following:\n", "```bash\n", "pip install julia\n", "```\n", "Now you can run the subsequent code:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "# Launch Julia:\n", "from julia.api import Julia\n", "Julia(compiled_modules=False)\n", "\n", "# Import LinearAlgebra\n", "from julia import LinearAlgebra" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a = np.random.rand(10, 10)\n", "a = a + np.transpose(a) + np.eye(10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res = LinearAlgebra.eigen(a)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res.values" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res.vectors" ] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 2 }