aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/sca/trace/combine.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/sca/trace/combine.py')
-rw-r--r--pyecsca/sca/trace/combine.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/pyecsca/sca/trace/combine.py b/pyecsca/sca/trace/combine.py
index 5eeaaec..26a3e98 100644
--- a/pyecsca/sca/trace/combine.py
+++ b/pyecsca/sca/trace/combine.py
@@ -52,6 +52,23 @@ def standard_deviation(*traces: Trace) -> Optional[CombinedTrace]:
@public
+def add(*traces: Trace) -> Optional[CombinedTrace]:
+ """
+ Add `traces`, sample-wise.
+
+ :param traces:
+ :return:
+ """
+ if not traces:
+ return None
+ if len(traces) == 1:
+ return CombinedTrace(traces[0].samples.copy())
+ dtype = traces[0].samples.dtype
+ result_samples = np.sum(np.array([trace.samples for trace in traces]), axis=0).astype(dtype)
+ return CombinedTrace(result_samples)
+
+
+@public
def subtract(one: Trace, other: Trace) -> CombinedTrace:
"""
Subtract `other` from `one`, sample-wise.