From ba65162be0fe50f301029cfdba95b916659992fe Mon Sep 17 00:00:00 2001 From: Klaus <klaus.boehnlein@tu-dresden.de> Date: Mon, 29 Aug 2022 17:56:00 +0200 Subject: [PATCH] Add more efficient sym-Implementation --- dune/microstructure/matrix_operations.hh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dune/microstructure/matrix_operations.hh b/dune/microstructure/matrix_operations.hh index 33b1e590..577a151c 100644 --- a/dune/microstructure/matrix_operations.hh +++ b/dune/microstructure/matrix_operations.hh @@ -31,14 +31,31 @@ namespace MatrixOperations { } + // static MatrixRT sym (MatrixRT M) { // 1/2 (M^T + M) + // MatrixRT ret(0); + // for (int i = 0; i< 3; i++) + // for (int j = 0; j< 3; j++) + // ret[i][j] = 0.5 * (M[i][j] + M[j][i]); + // return ret; + // } + + static MatrixRT sym (MatrixRT M) { // 1/2 (M^T + M) MatrixRT ret(0); - for (int i = 0; i< 3; i++) - for (int j = 0; j< 3; j++) - ret[i][j] = 0.5 * (M[i][j] + M[j][i]); + for (int i=0; i<3; i++) + { + ret[i][i] = M[i][i]; + for (int j=i+1; j<3; j++) + { + ret[i][j] = 0.5*(M[i][j] + M[j][i]); + ret[j][i] = ret[i][j]; + } + } return ret; } + + static VectorRT crossProduct (VectorRT v, VectorRT w) { // v otimes w return {v[1]*w[2] - v[2]*w[1], -1*(v[0]*w[2] - v[2]*w[0]), v[0]*w[1] - v[1]*w[0]}; } -- GitLab