Vector to Ket¶
This module is an ease of life adding to SageMath: it complements the latex
method to quantum ket notations.
-
vector_to_ket.
int_index_to_ket
(index, register_size)[source]¶ Makes a int from a register into a binary ket notation. IMPORTANT: this notation requires the physics package in Latex
- Example:
>>> int_index_to_ket(2,2) '\\ket{10}'
Parameters: Returns: string – a string in latex format
-
vector_to_ket.
vector_to_ket
(v)[source]¶ Transform a sage vector to a Latex ket notation
- Example:
>>> v = vector(SR,[1,0,0,1]) >>> vector_to_ket(v) 1 \ket{00} + 1 \ket{11}
Parameters: v (vector) – the vector corresponding to a pure state (size must be a power of two) Returns: str – a string corresponding to the Latex code for the ket notation of the input vector