{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "from pylatex import Document, Section, Subsection, Math, Matrix, VectorName\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    a = np.array([[100, 10, 20]]).T\n",
    "\n",
    "    doc = Document()\n",
    "    section = Section('Numpy tests')\n",
    "    subsection = Subsection('Array')\n",
    "\n",
    "    vec = Matrix(a)\n",
    "    vec_name = VectorName('a')\n",
    "    math = Math(data=[vec_name, '=', vec])\n",
    "\n",
    "    subsection.append(math)\n",
    "    section.append(subsection)\n",
    "\n",
    "    subsection = Subsection('Matrix')\n",
    "    M = np.matrix([[2, 3, 4],\n",
    "                   [0, 0, 1],\n",
    "                   [0, 0, 2]])\n",
    "    matrix = Matrix(M, mtype='b')\n",
    "    math = Math(data=['M=', matrix])\n",
    "\n",
    "    subsection.append(math)\n",
    "    section.append(subsection)\n",
    "\n",
    "    subsection = Subsection('Product')\n",
    "\n",
    "    math = Math(data=['M', vec_name, '=', Matrix(M * a)])\n",
    "    subsection.append(math)\n",
    "\n",
    "    section.append(subsection)\n",
    "\n",
    "    doc.append(section)\n",
    "    doc.generate_pdf('numpy_ex', clean_tex=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/ys/.pyenv/versions/3.12.0/bin/pip\n",
      "asttokens==3.0.0\n",
      "comm==0.2.2\n",
      "debugpy==1.8.9\n",
      "decorator==5.1.1\n",
      "executing==2.1.0\n",
      "ipykernel==6.29.5\n",
      "ipython==8.30.0\n",
      "jax==0.4.35\n",
      "jax-cuda12-pjrt==0.4.35\n",
      "jax-cuda12-plugin==0.4.35\n",
      "jaxlib==0.4.34\n",
      "jedi==0.19.2\n",
      "jupyter_client==8.6.3\n",
      "jupyter_core==5.7.2\n",
      "matplotlib-inline==0.1.7\n",
      "ml_dtypes==0.5.0\n",
      "nest-asyncio==1.6.0\n",
      "numpy==2.1.3\n",
      "nvidia-cublas-cu12==12.6.4.1\n",
      "nvidia-cuda-cupti-cu12==12.6.80\n",
      "nvidia-cuda-nvcc-cu12==12.6.85\n",
      "nvidia-cuda-runtime-cu12==12.6.77\n",
      "nvidia-cudnn-cu12==9.5.1.17\n",
      "nvidia-cufft-cu12==11.3.0.4\n",
      "nvidia-cusolver-cu12==11.7.1.2\n",
      "nvidia-cusparse-cu12==12.5.4.2\n",
      "nvidia-nccl-cu12==2.23.4\n",
      "nvidia-nvjitlink-cu12==12.6.85\n",
      "opt_einsum==3.4.0\n",
      "packaging==24.2\n",
      "parso==0.8.4\n",
      "pexpect==4.9.0\n",
      "platformdirs==4.3.6\n",
      "prompt_toolkit==3.0.48\n",
      "psutil==6.1.0\n",
      "ptyprocess==0.7.0\n",
      "pure_eval==0.2.3\n",
      "Pygments==2.18.0\n",
      "python-dateutil==2.9.0.post0\n",
      "pyzmq==26.2.0\n",
      "scipy==1.14.1\n",
      "six==1.16.0\n",
      "stack-data==0.6.3\n",
      "tornado==6.4.2\n",
      "traitlets==5.14.3\n",
      "wcwidth==0.2.13\n"
     ]
    }
   ],
   "source": [
    "!pyenv which pip\n",
    "!pip freeze\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import jax\n",
    "import jax.numpy as jnp\n",
    "\n",
    "x = jnp.arange(5)\n",
    "isinstance(x, jax.Array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{CpuDevice(id=0)}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.devices()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.        1.05      2.1       3.1499999 4.2      ]\n"
     ]
    }
   ],
   "source": [
    "import jax.numpy as jnp\n",
    "def selu(x, alpha=1.67, lmbda=1.05):\n",
    "  return lmbda * jnp.where(x > 0, x, alpha * jnp.exp(x) - alpha)\n",
    "\n",
    "x = jnp.arange(5.0)\n",
    "print(selu(x))"
   ]
  },
  {
   "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.12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
