How to use the blueqat.qasmparser.QasmRealUnaryFunctions function in blueqat

To help you get started, we’ve selected a few blueqat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def eval(self):
        func = None
        if self.func == QasmRealUnaryFunctions.Sin:
            func = math.sin
        elif self.func == QasmRealUnaryFunctions.Cos:
            func = math.cos
        elif self.func == QasmRealUnaryFunctions.Tan:
            func = math.tan
        elif self.func == QasmRealUnaryFunctions.Exp:
            func = math.exp
        elif self.func == QasmRealUnaryFunctions.Ln:
            func = math.log
        elif self.func == QasmRealUnaryFunctions.Sqrt:
            func = math.sqrt
        else:
            raise ValueError('Unexpected Enum value.')
        return func(self.arg.eval())
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def eval(self):
        func = None
        if self.func == QasmRealUnaryFunctions.Sin:
            func = math.sin
        elif self.func == QasmRealUnaryFunctions.Cos:
            func = math.cos
        elif self.func == QasmRealUnaryFunctions.Tan:
            func = math.tan
        elif self.func == QasmRealUnaryFunctions.Exp:
            func = math.exp
        elif self.func == QasmRealUnaryFunctions.Ln:
            func = math.log
        elif self.func == QasmRealUnaryFunctions.Sqrt:
            func = math.sqrt
        else:
            raise ValueError('Unexpected Enum value.')
        return func(self.arg.eval())
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def from_str(s: str) -> 'QasmRealUnaryFunctions':
        if s == 'sin':
            return QasmRealUnaryFunctions.Sin
        if s == 'cos':
            return QasmRealUnaryFunctions.Cos
        if s == 'tan':
            return QasmRealUnaryFunctions.Tan
        if s == 'exp':
            return QasmRealUnaryFunctions.Exp
        if s == 'ln':
            return QasmRealUnaryFunctions.Ln
        if s == 'sqrt':
            return QasmRealUnaryFunctions.Sqrt
        raise ValueError('Unexpected value')
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def eval(self):
        func = None
        if self.func == QasmRealUnaryFunctions.Sin:
            func = math.sin
        elif self.func == QasmRealUnaryFunctions.Cos:
            func = math.cos
        elif self.func == QasmRealUnaryFunctions.Tan:
            func = math.tan
        elif self.func == QasmRealUnaryFunctions.Exp:
            func = math.exp
        elif self.func == QasmRealUnaryFunctions.Ln:
            func = math.log
        elif self.func == QasmRealUnaryFunctions.Sqrt:
            func = math.sqrt
        else:
            raise ValueError('Unexpected Enum value.')
        return func(self.arg.eval())
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def _parse_factor(tokens):
        if tokens.get_if('('):
            expr = _parse_expr(tokens)
            tokens.get_if(')', 'Corresponded `)` not found.')
            return expr
        if tokens.get_if('pi'):
            return QasmRealConst(QasmRealConstValues.Pi)
        line_tok = tokens.get_if(_is_func)
        if line_tok:
            func = QasmRealUnaryFunctions.from_str(line_tok[1])
            tokens.get_if('(', '`(` is required after function')
            arg = _parse_expr(tokens)
            tokens.get_if(')', 'Corresponded `)` not found.')
            return QasmRealCall(func, arg)
        return _parse_number(tokens)
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def from_str(s: str) -> 'QasmRealUnaryFunctions':
        if s == 'sin':
            return QasmRealUnaryFunctions.Sin
        if s == 'cos':
            return QasmRealUnaryFunctions.Cos
        if s == 'tan':
            return QasmRealUnaryFunctions.Tan
        if s == 'exp':
            return QasmRealUnaryFunctions.Exp
        if s == 'ln':
            return QasmRealUnaryFunctions.Ln
        if s == 'sqrt':
            return QasmRealUnaryFunctions.Sqrt
        raise ValueError('Unexpected value')
github Blueqat / Blueqat / blueqat / qasmparser.py View on Github external
def from_str(s: str) -> 'QasmRealUnaryFunctions':
        if s == 'sin':
            return QasmRealUnaryFunctions.Sin
        if s == 'cos':
            return QasmRealUnaryFunctions.Cos
        if s == 'tan':
            return QasmRealUnaryFunctions.Tan
        if s == 'exp':
            return QasmRealUnaryFunctions.Exp
        if s == 'ln':
            return QasmRealUnaryFunctions.Ln
        if s == 'sqrt':
            return QasmRealUnaryFunctions.Sqrt
        raise ValueError('Unexpected value')