ket.qulib.math

Quantum arithmetic operations for quantum states.

Functions ket.qulib.math

addi(lhs, rhs[, multiplier])

Add two quantum states or a quantum state and an integer.

mul(lhs, rhs, result)

Multiply two quantum states.

set_int(qubits, state)

Set the state of a quantum register.

addi(lhs: Quant, rhs: Quant | int, multiplier: int = 1)

Add two quantum states or a quantum state and an integer.

The result is stored in the left-hand side quantum state.

The multiplier is used to scale the right-hand side.

Parameters:
  • lhs – Left-hand side quantum state.

  • rhs – Right-hand side quantum state or integer to add.

  • multiplier – Multiplier for the addition (default is 1).

mul(lhs: Quant, rhs: Quant | int, result: Quant)

Multiply two quantum states.

The result is stored in the result quantum state.

Parameters:
  • lhs – Left-hand side quantum state.

  • rhs – Right-hand side quantum state or integer to add.

  • result – Quantum state to store the result.

set_int(qubits: Quant, state: int)

Set the state of a quantum register.

If the qubits are in the state \(\ket{0\dots0}\), this function will set them to the state \(\ket{\texttt{state}}\).

Parameters:
  • state – Integer representing the state to set.

  • qubits – Quantum register to modify.