Skip to content
Snippets Groups Projects
Commit ba65162b authored by Klaus Böhnlein's avatar Klaus Böhnlein
Browse files

Add more efficient sym-Implementation

parent 61e72fdf
No related branches found
No related tags found
No related merge requests found
...@@ -31,14 +31,31 @@ namespace MatrixOperations { ...@@ -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) static MatrixRT sym (MatrixRT M) { // 1/2 (M^T + M)
MatrixRT ret(0); MatrixRT ret(0);
for (int i = 0; i< 3; i++) 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]); 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; return ret;
} }
static VectorRT crossProduct (VectorRT v, VectorRT w) { // v otimes w 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]}; 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]};
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment