{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Computing the elements of the local clifford group"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import product\n",
    "import sympy\n",
    "i = sympy.I\n",
    "exp = sympy.exp\n",
    "M = sympy.Matrix\n",
    "simplify = sympy.simplify\n",
    "from sympy.physics.quantum.dagger import Dagger\n",
    "\n",
    "sympy.init_printing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "I = M([[1, 0], [0, 1]])\n",
    "X = M([[0, 1], [1, 0]])\n",
    "Y = M([[0, -i], [i, 0]])\n",
    "Z = M([[1, 0], [0, -1]])\n",
    "O = M([[0, 0], [0, 0]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "H = M([[1, 1], [1, -1]]) / sympy.sqrt(2)\n",
    "S = M([[1, 0], [0, i]])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "C = [H, S]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_math_the_same(v):\n",
    "    return simplify(v[0] - v[1]) == O\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from multiprocessing import Pool, cpu_count\n",
    "\n",
    "pool = Pool(cpu_count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "found Matrix([[1, 0], [0, 1]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)/2], [sqrt(2)*I/2, -sqrt(2)*I/2]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)*I/2], [sqrt(2)/2, -sqrt(2)*I/2]])\n",
      "found Matrix([[1, 0], [0, -1]])\n",
      "found Matrix([[1/2 + I/2, 1/2 - I/2], [1/2 - I/2, 1/2 + I/2]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)/2], [-sqrt(2)/2, sqrt(2)/2]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)*I/2], [sqrt(2)*I/2, sqrt(2)/2]])\n",
      "found Matrix([[sqrt(2)/2, -sqrt(2)/2], [sqrt(2)/2, sqrt(2)/2]])\n",
      "found Matrix([[1, 0], [0, -I]])\n",
      "found Matrix([[1/2 + I/2, 1/2 - I/2], [1/2 + I/2, -1/2 + I/2]])\n",
      "found Matrix([[0, 1], [1, 0]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)/2], [-sqrt(2)*I/2, sqrt(2)*I/2]])\n",
      "found Matrix([[1/2 + I/2, 1/2 + I/2], [1/2 - I/2, -1/2 + I/2]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)*I/2], [-sqrt(2)/2, sqrt(2)*I/2]])\n",
      "found Matrix([[sqrt(2)/2, -sqrt(2)/2], [sqrt(2)*I/2, sqrt(2)*I/2]])\n",
      "found Matrix([[sqrt(2)/2, -sqrt(2)*I/2], [sqrt(2)/2, sqrt(2)*I/2]])\n",
      "found Matrix([[sqrt(2)*(1 + I)/2, 0], [0, sqrt(2)*(1 - I)/2]])\n",
      "found Matrix([[1/2 + I/2, 1/2 - I/2], [-1/2 + I/2, -1/2 - I/2]])\n",
      "found Matrix([[0, 1], [I, 0]])\n",
      "found Matrix([[1/2 - I/2, 1/2 + I/2], [1/2 + I/2, 1/2 - I/2]])\n",
      "found Matrix([[1/2 + I/2, 1/2 + I/2], [1/2 + I/2, I*(-1 + I)/2]])\n",
      "found Matrix([[0, I], [1, 0]])\n",
      "found Matrix([[sqrt(2)/2, sqrt(2)*I/2], [-sqrt(2)*I/2, -sqrt(2)/2]])\n",
      "found Matrix([[1/2 + I/2, -1/2 + I/2], [1/2 - I/2, I*(-1 + I)/2]])\n",
      "found Matrix([[sqrt(2)/2, -sqrt(2)/2], [-sqrt(2)/2, -sqrt(2)/2]])\n",
      "found Matrix([[sqrt(2)/2, -sqrt(2)*I/2], [sqrt(2)*I/2, -sqrt(2)/2]])\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#def list_contains_matrix(l, m):\n",
    "#    for elem in l:\n",
    "#        test = simplify(elem - m)\n",
    "#        if(test == 0):\n",
    "#            return True\n",
    "#    return False\n",
    "\n",
    "def list_contains_matrix(l, m):\n",
    "    #print(l, m)\n",
    "    for test in pool.map(is_math_the_same, [(e,m) for e in l]):\n",
    "        if(test):\n",
    "            return True\n",
    "\n",
    "\n",
    "#for i in range(10):\n",
    "while(len(C) < 24):\n",
    "    new_ops = ([c * H for c in C]\n",
    "                + [c * S for c in C])\n",
    "    for new_op in new_ops:\n",
    "        new_op.simplify()\n",
    "        #if(new_op not in C): # and Dagger(new_op) not in C):\n",
    "        if(not list_contains_matrix(C, new_op)):\n",
    "            print(\"found\", new_op)\n",
    "            C.append(new_op)\n",
    "        #else:\n",
    "            #print(new_op, \"is already known\")\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "for c in C:\n",
    "    c.simplify()\n",
    "#C = [c for c in C if Dagger(c) not in C]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32136 characters]\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & i\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\\\\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & - i\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\\\\\frac{1}{2} + \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\\\\\frac{1}{2} - \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\- \\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2} \\left(1 + i\\right)}{2} & 0\\\\0 & \\frac{\\sqrt{2} \\left(1 - i\\right)}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & - \\frac{1}{2} - \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\\\\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\\\\\frac{1}{2} + \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\\\\\frac{1}{2} - \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right]\\right]$"
      ],
      "text/plain": [
       "⎡⎡√2   √2 ⎤                  ⎡ √2     √2  ⎤  ⎡√2   √2⋅ⅈ ⎤           ⎡1   ⅈ  1 \n",
       "⎢⎢──   ── ⎥                  ⎢ ──     ──  ⎥  ⎢──   ──── ⎥           ⎢─ + ─  ─ \n",
       "⎢⎢2    2  ⎥  ⎡1  0⎤  ⎡1  0⎤  ⎢ 2      2   ⎥  ⎢2     2   ⎥  ⎡1  0 ⎤  ⎢2   2  2 \n",
       "⎢⎢        ⎥, ⎢    ⎥, ⎢    ⎥, ⎢            ⎥, ⎢          ⎥, ⎢     ⎥, ⎢         \n",
       "⎢⎢√2  -√2 ⎥  ⎣0  ⅈ⎦  ⎣0  1⎦  ⎢√2⋅ⅈ  -√2⋅ⅈ ⎥  ⎢√2  -√2⋅ⅈ ⎥  ⎣0  -1⎦  ⎢1   ⅈ  1 \n",
       "⎢⎢──  ────⎥                  ⎢────  ──────⎥  ⎢──  ──────⎥           ⎢─ - ─  ─ \n",
       "⎣⎣2    2  ⎦                  ⎣ 2      2   ⎦  ⎣2     2   ⎦           ⎣2   2  2 \n",
       "\n",
       "  ⅈ⎤  ⎡ √2   √2⎤  ⎡ √2   √2⋅ⅈ⎤  ⎡√2  -√2 ⎤           ⎡1   ⅈ   1   ⅈ ⎤         \n",
       "- ─⎥  ⎢ ──   ──⎥  ⎢ ──   ────⎥  ⎢──  ────⎥           ⎢─ + ─   ─ - ─ ⎥         \n",
       "  2⎥  ⎢ 2    2 ⎥  ⎢ 2     2  ⎥  ⎢2    2  ⎥  ⎡1  0 ⎤  ⎢2   2   2   2 ⎥  ⎡0  1⎤ \n",
       "   ⎥, ⎢        ⎥, ⎢          ⎥, ⎢        ⎥, ⎢     ⎥, ⎢              ⎥, ⎢    ⎥,\n",
       "  ⅈ⎥  ⎢-√2   √2⎥  ⎢√2⋅ⅈ   √2 ⎥  ⎢√2   √2 ⎥  ⎣0  -ⅈ⎦  ⎢1   ⅈ    1   ⅈ⎥  ⎣1  0⎦ \n",
       "+ ─⎥  ⎢────  ──⎥  ⎢────   ── ⎥  ⎢──   ── ⎥           ⎢─ + ─  - ─ + ─⎥         \n",
       "  2⎦  ⎣ 2    2 ⎦  ⎣ 2     2  ⎦  ⎣2    2  ⎦           ⎣2   2    2   2⎦         \n",
       "\n",
       " ⎡  √2     √2 ⎤  ⎡1   ⅈ   1   ⅈ ⎤  ⎡ √2   √2⋅ⅈ⎤  ⎡ √2   -√2 ⎤  ⎡√2  -√2⋅ⅈ ⎤  ⎡\n",
       " ⎢  ──     ── ⎥  ⎢─ + ─   ─ + ─ ⎥  ⎢ ──   ────⎥  ⎢ ──   ────⎥  ⎢──  ──────⎥  ⎢\n",
       " ⎢  2      2  ⎥  ⎢2   2   2   2 ⎥  ⎢ 2     2  ⎥  ⎢ 2     2  ⎥  ⎢2     2   ⎥  ⎢\n",
       " ⎢            ⎥, ⎢              ⎥, ⎢          ⎥, ⎢          ⎥, ⎢          ⎥, ⎢\n",
       " ⎢-√2⋅ⅈ   √2⋅ⅈ⎥  ⎢1   ⅈ    1   ⅈ⎥  ⎢-√2   √2⋅ⅈ⎥  ⎢√2⋅ⅈ  √2⋅ⅈ⎥  ⎢√2   √2⋅ⅈ ⎥  ⎢\n",
       " ⎢──────  ────⎥  ⎢─ - ─  - ─ + ─⎥  ⎢────  ────⎥  ⎢────  ────⎥  ⎢──   ──── ⎥  ⎢\n",
       " ⎣  2      2  ⎦  ⎣2   2    2   2⎦  ⎣ 2     2  ⎦  ⎣ 2     2  ⎦  ⎣2     2   ⎦  ⎣\n",
       "\n",
       "√2⋅(1 + ⅈ)            ⎤  ⎡ 1   ⅈ    1   ⅈ ⎤          ⎡1   ⅈ  1   ⅈ⎤  ⎡1   ⅈ   \n",
       "──────────      0     ⎥  ⎢ ─ + ─    ─ - ─ ⎥          ⎢─ - ─  ─ + ─⎥  ⎢─ + ─   \n",
       "    2                 ⎥  ⎢ 2   2    2   2 ⎥  ⎡0  1⎤  ⎢2   2  2   2⎥  ⎢2   2   \n",
       "                      ⎥, ⎢                ⎥, ⎢    ⎥, ⎢            ⎥, ⎢        \n",
       "            √2⋅(1 - ⅈ)⎥  ⎢  1   ⅈ    1   ⅈ⎥  ⎣ⅈ  0⎦  ⎢1   ⅈ  1   ⅈ⎥  ⎢1   ⅈ  ⅈ\n",
       "    0       ──────────⎥  ⎢- ─ + ─  - ─ - ─⎥          ⎢─ + ─  ─ - ─⎥  ⎢─ + ─  ─\n",
       "                2     ⎦  ⎣  2   2    2   2⎦          ⎣2   2  2   2⎦  ⎣2   2   \n",
       "\n",
       " 1   ⅈ   ⎤          ⎡  √2    √2⋅ⅈ⎤  ⎡1   ⅈ     1   ⅈ  ⎤  ⎡ √2   -√2 ⎤  ⎡ √2   \n",
       " ─ + ─   ⎥          ⎢  ──    ────⎥  ⎢─ + ─   - ─ + ─  ⎥  ⎢ ──   ────⎥  ⎢ ──   \n",
       " 2   2   ⎥  ⎡0  ⅈ⎤  ⎢  2      2  ⎥  ⎢2   2     2   2  ⎥  ⎢ 2     2  ⎥  ⎢ 2    \n",
       "         ⎥, ⎢    ⎥, ⎢            ⎥, ⎢                 ⎥, ⎢          ⎥, ⎢      \n",
       "⋅(-1 + ⅈ)⎥  ⎣1  0⎦  ⎢-√2⋅ⅈ   -√2 ⎥  ⎢1   ⅈ  ⅈ⋅(-1 + ⅈ)⎥  ⎢-√2   -√2 ⎥  ⎢√2⋅ⅈ  \n",
       "─────────⎥          ⎢──────  ────⎥  ⎢─ - ─  ──────────⎥  ⎢────  ────⎥  ⎢────  \n",
       "   2     ⎦          ⎣  2      2  ⎦  ⎣2   2      2     ⎦  ⎣ 2     2  ⎦  ⎣ 2    \n",
       "\n",
       "-√2⋅ⅈ ⎤⎤\n",
       "──────⎥⎥\n",
       "  2   ⎥⎥\n",
       "      ⎥⎥\n",
       " -√2  ⎥⎥\n",
       " ──── ⎥⎥\n",
       "  2   ⎦⎦"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABMAAAAOCAYAAADNGCeJAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABZklEQVQ4EXWTgVHDMAxFHY4BcmWDdoMCE5ARwgqwAT1GgA06Q9mgXaHdgG5A0w3Ce8HKNSTV3Y+tL/lbke2ibdtUFMU8pbQC2gM4gRWxg0QYeSXzd/AD7oD+hrwdY2cKSaQA/gdoQRWcI7a+9DO3ga/zPOmUE0kNfBM88xcRfoyuBXv9GyYVaPIvMO3N0svcAskFeHZyzRRz0RHl85Ukd9a2oEJ8+29jW7I2oe9TlB0joe+/8KCXtsTmiTegSNcv102KkbAE3YIQjxE+Dsf4Hsz7WEwuRxKsaurkanjFvAH+toKiO/VRZQQsfUrI0xzw+Ior5smXAzGI0YKoOBaEHyO8VSpY3/LpjBNylwVJr5mKl6Hri/Aujk4c7sjaL+Izr4aLbPgjgXhS0pobnLLImTyrmDKvz67gE83s31fOnjEuEfKyuqGX2+Y/ZXFpeVtj1Z+KebxWNmUHku4jkP/Ah+5vh/UP/Rd43VK9lG9blAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 28$"
      ],
      "text/plain": [
       "28"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(C)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is bad. Does one have to ignore global phases? Note that the matrices 10 and 18 are the same, disregarding a phase of $pi/4$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEIAAAAzCAYAAAAjKt6MAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADb0lEQVRoBe1bi3ETMRC1GQrwQAdOBwlUgNMBoQOgAxhXwIQOAhUwuIOECjJJB6EDPO7AvHfsZnQXaXUyOtu60c7IZ31ute9pV6eT7OlkMpkhPZHtdrt5UjiCgul06sVLaA9I2066AhGTMSbgvO5gJfbrZ/ignAP01Ekf/xWP7xMYW1iBsMGqRIwPcSKi533bI7ZO0fYn0hlYPYr5AzZdiv1/cD1BuoRtv6Us6WISIRPLd2hcI71CmidpH7AxbLuD+i8AvmI3YusdrnT9ZDLM0ODII10gMY5+sMNjEID9ADtmsKshgTbRVlyYv2I+VUwiUpXtsf0F+rr39HeLsoV4h6c6XFQqEQtAYrh2Recu1idJcUT0HO0XSSygcXFEwGYFqaPvYlYvmbmFfb6XSEQfXC/7NHLblEiEjrqLQ7+rt3BdkSTFESGPSYL0ub+W5V1HJFG638Y36G7u6VI9gvVJUpxHCDou9bnS7coZCu4dr+nWB/NFEgGg34BojUfpW0Umj9V3yL/XspSr+a5BReiA7DP2dAS4nueq7hYGfcX1UMLRX8IWDZHXyL+BTbQtWaJEQDGXs0cnsGsDoz7nMqzI0MgF3tVTiRA2KhGVCDcwynzpaiPIlKuhUUOj7UrVI6pHVI9oMyC56BKb7bCez3aQ4rVi4ELY/wldnGBZHjzKjBIBJVkPUgbGHFJPAh7PQHyNTCJAgvcgBeV6kHLuU3psZfAEHgeaEntqZD9IMa05YGWMiAVs822W8hWYwvpRSDA04P66EWoB1T1Cq81B6sR+hjbD4gHhYW4iWR6hIHX0XUDqJX3Icu/b5/elgOcO2zLWsUVE7F7WJx+k9FH6v23gDXPo4IEwhfNcdHs/GBq4WUedyrqi3pJ8kNJVFMqLa/9CfYrX8ScM3LNc46qPS4ZHdEsvSAQUbWAM7fQZomVRpqlgF2H/uI8btMki93IhqLvc3PU2JRYa2Q9STGvyV3JuWCkxlvoYEdkPUixjctZJaJ1CZ/NLH+T1NcHbjUkEmMx+kOK1YpjC5hwGGFYggZMnf08alOAc4dyR9SDF0TvoVxBwAwKY+MLF34KZ80SUCCjgpBWddQdFtaNy2N77XcgMjR37L/K2SoQMWyWiEtGO4OoRwoc+NeZ4zOiyuamSp0WbthHkujgB6RF3/eMK/rjyFzozUuFUA8PIAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & - i\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡1  0 ⎤\n",
       "⎢     ⎥\n",
       "⎣0  -ⅈ⎦"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C[10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKkAAAA/CAYAAACb6uhxAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAI80lEQVR4Ae2di3UVNxCGbR8KIKQDpwNDKojpwIQKwB2Ykwo40AHQQaAD6CCEDqADiDtw/m+RhLTW7tU+7t7ZRTpH3tVrNBr9Gj2udnx8dHR0Lv9evu2+3Nzc/NaOrOEqgX1I4Pj4+F/RPcvQfnQninwYvfP6rRUeHFTFN7sKaSAc78pT038KCTxRK++1WtoozwBSgeVDK8OkoAD6VAQuRff1JEK18E8hAeHkU7uhwtA1cSfthBnDj8YAVIxdyJ/OyEeWlOq4G9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KkasRqTBN2aZSp8ZIB2g0tgkYMGjJH1+VDeyU+zqu0WcxqxjRz76oHTTqbWU3RajSpnuNNP+YYnRonfhD2LUvLnk89wzJgal2Wy6ud5sxqTpGX2gOAO5cdOdrKb2+619RFQ3a5e7sybCSdKd6aWc0pomX5Msqs5smUWvdQ1gPwOkPb7wxLgJwpvq4oaRZzZjXHStDtM0ab1TR7BNUjEHOmCXt4NZUk4K/SrKY1kHptmetcr2U5N92Uk6ZhHb6YU32L1eUrytWpQVPEiCmQiulVmib0HTH2WdpZY+mvvZy1NSnyXJ1pwrWDwDr/pjSpE9bqTBNa7+Q2f5p62Xz6Hwv8Qb9Z05rmNKmmvtWZJmyDYAXhVZnWNAdS18GrMk24AlC2WSy5KN0uc7Cwxeme2y6ck3b+Xn0waW2n4pKL0mZaaxKkZqSzUUbckipuHaA1a1rT6nQfC7C+71EC2kRxicW0ac0K0j0CwDppAfRUPOYuSptivU73prpjOWY8QDX1mzetWTXpcrgwU5MDaOdFaTOMOkaCJhXj7d+PWUgHAwPWGK/8TJIAn+dwoM8zOPU3G6iDOOEPXlgf33L8wA+zD26l6AtDMc2nB9VVCexdAgIpAPWXiOL6Pv4PEXDm6Pb7a5AAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\frac{\\sqrt{2} \\left(1 + i\\right)}{2} & 0\\\\0 & \\frac{\\sqrt{2} \\left(1 - i\\right)}{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡√2⋅(1 + ⅈ)            ⎤\n",
       "⎢──────────      0     ⎥\n",
       "⎢    2                 ⎥\n",
       "⎢                      ⎥\n",
       "⎢            √2⋅(1 - ⅈ)⎥\n",
       "⎢    0       ──────────⎥\n",
       "⎣                2     ⎦"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C[18]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "XXX: continue here with computations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "lookup_table = [ca * cb for ca, cb in product(C, C)]\n",
    "for l in lookup_table:\n",
    "    l.simplify()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(lookup_table) == 24*24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "ltb = []\n",
    "row = []\n",
    "for i, result in enumerate(lookup_table):\n",
    "    if(i % 24):\n",
    "        ltb.append(row)\n",
    "        row = []\n",
    "    row.append(result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#lookup_table = [[C.index(i) for i in row] for row in ltb]\n"
   ]
  }
 ],
 "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.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
