peropq.variational_unitary¶
Classes¶
class representing the variational unitary ansatz. |
Module Contents¶
- class peropq.variational_unitary.VariationalUnitary(hamiltonian, number_of_layer, time)¶
class representing the variational unitary ansatz.
- Parameters:
hamiltonian (peropq.hamiltonian.Hamiltonian)
number_of_layer (int)
time (float)
- n_terms: int¶
- pauli_string_list: collections.abc.Sequence[peropq.pauli_bitstring.PauliString]¶
- depth: int¶
- theta: numpy.typing.NDArray¶
- cjs: collections.abc.Sequence[complex]¶
- time: float¶
- test: numpy.typing.NDArray¶
- trace_calculated = False¶
- update_theta(new_array)¶
Update theta ensuring that the condition Sum_i theta_i dt_i= is ensured.
- Parameters:
new_array (numpy.typing.NDArray) – the new array containing the variational parameters. It’s shape must be (R - 1, n_terms).
- 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
- unflatten_theta(flat_theta)¶
Returns the flattened variational parameters as an array with shape (depth,n_terms).
- Parameters:
flat_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.
- Parameters:
left_indices (numpy.typing.NDArray) – indices of the left tensor which give non-zero contributions in the calculation of chi.
right_indices (numpy.typing.NDArray) – 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.
- Return type:
numpy.typing.NDArray
- calculate_traces()¶
Calculate the trace tensor.
- Return type:
None
- c2_squared(theta=())¶
Perturbative 2-norm.
- Parameters:
theta (numpy.typing.ArrayLike) – parameters of the variational unitary.
- Returns:
the perturbative approximation of the 2-norm difference between the exact and the variational representation.
- Return type:
float