Skip to content
Snippets Groups Projects
Verified Commit c5d1a348 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Make code for AffineMap2D more elegant and expressive

parent aacf835a
No related branches found
No related tags found
1 merge request!40Add support for bubble enhanced P2 element in 2D
Pipeline #74767 passed with warnings
...@@ -620,19 +620,10 @@ class AffineMap2D(GeometryMap): ...@@ -620,19 +620,10 @@ class AffineMap2D(GeometryMap):
return False return False
def evaluate(self, x: sp.Matrix) -> sp.Matrix: def evaluate(self, x: sp.Matrix) -> sp.Matrix:
xnew = sp.zeros(2, 1) return self.mat * x + self.vec
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
def jacobian(self, x: sp.Matrix) -> sp.Matrix: def jacobian(self, x: sp.Matrix) -> sp.Matrix:
jac = sp.Matrix( jac = self.mat.copy()
[
[self.mat[0, 0], self.mat[0, 1]],
[self.mat[1, 0], self.mat[1, 1]],
]
)
return jac return jac
def hessian(self, x: sp.Matrix) -> List[sp.Matrix]: def hessian(self, x: sp.Matrix) -> List[sp.Matrix]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment