QNLP
v1.0
|
Functions | |
def | pow2bits (bin_val) |
def | get_type_offsets (encoding_dict) |
def | get_type_masks (encoding_dict, type_offsets=None) |
def | bin_to_sentence (bin_val, encoding_dict, decoding_dict, type_offsets=None) |
def | gen_state_string (l) |
def | HammingInt (int i1, int i2) |
def | num_qubits (dict enc_dict) |
def | encode_binary_pattern ((str, str, str) pattern, dict enc_dict) |
def | encode_binary_pattern_direct ([int, int, int] pattern, dict enc_dict) |
def | decode_binary_pattern (int pattern, dict dec_dict) |
def QNLP.encoding.utils.bin_to_sentence | ( | bin_val, | |
encoding_dict, | |||
decoding_dict, | |||
type_offsets = None |
|||
) |
Map the integer binary value to the result from the encoded basis mappings.
Definition at line 38 of file utils.py.
References QNLP.encoding.utils.get_type_masks(), and QNLP.encoding.utils.get_type_offsets().
def QNLP.encoding.utils.decode_binary_pattern | ( | int | pattern, |
dict | dec_dict | ||
) |
Pass in the pattern given as the encoded integer. The pattern will be deconstructed into the appropriate token tuple and output for plotting/printing. Inverse of encode_binary_pattern.
Definition at line 105 of file utils.py.
References QNLP.encoding.utils.num_qubits().
def QNLP.encoding.utils.encode_binary_pattern | ( | (str,str,str) | pattern, |
dict | enc_dict | ||
) |
Pass in the pattern given by the basis token values as (ns,v,no) The pattern will be constructed into the appropriate binary string and output for encoding.
Definition at line 80 of file utils.py.
References QNLP.encoding.utils.num_qubits().
def QNLP.encoding.utils.encode_binary_pattern_direct | ( | [int,int,int] | pattern, |
dict | enc_dict | ||
) |
Pass in the pattern given by the basis token values as (ns,v,no) The pattern will be constructed into the appropriate binary string and output for encoding.
Definition at line 93 of file utils.py.
References QNLP.encoding.utils.num_qubits().
def QNLP.encoding.utils.gen_state_string | ( | l | ) |
def QNLP.encoding.utils.get_type_masks | ( | encoding_dict, | |
type_offsets = None |
|||
) |
Definition at line 24 of file utils.py.
References QNLP.encoding.utils.get_type_offsets().
Referenced by QNLP.encoding.utils.bin_to_sentence().
def QNLP.encoding.utils.get_type_offsets | ( | encoding_dict | ) |
Definition at line 18 of file utils.py.
References QNLP.encoding.utils.pow2bits().
Referenced by QNLP.encoding.utils.bin_to_sentence(), and QNLP.encoding.utils.get_type_masks().
def QNLP.encoding.utils.HammingInt | ( | int | i1, |
int | i2 | ||
) |
Simple integer based hamming distance for bits
Definition at line 66 of file utils.py.
References QNLP_Python_MPI.count.
def QNLP.encoding.utils.num_qubits | ( | dict | enc_dict | ) |
Assuming simple.py encoding and give qubits as num_tokens/2 per meaning space
Definition at line 70 of file utils.py.
Referenced by QNLP.encoding.utils.decode_binary_pattern(), QNLP.encoding.utils.encode_binary_pattern(), and QNLP.encoding.utils.encode_binary_pattern_direct().
def QNLP.encoding.utils.pow2bits | ( | bin_val | ) |
Convert the integer value to a tuple of the next power of two, and number of bits required to represent it.
Definition at line 4 of file utils.py.
Referenced by QNLP.encoding.utils.get_type_offsets().