{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "a54ab4ef",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "435114bb",
            "cell_type": "markdown",
            "source": "Suppose we would like to use '?lange' routine which computes the selected\nnorm of an array. We pass our array in order to get the correct 'lange'\nflavor.\n",
            "metadata": {}
        },
        {
            "id": "481e07a2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nimport scipy.linalg as LA\nrng = np.random.default_rng()",
            "outputs": []
        },
        {
            "id": "56304809",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "a = rng.random((3,2))\nx_lange = LA.get_lapack_funcs('lange', (a,))\nx_lange.typecode",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "'d'"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "377c1d75",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x_lange = LA.get_lapack_funcs('lange',(a*1j,))\nx_lange.typecode",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "'z'"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "26b4a8bc",
            "cell_type": "markdown",
            "source": "Several LAPACK routines work best when its internal WORK array has\nthe optimal size (big enough for fast computation and small enough to\navoid waste of memory). This size is determined also by a dedicated query\nto the function which is often wrapped as a standalone function and\ncommonly denoted as ``###_lwork``. Below is an example for ``?sysv``\n",
            "metadata": {}
        },
        {
            "id": "2d9011d3",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "a = rng.random((1000, 1000))\nb = rng.random((1000, 1)) * 1j\n# We pick up zsysv and zsysv_lwork due to b array\nxsysv, xlwork = LA.get_lapack_funcs(('sysv', 'sysv_lwork'), (a, b))\nopt_lwork, _ = xlwork(a.shape[0])  # returns a complex for 'z' prefix\nudut, ipiv, x, info = xsysv(a, b, lwork=int(opt_lwork.real))",
            "outputs": []
        }
    ]
}