get_params_to_unitarytensor_func
- qujax.get_params_to_unitarytensor_func(gate_seq, qubit_inds_seq, param_inds_seq, n_qubits=None)
Creates a function that maps circuit parameters to a unitarytensor. The unitarytensor is an array with shape (2,) * 2 * n_qubits representing the full unitary matrix of the circuit.
- Parameters:
gate_seq (Sequence[str | Array | Callable[[Array], Array] | Callable[[], Array]]) – Sequence of gates. Each element is either a string matching a unitary array or function in qujax.gates, a custom unitary array or a custom function taking parameters and returning a unitary array. Unitary arrays will be reshaped into tensor form (2, 2,…)
qubit_inds_seq (Sequence[Sequence[int]]) – Sequences of sequences representing qubit indices (ints) that gates are acting on. i.e. [[0], [0,1], [1]] tells qujax the first gate is a single qubit gate acting on the zeroth qubit, the second gate is a two qubit gate acting on the zeroth and first qubit etc.
param_inds_seq (Sequence[None | Sequence[int]]) – Sequence of sequences representing parameter indices that gates are using, i.e. [[0], [], [5, 2]] tells qujax that the first gate uses the zeroth parameter (the float at position zero in the parameter vector/array), the second gate is not parameterised and the third gate uses the parameters at position five and two.
n_qubits (int | None) – Number of qubits, if fixed.
- Returns:
Function which maps any parameters to a unitarytensor.
- Return type:
Callable[[], ndarray] | Callable[[ndarray], ndarray]