ShiftGate.get_grad
- ShiftGate.get_grad(params=[])
Return the gradient for the unitary map as an np.ndarray.
- Parameters:
params (
Sequence[float] |float64|float32) – The unitary parameters, seeUnitary.get_unitary()for more info.- Returns:
The (num_params,N,N)-shaped, matrix-by-vector derivative of this unitary at the point specified by params.
- Return type:
complex128
Notes
The gradient of a unitary is defined as a matrix-by-vector derivative. If the UnitaryMatrix result of get_unitary has dimension NxN, then the shape of get_grad’s return value should equal (num_params,N,N), where the return value’s i-th element is the matrix derivative of the unitary with respect to the i-th parameter.
Gates backed by an openqudit UnitaryExpression (i.e. that set _expr) get a gradient definition for free here. Gates that don’t set _expr and don’t override this method raise NotImplementedError. Use
is_differentiable()to check whether a gate has a gradient definition.