peropq.bch_optimized ==================== .. py:module:: peropq.bch_optimized Classes ------- .. autoapisummary:: peropq.bch_optimized.NormTerm peropq.bch_optimized.VariationalNorm Functions --------- .. autoapisummary:: peropq.bch_optimized._get_non_zero_trace_indices peropq.bch_optimized._loop_over_trace peropq.bch_optimized._is_pauli_string peropq.bch_optimized._is_norm_term peropq.bch_optimized.commutator Module Contents --------------- .. py:function:: _get_non_zero_trace_indices(bitstrings) Get all the the term indices which have non zero trace, i.e Tr(term[i]*term[j])!=0. Works directly at the bitstring level. :param bitstring: array containing bitstrings one which to compute the trace over. :returns: an array containing the qubit indices on which the Pauli string does not have identity. .. py:function:: _loop_over_trace(trace_list, indices, theta, min_order, all_the_orders, all_the_indices, begin_list, end_list, all_the_coefficients) Just in timed compiled function which computes the norm once all the traces are calculated. :param trace_list: array containing all the non zero traces :param indices: array containing the indices corresponding to every trace :param theta: variational parameters :param min_order: minimum order to be taken into the calculation (i.e. 0 for uncontrained and 1 for contrained) :param all_the_orders: array containaing the order of every term included in the terms :param all_the_indices: indices of the theta parameters for all the terms in the trace :param begin_list: array containing the first index to take into account in the trace for the variational parameters :param end_list: array containing the last index to take into account in the trace for the variational parameters :param all_the_coefficients: coefficient of the NormTerms which need to be taken into account in the trace :returns: the perturbative norm .. py:class:: NormTerm Class representing a term to be taken into account in the norm. :param pauli_string: of the term :param order: at which the term is relevant :param coefficient: in front of the Pauli string :param theta_indices: represents the indices of the variational parameter to be multiplied in front .. py:attribute:: pauli_string :type: peropq.pauli_bitstring.PauliString .. py:attribute:: order :type: int .. py:attribute:: coefficient :type: complex .. py:attribute:: theta_indices :type: list[tuple[int, int]] .. py:function:: _is_pauli_string(to_test) .. py:function:: _is_norm_term(to_test) .. py:function:: commutator(aterm, other) Take the commutator between two NormTerm instances. .. py:class:: VariationalNorm(variational_unitary, order, *, unconstrained = False) Class representing the perturbative norm with some variational parameters. It is used in the optimization process. .. py:attribute:: variational_unitary .. py:attribute:: order .. py:attribute:: terms :type: dict[int, list[NormTerm]] .. py:attribute:: unconstrained .. py:attribute:: calculated_trace :value: False .. py:method:: compute_commutator_sum(term_list1, term_list2) Compute the commutator of two sums of Pauli strings: [term_list1[0]+term_list1[1]+term_list1[2]+...,term_list2[0]+term_list2[1]+term_list2[2]+...]. :returns: a list of instances of NormTerm corresponding to the commutator. .. py:method:: add_term(new_term) Take into account a new term in the variational norm. This is currently implemented up to order 4. .. py:method:: get_commutators() Get the commutators required to calculate the perturbative variational norm. .. py:method:: get_traces() Calculate all the traces of commutator needed for the perturbative variational norm. .. py:method:: calculate_norm(theta) Calculate the norm for a given variational parameter theta. :param theta: variational parameter :returns: the norm