qml.math.reduce_matrices

reduce_matrices(mats_and_wires_gen, reduce_func)[source]

Apply the given reduce_func cumulatively to the items of the mats_and_wires_gen generator, from left to right, reducing the sequence to a tuple containing a single matrix and the wires it acts on.

Parameters:
  • mats_and_wires_gen (Iterable) – tuples containing the matrix and the wires of each operator

  • reduce_func (callable) – function used to reduce the sequence of operators

Returns:

a tuple containing the reduced matrix and the wires it acts on

Return type:

Tuple[tensor, Sequence]