qgates.qfn¶
The qgates.qfn
includes helper functions for manipulating quantum gate and state matrices.
Specifically functions for creating state vectors, calculating the tensor product, matrix multiplication, and conjugating a number or matrix.
qgates.qfn
Contains helper functions for working with quantum gates.
-
qgates.qfn.
conjugate
(v: Union[complex, list, numpy.ndarray], *args, **kwargs) → Union[complex, numpy.ndarray]¶ Returns the complex conjugate of v.
- Parameters
v – number, vector, or matrix to conjugate
-
qgates.qfn.
matmul
(a: numpy.ndarray, *b: numpy.ndarray) → numpy.ndarray¶ Performs matrix multiplication between two or more
- Parameters
a – Start value for matrix multiplication
b – One or more other values for tensor product
-
qgates.qfn.
state
(arr: Union[int, Iterable]) → numpy.ndarray¶ Creates a state vector from either an iterable of 1s and 0s (or from an int that will be converted to a state vector based on its binary representation.
- Parameters
arr – Int or iterable for creating state vector
-
qgates.qfn.
tens
(a: Union[int, float, list, numpy.ndarray], *b: Union[int, float, list, numpy.ndarray]) → numpy.ndarray¶ Computes the tensor product of two (or more) vectors/matrices.
- Parameters
a – Start value for tensor product
b – One or more other values for tensor product