This folder contains code based on the methods of arXiv:1611.08012 by N. Chancellor, A. Kissenger, J. Roffe, S. Zohren, and D. Horsman
feel free to reuse/modify but please attribute the source and cite our paper in any published work.
All code in this folder was written by Nicholas Chancellor

The programs given here provides a utility to search for CPC codes of arbitrary code distance (in the form of CPC matrices) using random search, and to process the resulting codes both by turning the matrices into latex arrays and by converting them into stabilizer tables. We make no claim that random search is the optimal way to find these codes, in fact we strongly suspect that huge gains could be made by using more sophisticated numerical searching algorithms. This code is meant to provide proof-of-principle of the CPC idea, and allows a utility for others to experiment with simple codes found using the CPC formalism without having to understand our paper and produce the code themselves*.

This folder contains the following Python code, Jupyter notebook, and example output for the Jupyter notebook:

CPC_examples.ipynb - a Jupyter notebook which demonstrates how to use the module defined in python_CPC_functions.py. At the time of writing, Jupyter could be freely obtained from http://jupyter.org/ . The following files are output from the Jupyter example:
	MbCell.npy
	MpCell.npy
	McCell.npy
	MbCellY.npy
	MpCellY.npy
	McCellY.npy
	Mb_latex_example.txt
	stab_test.txt

python_CPC_functions.py - A python module for finding and manipulating CPC codes, the functions are:
	find_codes - a function for searching for CPC codes of any distance by random search, takes number of physical qubits (n), number of logical qubits (k) and minimum number of errors which code 	should correct as required arguments, as well as number of codes to check and number to keep as optional arguments also has optional argument which causes it to save the codes. Outputs codes as 		tuple of arrays, (MbCell,MpCell,McCell)

	find_codes_includeY - same as find_codes, but uses an error model which includes Pauli Y errors

	CPC_mats_2_stabilizers - a function for creating stablizer tables from CPC codes, and displaying to screen or saving in latex array format. Takes the three CPC matrices as required arguments, and 
	the name of file which results should be saved to as an optional argument, if no file name is specified, results are not saved.

	convert_to_latex_array - converts the CPC matricies to latex arrays and saves them. Takes a CPC matrix and a filename as a required argument.

CPC_randSearch_allDists_simple.py - a script which reproduces the functionality of the 'find_codes' function in the Python module

	

* Note that this statement of intended purpose does NOT imply that we provide any kind of warranty on our code, which we do not.
