{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Cartan matrix of E10:\n",
      "[ 2  0 -1  0  0  0  0  0  0  0]\n",
      "[ 0  2  0 -1  0  0  0  0  0  0]\n",
      "[-1  0  2 -1  0  0  0  0  0  0]\n",
      "[ 0 -1 -1  2 -1  0  0  0  0  0]\n",
      "[ 0  0  0 -1  2 -1  0  0  0  0]\n",
      "[ 0  0  0  0 -1  2 -1  0  0  0]\n",
      "[ 0  0  0  0  0 -1  2 -1  0  0]\n",
      "[ 0  0  0  0  0  0 -1  2 -1  0]\n",
      "[ 0  0  0  0  0  0  0 -1  2 -1]\n",
      "[ 0  0  0  0  0  0  0  0 -1  2]\n",
      "The Cartan matrix computed from the simple roots with GWall:\n",
      "[ 2  0 -1  0  0  0  0  0  0  0]\n",
      "[ 0  2  0 -1  0  0  0  0  0  0]\n",
      "[-1  0  2 -1  0  0  0  0  0  0]\n",
      "[ 0 -1 -1  2 -1  0  0  0  0  0]\n",
      "[ 0  0  0 -1  2 -1  0  0  0  0]\n",
      "[ 0  0  0  0 -1  2 -1  0  0  0]\n",
      "[ 0  0  0  0  0 -1  2 -1  0  0]\n",
      "[ 0  0  0  0  0  0 -1  2 -1  0]\n",
      "[ 0  0  0  0  0  0  0 -1  2 -1]\n",
      "[ 0  0  0  0  0  0  0  0 -1  2]\n",
      "Cartan = Cartan from simpleroots: True\n"
     ]
    }
   ],
   "source": [
    "load(\"generation_routines.sage\")\n",
    "import time\n",
    "def convert_to_hms(t):\n",
    "    hours=t//3600\n",
    "    minutes=(t-3600*hours)//60\n",
    "    seconds=(t-3600*hours-60*minutes)\n",
    "    return [hours,minutes,seconds]\n",
    "\n",
    "# Later; i will need to implement S3/2 and therefore h*, but even before that I need the \n",
    "# generalized Cartan matrix in order to conduct tests for the Berman generators:\n",
    "A=matrix([[2,0,-1,0,0,0,0,0,0,0],[0,2,0,-1,0,0,0,0,0,0],[-1,0,2,-1,0,0,0,0,0,0],[0,-1,-1,2,-1,0,0,0,0,0],\n",
    "         [0,0,0,-1,2,-1,0,0,0,0],[0,0,0,0,-1,2,-1,0,0,0],[0,0,0,0,0,-1,2,-1,0,0],\n",
    "         [0,0,0,0,0,0,-1,2,-1,0],[0,0,0,0,0,0,0,-1,2,-1],[0,0,0,0,0,0,0,0,-1,2]])\n",
    "print(\"The Cartan matrix of E10:\")\n",
    "print(A)\n",
    "# Simple roots of E10 in the Wall basis\n",
    "a1=vector([1,-1,0,0,0,0,0,0,0,0])\n",
    "a2=vector([-1,-1,-1,0,0,0,0,0,0,0])\n",
    "a3=vector([0,1,-1,0,0,0,0,0,0,0])\n",
    "a4=vector([0,0,1,-1,0,0,0,0,0,0])\n",
    "a5=vector([0,0,0,1,-1,0,0,0,0,0])\n",
    "a6=vector([0,0,0,0,1,-1,0,0,0,0])\n",
    "a7=vector([0,0,0,0,0,1,-1,0,0,0])\n",
    "a8=vector([0,0,0,0,0,0,1,-1,0,0])\n",
    "a9=vector([0,0,0,0,0,0,0,1,-1,0])\n",
    "a10=vector([0,0,0,0,0,0,0,0,1,-1])\n",
    "SimRoots=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]\n",
    "Gwall=matrix([[kron_delta(i, j) - 1/9 for j in range(0,10)] for i in range(0,10)])\n",
    "G_inverse=Gwall.inverse()\n",
    "test_Cartan=matrix([[SimRoots[i].dot_product(Gwall*SimRoots[j]) for j in range(0,10)] for i in range(0,10)])\n",
    "print(\"The Cartan matrix computed from the simple roots with GWall:\")\n",
    "print(test_Cartan)\n",
    "print(\"Cartan = Cartan from simpleroots:\", A==test_Cartan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]\n",
       "[1 1 1 1 1 1 1 1 1 1]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Define the S_{1/2}-representation manually. This implementation is based on a weight space\n",
    "# analysis that I conducted for S1/2 analytically. It has the advantage that the resulting\n",
    "# matrices are rather sparse.\n",
    "\n",
    "weightsa=[vector([1/2,1/2,1/2,1/2,1/2]),vector([1/2,1/2,1/2,-1/2,-1/2]),vector([1/2,1/2,-1/2,1/2,-1/2]),\n",
    "          vector([1/2,-1/2,1/2,1/2,-1/2]),vector([1/2,1/2,-1/2,-1/2,1/2]),vector([-1/2,1/2,1/2,1/2,-1/2]),\n",
    "          vector([1/2,-1/2,1/2,-1/2,1/2]),vector([-1/2,1/2,1/2,-1/2,1/2]),vector([1/2,-1/2,-1/2,1/2,1/2]),\n",
    "          vector([-1/2,1/2,-1/2,1/2,1/2]),vector([1/2,-1/2,-1/2,-1/2,-1/2]),vector([-1/2,-1/2,1/2,1/2,1/2]),\n",
    "          vector([-1/2,1/2,-1/2,-1/2,-1/2]),vector([-1/2,-1/2,1/2,-1/2,-1/2]),vector([-1/2,-1/2,-1/2,1/2,-1/2]),\n",
    "          vector([-1/2,-1/2,-1/2,-1/2,1/2])]\n",
    "weightsa.reverse()\n",
    "weightsb=[-w for w in weightsa]\n",
    "weightsa.reverse()\n",
    "weights=weightsa+weightsb\n",
    "weights\n",
    "n=len(weights)\n",
    "generate_as_sparse=True  # Note that in the current minimal script \"generation routines\"\n",
    "                         # there is no longer the option to perform checks for dense matrices\n",
    "X2=-I/2*matrix([[kron_delta(j,image2(i,weights)) for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X3=-I/2*matrix([[kron_delta(j,image(i,0,weights)) for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X5=-I/2*matrix([[kron_delta(j,image(i,1,weights)) for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X7=-I/2*matrix([[kron_delta(j,image(i,2,weights)) for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X9=-I/2*matrix([[kron_delta(j,image(i,3,weights)) for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X1=I*matrix([[kron_delta(j,i)*weights[i][0] for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X4=I*matrix([[kron_delta(j,i)*weights[i][1] for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X6=I*matrix([[kron_delta(j,i)*weights[i][2] for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X8=I*matrix([[kron_delta(j,i)*weights[i][3] for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "X10=I*matrix([[kron_delta(j,i)*weights[i][4] for i in range(0,n)] for j in range(0,n)],sparse=generate_as_sparse)\n",
    "Bermans=[X1,X2,X3,X4,X5,X6,X7,X8,X9,X10]\n",
    "Berman_check_sparse(Bermans,Cartan_matrix=A,silent=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Took  0.7677381038665771 seconds to compute the ladder operators\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, True, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n"
     ]
    }
   ],
   "source": [
    "#Now deduce the ladder operators and check if the D5-relations hold\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans)\n",
    "F=get_F_ladder(Bermans)\n",
    "H_weyl=get_H_weyl(Bermans)\n",
    "H_orth=get_H_orth(Bermans)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \"seconds to compute the ladder operators\")\n",
    "\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,\n",
    "                         silent=True)\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans,E_ladder=E,F_ladder=F,silent=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.03009033203125 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.030771255493164062 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.009412765502929688 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.009014368057250977 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.010833978652954102 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.013689756393432617 seconds\n"
     ]
    }
   ],
   "source": [
    "save_path = \"S12_matrices/\" \n",
    "try:\n",
    "    os.makedirs(save_path)\n",
    "except os.error as error:\n",
    "    print(save_path.\"already exists.\")\n",
    "IBermans=[]       # Sometimes useful as they only have entries in Q\n",
    "for x in Bermans:\n",
    "    IBermans.append(I*x)\n",
    "d=Bermans[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=IBermans,dim=d,path=save_path,\n",
    "                     name=\"IX\")\n",
    "write_to_file_by_key(matrices=Bermans,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=E,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Took  14.653613090515137 seconds to compute the ladder operators for S3/2\n"
     ]
    }
   ],
   "source": [
    "# Now generate the representation matrices for S3/2. First one has to implement the maps\n",
    "# s_\\alpha-1/2*Id, where s_\\alpha are the simple Weyl reflections\n",
    "\n",
    "taus=[weyl_orth(SimRoots[i],Gwall)-1/2*identity_matrix(10,sparse=True) for i in range(0,10)]\n",
    "Bermans_3_2=[tensor_homemade(taus[i],2*Bermans[i]) for i in range(0,10)]\n",
    "\n",
    "\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans_3_2)\n",
    "F=get_F_ladder(Bermans_3_2)\n",
    "H_weyl=get_H_weyl(Bermans_3_2)\n",
    "H_orth=get_H_orth(Bermans_3_2)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \"seconds to compute the ladder operators for S3/2\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, False, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n"
     ]
    }
   ],
   "source": [
    "print(Berman_check_sparse(Bermans=Bermans_3_2,Cartan_matrix=A,silent=True))\n",
    "print(\"\")\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,\n",
    "                        silent=True)\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans_3_2,E_ladder=E,F_ladder=F,silent=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "File already exists\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.18228960037231445 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.19292426109313965 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.042838335037231445 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.050795793533325195 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.05874991416931152 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.0795435905456543 seconds\n"
     ]
    }
   ],
   "source": [
    "save_path = \"S32_matrices/\"\n",
    "try:\n",
    "    os.makedirs(save_path)\n",
    "except os.error as error:\n",
    "    print(\"File already exists\")\n",
    "IBermans_3_2=[]\n",
    "for x in Bermans_3_2:\n",
    "    IBermans_3_2.append(I*x)\n",
    "d=Bermans_3_2[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=IBermans_3_2,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"IX\")\n",
    "write_to_file_by_key(matrices=Bermans_3_2,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=E,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Took  266.9089159965515 seconds to compute the ladder operators for S5/2\n"
     ]
    }
   ],
   "source": [
    "# Compute the tau-maps for S5/2 which includes computation of the induced Weyl reflections \n",
    "# on Sym^2(h):\n",
    "Sym_basis, Sym_linear_indices = normalizers(2,10)\n",
    "\n",
    "reflections=[induced_map_sparse_sym2(A=weyl_orth(SimRoots[i],Gwall),\n",
    "                                     basis=Sym_basis,linear=Sym_linear_indices) \n",
    "             for i in range(10)]\n",
    "taus = [reflections[i]-1/2*identity_matrix(55,sparse=True) for i in range(0,10)]\n",
    "\n",
    "Bermans_5_2=[tensor_homemade(taus[i],2*Bermans[i]) for i in range(0,10)]\n",
    "\n",
    "\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans_5_2)\n",
    "F=get_F_ladder(Bermans_5_2)\n",
    "H_weyl=get_H_weyl(Bermans_5_2)\n",
    "H_orth=get_H_orth(Bermans_5_2)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \"seconds to compute the ladder operators for S5/2\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Conducting checks on the Berman relations and Cartan-Weyl-relations:\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "\n",
      "Checking the Berman relations took 537.4116837978363 seconds.\n",
      "\n",
      "Cartan-Weyl-relations took 503.4294431209564 seconds.\n",
      "\n",
      "Finally, the skew-properties:\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, False, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n",
      "Checking skew-properties took 12.934399843215942 seconds.\n"
     ]
    }
   ],
   "source": [
    "print(\"Conducting checks on the Berman relations and Cartan-Weyl-relations:\")\n",
    "start=time.time()\n",
    "print(Berman_check_sparse(Bermans=Bermans_5_2,Cartan_matrix=A,silent=True))\n",
    "end=time.time()\n",
    "print(\"\")\n",
    "print(\"Checking the Berman relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "start=time.time()\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,\n",
    "                        silent=True)\n",
    "end=time.time()\n",
    "print(\"Cartan-Weyl-relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "print(\"Finally, the skew-properties:\")\n",
    "start=time.time()\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans_5_2,E_ladder=E,F_ladder=F,silent=False)\n",
    "end=time.time()\n",
    "print(\"Checking skew-properties took\",end-start,\"seconds.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "S52_matrices/ already exists.\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  1.843916893005371 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  1.7176125049591064 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.29531288146972656 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.35607481002807617 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.3664422035217285 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.4344606399536133 seconds\n"
     ]
    }
   ],
   "source": [
    "path_5_2=\"S52_matrices/\"\n",
    "try:\n",
    "    os.makedirs(path_5_2)\n",
    "except os.error as error:\n",
    "    print(path_5_2, \"already exists.\")\n",
    "IBermans_5_2=[]\n",
    "for x in Bermans_5_2:\n",
    "    IBermans_5_2.append(I*x)\n",
    "d=Bermans_5_2[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=Bermans_5_2,\n",
    "                     dim=d,path=path_5_2,name=\"X\")\n",
    "write_to_file_by_key(matrices=IBermans_5_2,\n",
    "                     dim=d,path=path_5_2,name=\"IX\")\n",
    "write_to_file_by_key(matrices=E,\n",
    "                     dim=d,path=path_5_2,name=\"E\")\n",
    "write_to_file_by_key(matrices=F,\n",
    "                     dim=d,path=path_5_2,name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,\n",
    "                     dim=d,path=path_5_2,name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,\n",
    "                     dim=d,path=path_5_2,name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Computing Berman number 0\n",
      "Computing Berman number 1\n",
      "Computing Berman number 2\n",
      "Computing Berman number 3\n",
      "Computing Berman number 4\n",
      "Computing Berman number 5\n",
      "Computing Berman number 6\n",
      "Computing Berman number 7\n",
      "Computing Berman number 8\n",
      "Computing Berman number 9\n",
      "Done, the computation took 4.198241710662842 seconds to terminate.\n",
      "Compute the ladder operators...\n",
      "Took  88.047034740448 seconds to compute the ladder operators for S1/2 times S1/2\n"
     ]
    }
   ],
   "source": [
    "# Now generate the matrices for S1/2 times S1/2\n",
    "start=time.time()\n",
    "Bermans_12_12=[]\n",
    "i=0\n",
    "for x in Bermans:\n",
    "    print(\"Computing Berman number\",i)\n",
    "    Bermans_12_12.append(Lie_tensor(x,x))\n",
    "    i=i+1\n",
    "\n",
    "end=time.time()\n",
    "print(\"Done, the computation took\",end-start,\"seconds to terminate.\")\n",
    "\n",
    "print(\"Compute the ladder operators...\")\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans_12_12)\n",
    "F=get_F_ladder(Bermans_12_12)\n",
    "H_weyl=get_H_weyl(Bermans_12_12)\n",
    "H_orth=get_H_orth(Bermans_12_12)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \"seconds to compute the ladder operators for S1/2 times S1/2\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Conducting checks on the Berman relations and Cartan-Weyl-relations:\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "\n",
      "Checking the Berman relations took 108.85057377815247 seconds.\n",
      "\n",
      "Cartan-Weyl-relations took 147.59945631027222 seconds.\n",
      "\n",
      "Finally, the skew-properties:\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, True, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n",
      "Checking skew-properties took 3.0818326473236084 seconds.\n"
     ]
    }
   ],
   "source": [
    "print(\"Conducting checks on the Berman relations and Cartan-Weyl-relations:\")\n",
    "start=time.time()\n",
    "print(Berman_check_sparse(Bermans=Bermans_12_12,Cartan_matrix=A,silent=True))\n",
    "end=time.time()\n",
    "print(\"\")\n",
    "print(\"Checking the Berman relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "start=time.time()\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,\n",
    "                        silent=True)\n",
    "end=time.time()\n",
    "print(\"Cartan-Weyl-relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "print(\"Finally, the skew-properties:\")\n",
    "start=time.time()\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans_12_12,E_ladder=E,F_ladder=F,silent=False)\n",
    "end=time.time()\n",
    "print(\"Checking skew-properties took\",end-start,\"seconds.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.5410735607147217 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.09630131721496582 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.09734845161437988 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.12250089645385742 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.09933996200561523 seconds\n"
     ]
    }
   ],
   "source": [
    "path_12_12=\"S12_times_S12_matrices/\"\n",
    "try:\n",
    "    os.makedirs(path_12_12)\n",
    "except os.error as error:\n",
    "    print(path_12_12,\"already exists.\")\n",
    "# Note: One does not need the I*Berman generators here as the result is already in Q\n",
    "d=Bermans_12_12[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=Bermans_12_12,dim=d,\n",
    "                     path=path_12_12,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=E,dim=d,\n",
    "                     path=path_12_12,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=d,\n",
    "                     path=path_12_12,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=d,\n",
    "                     path=path_12_12,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=d,\n",
    "                     path=path_12_12,\n",
    "                     name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read in all necessary matrices in 1.1403248310089111 seconds.\n",
      "Computing Berman number 0\n",
      "Took 5.761147737503052 seconds.\n",
      "Computing Berman number 1\n",
      "Took 14.297699451446533 seconds.\n",
      "Computing Berman number 2\n",
      "Took 7.0037171840667725 seconds.\n",
      "Computing Berman number 3\n",
      "Took 6.195460081100464 seconds.\n",
      "Computing Berman number 4\n",
      "Took 7.133878469467163 seconds.\n",
      "Computing Berman number 5\n",
      "Took 5.93920111656189 seconds.\n",
      "Computing Berman number 6\n",
      "Took 7.115603446960449 seconds.\n",
      "Computing Berman number 7\n",
      "Took 6.169271230697632 seconds.\n",
      "Computing Berman number 8\n",
      "Took 7.0123131275177 seconds.\n",
      "Computing Berman number 9\n",
      "Took 5.963977813720703 seconds.\n",
      "Computation of the Berman generators took 0 hours 1 minutes and 13 seconds\n",
      "Computing E_ladder number 0\n",
      "Took 97.45080089569092 seconds.\n",
      "Computing E_ladder number 1\n",
      "Took 97.1373016834259 seconds.\n",
      "Computing E_ladder number 2\n",
      "Took 99.73759388923645 seconds.\n",
      "Computing E_ladder number 3\n",
      "Took 97.00776052474976 seconds.\n",
      "Computing E_ladder number 4\n",
      "Took 100.02337694168091 seconds.\n",
      "Computation of the E_ladder took 0 hours 8 minutes and 12 seconds\n",
      "Computing F_ladder number 0\n",
      "Took 97.09635186195374 seconds.\n",
      "Computing F_ladder number 1\n",
      "Took 97.93998861312866 seconds.\n",
      "Computing F_ladder number 2\n",
      "Took 97.52634024620056 seconds.\n",
      "Computing F_ladder number 3\n",
      "Took 97.73071527481079 seconds.\n",
      "Computing F_ladder number 4\n",
      "Took 97.02802157402039 seconds.\n",
      "Computation of the F_ladder took 0 hours 8 minutes and 8 seconds\n",
      "Computing H_orth\n",
      "Computation of the H_orth took 0 hours 0 minutes and 5 seconds\n",
      "The entire computation  took 0 hours 17 minutes and 36 seconds\n"
     ]
    }
   ],
   "source": [
    "# Generating the tensor products for S3/2 times S1/2 the easy way\n",
    "Path32=\"S32_matrices/\"\n",
    "Path12=\"S12_matrices/\"\n",
    "Bermans1_2=read_in_SR(path=Path12,name=\"X\",number=10,\n",
    "                      silent=True)\n",
    "Bermans3_2=read_in_SR(path=Path32,name=\"X\",number=10,\n",
    "                     silent=True)\n",
    "start_read=time.time()\n",
    "Bermans_32_12=[]\n",
    "\n",
    "Bermans_12=read_in_SR(path=Path12,name=\"X\",number=10,silent=True)\n",
    "Bermans_32=read_in_SR(path=Path32,name=\"X\",number=10,silent=True)\n",
    "E_12=read_in_QQ(path=Path12,name=\"E\",number=5,silent=True)\n",
    "E_32=read_in_QQ(path=Path32,name=\"E\",number=5,silent=True)\n",
    "F_12=read_in_QQ(path=Path12,name=\"F\",number=5,silent=True)\n",
    "F_32=read_in_QQ(path=Path32,name=\"F\",number=5,silent=True)\n",
    "\n",
    "end_read=time.time()\n",
    "print(\"Read in all necessary matrices in\",end_read-start_read,\"seconds.\")\n",
    "\n",
    "start_total=time.time()\n",
    "Bermans_32_12=[]\n",
    "IBermans_32_12=[]\n",
    "start_Bermans=time.time()\n",
    "for i in range(10):\n",
    "    print(\"Computing Berman number\",i)\n",
    "    start=time.time()\n",
    "    x=Bermans_32[i]\n",
    "    y=Bermans_12[i]\n",
    "    z=Lie_tensor(x,y)\n",
    "    Bermans_32_12.append(z)\n",
    "    IBermans_32_12.append(I*z)\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_Bermans=time.time()\n",
    "tt=convert_to_hms(ceil(end_Bermans-start_Bermans))\n",
    "print(\"Computation of the Berman generators took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "start_E=time.time()\n",
    "E=[]\n",
    "for i in range(5):\n",
    "    print(\"Computing E_ladder number\",i)\n",
    "    start=time.time()\n",
    "    x=E_32[i]\n",
    "    y=E_12[i]\n",
    "    E.append(Lie_tensor(x,y))\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_E=time.time()\n",
    "tt=convert_to_hms(ceil(end_E-start_E))\n",
    "print(\"Computation of the E_ladder took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "\n",
    "start_F=time.time()\n",
    "F=[]\n",
    "for i in range(5):\n",
    "    print(\"Computing F_ladder number\",i)\n",
    "    start=time.time()\n",
    "    x=F_32[i]\n",
    "    y=F_12[i]\n",
    "    F.append(Lie_tensor(x,y))\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_F=time.time()\n",
    "tt=convert_to_hms(ceil(end_F-start_F))\n",
    "print(\"Computation of the F_ladder took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "start_H=time.time()\n",
    "H_orth=[]\n",
    "print(\"Computing H_orth\")\n",
    "H_orth=get_H_orth(Bermans_32_12)\n",
    "end_H=time.time()\n",
    "tt=convert_to_hms(ceil(end_H-start_H))\n",
    "print(\"Computation of the H_orth took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "\n",
    "end_total=time.time()\n",
    "tt=convert_to_hms(ceil(end_total-start_total))\n",
    "print(\"The entire computation  took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Probably do not conduct these tests...\n",
    "#print(\"Conducting checks on the Berman relations and Cartan-Weyl-relations:\")\n",
    "#start=time.time()\n",
    "#print(Berman_check_sparse(Bermans=Bermans_32_12,Cartan_matrix=A,silent=True))\n",
    "#end=time.time()\n",
    "#print(\"\")\n",
    "#print(\"Checking the Berman relations took\",end-start,\"seconds.\")\n",
    "#print(\"\")\n",
    "#start=time.time()\n",
    "#D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "#lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,silent=True)\n",
    "#end=time.time()\n",
    "#print(\"Cartan-Weyl-relations took\",end-start,\"seconds.\")\n",
    "#print(\"\")\n",
    "#print(\"Finally, the skew-properties:\")\n",
    "#start=time.time()\n",
    "#for l in lad:\n",
    "#    print(l)\n",
    "#    print(\"\")\n",
    "#sk = skew_properties(Bermans=Bermans_32_12,E_ladder=E,F_ladder=F,silent=False)\n",
    "#end=time.time()\n",
    "#print(\"Checking skew-properties took\",end-start,\"seconds.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  7.558332681655884 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  6.3438661098480225 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.5146486759185791 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.3148019313812256 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.058439016342163086 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  1.2560722827911377 seconds\n"
     ]
    }
   ],
   "source": [
    "path_32_12=\"S32_times_S12_matrices/\"\n",
    "try:\n",
    "    os.makedirs(path_32_12)\n",
    "except os.error as error:\n",
    "    print(path_32_12,\"already exists.\")\n",
    "\n",
    "IBermans_32_12=[]\n",
    "for x in Bermans_32_12:\n",
    "    IBermans_32_12.append(I*x)\n",
    "d=Bermans_32_12[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=Bermans_32_12,\n",
    "                     dim=d,path=path_32_12, name=\"X\")\n",
    "write_to_file_by_key(matrices=IBermans_32_12,\n",
    "                     dim=d,path=path_32_12, name=\"IX\")\n",
    "write_to_file_by_key(matrices=E,\n",
    "                     dim=d,path=path_32_12, name=\"E\")\n",
    "write_to_file_by_key(matrices=F,\n",
    "                     dim=d,path=path_32_12, name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,\n",
    "                     dim=d,path=path_32_12, name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,\n",
    "                     dim=d,path=path_32_12, name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Computing Berman number 0\n",
      "Computing Berman number 1\n",
      "Computing Berman number 2\n",
      "Computing Berman number 3\n",
      "Computing Berman number 4\n",
      "Computing Berman number 5\n",
      "Computing Berman number 6\n",
      "Computing Berman number 7\n",
      "Computing Berman number 8\n",
      "Computing Berman number 9\n",
      "Done, the computation took 2.9002583026885986 seconds to terminate.\n",
      "Conducting checks on the Berman relations:\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "\n",
      "Checking the Berman relations took 39.627583026885986 seconds.\n",
      "\n",
      "Compute the ladder operators...\n",
      "Took  34.54692721366882 seconds to compute the ladder operators for symmetric S1/2 times S1/2\n",
      "Check Cartan-Weyl-relations:\n",
      "Cartan-Weyl-relations took 44.349271297454834 seconds.\n",
      "\n",
      "Finally, the skew-properties:\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, True, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n",
      "Checking skew-properties took 1.8188483715057373 seconds.\n"
     ]
    }
   ],
   "source": [
    "# Now generate the matrices for Sym^2(S1/2):\n",
    "[Sym_basis,Sym_linear_indices]=normalizers(2,32)\n",
    "start=time.time()\n",
    "Bermans_sym2=[]\n",
    "i=0\n",
    "for x in Bermans:\n",
    "    print(\"Computing Berman number\",i)\n",
    "    Bermans_sym2.append(Lie_sym2(A=x,basis=Sym_basis,linear=Sym_linear_indices,A_dim=32))\n",
    "    i=i+1\n",
    "\n",
    "end=time.time()\n",
    "print(\"Done, the computation took\",end-start,\"seconds to terminate.\")\n",
    "\n",
    "print(\"Conducting checks on the Berman relations:\")\n",
    "start=time.time()\n",
    "print(Berman_check_sparse(Bermans=Bermans_sym2,Cartan_matrix=A,silent=True))\n",
    "end=time.time()\n",
    "print(\"\")\n",
    "print(\"Checking the Berman relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "start=time.time()\n",
    "\n",
    "print(\"Compute the ladder operators...\")\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans_sym2)\n",
    "F=get_F_ladder(Bermans_sym2)\n",
    "H_weyl=get_H_weyl(Bermans_sym2)\n",
    "H_orth=get_H_orth(Bermans_sym2)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \n",
    "      \"seconds to compute the ladder operators for symmetric S1/2 times S1/2\")\n",
    "start=time.time()\n",
    "print(\"Check Cartan-Weyl-relations:\")\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,silent=True)\n",
    "end=time.time()\n",
    "print(\"Cartan-Weyl-relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "print(\"Finally, the skew-properties:\")\n",
    "start=time.time()\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans_sym2,E_ladder=E,F_ladder=F,silent=False)\n",
    "end=time.time()\n",
    "print(\"Checking skew-properties took\",end-start,\"seconds.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "528 528\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.31447386741638184 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.2728414535522461 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.052276611328125 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.05600547790527344 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.06719112396240234 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.057459354400634766 seconds\n"
     ]
    }
   ],
   "source": [
    "path_sym2=\"Sym2_S12_matrices/\"   \n",
    "try:\n",
    "    os.makedirs(path_sym2)\n",
    "except os.error as error:\n",
    "    print(path_sym2,\"already exists.\")\n",
    "\n",
    "IBermans_sym2=[]\n",
    "for x in Bermans_sym2:\n",
    "    IBermans_sym2.append(I*x)\n",
    "dimension=len(Sym_basis)\n",
    "print(dimension,16*33)\n",
    "write_to_file_by_key(matrices=Bermans_sym2,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=IBermans_sym2,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"IX\")\n",
    "write_to_file_by_key(matrices=E,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=dimension,\n",
    "                     path=path_sym2,\n",
    "                     name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Computing Berman number 0\n",
      "Computing Berman number 1\n",
      "Computing Berman number 2\n",
      "Computing Berman number 3\n",
      "Computing Berman number 4\n",
      "Computing Berman number 5\n",
      "Computing Berman number 6\n",
      "Computing Berman number 7\n",
      "Computing Berman number 8\n",
      "Computing Berman number 9\n",
      "Done, the computation took 2.2008275985717773 seconds to terminate.\n",
      "Conducting checks on the Berman relations:\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "[1 1 1 1 1 1 1 1 1 1]\n",
      "\n",
      "Checking the Berman relations took 32.555259227752686 seconds.\n",
      "\n",
      "Compute the ladder operators...\n",
      "Took  27.60447883605957 seconds to compute the ladder operators for symmetric S1/2 times S1/2\n",
      "Check Cartan-Weyl-relations:\n",
      "Cartan-Weyl-relations took 36.772533893585205 seconds.\n",
      "\n",
      "Finally, the skew-properties:\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "[1 1 1 1 1]\n",
      "\n",
      "Bermans are skew-hermititan: [True, True, True, True, True, True, True, True, True, True]\n",
      "E_i dagger equals -F_i for i equals: [True, True, True, True, True]\n",
      "Checking skew-properties took 1.4504413604736328 seconds.\n"
     ]
    }
   ],
   "source": [
    "# Now generate the matrices for Ext^2(S1/2):\n",
    "[ext_basis,ext_linear_indices]=normalizers_ext(2,32)\n",
    "start=time.time()\n",
    "Bermans_ext2=[]\n",
    "i=0\n",
    "for x in Bermans:\n",
    "    print(\"Computing Berman number\",i)\n",
    "    Bermans_ext2.append(Lie_ext2(A=x,basis=ext_basis,linear=ext_linear_indices,A_dim=32))\n",
    "    i=i+1\n",
    "\n",
    "end=time.time()\n",
    "print(\"Done, the computation took\",end-start,\"seconds to terminate.\")\n",
    "\n",
    "print(\"Conducting checks on the Berman relations:\")\n",
    "start=time.time()\n",
    "print(Berman_check_sparse(Bermans=Bermans_ext2,Cartan_matrix=A,silent=True))\n",
    "end=time.time()\n",
    "print(\"\")\n",
    "print(\"Checking the Berman relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "start=time.time()\n",
    "\n",
    "print(\"Compute the ladder operators...\")\n",
    "start=time.time()\n",
    "E=get_E_ladder(Bermans_ext2)\n",
    "F=get_F_ladder(Bermans_ext2)\n",
    "H_weyl=get_H_weyl(Bermans_ext2)\n",
    "H_orth=get_H_orth(Bermans_ext2)\n",
    "end=time.time()\n",
    "\n",
    "print(\"Took \",end-start, \n",
    "      \"seconds to compute the ladder operators for symmetric S1/2 times S1/2\")\n",
    "start=time.time()\n",
    "print(\"Check Cartan-Weyl-relations:\")\n",
    "D5_Cartan=matrix([[2,-1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,-1],[0,0,-1,2,0],[0,0,-1,0,2]])\n",
    "lad=ladder_check_sparse(E_ladder=E,F_ladder=F,H_weyl=H_weyl,Cartan_matrix=D5_Cartan,silent=True)\n",
    "end=time.time()\n",
    "print(\"Cartan-Weyl-relations took\",end-start,\"seconds.\")\n",
    "print(\"\")\n",
    "print(\"Finally, the skew-properties:\")\n",
    "start=time.time()\n",
    "for l in lad:\n",
    "    print(l)\n",
    "    print(\"\")\n",
    "sk = skew_properties(Bermans=Bermans_ext2,E_ladder=E,F_ladder=F,silent=False)\n",
    "end=time.time()\n",
    "print(\"Checking skew-properties took\",end-start,\"seconds.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "496 496\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.2592499256134033 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  0.22974610328674316 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.04982876777648926 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.04983687400817871 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.06295299530029297 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.04916810989379883 seconds\n"
     ]
    }
   ],
   "source": [
    "path_ext2=\"Ext2_S12_matrices/\"\n",
    "try:\n",
    "    os.makedirs(path_ext2)\n",
    "except os.error as error:\n",
    "    print(path_ext2,\"already exists. Possible overwriting of old results.\")\n",
    "\n",
    "IBermans_ext2=[I*x for x in Bermans_ext2]\n",
    "    \n",
    "dimension=len(ext_basis)\n",
    "print(dimension,16*31)\n",
    "write_to_file_by_key(matrices=Bermans_ext2,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=IBermans_ext2,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"IX\")\n",
    "write_to_file_by_key(matrices=E,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=dimension,\n",
    "                     path=path_ext2,\n",
    "                     name=\"H\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read in all necessary matrices.\n",
      "Computing Berman number 0\n",
      "Took 128.9975025653839 seconds.\n",
      "Computing Berman number 1\n",
      "Took 317.9665017127991 seconds.\n",
      "Computing Berman number 2\n",
      "Took 185.67875337600708 seconds.\n",
      "Computing Berman number 3\n",
      "Took 113.00795078277588 seconds.\n",
      "Computing Berman number 4\n",
      "Took 184.42012286186218 seconds.\n",
      "Computing Berman number 5\n",
      "Took 95.2755081653595 seconds.\n",
      "Computing Berman number 6\n",
      "Took 182.0871181488037 seconds.\n",
      "Computing Berman number 7\n",
      "Took 94.10956406593323 seconds.\n",
      "Computing Berman number 8\n",
      "Took 182.59639430046082 seconds.\n",
      "Computing Berman number 9\n",
      "Took 94.0265645980835 seconds.\n",
      "Computation of the Berman generators took 0 hours 26 minutes and 19 seconds\n",
      "Computing E_ladder number 0\n",
      "Took 23775.045373916626 seconds.\n",
      "Computing E_ladder number 1\n",
      "Took 23750.675555706024 seconds.\n",
      "Computing E_ladder number 2\n",
      "Took 23745.894551992416 seconds.\n",
      "Computing E_ladder number 3\n",
      "Took 23622.573387145996 seconds.\n",
      "Computing E_ladder number 4\n",
      "Took 23651.012803316116 seconds.\n",
      "Computation of the E_ladder took 32 hours 55 minutes and 46 seconds\n",
      "Computing F_ladder number 0\n",
      "Took 23589.385926008224 seconds.\n",
      "Computing F_ladder number 1\n",
      "Took 23605.213775634766 seconds.\n",
      "Computing F_ladder number 2\n",
      "Took 23585.581474781036 seconds.\n",
      "Computing F_ladder number 3\n",
      "Took 23635.886209726334 seconds.\n",
      "Computing F_ladder number 4\n",
      "Took 23702.466992139816 seconds.\n",
      "Computation of the F_ladder took 32 hours 48 minutes and 39 seconds\n",
      "Computing H_orth\n",
      "Computation of the H_orth took 0 hours 2 minutes and 9 seconds\n",
      "The entire computation  took 66 hours 12 minutes and 51 seconds\n"
     ]
    }
   ],
   "source": [
    "# Generating the tensor products for S3/2 times Ext2 S1/2 the easy way\n",
    "Path12=\"Ext2_S12_matrices/\"\n",
    "Path32=\"S32_matrices/\"\n",
    "Bermans_12=read_in_SR(path=Path12,name=\"X\",number=10,silent=True)\n",
    "Bermans_32=read_in_SR(path=Path32,name=\"X\",number=10,silent=True)\n",
    "E_12=read_in_QQ(path=Path12,name=\"E\",number=5,silent=True)\n",
    "E_32=read_in_QQ(path=Path32,name=\"E\",number=5,silent=True)\n",
    "F_12=read_in_QQ(path=Path12,name=\"F\",number=5,silent=True)\n",
    "F_32=read_in_QQ(path=Path32,name=\"F\",number=5,silent=True)\n",
    "\n",
    "\n",
    "print(\"Read in all necessary matrices.\")\n",
    "\n",
    "start_total=time.time()\n",
    "Bermans=[]\n",
    "IBermans=[]\n",
    "start_Bermans=time.time()\n",
    "for i in range(10):\n",
    "    print(\"Computing Berman number\",i)\n",
    "    start=time.time()\n",
    "    x=Bermans_32[i]\n",
    "    y=Bermans_12[i]\n",
    "    z=Lie_tensor(x,y)\n",
    "    Bermans.append(z)\n",
    "    IBermans.append(I*z)\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_Bermans=time.time()\n",
    "tt=convert_to_hms(ceil(end_Bermans-start_Bermans))\n",
    "print(\"Computation of the Berman generators took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "start_E=time.time()\n",
    "E=[]\n",
    "for i in range(5):\n",
    "    print(\"Computing E_ladder number\",i)\n",
    "    start=time.time()\n",
    "    x=E_32[i]\n",
    "    y=E_12[i]\n",
    "    E.append(Lie_tensor(x,y))\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_E=time.time()\n",
    "tt=convert_to_hms(ceil(end_E-start_E))\n",
    "print(\"Computation of the E_ladder took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "\n",
    "start_F=time.time()\n",
    "F=[]\n",
    "for i in range(5):\n",
    "    print(\"Computing F_ladder number\",i)\n",
    "    start=time.time()\n",
    "    x=F_32[i]\n",
    "    y=F_12[i]\n",
    "    F.append(Lie_tensor(x,y))\n",
    "    end=time.time()\n",
    "    print(\"Took\",end-start,\"seconds.\")\n",
    "end_F=time.time()\n",
    "tt=convert_to_hms(ceil(end_F-start_F))\n",
    "print(\"Computation of the F_ladder took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "start_H=time.time()\n",
    "H_orth=[]\n",
    "print(\"Computing H_orth\")\n",
    "H_orth=get_H_orth(Bermans)\n",
    "end_H=time.time()\n",
    "tt=convert_to_hms(ceil(end_H-start_H))\n",
    "print(\"Computation of the H_orth took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")\n",
    "\n",
    "\n",
    "end_total=time.time()\n",
    "tt=convert_to_hms(ceil(end_total-start_total))\n",
    "print(\"The entire computation  took\",tt[0],\"hours\",tt[1],\"minutes and\",\n",
    "      tt[2],\"seconds\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  138.67316031455994 seconds\n",
      "Writing matrix number 0 of 9\n",
      "Writing matrix number 1 of 9\n",
      "Writing matrix number 2 of 9\n",
      "Writing matrix number 3 of 9\n",
      "Writing matrix number 4 of 9\n",
      "Writing matrix number 5 of 9\n",
      "Writing matrix number 6 of 9\n",
      "Writing matrix number 7 of 9\n",
      "Writing matrix number 8 of 9\n",
      "Writing matrix number 9 of 9\n",
      "Writing the matrices to file by key took  150.66079950332642 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  6.7502219676971436 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  5.355886220932007 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  0.06326484680175781 seconds\n",
      "Writing matrix number 0 of 4\n",
      "Writing matrix number 1 of 4\n",
      "Writing matrix number 2 of 4\n",
      "Writing matrix number 3 of 4\n",
      "Writing matrix number 4 of 4\n",
      "Writing the matrices to file by key took  34.203513860702515 seconds\n"
     ]
    }
   ],
   "source": [
    "save_path=\"S32_times_Ext2_S12_matrices/\"\n",
    "try:\n",
    "    os.makedirs(save_path)\n",
    "except os.error as error:\n",
    "    print(save_path,\"already exists. Possible overwriting of old results.\")\n",
    "\n",
    "\n",
    "d=Bermans[0].dimensions()[0]\n",
    "write_to_file_by_key(matrices=IBermans,dim=d,path=save_path,\n",
    "                     name=\"IX\")\n",
    "write_to_file_by_key(matrices=Bermans,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"X\")\n",
    "write_to_file_by_key(matrices=E,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"E\")\n",
    "write_to_file_by_key(matrices=F,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"F\")\n",
    "write_to_file_by_key(matrices=H_weyl,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"h_weyl\")\n",
    "write_to_file_by_key(matrices=H_orth,dim=d,\n",
    "                     path=save_path,\n",
    "                     name=\"H\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 9.0",
   "language": "sage",
   "name": "sagemath"
  },
  "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
}
