860 lines
31 KiB
C++
860 lines
31 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./VectorN.py n = 4, TYPE = float */
|
|
|
|
#include "ZUnitTest.hpp"
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <SST/SST_Vec4.h>
|
|
|
|
|
|
|
|
|
|
static const char* testSST_Math_Vec4fAdd();
|
|
static const char* testSST_Math_Vec4fAddLocal();
|
|
static const char* testSST_Math_Vec4fSubtract();
|
|
static const char* testSST_Math_Vec4fSubtractLocal();
|
|
static const char* testSST_Math_Vec4fMultiply();
|
|
static const char* testSST_Math_Vec4fMultiplyLocal();
|
|
static const char* testSST_Math_Vec4fScale();
|
|
static const char* testSST_Math_Vec4fScaleLocal();
|
|
static const char* testSST_Math_Vec4fDivide();
|
|
static const char* testSST_Math_Vec4fDivideLocal();
|
|
static const char* testSST_Math_Vec4fAbs();
|
|
static const char* testSST_Math_Vec4fAbsLocal();
|
|
static const char* testSST_Math_Vec4fNegate();
|
|
static const char* testSST_Math_Vec4fNegateLocal();
|
|
static const char* testSST_Math_Vec4fBias();
|
|
static const char* testSST_Math_Vec4fBiasLocal();
|
|
static const char* testSST_Math_Vec4fRecip();
|
|
static const char* testSST_Math_Vec4fRecipLocal();
|
|
static const char* testSST_Math_Vec4fRecipSqrt();
|
|
static const char* testSST_Math_Vec4fRecipSqrtLocal();
|
|
static const char* testSST_Math_Vec4fSqrt();
|
|
static const char* testSST_Math_Vec4fSqrtLocal();
|
|
static const char* testSST_Math_Vec4fSqrt();
|
|
static const char* testSST_Math_Vec4fSqrtLocal();
|
|
static const char* testSST_Math_Vec4fProject();
|
|
static const char* testSST_Math_Vec4fProjectLocal();
|
|
static const char* testSST_Math_Vec4fMagnitude();
|
|
static const char* testSST_Math_Vec4fNormalize();
|
|
static const char* testSST_Math_Vec4fNormalizeLocal();
|
|
static const char* testSST_Math_Vec4fMagnitudeSquared();
|
|
static const char* testSST_Math_Vec4fDot();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Vec4fUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Vec4fAdd " , testSST_Math_Vec4fAdd },
|
|
{ "testSST_Math_Vec4fAddLocal " , testSST_Math_Vec4fAddLocal },
|
|
{ "testSST_Math_Vec4fSubtract " , testSST_Math_Vec4fSubtract },
|
|
{ "testSST_Math_Vec4fSubtractLocal " , testSST_Math_Vec4fSubtractLocal },
|
|
{ "testSST_Math_Vec4fMultiply " , testSST_Math_Vec4fMultiply },
|
|
{ "testSST_Math_Vec4fMultiplyLocal " , testSST_Math_Vec4fMultiplyLocal },
|
|
{ "testSST_Math_Vec4fScale " , testSST_Math_Vec4fScale },
|
|
{ "testSST_Math_Vec4fScaleLocal " , testSST_Math_Vec4fScaleLocal },
|
|
{ "testSST_Math_Vec4fDivide " , testSST_Math_Vec4fDivide },
|
|
{ "testSST_Math_Vec4fDivideLocal " , testSST_Math_Vec4fDivideLocal },
|
|
{ "testSST_Math_Vec4fAbs " , testSST_Math_Vec4fAbs },
|
|
{ "testSST_Math_Vec4fAbsLocal " , testSST_Math_Vec4fAbsLocal },
|
|
{ "testSST_Math_Vec4fNegate " , testSST_Math_Vec4fNegate },
|
|
{ "testSST_Math_Vec4fNegateLocal " , testSST_Math_Vec4fNegateLocal },
|
|
{ "testSST_Math_Vec4fBias " , testSST_Math_Vec4fBias },
|
|
{ "testSST_Math_Vec4fBiasLocal " , testSST_Math_Vec4fBiasLocal },
|
|
{ "testSST_Math_Vec4fRecip " , testSST_Math_Vec4fRecip },
|
|
{ "testSST_Math_Vec4fRecipLocal " , testSST_Math_Vec4fRecipLocal },
|
|
{ "testSST_Math_Vec4fRecipSqrt " , testSST_Math_Vec4fRecipSqrt },
|
|
{ "testSST_Math_Vec4fRecipSqrtLocal " , testSST_Math_Vec4fRecipSqrtLocal },
|
|
{ "testSST_Math_Vec4fSqrt " , testSST_Math_Vec4fSqrt },
|
|
{ "testSST_Math_Vec4fSqrtLocal " , testSST_Math_Vec4fSqrtLocal },
|
|
{ "testSST_Math_Vec4fSqrt " , testSST_Math_Vec4fSqrt },
|
|
{ "testSST_Math_Vec4fSqrtLocal " , testSST_Math_Vec4fSqrtLocal },
|
|
{ "testSST_Math_Vec4fMagnitude " , testSST_Math_Vec4fMagnitude },
|
|
{ "testSST_Math_Vec4fNormalize " , testSST_Math_Vec4fNormalize },
|
|
{ "testSST_Math_Vec4fNormalizeLocal " , testSST_Math_Vec4fNormalizeLocal },
|
|
{ "testSST_Math_Vec4fProject " , testSST_Math_Vec4fProject },
|
|
{ "testSST_Math_Vec4fProjectLocal " , testSST_Math_Vec4fProjectLocal },
|
|
{ "testSST_Math_Vec4fMagnitudeSquared " , testSST_Math_Vec4fMagnitudeSquared },
|
|
{ "testSST_Math_Vec4fDot " , testSST_Math_Vec4fDot }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Vec4f)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fAdd()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 19.000000f;
|
|
x.v[1] = -3.000000f;
|
|
x.v[2] = 1.000000f;
|
|
x.v[3] = -7.000000f;
|
|
y.v[0] = 3.000000f;
|
|
y.v[1] = -10.000000f;
|
|
y.v[2] = 0.000000f;
|
|
y.v[3] = 8.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 19. -3. 1. -7.]
|
|
[ 3. -10. 0. 8.]
|
|
[ 22. -13. 1. 1.]
|
|
*/
|
|
SST_Math_Vec4fAdd(&x,&y,&w);
|
|
TASSERT(fabsf((w.v[0])-(22.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(-13.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(1.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(1.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fAddLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 4.000000f;
|
|
x.v[1] = 10.000000f;
|
|
x.v[2] = -4.000000f;
|
|
x.v[3] = -18.000000f;
|
|
y.v[0] = 7.000000f;
|
|
y.v[1] = -15.000000f;
|
|
y.v[2] = 0.000000f;
|
|
y.v[3] = -16.000000f;
|
|
/*
|
|
[ 4. 10. -4. -18.]
|
|
[ 7. -15. 0. -16.]
|
|
[ 11. -5. -4. -34.]
|
|
*/
|
|
SST_Math_Vec4fAddLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(11.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(-5.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(-4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(-34.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fSubtract()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 3.000000f;
|
|
x.v[1] = 1.000000f;
|
|
x.v[2] = -19.000000f;
|
|
x.v[3] = -13.000000f;
|
|
y.v[0] = 5.000000f;
|
|
y.v[1] = -3.000000f;
|
|
y.v[2] = -2.000000f;
|
|
y.v[3] = -15.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 3. 1. -19. -13.]
|
|
[ 5. -3. -2. -15.]
|
|
[ -2. 4. -17. 2.]
|
|
*/
|
|
SST_Math_Vec4fSubtract(&x,&y,&w);
|
|
TASSERT(fabsf((w.v[0])-(-2.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(-17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(2.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fSubtractLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -9.000000f;
|
|
x.v[1] = 0.000000f;
|
|
x.v[2] = 8.000000f;
|
|
x.v[3] = 13.000000f;
|
|
y.v[0] = 10.000000f;
|
|
y.v[1] = -19.000000f;
|
|
y.v[2] = -9.000000f;
|
|
y.v[3] = -19.000000f;
|
|
/*
|
|
[ -9. 0. 8. 13.]
|
|
[ 10. -19. -9. -19.]
|
|
[-19. 19. 17. 32.]
|
|
*/
|
|
SST_Math_Vec4fSubtractLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-19.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(19.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(32.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fMultiply()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 9.000000f;
|
|
x.v[1] = -3.000000f;
|
|
x.v[2] = -18.000000f;
|
|
x.v[3] = 1.000000f;
|
|
y.v[0] = -15.000000f;
|
|
y.v[1] = -4.000000f;
|
|
y.v[2] = -17.000000f;
|
|
y.v[3] = -13.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 9. -3. -18. 1.]
|
|
[-15. -4. -17. -13.]
|
|
[-135. 12. 306. -13.]
|
|
*/
|
|
SST_Math_Vec4fMultiply(&x,&y,&w);
|
|
TASSERT(fabsf((w.v[0])-(-135.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(12.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(306.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(-13.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fMultiplyLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 2.000000f;
|
|
x.v[1] = 0.000000f;
|
|
x.v[2] = -19.000000f;
|
|
x.v[3] = -20.000000f;
|
|
y.v[0] = -16.000000f;
|
|
y.v[1] = 5.000000f;
|
|
y.v[2] = -3.000000f;
|
|
y.v[3] = 13.000000f;
|
|
/*
|
|
[ 2. 0. -19. -20.]
|
|
[-16. 5. -3. 13.]
|
|
[ -32. 0. 57. -260.]
|
|
*/
|
|
SST_Math_Vec4fMultiplyLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-32.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(0.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(57.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(-260.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fDivide()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 1.000000f;
|
|
x.v[1] = 24.000000f;
|
|
x.v[2] = 26.000000f;
|
|
x.v[3] = 7.000000f;
|
|
y.v[0] = 29.000000f;
|
|
y.v[1] = 38.000000f;
|
|
y.v[2] = 14.000000f;
|
|
y.v[3] = 30.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 1. 24. 26. 7.]
|
|
[ 29. 38. 14. 30.]
|
|
[ 0.03448276 0.63157892 1.85714281 0.23333333]
|
|
*/
|
|
SST_Math_Vec4fDivide(&x,&y,&w);
|
|
TASSERT(fabsf((w.v[0])-(0.034483f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(0.631579f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(1.857143f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(0.233333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fDivideLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 26.000000f;
|
|
x.v[1] = 9.000000f;
|
|
x.v[2] = 12.000000f;
|
|
x.v[3] = 10.000000f;
|
|
y.v[0] = 24.000000f;
|
|
y.v[1] = 3.000000f;
|
|
y.v[2] = 25.000000f;
|
|
y.v[3] = 4.000000f;
|
|
/*
|
|
[ 26. 9. 12. 10.]
|
|
[ 24. 3. 25. 4.]
|
|
[ 1.08333337 3. 0.47999999 2.5 ]
|
|
*/
|
|
SST_Math_Vec4fDivideLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(1.083333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(3.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(0.480000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(2.500000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fScale()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 8.000000f;
|
|
x.v[1] = -9.000000f;
|
|
x.v[2] = 10.000000f;
|
|
x.v[3] = -20.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
a = 2.000000f;
|
|
/*
|
|
[ 8. -9. 10. -20.]
|
|
[ 16. -18. 20. -40.]
|
|
*/
|
|
SST_Math_Vec4fScale(&x,a,&w);
|
|
TASSERT(fabsf((w.v[0])-(16.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(-18.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(20.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(-40.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fScaleLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -9.000000f;
|
|
x.v[1] = -9.000000f;
|
|
x.v[2] = 12.000000f;
|
|
x.v[3] = -20.000000f;
|
|
a = 2.000000f;
|
|
/*
|
|
[ -9. -9. 12. -20.]
|
|
[-18. -18. 24. -40.]
|
|
*/
|
|
SST_Math_Vec4fScaleLocal(&x,a); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-18.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(-18.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(24.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(-40.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fAbs()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 17.000000f;
|
|
x.v[1] = -13.000000f;
|
|
x.v[2] = -16.000000f;
|
|
x.v[3] = -14.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 17. -13. -16. -14.]
|
|
[ 17. 13. 16. 14.]
|
|
*/
|
|
SST_Math_Vec4fAbs(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(13.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(16.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(14.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fAbsLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -14.000000f;
|
|
x.v[1] = -9.000000f;
|
|
x.v[2] = -20.000000f;
|
|
x.v[3] = 10.000000f;
|
|
/*
|
|
[-14. -9. -20. 10.]
|
|
[ 14. 9. 20. 10.]
|
|
*/
|
|
SST_Math_Vec4fAbsLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(14.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(9.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(20.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(10.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fBias()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 5.000000f;
|
|
x.v[1] = 12.000000f;
|
|
x.v[2] = -7.000000f;
|
|
x.v[3] = 17.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
a = -13.000000f;
|
|
/*
|
|
[ 5. 12. -7. 17.]
|
|
[ 10. 24. -14. 34.]
|
|
*/
|
|
SST_Math_Vec4fBias(&x,a,&w);
|
|
TASSERT(fabsf((w.v[0])-(-8.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(-1.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(-20.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fBiasLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 10.000000f;
|
|
x.v[1] = 10.000000f;
|
|
x.v[2] = -5.000000f;
|
|
x.v[3] = 14.000000f;
|
|
a = 7.000000f;
|
|
/*
|
|
[ 10. 10. -5. 14.]
|
|
[ 20. 20. -10. 28.]
|
|
*/
|
|
SST_Math_Vec4fBiasLocal(&x,a); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(2.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(21.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fNegate()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -17.000000f;
|
|
x.v[1] = -8.000000f;
|
|
x.v[2] = -15.000000f;
|
|
x.v[3] = 8.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[-17. -8. -15. 8.]
|
|
[ 17. 8. 15. -8.]
|
|
*/
|
|
SST_Math_Vec4fNegate(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(17.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(8.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(15.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(-8.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fNegateLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 14.000000f;
|
|
x.v[1] = -4.000000f;
|
|
x.v[2] = 4.000000f;
|
|
x.v[3] = 5.000000f;
|
|
/*
|
|
[ 14. -4. 4. 5.]
|
|
[-14. 4. -4. -5.]
|
|
*/
|
|
SST_Math_Vec4fNegateLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-14.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(-4.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(-5.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fSqrt()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 6.000000f;
|
|
x.v[1] = 6.000000f;
|
|
x.v[2] = 38.000000f;
|
|
x.v[3] = 22.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 6. 6. 38. 22.]
|
|
[ 2.44948983 2.44948983 6.16441393 4.69041586]
|
|
*/
|
|
SST_Math_Vec4fSqrt(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(2.449490f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(2.449490f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(6.164414f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(4.690416f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fSqrtLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 17.000000f;
|
|
x.v[1] = 39.000000f;
|
|
x.v[2] = 17.000000f;
|
|
x.v[3] = 8.000000f;
|
|
/*
|
|
[ 17. 39. 17. 8.]
|
|
[ 4.12310553 6.24499798 4.12310553 2.82842708]
|
|
*/
|
|
SST_Math_Vec4fSqrtLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(4.123106f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(6.244998f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(4.123106f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(2.828427f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fRecipSqrt()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 16.000000f;
|
|
x.v[1] = 31.000000f;
|
|
x.v[2] = 37.000000f;
|
|
x.v[3] = 23.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 16. 31. 37. 23.]
|
|
[ 0.25 0.17960531 0.16439898 0.20851441]
|
|
*/
|
|
SST_Math_Vec4fRecipSqrt(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(0.250000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(0.179605f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(0.164399f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(0.208514f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fRecipSqrtLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 28.000000f;
|
|
x.v[1] = 38.000000f;
|
|
x.v[2] = 14.000000f;
|
|
x.v[3] = 9.000000f;
|
|
/*
|
|
[ 28. 38. 14. 9.]
|
|
[ 0.18898225 0.16222142 0.26726124 0.33333334]
|
|
*/
|
|
SST_Math_Vec4fRecipSqrtLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(0.188982f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(0.162221f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(0.267261f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(0.333333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fRecip()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 36.000000f;
|
|
x.v[1] = 15.000000f;
|
|
x.v[2] = 31.000000f;
|
|
x.v[3] = 3.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 36. 15. 31. 3.]
|
|
[ 0.02777778 0.06666667 0.03225806 0.33333334]
|
|
*/
|
|
SST_Math_Vec4fRecip(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(0.027778f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(0.066667f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(0.032258f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(0.333333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fRecipLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 4.000000f;
|
|
x.v[1] = 11.000000f;
|
|
x.v[2] = 3.000000f;
|
|
x.v[3] = 39.000000f;
|
|
/*
|
|
[ 4. 11. 3. 39.]
|
|
[ 0.5 0.30151135 0.57735026 0.16012816]
|
|
*/
|
|
SST_Math_Vec4fRecipLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(0.250000f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(0.090909f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(0.333333f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(0.025641f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fNormalize()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 1.000000f;
|
|
x.v[1] = 11.000000f;
|
|
x.v[2] = 11.000000f;
|
|
x.v[3] = -12.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[ 1. 11. 11. -12.]
|
|
[ 0.05083286 0.55916142 0.55916142 -0.60999429]
|
|
*/
|
|
SST_Math_Vec4fNormalize(&x,&w);
|
|
TASSERT(fabsf((w.v[0])-(0.050833f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(0.559161f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(0.559161f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(-0.609994f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fNormalizeLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -4.000000f;
|
|
x.v[1] = -14.000000f;
|
|
x.v[2] = -6.000000f;
|
|
x.v[3] = 2.000000f;
|
|
/*
|
|
[ -4. -14. -6. 2.]
|
|
[-0.25197631 -0.88191712 -0.37796447 0.12598816]
|
|
*/
|
|
SST_Math_Vec4fNormalizeLocal(&x); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-0.251976f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(-0.881917f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(-0.377964f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(0.125988f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fProject()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
SST_Vec4f w; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -2.000000f;
|
|
x.v[1] = 8.000000f;
|
|
x.v[2] = -8.000000f;
|
|
x.v[3] = 5.000000f;
|
|
y.v[0] = 3.000000f;
|
|
y.v[1] = -4.000000f;
|
|
y.v[2] = 17.000000f;
|
|
y.v[3] = 2.000000f;
|
|
w.v[0] = 0.000000f;
|
|
w.v[1] = 0.000000f;
|
|
w.v[2] = 0.000000f;
|
|
w.v[3] = 0.000000f;
|
|
/*
|
|
[-2. 8. -8. 5.]
|
|
[ 3. -4. 17. 2.]
|
|
[-1.54716992 2.06289315 -8.76729584 -1.03144658]
|
|
*/
|
|
SST_Math_Vec4fProject(&x,&y,&w);
|
|
TASSERT(fabsf((w.v[0])-(-1.547170f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((w.v[1])-(2.062893f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((w.v[2])-(-8.767296f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((w.v[3])-(-1.031447f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fProjectLocal()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -11.000000f;
|
|
x.v[1] = 4.000000f;
|
|
x.v[2] = -7.000000f;
|
|
x.v[3] = -1.000000f;
|
|
y.v[0] = -20.000000f;
|
|
y.v[1] = -5.000000f;
|
|
y.v[2] = 14.000000f;
|
|
y.v[3] = -18.000000f;
|
|
/*
|
|
[-11. 4. -7. -1.]
|
|
[-20. -5. 14. -18.]
|
|
[-2.53968263 -0.63492066 1.77777791 -2.28571439]
|
|
*/
|
|
SST_Math_Vec4fProjectLocal(&x,&y); /* for accuracy */
|
|
TASSERT(fabsf((x.v[0])-(-2.539683f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _x failed!");
|
|
TASSERT(fabsf((x.v[1])-(-0.634921f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _y failed!");
|
|
TASSERT(fabsf((x.v[2])-(1.777778f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _z failed!");
|
|
TASSERT(fabsf((x.v[3])-(-2.285714f)) <=100*FLT_EPSILON /* yes this is bad */,"Entry _w failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fMagnitude()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 17.000000f;
|
|
x.v[1] = -10.000000f;
|
|
x.v[2] = 8.000000f;
|
|
x.v[3] = 0.000000f;
|
|
/*
|
|
[ 17. -10. 8. 0.]
|
|
21.2838
|
|
*/
|
|
a = SST_Math_Vec4fMagnitude(&x);
|
|
TASSERT(fabsf((a)-(21.283796f)) <=100*FLT_EPSILON /* yes this is bad */,"Magnitude failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fMagnitudeSquared()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 5.000000f;
|
|
x.v[1] = 1.000000f;
|
|
x.v[2] = 8.000000f;
|
|
x.v[3] = 13.000000f;
|
|
/*
|
|
[ 5. 1. 8. 13.]
|
|
259.0
|
|
*/
|
|
a = SST_Math_Vec4fMagnitudeSquared(&x);
|
|
TASSERT(fabsf((a)-(259.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"MagnitudeSquared failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec4fDot()
|
|
{
|
|
SST_Vec4f x; /* 4 vector */
|
|
SST_Vec4f y; /* 4 vector */
|
|
float a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 9.000000f;
|
|
x.v[1] = -9.000000f;
|
|
x.v[2] = -3.000000f;
|
|
x.v[3] = -12.000000f;
|
|
y.v[0] = 9.000000f;
|
|
y.v[1] = 5.000000f;
|
|
y.v[2] = -3.000000f;
|
|
y.v[3] = -19.000000f;
|
|
/*
|
|
[ 9. -9. -3. -12.]
|
|
273.0
|
|
*/
|
|
a = SST_Math_Vec4fDot(&x,&y);
|
|
TASSERT(fabsf((a)-(273.000000f)) <=100*FLT_EPSILON /* yes this is bad */,"Dot failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|