mpsprep.helpers

Helper functions for the Matrix Product State-based state preparation

Helper functions that are used in the MPS technique, or just generally helpful when using this technique.

Functions

best_s_val_truncation_idx(s_vals)

Given a list of singular values, this function returns the index of the singular value that is the best valid candidate for truncation.

bit_string(nqubits, decimal)

Returns a binary string that is nqubits wide, with the least significant bit at the right.

coarse_truncate_s_vals(s_vals[, threshold])

Given a list of singular values, this function returns the list of singular values after truncating the singular values below the given threshold.

entropy_of_random_sparse(num_qubits, ...[, seed])

Given a number of qubits, a sparsity, and a number of random samples to generate, this function returns the mean fractional entropy of the generated samples.

generate_target_state(num_qubits, case[, ...])

Generates a target state for the state preparation circuit.

get_max_s_val_ratio(s_vals)

Given a list of singular values, this function returns the ratio of the largest singular value to the smallest singular value.

mean_fractional_entropy(y_amp)

Given an array of amplitudes y_amp that define the quantum state \(|y> = \sum_i y_{amp}[i] |i>\), this function returns the mean fractional entropy of \(|y>\).

ranks_from_s_vals(s_vals)

Given a list of singular values from multiple SVDs, this function returns the rank of each matrix in the SVDs as a list.

state_fidelity(statevec_a, statevec_b)

Given two statevectors, this function returns the fidelity between the two states.

truncate_s_vals(s_vals, index_to_drop)

Given a list of singular values, this function returns the list of singular values after dropping the singular value at the given index.

update_kwargs_dict(default_kwargs[, kwargs])

Given a kwargs dict, this function updates it with the key, value pair of default_kwargs if the key in default_kwargs is not found in kwargs.