<jupyter_start><jupyter_text>Test 1. Constant Algorithm<jupyter_code>from QCAD import Module, execute
from QCAD import TypicalModule as tm
from QCAD.CircuitDrawer import draw

import numpy as np

UCX = tm.U('UCX', 2, [[1., 0., 0., 0.],
                     [0., 0., 0., 1.],
                     [0., 0., 1., 0.],
                     [0., 1., 0., 0.]])

QC = Module('QC', 3, [tm.H[0],
                     tm.X[1],
                     tm.H[1],
                     tm.CX[1, 2],
                     UCX[1, 2],
                     tm.H[0],
                     tm.H[1],
                     tm.X[1]])

draw(QC, 'decomposed')

execute('MatrixModel', QC, option='barplot')
execute('MatrixModel', QC, initial_state = [[1, 0], [1/np.sqrt(2), 1/np.sqrt(2)], [1, 0]], option='barplot')
execute('MatrixModel', QC, initial_state = [0.5, 0.5, 0, 0.5, 0, 0, 0.5, 0], option='barplot')
execute('Cimulator', QC, option='barplot')
execute('Cimulator', QC, initial_state = [[0, 1], [1/np.sqrt(2), 1/np.sqrt(2)], [1, 0]], option='barplot')
execute('Cimulator', QC, initial_state = [0.5, 0.5, 0, 0.5, 0, 0, 0.5, 0], option='barplot')<jupyter_output><empty_output><jupyter_text>Test 2. Quite Complicated<jupyter_code>SWAP = Module('SWAP', 2, [tm.CX[0, 1],
                         tm.CX[1, 0],
                         tm.CX[0, 1]])

# Controlled Gates

CH = tm.MCU('CH', 2, [0], tm.H[1])
CS = tm.MCU('CS', 2, [0], tm.S[1])
CT = tm.MCU('CT', 2, [0], tm.T[1])

# Module Fourier3

F3 = Module('F3', 3, [tm.H[0],
                      CS[1, 0],
                      CT[2, 0],
                      tm.H[1],
                      CS[2, 1],
                      tm.H[2],
                      SWAP[0, 2]])

# Module Quantum Circuit

CSWAP = tm.MCU('CSWAP', 3, [0], SWAP[1, 2])

QC = Module('QC', 5, [F3[0, 2, 4],
                      CSWAP[4, 0, 2],
                      tm.MCU('MCF3', 5, [0, 1], F3[2, 3, 4])[0, 1, 2, 3, 4]])

draw(F3)
draw(CSWAP)
draw(CSWAP, 'decomposed')
draw(QC)
draw(QC, option='decomposed')

execute('Cimulator', QC, option='nonzero')
execute('MatrixModel', QC, option='nonzero')
execute('Cimulator', QC, [[1, 0], [1/np.sqrt(2), 1/np.sqrt(2)], [1, 0], [1, 0], [1, 0]], option='barplot')
execute('MatrixModel', QC, [[1, 0], [1/np.sqrt(2), 1/np.sqrt(2)], [1, 0], [1, 0], [1, 0]], option='nonzero')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2221269296740995, 'fraction_numerical': 0.06475128644939966, 'mean_word_length': 2.114819759679573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '330608', 'license': 'MIT', 'n_tokens_mistral': 1045, 'n_tokens_neox': 927, 'n_words': 218, 'path': 'Test.ipynb', 'repo_name': 'bus6479/QCAD', 'size': '2332'}