Esempio n. 1
0
    def process(self):

        self.ensure_enums_have_no_space(enums=["current_op"])

        if self.outputs[0].is_linked:
            current_func = func_from_mode(self.current_op)
            params = [
                si.sv_get(default=[[]], deepcopy=False) for si in self.inputs
            ]
            matching_f = list_match_func[self.list_match]
            desired_levels = [2 for p in params]

            if self.current_op in ['GCD', 'ROUND-N']:
                result = recurse_fxy(params[0], params[1], current_func)
            elif self.current_op == 'SINCOS':
                ops = [np.sin, self.list_match, self.output_numpy]
                result = recurse_f_level_control(params, ops, math_numpy,
                                                 matching_f, desired_levels)
                ops2 = [np.cos, self.list_match, self.output_numpy]
                result2 = recurse_f_level_control(params, ops2, math_numpy,
                                                  matching_f, desired_levels)
                self.outputs[1].sv_set(result2)
            else:
                ops = [current_func, self.list_match, self.output_numpy]
                result = recurse_f_level_control(params, ops, math_numpy,
                                                 matching_f, desired_levels)

            self.outputs[0].sv_set(result)
Esempio n. 2
0
    def process(self):

        if  not self.outputs['Gate'].is_linked:
            return

        if 'X' in self.inputs:
            x = self.inputs['X'].sv_get(deepcopy=False)

        if 'Y' in self.inputs:
            y = self.inputs['Y'].sv_get(deepcopy=False)

        out= []
        if self.items_ in self.constant:
            out = [[self.constant[self.items_]]]
        elif self.items_ in self.fx:
            out = recurse_fx(x, self.fx[self.items_])
        elif self.items_ in self.fxy:
            out = recurse_fxy(x, y, self.fxy[self.items_])
        elif self.items_ in self.fxy2:
            out = recurse_fxy(x, y, self.fxy2[self.items_])

        self.outputs['Gate'].sv_set(out)
Esempio n. 3
0
    def process(self):

        if not self.outputs['Gate'].is_linked:
            return

        if 'X' in self.inputs:
            x = self.inputs['X'].sv_get(deepcopy=False)

        if 'Y' in self.inputs:
            y = self.inputs['Y'].sv_get(deepcopy=False)

        out = []
        if self.items_ in self.constant:
            out = [[self.constant[self.items_]]]
        elif self.items_ in self.fx:
            out = recurse_fx(x, self.fx[self.items_])
        elif self.items_ in self.fxy:
            out = recurse_fxy(x, y, self.fxy[self.items_])
        elif self.items_ in self.fxy2:
            out = recurse_fxy(x, y, self.fxy2[self.items_])

        self.outputs['Gate'].sv_set(out)
Esempio n. 4
0
    def process(self):
        # inputs
        if not self.outputs["Gate"].is_linked:
            return

        if "X" in self.inputs:
            x = self.inputs["X"].sv_get(deepcopy=False)

        if "Y" in self.inputs:
            y = self.inputs["Y"].sv_get(deepcopy=False)

        # outputs
        out = []
        if self.items_ in self.constant:
            out = [[self.constant[self.items_]]]
        elif self.items_ in self.fx:
            out = recurse_fx(x, self.fx[self.items_])
        elif self.items_ in self.fxy:
            out = recurse_fxy(x, y, self.fxy[self.items_])
        elif self.items_ in self.fxy2:
            out = recurse_fxy(x, y, self.fxy2[self.items_])

        self.outputs["Gate"].sv_set(out)
Esempio n. 5
0
    def process(self):
        in_count = len(self.inputs)
        if in_count > 0:
            x = self.inputs['X'].sv_get(deepcopy=False)

        if in_count > 1:
            y = self.inputs['Y'].sv_get(deepcopy=False)
        # outputs
        if self.outputs['float'].is_linked:
            result = []
            if in_count == 0:
                result = [[self.constant[self.items_]]]
            elif in_count == 1:
                result = recurse_fx(x, self.fx[self.items_])
            elif in_count == 2:
                result = recurse_fxy(x, y, self.fxy[self.items_])
            self.outputs['float'].sv_set(result)
Esempio n. 6
0
    def process(self):
        signature = (len(self.inputs), len(self.outputs))

        x = self.inputs['x'].sv_get(deepcopy=False)
        if signature == (2, 1):
            y = self.inputs['y'].sv_get(deepcopy=False)

        if self.outputs[0].is_linked:
            result = []
            current_func = func_from_mode(self.current_op)
            if signature == (1, 1):
                result = recurse_fx(x, current_func)
            elif signature == (2, 1):
                result = recurse_fxy(x, y, current_func)
            elif signature == (1, 2):
                # special case at the moment
                result = recurse_fx(x, sin)
                result2 = recurse_fx(x, cos)
                self.outputs[1].sv_set(result2)

            self.outputs[0].sv_set(result)
Esempio n. 7
0
    def process(self):
        signature = (len(self.inputs), len(self.outputs))

        x = self.inputs['x'].sv_get(deepcopy=False)
        if signature == (2, 1):
            y = self.inputs['y'].sv_get(deepcopy=False)

        if self.outputs[0].is_linked:
            result = []
            current_func = func_from_mode(self.current_op)
            if signature == (1, 1):
                result = recurse_fx(x, current_func)
            elif signature == (2, 1):
                result = recurse_fxy(x, y, current_func)
            elif signature == (1, 2):
                # special case at the moment
                result = recurse_fx(x, sin)
                result2 = recurse_fx(x, cos)
                self.outputs[1].sv_set(result2)

            self.outputs[0].sv_set(result)