From 4071c8279c59123d0745f14fd158dfa0a260ce3d Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Thu, 13 Jul 2023 11:17:27 +0100 Subject: [PATCH] feat: matmul method added to correlator class. --- pyerrors/correlators.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 8573cdbf..93d20850 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -1078,6 +1078,20 @@ class Corr: else: raise TypeError("Corr * wrong type") + def __matmul__(self, y): + if isinstance(y, np.ndarray): + if not self.N == y.shape[0]: + raise TypeError("Shape mismatch") + newcontent = [] + for t in range(self.T): + if _check_for_none(self, self.content[t]): + newcontent.append(None) + else: + newcontent.append(self.content[t] @ y) + return Corr(newcontent) + else: + raise NotImplementedError("Matmul not implemented for this type.") + def __truediv__(self, y): if isinstance(y, Corr): if not ((self.N == 1 or y.N == 1 or self.N == y.N) and self.T == y.T):