# qml.Hermitian¶

class Hermitian(A, wires)[source]

An arbitrary Hermitian observable.

For a Hermitian matrix $$A$$, the expectation command returns the value

$\braket{A} = \braketT{\psi}{\cdots \otimes I\otimes A\otimes I\cdots}{\psi}$

where $$A$$ acts on the requested wires.

If acting on $$N$$ wires, then the matrix $$A$$ must be of size $$2^N\times 2^N$$.

Details:

• Number of wires: Any

• Number of parameters: 1

Parameters
• A (array) – square hermitian matrix

• wires (Sequence[int] or int) – the wire(s) the operation acts on

 do_check_domain eigendecomposition Return the eigendecomposition of the matrix specified by the Hermitian observable. eigvals Return the eigenvalues of the specified Hermitian observable. grad_method matrix Matrix representation of an instantiated operator in the computational basis. name String for the name of the operator. num_params num_wires par_domain parameters Current parameter values. return_type wires Wires of this operator.
do_check_domain = True
eigendecomposition

Return the eigendecomposition of the matrix specified by the Hermitian observable.

This method uses pre-stored eigenvalues for standard observables where possible and stores the corresponding eigenvectors from the eigendecomposition.

It transforms the input operator according to the wires specified.

Returns

dictionary containing the eigenvalues and the eigenvectors of the Hermitian observable

Return type

dict[str, array]

eigvals

Return the eigenvalues of the specified Hermitian observable.

This method uses pre-stored eigenvalues for standard observables where possible and stores the corresponding eigenvectors from the eigendecomposition.

Returns

array containing the eigenvalues of the Hermitian observable

Return type

array

grad_method = 'F'
matrix

Matrix representation of an instantiated operator in the computational basis.

Example:

>>> U = qml.RY(0.5, wires=1)
>>> U.matrix
>>> array([[ 0.96891242+0.j, -0.24740396+0.j],
[ 0.24740396+0.j,  0.96891242+0.j]])

Returns

matrix representation

Return type

array

name

String for the name of the operator.

num_params = 1
num_wires = -1
par_domain = 'A'
parameters

Current parameter values.

Fixed parameters are returned as is, free parameters represented by Variable instances are replaced by their current numerical value.

Returns

parameter values

Return type

list[Any]

return_type = None
wires

Wires of this operator.

Returns

wires

Return type

Wires

 check_domain(p[, flattened]) Check the validity of a parameter. Return the gate set that diagonalizes a circuit according to the specified Hermitian observable. Append the operator to the Operator queue.
check_domain(p, flattened=False)

Check the validity of a parameter.

Variable instances can represent any real scalars (but not arrays).

Parameters
• p (Number, array, Variable) – parameter to check

• flattened (bool) – True means p is an element of a flattened parameter sequence (affects the handling of ‘A’ parameters)

Raises
• TypeError – parameter is not an element of the expected domain

• ValueError – parameter is an element of an unknown domain

Returns

p

Return type

Number, array, Variable

diagonalizing_gates()[source]

Return the gate set that diagonalizes a circuit according to the specified Hermitian observable.

This method uses pre-stored eigenvalues for standard observables where possible and stores the corresponding eigenvectors from the eigendecomposition.

Returns

list containing the gates diagonalizing the Hermitian observable

Return type

list

queue()

Append the operator to the Operator queue.