Skip to content

Commit

Permalink
revert changes to np.cross
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt authored and pablolh committed Dec 13, 2023
1 parent 12c40ac commit cca2bfe
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions opensquirrel/mckay_decomposer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
from typing import Tuple

import numpy as np
import numpy.typing as npt

from opensquirrel.common import ATOL, ArgType
from opensquirrel.gates import SingleQubitAxisAngleSemantic, queryEntry, querySemantic, querySignature
from opensquirrel.squirrel_ast import SquirrelAST

FloatArray = npt.NDArray[np.float64]


def normalizeAngle(x: float) -> float:
t = x - 2 * pi * (x // (2 * pi) + 1)
Expand All @@ -20,10 +17,6 @@ def normalizeAngle(x: float) -> float:
return t


def cross(l: FloatArray, r: FloatArray) -> FloatArray:
return np.array([l[1] * r[2] - l[2] * r[1], l[2] * r[0] - l[0] * r[2], l[0] * r[1] - l[1] * r[0]], dtype=l.dtype)


class McKayDecomposer:
def __init__(self, gates):
self.gates = gates
Expand Down Expand Up @@ -99,7 +92,7 @@ def _acc(self, qubit, semantic: SingleQubitAxisAngleSemantic):
combinedAxis = (
1
/ sin(combinedAngle / 2)
* (sin(a / 2) * cos(b / 2) * l + cos(a / 2) * sin(b / 2) * m + sin(a / 2) * sin(b / 2) * cross(l, m))
* (sin(a / 2) * cos(b / 2) * l + cos(a / 2) * sin(b / 2) * m + sin(a / 2) * sin(b / 2) * np.cross(l, m))
)

self.oneQubitGates[qubit] = {"angle": combinedAngle, "axis": combinedAxis, "phase": combinedPhase}
Expand Down

0 comments on commit cca2bfe

Please sign in to comment.