TNDistance module
TensorNetworkCodes.TNDistance
— ModuleCalculate distances and distributions of logical operator and stabilizer weights for a TensorNetworkCode
, see tn_distance
and tn_operator_weights
.
Operator Weights
TensorNetworkCodes.TNDistance.OperatorWeights
— TypeOperatorWeights(stabilizer_weights,all_operator_weights)
Stores operator weight distribution for stabilizers and all code operators (stabilizers + all logical representatives). Also stores distance. Fields:
stabilizer_weights::Array{Int64,1}
all_operator_weights::Array{Int64,1}
distance::Int64
Note that since julia is 1-indexed stabilizer_weights[j]
gives the number of stabilizers of weight j-1.
Distance and Operator Weight functions
TensorNetworkCodes.TNDistance.tn_operator_weights
— Functiontn_operator_weights(code::TensorNetworkCode;truncate_to=num_qubits(code)+1)
-> OperatorWeights
Returns OperatorWeights
which includes the number of stabilizers of each weight, as well as the number of logical representatives (excluding identity) of each weight, as well as the code distance.
Examples
julia> using TensorNetworkCodes.TNDistance
julia> code = TensorNetworkCode(five_qubit_code());
julia> code = contract(code,code,[[1,1],[3,3]]);
julia> tn_operator_weights(code)
OperatorWeights([1, 0, 0, 0, 9, 0, 6], [1, 0, 9, 24, 99, 72, 51], 2)
TensorNetworkCodes.TNDistance.tn_distance
— Functiontn_distance(code::TensorNetworkCode;truncate_to=num_qubits(code)+1)
-> Int64
Returns the code distance calculated by contracting a tensor network. Returns zero for stabilizer states (codes with no logical qubits).
Examples
julia> using TensorNetworkCodes.TNDistance
julia> code = TensorNetworkCode(steane_code());
julia> code = contract(code,code,[[1,1],[3,3]]); # contract two copies
julia> tn_distance(code) # this code has poor distance!
2
TensorNetworkCodes.TNDistance.plot_operator_weights
— Functionplot_operator_weights(
weights::OperatorWeights; truncate_to=length(weights.stabilizer_weights)
)
Plots a bar plot (on a log scale) of the number of operators of each weight. This includes all code operators (logicals plus stabilizers) and all stabilizers plotted separately.