From c5d1a3482b76d157e211305557c317b1f08c7c81 Mon Sep 17 00:00:00 2001 From: Marcus Mohr <marcus.mohr@lmu.de> Date: Fri, 28 Feb 2025 09:58:28 +0100 Subject: [PATCH] Make code for AffineMap2D more elegant and expressive --- hog/blending.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hog/blending.py b/hog/blending.py index 13ef306..e908feb 100644 --- a/hog/blending.py +++ b/hog/blending.py @@ -620,19 +620,10 @@ class AffineMap2D(GeometryMap): return False def evaluate(self, x: sp.Matrix) -> sp.Matrix: - xnew = sp.zeros(2, 1) - xnew[0] = self.mat[0, 0] * x[0] + self.mat[0, 1] * x[1] + self.vec[0] - xnew[1] = self.mat[1, 0] * x[0] + self.mat[1, 1] * x[1] + self.vec[1] - return xnew + return self.mat * x + self.vec def jacobian(self, x: sp.Matrix) -> sp.Matrix: - jac = sp.Matrix( - [ - [self.mat[0, 0], self.mat[0, 1]], - [self.mat[1, 0], self.mat[1, 1]], - ] - ) - + jac = self.mat.copy() return jac def hessian(self, x: sp.Matrix) -> List[sp.Matrix]: -- GitLab