Quantum Utilities¶
As more and more lowlevel functions migrate to the quantum space, such as dot products and distance estimation between vectors, they comprise a category we (so far) simply refer to as “utility” functions

qcware.qutils.
qdot
(x: Union[float, numpy.ndarray], y: Union[float, numpy.ndarray], circuit: quasar.circuit.Circuit = None, loader_mode: str = 'parallel', circuit_mode: str = 'sequential', backend: str = 'qcware/cpu_simulator', num_measurements: int = None)¶  Outputs the dot product of two arrays; quantum analogue of::
numpy.dot
 Cases (following numpy.dot):
x is 1d, y is 1d; performs vector  vector multiplication. Returns float. x is 2d, y is 1d; performs matrix  vector multiplication. Returns 1d array. x is 1d, y is 2d; performs vector  matrix multiplication. Returns 1d array. x is 2d, y is 2d; performs matrix  matrix multiplication. Returns 2d array.
Arguments:
 Parameters
x (Union[float, numpy.ndarray]) – 1d or 2d array
y (Union[float, numpy.ndarray]) – 1d or 2d array
circuit (quasar.Circuit) – Circuit to use for evaluation (None to implicitly create circuit), defaults to None
loader_mode (str) – , defaults to parallel
circuit_mode (str) – , defaults to sequential
backend (str) – , defaults to qcware/cpu_simulator
num_measurements (int) – , defaults to None
 Returns
float, 1d array, or 2d array: dot product
 Return type
Union[float, numpy.ndarray]

qcware.qutils.
distance_estimation
(x: Union[float, numpy.ndarray], y: Union[float, numpy.ndarray], circuit: quasar.circuit.Circuit = None, loader_mode: str = 'parallel', circuit_mode: str = 'sequential', backend: str = 'qcware/cpu_simulator', num_measurements: int = None)¶  Outputs the distance between input vectors; quantum analogue of::
numpy.linalg.norm(X  Y)**2
 Cases (following numpy.dot):
x is 1d, y is 1d; performs vector  vector multiplication. Returns float. x is 2d, y is 1d; performs matrix  vector multiplication. Returns 1d array. x is 1d, y is 2d; performs vector  matrix multiplication. Returns 1d array. x is 2d, y is 2d; performs matrix  matrix multiplication. Returns 2d array.
Arguments:
 Parameters
x (Union[float, numpy.ndarray]) – 1d or 2d array
y (Union[float, numpy.ndarray]) – 1d or 2d array
circuit (quasar.Circuit) – Circuit to use for evaluation (None to implicitly create circuit), defaults to None
loader_mode (str) – , defaults to parallel
circuit_mode (str) – , defaults to sequential
backend (str) – , defaults to qcware/cpu_simulator
num_measurements (int) – , defaults to None
 Returns
float, 1d array, or 2d array: distance estimation
 Return type
Union[float, numpy.ndarray]