# Import necessary libraries
from typing import List, Tuple
import numpy as np
class XPowGate:
# Initialize class attribute
_eigencomponents = {}
def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
# Check if eigen components for the given dimension exists
if self._dimension not in XPowGate._eigencomponents:
components = []
root = 1j ** (4 / self._dimension)
# Loop through each dimension
for i in range(self._dimension):
half_turns = i * 2 / self._dimension
v = np.array([root ** (i * j) / self._dimension for j in range(self._dimension)])
m = np.array([np.roll(v, j) for j in range(self._dimension)])
# Append the tuple of half_turns and matrix to the list of components
components.append((half_turns, m))
# Save the components for the given dimension
XPowGate._eigencomponents[self._dimension] = components
# Return the eigen components for the given dimension
return XPowGate._eigencomponents[self._dimension]
Associated Context | |
---|---|
Type | Code Snippet ( .py ) |
Associated Tags | cirq https://github.com/davidmerwin |
Description | 'No Description Provided' |
Related Links | https://github.com/davidmerwin |
Related People | David Merwin, CIRQ, David Jeffrey Merwin |
Sensitive Information | No Sensitive Information Detected |
Shareable Link | https://davidmerwin.pieces.cloud/?p=c39d4d9f48 |
https://gist.github.com/2c15fdb780580fc0d7d322703dea2b40
https://cdn.mathpix.com/snip/images/9aBALUhM0a49py-QpXpunvXJjbFlAC-w-IB6CaRsEiI.original.fullsize.png
https://davidmerwin.pieces.cloud/?p=c39d4d9f48
https://cdn.mathpix.com/snip/images/9aBALUhM0a49py-QpXpunvXJjbFlAC-w-IB6CaRsEiI.original.fullsize.png
@davidmerwin1992 @davidmerwin1992 @CirqBot