/* AUTOMATICALLY GENERATED FILE - DO NOT EDIT! Please change MatrixNxN.py and re-run it */ /* Generated with ./VectorN.py n = 4, TYPE = double */ #include "ZUnitTest.hpp" #include #include #include #include #include static const char* testSST_Math_Vec4dAdd(); static const char* testSST_Math_Vec4dAddLocal(); static const char* testSST_Math_Vec4dSubtract(); static const char* testSST_Math_Vec4dSubtractLocal(); static const char* testSST_Math_Vec4dMultiply(); static const char* testSST_Math_Vec4dMultiplyLocal(); static const char* testSST_Math_Vec4dScale(); static const char* testSST_Math_Vec4dScaleLocal(); static const char* testSST_Math_Vec4dDivide(); static const char* testSST_Math_Vec4dDivideLocal(); static const char* testSST_Math_Vec4dAbs(); static const char* testSST_Math_Vec4dAbsLocal(); static const char* testSST_Math_Vec4dNegate(); static const char* testSST_Math_Vec4dNegateLocal(); static const char* testSST_Math_Vec4dBias(); static const char* testSST_Math_Vec4dBiasLocal(); static const char* testSST_Math_Vec4dRecip(); static const char* testSST_Math_Vec4dRecipLocal(); static const char* testSST_Math_Vec4dRecipSqrt(); static const char* testSST_Math_Vec4dRecipSqrtLocal(); static const char* testSST_Math_Vec4dSqrt(); static const char* testSST_Math_Vec4dSqrtLocal(); static const char* testSST_Math_Vec4dSqrt(); static const char* testSST_Math_Vec4dSqrtLocal(); static const char* testSST_Math_Vec4dProject(); static const char* testSST_Math_Vec4dProjectLocal(); static const char* testSST_Math_Vec4dMagnitude(); static const char* testSST_Math_Vec4dNormalize(); static const char* testSST_Math_Vec4dNormalizeLocal(); static const char* testSST_Math_Vec4dMagnitudeSquared(); static const char* testSST_Math_Vec4dDot(); // List of unit tests ZUnitTest SST_Math_Vec4dUnitTests[] = { { "testSST_Math_Vec4dAdd " , testSST_Math_Vec4dAdd }, { "testSST_Math_Vec4dAddLocal " , testSST_Math_Vec4dAddLocal }, { "testSST_Math_Vec4dSubtract " , testSST_Math_Vec4dSubtract }, { "testSST_Math_Vec4dSubtractLocal " , testSST_Math_Vec4dSubtractLocal }, { "testSST_Math_Vec4dMultiply " , testSST_Math_Vec4dMultiply }, { "testSST_Math_Vec4dMultiplyLocal " , testSST_Math_Vec4dMultiplyLocal }, { "testSST_Math_Vec4dScale " , testSST_Math_Vec4dScale }, { "testSST_Math_Vec4dScaleLocal " , testSST_Math_Vec4dScaleLocal }, { "testSST_Math_Vec4dDivide " , testSST_Math_Vec4dDivide }, { "testSST_Math_Vec4dDivideLocal " , testSST_Math_Vec4dDivideLocal }, { "testSST_Math_Vec4dAbs " , testSST_Math_Vec4dAbs }, { "testSST_Math_Vec4dAbsLocal " , testSST_Math_Vec4dAbsLocal }, { "testSST_Math_Vec4dNegate " , testSST_Math_Vec4dNegate }, { "testSST_Math_Vec4dNegateLocal " , testSST_Math_Vec4dNegateLocal }, { "testSST_Math_Vec4dBias " , testSST_Math_Vec4dBias }, { "testSST_Math_Vec4dBiasLocal " , testSST_Math_Vec4dBiasLocal }, { "testSST_Math_Vec4dRecip " , testSST_Math_Vec4dRecip }, { "testSST_Math_Vec4dRecipLocal " , testSST_Math_Vec4dRecipLocal }, { "testSST_Math_Vec4dRecipSqrt " , testSST_Math_Vec4dRecipSqrt }, { "testSST_Math_Vec4dRecipSqrtLocal " , testSST_Math_Vec4dRecipSqrtLocal }, { "testSST_Math_Vec4dSqrt " , testSST_Math_Vec4dSqrt }, { "testSST_Math_Vec4dSqrtLocal " , testSST_Math_Vec4dSqrtLocal }, { "testSST_Math_Vec4dSqrt " , testSST_Math_Vec4dSqrt }, { "testSST_Math_Vec4dSqrtLocal " , testSST_Math_Vec4dSqrtLocal }, { "testSST_Math_Vec4dMagnitude " , testSST_Math_Vec4dMagnitude }, { "testSST_Math_Vec4dNormalize " , testSST_Math_Vec4dNormalize }, { "testSST_Math_Vec4dNormalizeLocal " , testSST_Math_Vec4dNormalizeLocal }, { "testSST_Math_Vec4dProject " , testSST_Math_Vec4dProject }, { "testSST_Math_Vec4dProjectLocal " , testSST_Math_Vec4dProjectLocal }, { "testSST_Math_Vec4dMagnitudeSquared " , testSST_Math_Vec4dMagnitudeSquared }, { "testSST_Math_Vec4dDot " , testSST_Math_Vec4dDot } }; DECLARE_ZTESTBLOCK(SST_Math_Vec4d) /******************************************************************************/ static const char* testSST_Math_Vec4dAdd() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -16.0000000000000000; x.v[1] = 8.0000000000000000; x.v[2] = -12.0000000000000000; x.v[3] = 3.0000000000000000; y.v[0] = -1.0000000000000000; y.v[1] = 9.0000000000000000; y.v[2] = 11.0000000000000000; y.v[3] = 10.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [-16. 8. -12. 3.] [ -1. 9. 11. 10.] [-17. 17. -1. 13.] */ SST_Math_Vec4dAdd(&x,&y,&w); TASSERT(fabs((w.v[0])-( -17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -1.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 13.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dAddLocal() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -7.0000000000000000; x.v[1] = -6.0000000000000000; x.v[2] = -15.0000000000000000; x.v[3] = -1.0000000000000000; y.v[0] = -1.0000000000000000; y.v[1] = 14.0000000000000000; y.v[2] = 7.0000000000000000; y.v[3] = 10.0000000000000000; /* [ -7. -6. -15. -1.] [ -1. 14. 7. 10.] [-8. 8. -8. 9.] */ SST_Math_Vec4dAddLocal(&x,&y); /* for accuracy */ TASSERT(fabs((x.v[0])-( -8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( -8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 9.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dSubtract() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -16.0000000000000000; x.v[1] = 1.0000000000000000; x.v[2] = -19.0000000000000000; x.v[3] = 8.0000000000000000; y.v[0] = 11.0000000000000000; y.v[1] = 15.0000000000000000; y.v[2] = 3.0000000000000000; y.v[3] = -19.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [-16. 1. -19. 8.] [ 11. 15. 3. -19.] [-27. -14. -22. 27.] */ SST_Math_Vec4dSubtract(&x,&y,&w); TASSERT(fabs((w.v[0])-( -27.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( -14.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -22.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 27.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dSubtractLocal() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -10.0000000000000000; x.v[1] = 17.0000000000000000; x.v[2] = 16.0000000000000000; x.v[3] = 16.0000000000000000; y.v[0] = -15.0000000000000000; y.v[1] = 0.0000000000000000; y.v[2] = 15.0000000000000000; y.v[3] = 3.0000000000000000; /* [-10. 17. 16. 16.] [-15. 0. 15. 3.] [ 5. 17. 1. 13.] */ SST_Math_Vec4dSubtractLocal(&x,&y); /* for accuracy */ TASSERT(fabs((x.v[0])-( 5.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 1.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 13.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dMultiply() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -11.0000000000000000; x.v[1] = -13.0000000000000000; x.v[2] = 3.0000000000000000; x.v[3] = -15.0000000000000000; y.v[0] = -6.0000000000000000; y.v[1] = -4.0000000000000000; y.v[2] = -16.0000000000000000; y.v[3] = 10.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [-11. -13. 3. -15.] [ -6. -4. -16. 10.] [ 66. 52. -48. -150.] */ SST_Math_Vec4dMultiply(&x,&y,&w); TASSERT(fabs((w.v[0])-( 66.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 52.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -48.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( -150.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dMultiplyLocal() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -3.0000000000000000; x.v[1] = 14.0000000000000000; x.v[2] = 2.0000000000000000; x.v[3] = 13.0000000000000000; y.v[0] = -18.0000000000000000; y.v[1] = -11.0000000000000000; y.v[2] = 4.0000000000000000; y.v[3] = -2.0000000000000000; /* [ -3. 14. 2. 13.] [-18. -11. 4. -2.] [ 54. -154. 8. -26.] */ SST_Math_Vec4dMultiplyLocal(&x,&y); /* for accuracy */ TASSERT(fabs((x.v[0])-( 54.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( -154.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( -26.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dDivide() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 4.0000000000000000; x.v[1] = 34.0000000000000000; x.v[2] = 17.0000000000000000; x.v[3] = 9.0000000000000000; y.v[0] = 26.0000000000000000; y.v[1] = 16.0000000000000000; y.v[2] = 8.0000000000000000; y.v[3] = 20.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 4. 34. 17. 9.] [ 26. 16. 8. 20.] [ 0.15384615 2.125 2.125 0.45 ] */ SST_Math_Vec4dDivide(&x,&y,&w); TASSERT(fabs((w.v[0])-( 0.1538461538461539)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 2.1250000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 2.1250000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 0.4500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dDivideLocal() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 7.0000000000000000; x.v[1] = 35.0000000000000000; x.v[2] = 16.0000000000000000; x.v[3] = 4.0000000000000000; y.v[0] = 28.0000000000000000; y.v[1] = 22.0000000000000000; y.v[2] = 3.0000000000000000; y.v[3] = 39.0000000000000000; /* [ 7. 35. 16. 4.] [ 28. 22. 3. 39.] [ 0.25 1.59090909 5.33333333 0.1025641 ] */ SST_Math_Vec4dDivideLocal(&x,&y); /* for accuracy */ TASSERT(fabs((x.v[0])-( 0.2500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 1.5909090909090908)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 5.3333333333333330)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 0.1025641025641026)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dScale() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = -7.0000000000000000; x.v[1] = 1.0000000000000000; x.v[2] = 5.0000000000000000; x.v[3] = 0.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; a = 2.0000000000000000; /* [-7. 1. 5. 0.] [-14. 2. 10. 0.] */ SST_Math_Vec4dScale(&x,a,&w); TASSERT(fabs((w.v[0])-( -14.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 2.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 10.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 0.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dScaleLocal() { SST_Vec4d x; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 4.0000000000000000; x.v[1] = 7.0000000000000000; x.v[2] = -8.0000000000000000; x.v[3] = 11.0000000000000000; a = 2.0000000000000000; /* [ 4. 7. -8. 11.] [ 8. 14. -16. 22.] */ SST_Math_Vec4dScaleLocal(&x,a); /* for accuracy */ TASSERT(fabs((x.v[0])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 14.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( -16.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 22.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dAbs() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 10.0000000000000000; x.v[1] = -8.0000000000000000; x.v[2] = -17.0000000000000000; x.v[3] = -13.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 10. -8. -17. -13.] [ 10. 8. 17. 13.] */ SST_Math_Vec4dAbs(&x,&w); TASSERT(fabs((w.v[0])-( 10.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 13.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dAbsLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 3.0000000000000000; x.v[1] = -11.0000000000000000; x.v[2] = 9.0000000000000000; x.v[3] = 9.0000000000000000; /* [ 3. -11. 9. 9.] [ 3. 11. 9. 9.] */ SST_Math_Vec4dAbsLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 3.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 11.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 9.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 9.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dBias() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 6.0000000000000000; x.v[1] = 10.0000000000000000; x.v[2] = -16.0000000000000000; x.v[3] = -12.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; a = -5.0000000000000000; /* [ 6. 10. -16. -12.] [ 12. 20. -32. -24.] */ SST_Math_Vec4dBias(&x,a,&w); TASSERT(fabs((w.v[0])-( 1.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 5.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -21.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( -17.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dBiasLocal() { SST_Vec4d x; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 1.0000000000000000; x.v[1] = 4.0000000000000000; x.v[2] = -13.0000000000000000; x.v[3] = -2.0000000000000000; a = -12.0000000000000000; /* [ 1. 4. -13. -2.] [ 2. 8. -26. -4.] */ SST_Math_Vec4dBiasLocal(&x,a); /* for accuracy */ TASSERT(fabs((x.v[0])-( -11.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( -8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( -25.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( -14.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dNegate() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 8.0000000000000000; x.v[1] = -8.0000000000000000; x.v[2] = 12.0000000000000000; x.v[3] = -12.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 8. -8. 12. -12.] [ -8. 8. -12. 12.] */ SST_Math_Vec4dNegate(&x,&w); TASSERT(fabs((w.v[0])-( -8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dNegateLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -8.0000000000000000; x.v[1] = -12.0000000000000000; x.v[2] = 12.0000000000000000; x.v[3] = -5.0000000000000000; /* [ -8. -12. 12. -5.] [ 8. 12. -12. 5.] */ SST_Math_Vec4dNegateLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 8.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( -12.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 5.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dSqrt() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 12.0000000000000000; x.v[1] = 19.0000000000000000; x.v[2] = 35.0000000000000000; x.v[3] = 3.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 12. 19. 35. 3.] [ 3.46410162 4.35889894 5.91607978 1.73205081] */ SST_Math_Vec4dSqrt(&x,&w); TASSERT(fabs((w.v[0])-( 3.4641016151377544)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 4.3588989435406740)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 5.9160797830996161)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 1.7320508075688772)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dSqrtLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 23.0000000000000000; x.v[1] = 16.0000000000000000; x.v[2] = 29.0000000000000000; x.v[3] = 31.0000000000000000; /* [ 23. 16. 29. 31.] [ 4.79583152 4. 5.38516481 5.56776436] */ SST_Math_Vec4dSqrtLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 4.7958315233127191)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 4.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 5.3851648071345037)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 5.5677643628300215)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dRecipSqrt() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 27.0000000000000000; x.v[1] = 26.0000000000000000; x.v[2] = 32.0000000000000000; x.v[3] = 16.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 27. 26. 32. 16.] [ 0.19245009 0.19611614 0.1767767 0.25 ] */ SST_Math_Vec4dRecipSqrt(&x,&w); TASSERT(fabs((w.v[0])-( 0.1924500897298753)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 0.1961161351381840)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 0.1767766952966369)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 0.2500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dRecipSqrtLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 10.0000000000000000; x.v[1] = 3.0000000000000000; x.v[2] = 39.0000000000000000; x.v[3] = 4.0000000000000000; /* [ 10. 3. 39. 4.] [ 0.31622777 0.57735027 0.16012815 0.5 ] */ SST_Math_Vec4dRecipSqrtLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 0.3162277660168379)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 0.5773502691896258)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 0.1601281538050871)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 0.5000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dRecip() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 14.0000000000000000; x.v[1] = 11.0000000000000000; x.v[2] = 3.0000000000000000; x.v[3] = 11.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 14. 11. 3. 11.] [ 0.07142857 0.09090909 0.33333333 0.09090909] */ SST_Math_Vec4dRecip(&x,&w); TASSERT(fabs((w.v[0])-( 0.0714285714285714)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 0.0909090909090909)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 0.3333333333333333)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 0.0909090909090909)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dRecipLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 8.0000000000000000; x.v[1] = 6.0000000000000000; x.v[2] = 33.0000000000000000; x.v[3] = 31.0000000000000000; /* [ 8. 6. 33. 31.] [ 0.35355339 0.40824829 0.17407766 0.1796053 ] */ SST_Math_Vec4dRecipLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 0.1250000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 0.1666666666666667)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 0.0303030303030303)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( 0.0322580645161290)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dNormalize() { SST_Vec4d x; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = -1.0000000000000000; x.v[1] = 2.0000000000000000; x.v[2] = -17.0000000000000000; x.v[3] = 10.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ -1. 2. -17. 10.] [-0.05037927 0.10075854 -0.85644763 0.50379272] */ SST_Math_Vec4dNormalize(&x,&w); TASSERT(fabs((w.v[0])-( -0.0503792721859878)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 0.1007585443719757)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( -0.8564476271617932)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 0.5037927218598783)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dNormalizeLocal() { SST_Vec4d x; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 0.0000000000000000; x.v[1] = 7.0000000000000000; x.v[2] = -5.0000000000000000; x.v[3] = -12.0000000000000000; /* [ 0. 7. -5. -12.] [ 0. 0.47409982 -0.33864273 -0.81274255] */ SST_Math_Vec4dNormalizeLocal(&x); /* for accuracy */ TASSERT(fabs((x.v[0])-( 0.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( 0.4740998230350175)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( -0.3386427307392982)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( -0.8127425537743156)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dProject() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ SST_Vec4d w; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 11.0000000000000000; x.v[1] = -10.0000000000000000; x.v[2] = 7.0000000000000000; x.v[3] = 10.0000000000000000; y.v[0] = 16.0000000000000000; y.v[1] = -1.0000000000000000; y.v[2] = -9.0000000000000000; y.v[3] = -19.0000000000000000; w.v[0] = 0.0000000000000000; w.v[1] = 0.0000000000000000; w.v[2] = 0.0000000000000000; w.v[3] = 0.0000000000000000; /* [ 11. -10. 7. 10.] [ 16. -1. -9. -19.] [-1.53361946 0.09585122 0.86266094 1.8211731 ] */ SST_Math_Vec4dProject(&x,&y,&w); TASSERT(fabs((w.v[0])-( -1.5336194563662375)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((w.v[1])-( 0.0958512160228898)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((w.v[2])-( 0.8626609442060086)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((w.v[3])-( 1.8211731044349071)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dProjectLocal() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ /* Resetting test vectors */ x.v[0] = 15.0000000000000000; x.v[1] = -7.0000000000000000; x.v[2] = -10.0000000000000000; x.v[3] = -19.0000000000000000; y.v[0] = 12.0000000000000000; y.v[1] = -5.0000000000000000; y.v[2] = 3.0000000000000000; y.v[3] = -20.0000000000000000; /* [ 15. -7. -10. -19.] [ 12. -5. 3. -20.] [ 11.73010381 -4.88754325 2.93252595 -19.55017301] */ SST_Math_Vec4dProjectLocal(&x,&y); /* for accuracy */ TASSERT(fabs((x.v[0])-( 11.7301038062283745)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _x failed!"); TASSERT(fabs((x.v[1])-( -4.8875432525951554)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _y failed!"); TASSERT(fabs((x.v[2])-( 2.9325259515570936)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _z failed!"); TASSERT(fabs((x.v[3])-( -19.5501730103806217)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _w failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ /******************************************************************************/ static const char* testSST_Math_Vec4dMagnitude() { SST_Vec4d x; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 9.0000000000000000; x.v[1] = -19.0000000000000000; x.v[2] = 12.0000000000000000; x.v[3] = 12.0000000000000000; /* [ 9. -19. 12. 12.] 27.0185121722 */ a = SST_Math_Vec4dMagnitude(&x); TASSERT(fabs((a)-( 27.0185121722125920)) <=100*DBL_EPSILON /* yes this is bad */,"Magnitude failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dMagnitudeSquared() { SST_Vec4d x; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 13.0000000000000000; x.v[1] = 5.0000000000000000; x.v[2] = 18.0000000000000000; x.v[3] = 5.0000000000000000; /* [ 13. 5. 18. 5.] 543.0 */ a = SST_Math_Vec4dMagnitudeSquared(&x); TASSERT(fabs((a)-( 543.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"MagnitudeSquared failed!"); return ZTEST_SUCCESS; } /******************************************************************************/ static const char* testSST_Math_Vec4dDot() { SST_Vec4d x; /* 4 vector */ SST_Vec4d y; /* 4 vector */ double a; /* scalar */ /* Resetting test vectors */ x.v[0] = 12.0000000000000000; x.v[1] = -12.0000000000000000; x.v[2] = -3.0000000000000000; x.v[3] = -9.0000000000000000; y.v[0] = -9.0000000000000000; y.v[1] = 7.0000000000000000; y.v[2] = -11.0000000000000000; y.v[3] = -7.0000000000000000; /* [ 12. -12. -3. -9.] -96.0 */ a = SST_Math_Vec4dDot(&x,&y); TASSERT(fabs((a)-( -96.0000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Dot failed!"); return ZTEST_SUCCESS; } /******************************************************************************/