peropq.variational_unitary ========================== .. py:module:: peropq.variational_unitary Classes ------- .. autoapisummary:: peropq.variational_unitary.VariationalUnitary Module Contents --------------- .. py:class:: VariationalUnitary(hamiltonian, number_of_layer, time) class representing the variational unitary ansatz. .. py:attribute:: n_terms :type: int .. py:attribute:: pauli_string_list :type: collections.abc.Sequence[peropq.pauli_bitstring.PauliString] .. py:attribute:: depth :type: int .. py:attribute:: theta :type: numpy.typing.NDArray .. py:attribute:: cjs :type: collections.abc.Sequence[complex] .. py:attribute:: time :type: float .. py:attribute:: test :type: numpy.typing.NDArray .. py:attribute:: trace_calculated :value: False .. py:method:: update_theta(new_array) Update theta ensuring that the condition Sum_i theta_i dt_i= is ensured. :param new_array: the new array containing the variational parameters. It's shape must be (R - 1, n_terms). .. py:method:: get_initial_trotter_vector() Get the variational parameters corresponding to the Trotterization. Useful to initialize the optimization. .. py:method:: flatten_theta(theta) Returns the variational parameters as flatten (R-1)*n_terms array. Useful to pass to a minimization function. .. py:method:: unflatten_theta(flat_theta) Returns the flattened variational parameters as an array with shape (depth,n_terms). .. py:method:: set_theta_to_trotter() Sets the variational parameters to the Trotter parameters. .. py:method:: chi_tensor(left_indices, right_indices) Vectorized function to calculate all the chi coefficient at once. :param left_indices: indices of the left tensor which give non-zero contributions in the calculation of chi. :param right_indices: indices of the right tensor which give non-zero contributions in the calculation of chi. :returns: numpy array representing the tensor used in the norm calculation. .. py:method:: calculate_traces() Calculate the trace tensor. .. py:method:: c2_squared(theta = ()) Perturbative 2-norm. :param theta: parameters of the variational unitary. :returns: the perturbative approximation of the 2-norm difference between the exact and the variational representation.