Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -5,11 +5,8 @@
// Copyright (c) 2011 Apple Inc.
//
#include "LinearMath/btScalar.h"
#if defined (BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
#if defined(BT_USE_SSE_IN_API) || defined(BT_USE_NEON)
#include "Test_qtnorm.h"
#include "vector.h"
@@ -20,23 +17,23 @@
#include <LinearMath/btQuaternion.h>
#define BT_OP(a) (a.normalize())
#define BT_OP(a) (a.normalize())
// reference code for testing purposes
static inline btQuaternion& qtnorm_ref(btQuaternion& q1);
static inline btQuaternion& qtnorm_ref(btQuaternion& q1)
{
float dot =
q1.x() * q1.x() +
q1.y() * q1.y() +
q1.z() * q1.z() +
q1.w() * q1.w();
float dot =
q1.x() * q1.x() +
q1.y() * q1.y() +
q1.z() * q1.z() +
q1.w() * q1.w();
dot = 1.0f / sqrtf(dot);
q1.setValue(q1.x()*dot, q1.y()*dot, q1.z()*dot, q1.w()*dot);
q1.setValue(q1.x() * dot, q1.y() * dot, q1.z() * dot, q1.w() * dot);
return q1;
return q1;
}
#define LOOPCOUNT 1024
@@ -44,133 +41,142 @@ static inline btQuaternion& qtnorm_ref(btQuaternion& q1)
int Test_qtnorm(void)
{
int i;
btQuaternion q1, q2;
int i;
btQuaternion q1, q2;
float x, y, z, w, vNaN;
vNaN = BT_NAN; // w channel NaN
btQuaternion correct_res, test_res;
for (i=0; i<LOOPCOUNT; i++)
{
// Init the data
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
q1.setValue(x,y,z,w);
q2 = q1;
vNaN = BT_NAN; // w channel NaN
correct_res.setValue(vNaN, vNaN, vNaN, vNaN);
btQuaternion correct_res, test_res;
for (i = 0; i < LOOPCOUNT; i++)
{
// Init the data
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
q1.setValue(x, y, z, w);
q2 = q1;
correct_res.setValue(vNaN, vNaN, vNaN, vNaN);
test_res.setValue(vNaN, vNaN, vNaN, vNaN);
correct_res = qtnorm_ref(q1);
test_res = BT_OP(q2);
if( fabsf(correct_res.x() - test_res.x()) +
fabsf(correct_res.y() - test_res.y()) +
fabsf(correct_res.z() - test_res.z()) +
fabsf(correct_res.w() - test_res.w()) > FLT_EPSILON*10 )
{
vlog( "Error - qtnorm result error! "
"\ncorrect = (%10.7f, %10.7f, %10.7f, %10.7f) "
"\ntested = (%10.7f, %10.7f, %10.7f, %10.7f) \n",
correct_res.x(), correct_res.y(),
correct_res.z(), correct_res.w(),
test_res.x(), test_res.y(),
test_res.z(), test_res.w());
if (fabsf(correct_res.x() - test_res.x()) +
fabsf(correct_res.y() - test_res.y()) +
fabsf(correct_res.z() - test_res.z()) +
fabsf(correct_res.w() - test_res.w()) >
FLT_EPSILON * 10)
{
vlog(
"Error - qtnorm result error! "
"\ncorrect = (%10.7f, %10.7f, %10.7f, %10.7f) "
"\ntested = (%10.7f, %10.7f, %10.7f, %10.7f) \n",
correct_res.x(), correct_res.y(),
correct_res.z(), correct_res.w(),
test_res.x(), test_res.y(),
test_res.z(), test_res.w());
return 1;
}
}
#define DATA_SIZE LOOPCOUNT
btQuaternion qt_arr0[DATA_SIZE];
btQuaternion qt_arr1[DATA_SIZE];
uint64_t scalarTime;
uint64_t vectorTime;
size_t j, k;
uint64_t scalarTime;
uint64_t vectorTime;
size_t j, k;
{
uint64_t startTime, bestTime, currentTime;
bestTime = -1LL;
scalarTime = 0;
for (j = 0; j < NUM_CYCLES; j++)
{
for( k = 0; k < DATA_SIZE; k++ )
{
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
qt_arr1[k].setValue(x,y,z,w);
}
uint64_t startTime, bestTime, currentTime;
startTime = ReadTicks();
for( k = 0; k+4 <= LOOPCOUNT; k+=4 )
bestTime = -1LL;
scalarTime = 0;
for (j = 0; j < NUM_CYCLES; j++)
{
for (k = 0; k < DATA_SIZE; k++)
{
size_t km = (k & (DATA_SIZE-1));
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
qt_arr1[k].setValue(x, y, z, w);
}
startTime = ReadTicks();
for (k = 0; k + 4 <= LOOPCOUNT; k += 4)
{
size_t km = (k & (DATA_SIZE - 1));
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);
km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);
km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);
km++;
qt_arr0[km] = qtnorm_ref(qt_arr1[km]);
}
currentTime = ReadTicks() - startTime;
scalarTime += currentTime;
if( currentTime < bestTime )
bestTime = currentTime;
}
if( 0 == gReportAverageTimes )
scalarTime = bestTime;
else
scalarTime /= NUM_CYCLES;
}
{
uint64_t startTime, bestTime, currentTime;
bestTime = -1LL;
vectorTime = 0;
for (j = 0; j < NUM_CYCLES; j++)
scalarTime += currentTime;
if (currentTime < bestTime)
bestTime = currentTime;
}
if (0 == gReportAverageTimes)
scalarTime = bestTime;
else
scalarTime /= NUM_CYCLES;
}
{
uint64_t startTime, bestTime, currentTime;
bestTime = -1LL;
vectorTime = 0;
for (j = 0; j < NUM_CYCLES; j++)
{
for( k = 0; k < DATA_SIZE; k++ )
{
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
qt_arr1[k].setValue(x,y,z,w);
}
startTime = ReadTicks();
for( k = 0; k+4 <= LOOPCOUNT; k+=4 )
for (k = 0; k < DATA_SIZE; k++)
{
size_t km = (k & (DATA_SIZE-1));
qt_arr0[km] = BT_OP(qt_arr1[km]);km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);km++;
x = RANDF_01;
y = RANDF_01;
z = RANDF_01;
w = RANDF_01;
qt_arr1[k].setValue(x, y, z, w);
}
startTime = ReadTicks();
for (k = 0; k + 4 <= LOOPCOUNT; k += 4)
{
size_t km = (k & (DATA_SIZE - 1));
qt_arr0[km] = BT_OP(qt_arr1[km]);
km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);
km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);
km++;
qt_arr0[km] = BT_OP(qt_arr1[km]);
km++;
}
currentTime = ReadTicks() - startTime;
vectorTime += currentTime;
if( currentTime < bestTime )
bestTime = currentTime;
}
if( 0 == gReportAverageTimes )
vectorTime = bestTime;
else
vectorTime /= NUM_CYCLES;
}
vectorTime += currentTime;
if (currentTime < bestTime)
bestTime = currentTime;
}
if (0 == gReportAverageTimes)
vectorTime = bestTime;
else
vectorTime /= NUM_CYCLES;
}
vlog( "Timing:\n" );
vlog( " \t scalar\t vector\n" );
vlog( " \t%10.4f\t%10.4f\n", TicksToCycles( scalarTime ) / LOOPCOUNT,
TicksToCycles( vectorTime ) / LOOPCOUNT );
vlog("Timing:\n");
vlog(" \t scalar\t vector\n");
vlog(" \t%10.4f\t%10.4f\n", TicksToCycles(scalarTime) / LOOPCOUNT,
TicksToCycles(vectorTime) / LOOPCOUNT);
return 0;
return 0;
}
#endif //BT_USE_SSE
#endif //BT_USE_SSE