diff --git a/python/project_tool.hpp b/python/project_tool.hpp index 6f8c1d7..c185c44 100644 --- a/python/project_tool.hpp +++ b/python/project_tool.hpp @@ -5,14 +5,14 @@ template static T project_tool(T *vertex_value, T *u, T *u0) { T ret0 = 0; - for (int i = 0; i < 8; i++) + for (unsigned int i = 0; i < 8; i++) { - int c[3] = { i & 1, (i>>1)&1, (i>>2)&1 }; + unsigned int c[3] = { i & 1, (i>>1)&1, (i>>2)&1 }; int epsilon[3]; T ret = 0; for (int q = 0; q < 3; q++) - epsilon[q] = (2*c[q]-1); + epsilon[q] = 2*c[q]-1; for (int q = 0; q < ProdType::numProducts; q++) ret += ProdType::product(u, u0, epsilon, q); @@ -27,7 +27,8 @@ static T project_tool(T *vertex_value, T *u, T *u0) template static inline T get_u0(const T& u0, int epsilon) { - return (epsilon > 0) ? u0 : (1-u0); + return (1-epsilon)/2 + epsilon*u0; +// return (epsilon > 0) ? u0 : (1-u0); } template @@ -39,7 +40,7 @@ struct ProductTerm0 { T a = 1; - for (int r = 0; r < 3; r++) + for (unsigned int r = 0; r < 3; r++) a *= get_u0(u0[r], epsilon[r]); return a; } @@ -54,14 +55,14 @@ struct ProductTerm1 static T product(T *u, T *u0, int *epsilon, int q) { T a = 1; - double G[3]; + T G[3]; - for (int r = 0; r < 3; r++) + for (unsigned int r = 0; r < 3; r++) { G[r] = get_u0(u0[r], epsilon[r]); } - double F[3] = { G[1]*G[2], G[0]*G[2], G[0]*G[1] }; + T F[3] = { G[1]*G[2], G[0]*G[2], G[0]*G[1] }; return F[q] * u[q] * epsilon[q]; } @@ -75,14 +76,14 @@ struct ProductTerm2 static inline T product(T *u, T *u0, int *epsilon, int q) { T a = 1; - double G[3]; + T G[3]; - for (int r = 0; r < 3; r++) + for (unsigned int r = 0; r < 3; r++) { G[r] = get_u0(u0[r], epsilon[r]); } - double F[3] = { epsilon[1]*epsilon[2]*u[1]*u[2], epsilon[0]*epsilon[2]*u[0]*u[2], epsilon[0]*epsilon[1]*u[0]*u[1] }; + T F[3] = { epsilon[1]*epsilon[2]*u[1]*u[2], epsilon[0]*epsilon[2]*u[0]*u[2], epsilon[0]*epsilon[1]*u[0]*u[1] }; return F[q] * G[q]; }