From 76912da8bf9e58150fe2f6f74299ae7173347d66 Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Thu, 8 Feb 2024 10:54:25 +0100 Subject: [PATCH] standard batch multiplication can be done with @ --- python/damask/mechanics.py | 2 +- python/tests/test_mechanics.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/mechanics.py b/python/damask/mechanics.py index ccdeea4d8..620f07105 100644 --- a/python/damask/mechanics.py +++ b/python/damask/mechanics.py @@ -337,7 +337,7 @@ def _polar_decomposition(T: _np.ndarray, if isinstance(requested, str): requested = [requested] u, _, vh = _np.linalg.svd(T) - R = _np.einsum('...ij,...jk',u,vh) + R = u @ vh output = [] if 'R' in requested: diff --git a/python/tests/test_mechanics.py b/python/tests/test_mechanics.py index 825d88463..a53472c8b 100644 --- a/python/tests/test_mechanics.py +++ b/python/tests/test_mechanics.py @@ -158,7 +158,7 @@ class TestMechanics: @pytest.mark.parametrize('side',[('left','V'),('right','U')]) def test_polar_decomposition(self,side): F = np.random.rand(self.n,3,3) - F = np.einsum('...ij,...jk',F,F) # positive determinant + F = F @ F # positive determinant F_vec = np.reshape(F,(self.n//10,10,3,3)) p = mechanics._polar_decomposition(F_vec,side[1]) for p_,F_ in zip(np.reshape(p,F.shape),F):