Fix clang errors

This commit is contained in:
Erik Hofman 2016-11-20 23:54:15 +01:00
parent 0d213a1990
commit aec29a3a37
2 changed files with 39 additions and 20 deletions

View File

@ -307,7 +307,8 @@ public:
}
inline simd4_t<float,N>& operator+=(float f) {
simd4 += f;
simd4_t<float,N> r(f);
simd4 += r;
return *this;
}
inline simd4_t<float,N>& operator+=(const simd4_t<float,N>& v) {
@ -316,7 +317,8 @@ public:
}
inline simd4_t<float,N>& operator-=(float f) {
simd4 -= f;
simd4_t<float,N> r(f);
simd4 -= r;
return *this;
}
inline simd4_t<float,N>& operator-=(const simd4_t<float,N>& v) {
@ -325,7 +327,8 @@ public:
}
inline simd4_t<float,N>& operator *=(float f) {
simd4 *= f;
simd4_t<float,N> r(f);
simd4 *= r.simd4;
return *this;
}
inline simd4_t<float,N>& operator*=(const simd4_t<float,N>& v) {
@ -334,8 +337,8 @@ public:
}
inline simd4_t<float,N>& operator/=(float f) {
f = (1.0f/f);
simd4 *= f;
simd4_t<float,N> r(1.0f/f);
simd4 *= r.simd4;
return *this;
}
inline simd4_t<float,N>& operator/=(const simd4_t<float,N>& v) {
@ -412,8 +415,9 @@ public:
}
inline simd4_t<double,N>& operator+=(double d) {
simd4[0] += d;
simd4[1] += d;
simd4_t<double,N> r(d);
simd4[0] += r;
simd4[1] += r;
return *this;
}
inline simd4_t<double,N>& operator+=(const simd4_t<double,N>& v) {
@ -423,8 +427,9 @@ public:
}
inline simd4_t<double,N>& operator-=(double d) {
simd4[0] -= d;
simd4[1] -= d;
simd4_t<double,N> r(d);
simd4[0] -= r;
simd4[1] -= r;
return *this;
}
inline simd4_t<double,N>& operator-=(const simd4_t<double,N>& v) {
@ -434,8 +439,9 @@ public:
}
inline simd4_t<double,N>& operator *=(double d) {
simd4[0] *= d;
simd4[1] *= d;
simd4_t<double,N> r(d);
simd4[0] *= r;
simd4[1] *= r;
return *this;
}
inline simd4_t<double,N>& operator*=(const simd4_t<double,N>& v) {
@ -445,9 +451,9 @@ public:
}
inline simd4_t<double,N>& operator/=(double d) {
d = (1.0/d);
simd4[0] *= d;
simd4[1] *= d;
simd4_t<double,N> r(1.0/d);
simd4[0] *= r;
simd4[1] *= r;
return *this;
}
inline simd4_t<double,N>& operator/=(const simd4_t<double,N>& v) {
@ -515,7 +521,8 @@ public:
}
inline simd4_t<int,N>& operator+=(int i) {
simd4 += i;
simd4_t<int,N> r(i);
simd4 += r;
return *this;
}
inline simd4_t<int,N>& operator+=(const simd4_t<int,N>& v) {
@ -524,7 +531,8 @@ public:
}
inline simd4_t<int,N>& operator-=(int i) {
simd4 -= i;
simd4_t<int,N> r(i);
simd4 -= r;
return *this;
}
inline simd4_t<int,N>& operator-=(const simd4_t<int,N>& v) {
@ -533,7 +541,8 @@ public:
}
inline simd4_t<int,N>& operator *=(int i) {
simd4 *= i;
simd4_t<int,N> r(i);
simd4 *= r;
return *this;
}
inline simd4_t<int,N>& operator*=(const simd4_t<int,N>& v) {
@ -542,8 +551,8 @@ public:
}
inline simd4_t<int,N>& operator/=(int i) {
i = (1/i);
simd4 *= i;
simd4_t<int,N> r(i);
simd4 /= r;
return *this;
}
inline simd4_t<int,N>& operator/=(const simd4_t<int,N>& v) {

View File

@ -3,7 +3,6 @@
#include <cmath>
#include <cfloat>
#include "SGVec3.hxx"
#include "SGVec4.hxx"
// set to 0 for a timing test
@ -26,6 +25,7 @@ int main()
{
T p[4] = { 1.03, 0.55, 0.707, -0.01 };
const SGVec4<T> q( 0.31, 0.43, 0.69, 1.0 );
float res = 0.0f;
long int i;
for (i=0; i<MAX; i++)
@ -68,22 +68,32 @@ int main()
f = dot(x, v);
g = (x[0]*v[0] + x[1]*v[1] + x[2]*v[2] + x[3]*v[3]);
#if TEST_ACCURACY
if (f != g) {
printf("line: %i: dot: f: %5.4f, g: %5.4f\n", __LINE__, f, g);
}
#endif
f = dot(v, v);
g = (v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]);
#if TEST_ACCURACY
if (f != g) {
printf("line: %i: dot: f: %5.4f, g: %5.4f\n", __LINE__, f, g);
}
#endif
x = v; v -= y;
SGVec4<T> t = x - y;
f = dot(v, v);
g = (t[0]*t[0] + t[1]*t[1] + t[2]*t[2] + t[3]*t[3]);
#if TEST_ACCURACY
if (f != g) {
printf("line: %i: dot: f: %5.4f, g: %5.4f\n", __LINE__, f, g);
}
#endif
res += f;
}
printf("res: %f\n", res);
}