peropq.variational_unitary#
Module Contents#
Classes#
class representing the variational unitary ansataz. |
- class peropq.variational_unitary.VariationalUnitary(hamiltonian, number_of_layer, time)#
class representing the variational unitary ansataz.
- Parameters:
hamiltonian (peropq.hamiltonian.Hamiltonian) –
number_of_layer (int) –
time (float) –
- 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).
- Parameters:
new_array (numpy.typing.NDArray) –
- Return type:
None
- get_initial_trotter_vector()#
Get the variational parameters corresponding to the Trotterization. Useful to initialize the optimization.
- Return type:
numpy.typing.NDArray
- flatten_theta(theta)#
Returns the variational parameters as flatten (R-1)*n_terms array. Useful to pass to a minimization function.
- Parameters:
theta (numpy.typing.NDArray) –
- Return type:
numpy.typing.NDArray
- set_theta_to_trotter()#
Sets the variational parameters to the Trotter parameters.
- Return type:
None
- 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.
- Parameters:
left_indices (numpy.typing.NDArray) –
right_indices (numpy.typing.NDArray) –
- Return type:
numpy.typing.NDArray
- calculate_traces()#
Calculate the trace tensor.
- Return type:
None
- 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.
- Parameters:
theta (numpy.typing.ArrayLike) –
- Return type:
float