Skip to content
Snippets Groups Projects

Resolve "Operation Evaluation"

Merged Angus Lothian requested to merge 5-operation-evaluation into develop
Files
7
+ 25
2
@@ -4,10 +4,8 @@ TODO: More info.
"""
from numbers import Number
from typing import Any
from numpy import conjugate, sqrt, abs as np_abs
from b_asic.port import InputPort, OutputPort
from b_asic.graph_id import GraphIDType
from b_asic.operation import AbstractOperation
from b_asic.graph_component import Name, TypeName
@@ -335,3 +333,28 @@ class ConstantDivision(AbstractOperation):
@property
def type_name(self) -> TypeName:
return "cdiv"
class Butterfly(AbstractOperation):
"""Butterfly operation that returns two outputs.
The first output is a + b and the second output is a - b.
TODO: More info.
"""
def __init__(self, source1: OutputPort = None, source2: OutputPort = None, name: Name = ""):
super().__init__(name)
self._input_ports = [InputPort(0, self), InputPort(1, self)]
self._output_ports = [OutputPort(0, self), OutputPort(1, self)]
if source1 is not None:
self._input_ports[0].connect(source1)
if source2 is not None:
self._input_ports[1].connect(source2)
def evaluate(self, a, b):
return a + b, a - b
@property
def type_name(self) -> TypeName:
return "bfly"
Loading