get_params_to_densitytensor_func

qujax.get_params_to_densitytensor_func(kraus_ops_seq, qubit_inds_seq, param_inds_seq, n_qubits=None)

Creates a function that maps circuit parameters to a density tensor (a density matrix in tensor form). densitytensor = densitymatrix.reshape((2,) * 2 * n_qubits) densitymatrix = densitytensor.reshape(2 ** n_qubits, 2 ** n_qubits)

Parameters:
  • kraus_ops_seq (Sequence[str | Array | Callable[[Array], Array] | Callable[[], Array] | Iterable[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[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 parameters (and optional densitytensor_in) to a densitytensor. If no parameters are found then the function only takes optional densitytensor_in.

Return type:

Union[Callable[[ndarray, Optional[ndarray]], ndarray], Callable[[Optional[ndarray]], ndarray]]