コード例 #1
0
ファイル: parser.py プロジェクト: vishalbelsare/pyquil
 def classical_comparison(self, op, target, left, right):
     if op == "EQ":
         return ClassicalEqual(target, left, right)
     elif op == "GT":
         return ClassicalGreaterThan(target, left, right)
     elif op == "GE":
         return ClassicalGreaterEqual(target, left, right)
     elif op == "LT":
         return ClassicalLessThan(target, left, right)
     elif op == "LE":
         return ClassicalLessEqual(target, left, right)
コード例 #2
0
ファイル: gates.py プロジェクト: timasq/pyquil
def EQ(classical_reg1, classical_reg2, classical_reg3):
    """
    Produce an EQ instruction.

    :param classical_reg1: Memory address to which to store the comparison result.
    :param classical_reg2: Left comparison operand.
    :param classical_reg3: Right comparison operand.
    :return: A ClassicalEqual instance.
    """
    classical_reg1, classical_reg2, classical_reg3 = prepare_ternary_operands(
        classical_reg1, classical_reg2, classical_reg3)

    return ClassicalEqual(classical_reg1, classical_reg2, classical_reg3)
コード例 #3
0
ファイル: gates.py プロジェクト: tbcdebug/pyquil
def EQ(classical_reg1: MemoryReferenceDesignator,
       classical_reg2: MemoryReferenceDesignator,
       classical_reg3: Union[MemoryReferenceDesignator, int, float]) -> ClassicalEqual:
    """
    Produce an EQ instruction.

    :param classical_reg1: Memory address to which to store the comparison result.
    :param classical_reg2: Left comparison operand.
    :param classical_reg3: Right comparison operand.
    :return: A ClassicalEqual instance.
    """
    classical_reg1, classical_reg2, classical_reg3 = prepare_ternary_operands(classical_reg1,
                                                                              classical_reg2,
                                                                              classical_reg3)

    return ClassicalEqual(classical_reg1, classical_reg2, classical_reg3)
コード例 #4
0
ファイル: PyQuilListener.py プロジェクト: tsatir/pyquil
    def exitClassicalComparison(self, ctx):
        # type: (QuilParser.ClassicalComparisonContext) -> None
        target = _addr(ctx.addr(0))
        left = _addr(ctx.addr(1))
        if ctx.number():
            right = _number(ctx.number())
        else:
            right = _addr(ctx.addr(2))

        if ctx.EQ():
            self.result.append(ClassicalEqual(target, left, right))
        elif ctx.GT():
            self.result.append(ClassicalGreaterThan(target, left, right))
        elif ctx.GE():
            self.result.append(ClassicalGreaterEqual(target, left, right))
        elif ctx.LT():
            self.result.append(ClassicalLessThan(target, left, right))
        elif ctx.LE():
            self.result.append(ClassicalLessEqual(target, left, right))