diff --git a/computations/lookup_table_2_qbits_CZ_states.ipynb b/computations/lookup_table_2_qbits_CZ_states.ipynb index 36bd041..8a99fcd 100644 --- a/computations/lookup_table_2_qbits_CZ_states.ipynb +++ b/computations/lookup_table_2_qbits_CZ_states.ipynb @@ -384,16 +384,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Invert the resulting matrices to check if they match a starting matrix." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "resulting_matrices_np_invers = np.array([m.transpose().conjugate() for m in resulting_matrices_np])" + "Compute the starting and resulting states. Note that a graph state is always computed beginning from a $|+>$ state." ] }, { @@ -407,7 +398,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -416,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -424,39 +415,46 @@ ] }, { - "cell_type": "code", - "execution_count": 41, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "def state_eq(s1, s2):\n", - " if(not np.allclose(np.absolute(s1), np.absolute(s2))):\n", - " return False\n", - " angles = np.angle(s1) - np.angle(s2)\n", - " if(angles[0] != angles[1] or\n", - " angles[2] != angles[3]):\n", - " return False\n", - " #if(not np.allclose(angles - angles[0], np.zeros(4))):\n", - " # return False\n", - " return True\n" + "When comparing states one has to keep in mind that one can ignore qbit-global phases, as they cannot be measured by projection." ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "def state_eq(s1, s2):\n", + " if(np.allclose(s1, s2)):\n", + " return True\n", + " if(not np.allclose(s1 == 0, s2 == 0)):\n", + " return False\n", + " nonzeros = s1 != 0\n", + " phases = s1[nonzeros] / s2[nonzeros]\n", + " angles = np.angle(phases)\n", + " phaseless = np.exp(-1j * np.max(angles)) * phases\n", + " return np.allclose(phaseless, np.ones(len([n for n in nonzeros if n])))" + ] + }, + { + "cell_type": "code", + "execution_count": 39, "metadata": {}, "outputs": [ { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAOCAYAAACsAAXLAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB3ElEQVRIDbWVgVECMRBFOccCbrACpQPQCqQEbEE70KEE7QBbwA6gAwc6gA4EOsD3MskR8BiYkduZvd1sNpufzW6u2G63rURFUXTRx3AP+ybZD+UpP+bvWPMW190jV46JOY+2IPArUYbwD3wDOx7jN0UGCga0ETyDRVsKOmdtsMBP+QnMDar1jN9h4/YP7KN8rA65xyDo+STGV7gW3Ll+MXjd4dbMrVMc9Gc5jZPEZhJmjq9QLk19Aq7jleWxvaoyXrn2DvykcoyaACeIJSffHNnUzEgTuA/YycFBLAFLp3Xt55IEqGPZsNmsw9AUyCmgvjANYDNtA5nNCXPaG7lW4+4RGwss7+AwHw/yEZ3NmJ1ddXQT1xr32hN24CdgEpAwCWizJpkxy8FDLLBbtyHNecv/u1sBUMVTh6yfuifDbt2zMxasi+zs8uI1R9CKyIAABPtSGXeK13i7Gwa/L9aYxQXcbwxcvLJODgybdSf5x/At/NPR2Jb42RDtRmqO4NbOAxulXxjDQF7bKoLaZGDjdCV8bqYXz1zc0AbwqQjvVdyyjewCLDWFT84Yn8cINrgxthR8TpYFnxYGg4nWVlYuYVv6Owt2lh+x/D+buTqaE6+XJvDVbwh7zYmqH/8vW6V5halvul4AAAAASUVORK5CYII=\n", + "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAPCAYAAABnXNZuAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABw0lEQVRIDcWWgVECMRBFOccCbigBOkDtADvQFrQDqUE7wBKkBOjAkQ6gBKADfC8kR+5A0BmQnVmS3fxsfjabHMV6vW6dWoqi6BF3msfFV2K38c9z/8G+5JIC7KEztEy+fe0xHONL1F1/RTXmTlx8HXQYVewYdWOBE/2WOxqhggQYdIecPvQozsBIIqNh/xWtxcSW2CgRifPEOacf7MbgSxysBcoxMchBXHPR5vwYw43urIPPrC/FXNG5lPRZeBlrMecwwSjxdy5JThJzMrTKmWX98jozTtpl508EtE6VLjqESHWD6T+Gkd0fL6UXYnoucpL6SFnxiLBntPf4zNheYVxiYgcBADh/Sg4WesIy8Ve4hLdFfCZmua/Zdxw1w4HTf9acj28nZpFuXfD7lE0g9pxGTk6ORcao7+VPkuqwGgdvfZqtipj2OWrulrgLgzekrQ2B6lJoQ+yBppsTw2fdneWde2chb2dTfNdqlwESXoA78JsLsJ0h4cU5MjdkUYu6OiJsL5BSPR8xO34lJuLD6ObHDPt9fSv4MbXhU4LTI7EmLF7T/ymINsgfcNvngH8iTPaYB8RabSKF47Quzdw+mYK9+QYkdqlSSVVlyAAAAABJRU5ErkJggg==\n", "text/latex": [ - "$\\displaystyle 1128$" + "$\\displaystyle 1152$" ], "text/plain": [ - "1128" + "1152" ] }, - "execution_count": 42, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -472,161 +470,128 @@ "len(found_indices.keys())" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now compute the lookup table that maps the vertex operators and the entanglement **before** the $CZ$ to the index in the lookup table **after** the $CZ$:" + ] + }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 41, "metadata": {}, "outputs": [ { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAABM0AAAAVCAYAAABVCBmpAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAWqUlEQVR4Ae1djbXlNNJk5hAAO18Ey2bATwZsBjO7EQAZwCGCPZAB+0WwCxnMZsAyGUAGwMuArfJTG1lXtqplWdeeJ53jZ1ludVeXumVfPV/fZ++8884X2D7HxvLq999/f/NYHX8HA4OBwcBgYDAwGBgMDAYGA4OBwcBgYDAwGBgMDAYGA0+DgWfPni3WyJ7D7f/D9jkWy/7iXTCDsvexfYbtvavRN7BfbcSOx4uY+CC1wthmrKTtZztuiZ3+YuuW1y2x32NcFPweThV99/DzTDY9fJ4JtxfLU/HTy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AAAAAElFTkSuQmCC\n", "text/latex": [ - "$\\displaystyle \\left[ 373, \\ 376, \\ 379, \\ 468, \\ 503, \\ 527, \\ 549, \\ 575, \\ 623, \\ 713, \\ 879, \\ 968, \\ 974, \\ 989, \\ 1003, \\ 1023, \\ 1049, \\ 1078, \\ 1097, \\ 1102, \\ 1125, \\ 1127, \\ 1129, \\ 1151\\right]$" + "$\\displaystyle \\left( 24, \\ 24, \\ 2\\right)$" ], "text/plain": [ - "[373, 376, 379, 468, 503, 527, 549, 575, 623, 713, 879, 968, 974, 989, 1003, 1\n", - "023, 1049, 1078, 1097, 1102, 1125, 1127, 1129, 1151]" + "(24, 24, 2)" ] }, - "execution_count": 43, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "not_found = [i for i in range(1152) if not i in found_indices]\n", - "not_found" + "from collections import deque\n", + "lookup_edge_c0_c1_to_number = []\n", + "r = []\n", + "c = []\n", + "\n", + "i = 0\n", + "\n", + "for _ in C_L_0:\n", + " r = []\n", + " for _ in C_L_1:\n", + " c = []\n", + " for _ in (I_4, CZ):\n", + " c.append(i)\n", + " i += 1 \n", + " r.append(c)\n", + " lookup_edge_c0_c1_to_number.append(r)\n", + " \n", + "lookup_edge_c0_c1_to_number = np.array(lookup_edge_c0_c1_to_number, dtype=np.int)\n", + "lookup_edge_c0_c1_to_number.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Produce (almost valid) `C` code to look up the lookup table number from given clifford operator indices and entanglement (0 means no entanglement)." + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " , {0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}, {10, 11}, {12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}, {24, 25}, {26, 27}, {28, 29}, {30, 31}, {32, 33}, {34, 35}, {36, 37}, {38, 39}, {40, 41}, {42, 43}, {44, 45}, {46, 47} }\n", + " , {48, 49}, {50, 51}, {52, 53}, {54, 55}, {56, 57}, {58, 59}, {60, 61}, {62, 63}, {64, 65}, {66, 67}, {68, 69}, {70, 71}, {72, 73}, {74, 75}, {76, 77}, {78, 79}, {80, 81}, {82, 83}, {84, 85}, {86, 87}, {88, 89}, {90, 91}, {92, 93}, {94, 95} }\n", + " , {96, 97}, {98, 99}, {100, 101}, {102, 103}, {104, 105}, {106, 107}, {108, 109}, {110, 111}, {112, 113}, {114, 115}, {116, 117}, {118, 119}, {120, 121}, {122, 123}, {124, 125}, {126, 127}, {128, 129}, {130, 131}, {132, 133}, {134, 135}, {136, 137}, {138, 139}, {140, 141}, {142, 143} }\n", + " , {144, 145}, {146, 147}, {148, 149}, {150, 151}, {152, 153}, {154, 155}, {156, 157}, {158, 159}, {160, 161}, {162, 163}, {164, 165}, {166, 167}, {168, 169}, {170, 171}, {172, 173}, {174, 175}, {176, 177}, {178, 179}, {180, 181}, {182, 183}, {184, 185}, {186, 187}, {188, 189}, {190, 191} }\n", + " , {192, 193}, {194, 195}, {196, 197}, {198, 199}, {200, 201}, {202, 203}, {204, 205}, {206, 207}, {208, 209}, {210, 211}, {212, 213}, {214, 215}, {216, 217}, {218, 219}, {220, 221}, {222, 223}, {224, 225}, {226, 227}, {228, 229}, {230, 231}, {232, 233}, {234, 235}, {236, 237}, {238, 239} }\n", + " , {240, 241}, {242, 243}, {244, 245}, {246, 247}, {248, 249}, {250, 251}, {252, 253}, {254, 255}, {256, 257}, {258, 259}, {260, 261}, {262, 263}, {264, 265}, {266, 267}, {268, 269}, {270, 271}, {272, 273}, {274, 275}, {276, 277}, {278, 279}, {280, 281}, {282, 283}, {284, 285}, {286, 287} }\n", + " , {288, 289}, {290, 291}, {292, 293}, {294, 295}, {296, 297}, {298, 299}, {300, 301}, {302, 303}, {304, 305}, {306, 307}, {308, 309}, {310, 311}, {312, 313}, {314, 315}, {316, 317}, {318, 319}, {320, 321}, {322, 323}, {324, 325}, {326, 327}, {328, 329}, {330, 331}, {332, 333}, {334, 335} }\n", + " , {336, 337}, {338, 339}, {340, 341}, {342, 343}, {344, 345}, {346, 347}, {348, 349}, {350, 351}, {352, 353}, {354, 355}, {356, 357}, {358, 359}, {360, 361}, {362, 363}, {364, 365}, {366, 367}, {368, 369}, {370, 371}, {372, 373}, {374, 375}, {376, 377}, {378, 379}, {380, 381}, {382, 383} }\n", + " , {384, 385}, {386, 387}, {388, 389}, {390, 391}, {392, 393}, {394, 395}, {396, 397}, {398, 399}, {400, 401}, {402, 403}, {404, 405}, {406, 407}, {408, 409}, {410, 411}, {412, 413}, {414, 415}, {416, 417}, {418, 419}, {420, 421}, {422, 423}, {424, 425}, {426, 427}, {428, 429}, {430, 431} }\n", + " , {432, 433}, {434, 435}, {436, 437}, {438, 439}, {440, 441}, {442, 443}, {444, 445}, {446, 447}, {448, 449}, {450, 451}, {452, 453}, {454, 455}, {456, 457}, {458, 459}, {460, 461}, {462, 463}, {464, 465}, {466, 467}, {468, 469}, {470, 471}, {472, 473}, {474, 475}, {476, 477}, {478, 479} }\n", + " , {480, 481}, {482, 483}, {484, 485}, {486, 487}, {488, 489}, {490, 491}, {492, 493}, {494, 495}, {496, 497}, {498, 499}, {500, 501}, {502, 503}, {504, 505}, {506, 507}, {508, 509}, {510, 511}, {512, 513}, {514, 515}, {516, 517}, {518, 519}, {520, 521}, {522, 523}, {524, 525}, {526, 527} }\n", + " , {528, 529}, {530, 531}, {532, 533}, {534, 535}, {536, 537}, {538, 539}, {540, 541}, {542, 543}, {544, 545}, {546, 547}, {548, 549}, {550, 551}, {552, 553}, {554, 555}, {556, 557}, {558, 559}, {560, 561}, {562, 563}, {564, 565}, {566, 567}, {568, 569}, {570, 571}, {572, 573}, {574, 575} }\n", + " , {576, 577}, {578, 579}, {580, 581}, {582, 583}, {584, 585}, {586, 587}, {588, 589}, {590, 591}, {592, 593}, {594, 595}, {596, 597}, {598, 599}, {600, 601}, {602, 603}, {604, 605}, {606, 607}, {608, 609}, {610, 611}, {612, 613}, {614, 615}, {616, 617}, {618, 619}, {620, 621}, {622, 623} }\n", + " , {624, 625}, {626, 627}, {628, 629}, {630, 631}, {632, 633}, {634, 635}, {636, 637}, {638, 639}, {640, 641}, {642, 643}, {644, 645}, {646, 647}, {648, 649}, {650, 651}, {652, 653}, {654, 655}, {656, 657}, {658, 659}, {660, 661}, {662, 663}, {664, 665}, {666, 667}, {668, 669}, {670, 671} }\n", + " , {672, 673}, {674, 675}, {676, 677}, {678, 679}, {680, 681}, {682, 683}, {684, 685}, {686, 687}, {688, 689}, {690, 691}, {692, 693}, {694, 695}, {696, 697}, {698, 699}, {700, 701}, {702, 703}, {704, 705}, {706, 707}, {708, 709}, {710, 711}, {712, 713}, {714, 715}, {716, 717}, {718, 719} }\n", + " , {720, 721}, {722, 723}, {724, 725}, {726, 727}, {728, 729}, {730, 731}, {732, 733}, {734, 735}, {736, 737}, {738, 739}, {740, 741}, {742, 743}, {744, 745}, {746, 747}, {748, 749}, {750, 751}, {752, 753}, {754, 755}, {756, 757}, {758, 759}, {760, 761}, {762, 763}, {764, 765}, {766, 767} }\n", + " , {768, 769}, {770, 771}, {772, 773}, {774, 775}, {776, 777}, {778, 779}, {780, 781}, {782, 783}, {784, 785}, {786, 787}, {788, 789}, {790, 791}, {792, 793}, {794, 795}, {796, 797}, {798, 799}, {800, 801}, {802, 803}, {804, 805}, {806, 807}, {808, 809}, {810, 811}, {812, 813}, {814, 815} }\n", + " , {816, 817}, {818, 819}, {820, 821}, {822, 823}, {824, 825}, {826, 827}, {828, 829}, {830, 831}, {832, 833}, {834, 835}, {836, 837}, {838, 839}, {840, 841}, {842, 843}, {844, 845}, {846, 847}, {848, 849}, {850, 851}, {852, 853}, {854, 855}, {856, 857}, {858, 859}, {860, 861}, {862, 863} }\n", + " , {864, 865}, {866, 867}, {868, 869}, {870, 871}, {872, 873}, {874, 875}, {876, 877}, {878, 879}, {880, 881}, {882, 883}, {884, 885}, {886, 887}, {888, 889}, {890, 891}, {892, 893}, {894, 895}, {896, 897}, {898, 899}, {900, 901}, {902, 903}, {904, 905}, {906, 907}, {908, 909}, {910, 911} }\n", + " , {912, 913}, {914, 915}, {916, 917}, {918, 919}, {920, 921}, {922, 923}, {924, 925}, {926, 927}, {928, 929}, {930, 931}, {932, 933}, {934, 935}, {936, 937}, {938, 939}, {940, 941}, {942, 943}, {944, 945}, {946, 947}, {948, 949}, {950, 951}, {952, 953}, {954, 955}, {956, 957}, {958, 959} }\n", + " , {960, 961}, {962, 963}, {964, 965}, {966, 967}, {968, 969}, {970, 971}, {972, 973}, {974, 975}, {976, 977}, {978, 979}, {980, 981}, {982, 983}, {984, 985}, {986, 987}, {988, 989}, {990, 991}, {992, 993}, {994, 995}, {996, 997}, {998, 999}, {1000, 1001}, {1002, 1003}, {1004, 1005}, {1006, 1007} }\n", + " , {1008, 1009}, {1010, 1011}, {1012, 1013}, {1014, 1015}, {1016, 1017}, {1018, 1019}, {1020, 1021}, {1022, 1023}, {1024, 1025}, {1026, 1027}, {1028, 1029}, {1030, 1031}, {1032, 1033}, {1034, 1035}, {1036, 1037}, {1038, 1039}, {1040, 1041}, {1042, 1043}, {1044, 1045}, {1046, 1047}, {1048, 1049}, {1050, 1051}, {1052, 1053}, {1054, 1055} }\n", + " , {1056, 1057}, {1058, 1059}, {1060, 1061}, {1062, 1063}, {1064, 1065}, {1066, 1067}, {1068, 1069}, {1070, 1071}, {1072, 1073}, {1074, 1075}, {1076, 1077}, {1078, 1079}, {1080, 1081}, {1082, 1083}, {1084, 1085}, {1086, 1087}, {1088, 1089}, {1090, 1091}, {1092, 1093}, {1094, 1095}, {1096, 1097}, {1098, 1099}, {1100, 1101}, {1102, 1103} }\n", + " , {1104, 1105}, {1106, 1107}, {1108, 1109}, {1110, 1111}, {1112, 1113}, {1114, 1115}, {1116, 1117}, {1118, 1119}, {1120, 1121}, {1122, 1123}, {1124, 1125}, {1126, 1127}, {1128, 1129}, {1130, 1131}, {1132, 1133}, {1134, 1135}, {1136, 1137}, {1138, 1139}, {1140, 1141}, {1142, 1143}, {1144, 1145}, {1146, 1147}, {1148, 1149}, {1150, 1151} }\n", + "}\n" + ] + } + ], + "source": [ + "print(\"{\")\n", + "for r in lookup_edge_c0_c1_to_number:\n", + " print(\" , \", \", \".join((\"{%d, %d}\" % (c[0], c[1]) for c in r)), \"}\")\n", + "print(\"}\") " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To satisfy some constraints try one wants to keep the indentity on one qbit if possible." ] }, { "cell_type": "code", "execution_count": 44, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[[ 0. +0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [-0.70710678+0.j ]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.70710678-0.70710678j]],\n", - "\n", - " [[-0.70710678+0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [-0.70710678+0.j ]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [-0.70710678+0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. -0.70710678j]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[ 0. -0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.70710678+0.j ]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[ 0. -0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.70710678j]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[ 0. +0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [-0.70710678+0.j ]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [-0.70710678+0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. -0.70710678j]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.70710678-0.70710678j]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[-0.5 +0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[-0.70710678+0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [-0.70710678+0.j ]],\n", - "\n", - " [[-0.5 +0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [-0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [-0.5 -0.5j ]],\n", - "\n", - " [[-0.35355339+0.35355339j],\n", - " [-0.35355339-0.35355339j],\n", - " [-0.35355339+0.35355339j],\n", - " [-0.35355339-0.35355339j]],\n", - "\n", - " [[ 0. +0.j ],\n", - " [-0.70710678+0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. -0.70710678j]],\n", - "\n", - " [[ 0. -0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.70710678+0.j ]],\n", - "\n", - " [[ 0. -0.70710678j],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.70710678j]],\n", - "\n", - " [[ 0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [ 0.5 -0.5j ]],\n", - "\n", - " [[-0.5 -0.5j ],\n", - " [ 0. +0.j ],\n", - " [ 0. +0.j ],\n", - " [-0.5 +0.5j ]]])" + "array([ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,\n", + " 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n", + " 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,\n", + " 135, 136, 137, 138, 139, 140, 141, 142, 143])" ] }, "execution_count": 44, @@ -635,7 +600,136 @@ } ], "source": [ - "resulting_states[not_found]" + "I0_indices = lookup_edge_c0_c1_to_number[2, :, :].reshape(2*24)\n", + "I0_indices" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 4, 5, 52, 53, 100, 101, 148, 149, 196, 197, 244,\n", + " 245, 292, 293, 340, 341, 388, 389, 436, 437, 484, 485,\n", + " 532, 533, 580, 581, 628, 629, 676, 677, 724, 725, 772,\n", + " 773, 820, 821, 868, 869, 916, 917, 964, 965, 1012, 1013,\n", + " 1060, 1061, 1108, 1109])" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "I1_indices = lookup_edge_c0_c1_to_number[:, 2, :].reshape(2*24)\n", + "I1_indices" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Throw away all the matrices that produce the same result that we don't need." + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "def contract_indices(equivs):\n", + " indices_I1 = [e for e in equivs if e in I1_indices]\n", + " indices_I0 = [e for e in equivs if e in I0_indices]\n", + " \n", + " if(not indices_I0 and not indices_I1):\n", + " return [equivs[0], -1, -1]\n", + " if(indices_I0 and not indices_I1):\n", + " return [-1, indices_I0[0], -1]\n", + " if(indices_I1 and not indices_I0):\n", + " return [-1, -1, indices_I1[0]]\n", + " return [-1, indices_I0[0], indices_I1[0]]" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "indices_contracted = {k: contract_indices(v) for k,v in found_indices.items()}" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [], + "source": [ + "starting_indices_to_operators = {i: (c0, c1, e) for i, (c0, c1, e) in enumerate(product(range(24), range(24), range(2)))}" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "def contract_indices_to_single(result_index, indices):\n", + " c0, c1, e = starting_indices_to_operators[result_index]\n", + " # Preserve identity on one qbit.\n", + " # Note that there is no case where both vops are the identity,\n", + " # As they are handled by a different case.\n", + " if(c0 == 2):\n", + " return indices[1]\n", + " if(c1 == 2):\n", + " return indices[2]\n", + " \n", + " # Try to have an identity if it is possible.\n", + " if(indices[1] != -1):\n", + " return indices[1]\n", + " if(indices[2] != -1):\n", + " return indices[2]\n", + " # No identity is possible.\n", + " return indices[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "-1", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mremap_lookup_table_indices\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mcontract_indices_to_single\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mindices\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindices_contracted\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mremap_lookup_table_operators\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mstarting_indices_to_operators\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mremap_lookup_table_indices\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mremap_lookup_table_indices\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mcontract_indices_to_single\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mindices\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindices_contracted\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mremap_lookup_table_operators\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mstarting_indices_to_operators\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mremap_lookup_table_indices\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m: -1" + ] + } + ], + "source": [ + "remap_lookup_table_indices = [contract_indices_to_single(i, indices) for i,indices in sorted(indices_contracted.items())]\n", + "remap_lookup_table_operators = [starting_indices_to_operators[i] for i in remap_lookup_table_indices]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"{\")\n", + "print(\"\\n , \".join((\"{%d, %d, %d}\" % i for i in remap_lookup_table_operators)))\n", + "print(\"}\")" ] } ],