1003 lines
49 KiB
C++
1003 lines
49 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./MatrixNxN.py n = 3, TYPE = double */
|
|
|
|
#include "ZUnitTest.hpp"
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <SST/SST_Mat33.h>
|
|
#include <SST/SST_Vec3.h>
|
|
|
|
|
|
|
|
|
|
static const char* testSST_Math_Mat33dAdd();
|
|
static const char* testSST_Math_Mat33dAddLocal();
|
|
static const char* testSST_Math_Mat33dSubtract();
|
|
static const char* testSST_Math_Mat33dSubtractLocal();
|
|
static const char* testSST_Math_Mat33dMultiplyElementwise();
|
|
static const char* testSST_Math_Mat33dMultiplyElementwiseLocal();
|
|
static const char* testSST_Math_Mat33dMultiplyScalar();
|
|
static const char* testSST_Math_Mat33dMultiplyScalarLocal();
|
|
static const char* testSST_Math_Mat33dMultiplyMatrix();
|
|
static const char* testSST_Math_Mat33dMultiplyMatrixLocal();
|
|
static const char* testSST_Math_Mat33dMultiplyVector();
|
|
static const char* testSST_Math_Mat33dMultiplyVectorLocal();
|
|
static const char* testSST_Math_Mat33dTranspose();
|
|
static const char* testSST_Math_Mat33dTransposeLocal();
|
|
static const char* testSST_Math_Mat33dDeterminant();
|
|
static const char* testSST_Math_Mat33dCheckOrthonormal();
|
|
static const char* testSST_Math_Mat33dInvert();
|
|
static const char* testSST_Math_Mat33dInvertLocal();
|
|
static const char* testSST_Math_Mat33dCreateLU();
|
|
static const char* testSST_Math_Mat33dCreateLULocal();
|
|
static const char* testSST_Math_Mat33dApplyLUMat();
|
|
static const char* testSST_Math_Mat33dApplyLUMatLocal();
|
|
static const char* testSST_Math_Mat33dApplyLUVec();
|
|
static const char* testSST_Math_Mat33dApplyLUVecLocal();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Mat33dUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Mat33dAdd " , testSST_Math_Mat33dAdd },
|
|
{ "testSST_Math_Mat33dAddLocal " , testSST_Math_Mat33dAddLocal },
|
|
{ "testSST_Math_Mat33dSubtract " , testSST_Math_Mat33dSubtract },
|
|
{ "testSST_Math_Mat33dSubtractLocal " , testSST_Math_Mat33dSubtractLocal },
|
|
{ "testSST_Math_Mat33dMultiplyElementwise " , testSST_Math_Mat33dMultiplyElementwise },
|
|
{ "testSST_Math_Mat33dMultiplyElementwiseLocal " , testSST_Math_Mat33dMultiplyElementwiseLocal },
|
|
{ "testSST_Math_Mat33dMultiplyScalar " , testSST_Math_Mat33dMultiplyScalar },
|
|
{ "testSST_Math_Mat33dMultiplyScalarLocal " , testSST_Math_Mat33dMultiplyScalarLocal },
|
|
{ "testSST_Math_Mat33dMultiplyMatrix " , testSST_Math_Mat33dMultiplyMatrix },
|
|
{ "testSST_Math_Mat33dMultiplyMatrixLocal " , testSST_Math_Mat33dMultiplyMatrixLocal },
|
|
{ "testSST_Math_Mat33dMultiplyVector " , testSST_Math_Mat33dMultiplyVector },
|
|
{ "testSST_Math_Mat33dMultiplyVectorLocal " , testSST_Math_Mat33dMultiplyVectorLocal },
|
|
{ "testSST_Math_Mat33dDeterminant " , testSST_Math_Mat33dDeterminant },
|
|
{ "testSST_Math_Mat33dCheckOrthonormal " , testSST_Math_Mat33dCheckOrthonormal },
|
|
{ "testSST_Math_Mat33dInvert " , testSST_Math_Mat33dInvert },
|
|
{ "testSST_Math_Mat33dInvertLocal " , testSST_Math_Mat33dInvertLocal },
|
|
{ "testSST_Math_Mat33dCreateLU " , testSST_Math_Mat33dCreateLU },
|
|
{ "testSST_Math_Mat33dCreateLULocal " , testSST_Math_Mat33dCreateLULocal },
|
|
{ "testSST_Math_Mat33dApplyLUMat " , testSST_Math_Mat33dApplyLUMat },
|
|
{ "testSST_Math_Mat33dApplyLUMatLocal " , testSST_Math_Mat33dApplyLUMatLocal },
|
|
{ "testSST_Math_Mat33dApplyLUVec " , testSST_Math_Mat33dApplyLUVec },
|
|
{ "testSST_Math_Mat33dApplyLUVecLocal " , testSST_Math_Mat33dApplyLUVecLocal },
|
|
{ "testSST_Math_Mat33dTranspose " , testSST_Math_Mat33dTranspose },
|
|
{ "testSST_Math_Mat33dTransposeLocal " , testSST_Math_Mat33dTransposeLocal }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Mat33d)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dAdd(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -5.000000000000000;
|
|
X.v[1] = 9.000000000000000;
|
|
X.v[2] = 5.000000000000000;
|
|
X.v[3] = 14.000000000000000;
|
|
X.v[4] = -11.000000000000000;
|
|
X.v[5] = -1.000000000000000;
|
|
X.v[6] = 3.000000000000000;
|
|
X.v[7] = -18.000000000000000;
|
|
X.v[8] = -20.000000000000000;
|
|
Y.v[0] = -14.000000000000000;
|
|
Y.v[1] = -7.000000000000000;
|
|
Y.v[2] = 1.000000000000000;
|
|
Y.v[3] = -4.000000000000000;
|
|
Y.v[4] = 3.000000000000000;
|
|
Y.v[5] = -12.000000000000000;
|
|
Y.v[6] = -14.000000000000000;
|
|
Y.v[7] = 11.000000000000000;
|
|
Y.v[8] = -3.000000000000000;
|
|
/*
|
|
[[ -5. 14. 3.]
|
|
[ 9. -11. -18.]
|
|
[ 5. -1. -20.]]
|
|
[[-14. -4. -14.]
|
|
[ -7. 3. 11.]
|
|
[ 1. -12. -3.]]
|
|
[[-19. 10. -11.]
|
|
[ 2. -8. -7.]
|
|
[ 6. -13. -23.]]
|
|
*/
|
|
SST_Math_Mat33dAdd(&X,&Y,&A);
|
|
TASSERT(fabs((A.v[0])-( -19.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( 10.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( -11.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( -8.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( -7.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( 6.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( -13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( -23.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dAddLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 3.000000000000000;
|
|
X.v[1] = 14.000000000000000;
|
|
X.v[2] = 8.000000000000000;
|
|
X.v[3] = 10.000000000000000;
|
|
X.v[4] = 16.000000000000000;
|
|
X.v[5] = 3.000000000000000;
|
|
X.v[6] = -3.000000000000000;
|
|
X.v[7] = -10.000000000000000;
|
|
X.v[8] = -4.000000000000000;
|
|
Y.v[0] = 19.000000000000000;
|
|
Y.v[1] = 16.000000000000000;
|
|
Y.v[2] = -2.000000000000000;
|
|
Y.v[3] = 3.000000000000000;
|
|
Y.v[4] = -20.000000000000000;
|
|
Y.v[5] = 3.000000000000000;
|
|
Y.v[6] = 5.000000000000000;
|
|
Y.v[7] = -1.000000000000000;
|
|
Y.v[8] = 18.000000000000000;
|
|
/*
|
|
[[ 3. 10. -3.]
|
|
[ 14. 16. -10.]
|
|
[ 8. 3. -4.]]
|
|
[[ 19. 3. 5.]
|
|
[ 16. -20. -1.]
|
|
[ -2. 3. 18.]]
|
|
[[ 22. 13. 2.]
|
|
[ 30. -4. -11.]
|
|
[ 6. 6. 14.]]
|
|
*/
|
|
SST_Math_Mat33dAddLocal(&X,&Y); /* for accuracy */
|
|
TASSERT(fabs((X.v[0])-( 22.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( 13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 30.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( -4.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( -11.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 6.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( 6.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( 14.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dSubtract(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -3.000000000000000;
|
|
X.v[1] = 12.000000000000000;
|
|
X.v[2] = -20.000000000000000;
|
|
X.v[3] = 3.000000000000000;
|
|
X.v[4] = -11.000000000000000;
|
|
X.v[5] = -16.000000000000000;
|
|
X.v[6] = 2.000000000000000;
|
|
X.v[7] = -18.000000000000000;
|
|
X.v[8] = 11.000000000000000;
|
|
Y.v[0] = -14.000000000000000;
|
|
Y.v[1] = -9.000000000000000;
|
|
Y.v[2] = 10.000000000000000;
|
|
Y.v[3] = 13.000000000000000;
|
|
Y.v[4] = -8.000000000000000;
|
|
Y.v[5] = -17.000000000000000;
|
|
Y.v[6] = -9.000000000000000;
|
|
Y.v[7] = 13.000000000000000;
|
|
Y.v[8] = -14.000000000000000;
|
|
/*
|
|
[[ -3. 3. 2.]
|
|
[ 12. -11. -18.]
|
|
[-20. -16. 11.]]
|
|
[[-14. 13. -9.]
|
|
[ -9. -8. 13.]
|
|
[ 10. -17. -14.]]
|
|
[[ 11. -10. 11.]
|
|
[ 21. -3. -31.]
|
|
[-30. 1. 25.]]
|
|
*/
|
|
SST_Math_Mat33dSubtract(&X,&Y,&A);
|
|
TASSERT(fabs((A.v[0])-( 11.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( -10.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( 11.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( 21.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( -3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( -31.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( -30.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( 25.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dSubtractLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 10.000000000000000;
|
|
X.v[1] = 0.000000000000000;
|
|
X.v[2] = 18.000000000000000;
|
|
X.v[3] = 10.000000000000000;
|
|
X.v[4] = -4.000000000000000;
|
|
X.v[5] = -8.000000000000000;
|
|
X.v[6] = 16.000000000000000;
|
|
X.v[7] = 7.000000000000000;
|
|
X.v[8] = -4.000000000000000;
|
|
Y.v[0] = 1.000000000000000;
|
|
Y.v[1] = 9.000000000000000;
|
|
Y.v[2] = 17.000000000000000;
|
|
Y.v[3] = -1.000000000000000;
|
|
Y.v[4] = 17.000000000000000;
|
|
Y.v[5] = 5.000000000000000;
|
|
Y.v[6] = -18.000000000000000;
|
|
Y.v[7] = -6.000000000000000;
|
|
Y.v[8] = -10.000000000000000;
|
|
/*
|
|
[[ 10. 10. 16.]
|
|
[ 0. -4. 7.]
|
|
[ 18. -8. -4.]]
|
|
[[ 1. -1. -18.]
|
|
[ 9. 17. -6.]
|
|
[ 17. 5. -10.]]
|
|
[[ 9. 11. 34.]
|
|
[ -9. -21. 13.]
|
|
[ 1. -13. 6.]]
|
|
*/
|
|
SST_Math_Mat33dSubtractLocal(&X,&Y); /* for accuracy */
|
|
TASSERT(fabs((X.v[0])-( 9.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( 11.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( 34.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( -9.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( -21.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( 13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( -13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( 6.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyElementwise(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -14.000000000000000;
|
|
X.v[1] = -6.000000000000000;
|
|
X.v[2] = -11.000000000000000;
|
|
X.v[3] = 14.000000000000000;
|
|
X.v[4] = -19.000000000000000;
|
|
X.v[5] = 8.000000000000000;
|
|
X.v[6] = -19.000000000000000;
|
|
X.v[7] = 9.000000000000000;
|
|
X.v[8] = -10.000000000000000;
|
|
Y.v[0] = 11.000000000000000;
|
|
Y.v[1] = 13.000000000000000;
|
|
Y.v[2] = 12.000000000000000;
|
|
Y.v[3] = 2.000000000000000;
|
|
Y.v[4] = 7.000000000000000;
|
|
Y.v[5] = -13.000000000000000;
|
|
Y.v[6] = -7.000000000000000;
|
|
Y.v[7] = 19.000000000000000;
|
|
Y.v[8] = -6.000000000000000;
|
|
/*
|
|
[[-14. 14. -19.]
|
|
[ -6. -19. 9.]
|
|
[-11. 8. -10.]]
|
|
[[ 11. 2. -7.]
|
|
[ 13. 7. 19.]
|
|
[ 12. -13. -6.]]
|
|
[[-154. 28. 133.]
|
|
[ -78. -133. 171.]
|
|
[-132. -104. 60.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyElementwise(&X, &Y, &A);
|
|
TASSERT(fabs((A.v[0])-( -154.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( 28.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( 133.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( -78.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( -133.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( 171.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( -132.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( -104.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( 60.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyElementwiseLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -17.000000000000000;
|
|
X.v[1] = -1.000000000000000;
|
|
X.v[2] = -16.000000000000000;
|
|
X.v[3] = -13.000000000000000;
|
|
X.v[4] = 10.000000000000000;
|
|
X.v[5] = -17.000000000000000;
|
|
X.v[6] = 19.000000000000000;
|
|
X.v[7] = -11.000000000000000;
|
|
X.v[8] = -2.000000000000000;
|
|
Y.v[0] = -19.000000000000000;
|
|
Y.v[1] = -5.000000000000000;
|
|
Y.v[2] = 5.000000000000000;
|
|
Y.v[3] = 19.000000000000000;
|
|
Y.v[4] = 6.000000000000000;
|
|
Y.v[5] = -19.000000000000000;
|
|
Y.v[6] = -15.000000000000000;
|
|
Y.v[7] = -19.000000000000000;
|
|
Y.v[8] = -13.000000000000000;
|
|
/*
|
|
[[-17. -13. 19.]
|
|
[ -1. 10. -11.]
|
|
[-16. -17. -2.]]
|
|
[[-19. 19. -15.]
|
|
[ -5. 6. -19.]
|
|
[ 5. -19. -13.]]
|
|
[[ 323. -247. -285.]
|
|
[ 5. 60. 209.]
|
|
[ -80. 323. 26.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyElementwiseLocal(&X,&Y);
|
|
TASSERT(fabs((X.v[0])-( 323.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( -247.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( -285.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 5.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( 60.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( 209.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( -80.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( 323.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( 26.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyScalar(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -13.000000000000000;
|
|
X.v[1] = -5.000000000000000;
|
|
X.v[2] = -18.000000000000000;
|
|
X.v[3] = 1.000000000000000;
|
|
X.v[4] = -18.000000000000000;
|
|
X.v[5] = 13.000000000000000;
|
|
X.v[6] = 13.000000000000000;
|
|
X.v[7] = -15.000000000000000;
|
|
X.v[8] = -17.000000000000000;
|
|
/*
|
|
[[-13. 1. 13.]
|
|
[ -5. -18. -15.]
|
|
[-18. 13. -17.]]
|
|
[[-26. 2. 26.]
|
|
[-10. -36. -30.]
|
|
[-36. 26. -34.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyScalar(&X, 2.000000000000000,&A);
|
|
TASSERT(fabs((A.v[0])-( -26.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( 26.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( -10.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( -36.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( -30.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( -36.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( 26.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( -34.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyScalarLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 6.000000000000000;
|
|
X.v[1] = -19.000000000000000;
|
|
X.v[2] = 17.000000000000000;
|
|
X.v[3] = -17.000000000000000;
|
|
X.v[4] = -10.000000000000000;
|
|
X.v[5] = 12.000000000000000;
|
|
X.v[6] = -14.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = -4.000000000000000;
|
|
/*
|
|
[[ 6. -17. -14.]
|
|
[-19. -10. -1.]
|
|
[ 17. 12. -4.]]
|
|
[[ 12. -34. -28.]
|
|
[-38. -20. -2.]
|
|
[ 34. 24. -8.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyScalarLocal(&X, 2.000000000000000);
|
|
TASSERT(fabs((X.v[0])-( 12.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( -34.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( -28.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( -38.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( -20.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( -2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 34.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( 24.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( -8.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyMatrix(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 14.000000000000000;
|
|
X.v[1] = 5.000000000000000;
|
|
X.v[2] = 15.000000000000000;
|
|
X.v[3] = -3.000000000000000;
|
|
X.v[4] = -16.000000000000000;
|
|
X.v[5] = 4.000000000000000;
|
|
X.v[6] = 12.000000000000000;
|
|
X.v[7] = 6.000000000000000;
|
|
X.v[8] = -4.000000000000000;
|
|
Y.v[0] = 13.000000000000000;
|
|
Y.v[1] = 0.000000000000000;
|
|
Y.v[2] = 0.000000000000000;
|
|
Y.v[3] = -17.000000000000000;
|
|
Y.v[4] = -9.000000000000000;
|
|
Y.v[5] = -12.000000000000000;
|
|
Y.v[6] = 2.000000000000000;
|
|
Y.v[7] = -5.000000000000000;
|
|
Y.v[8] = -14.000000000000000;
|
|
/*
|
|
X
|
|
[[ 14. -3. 12.]
|
|
[ 5. -16. 6.]
|
|
[ 15. 4. -4.]]
|
|
Y
|
|
[[ 13. -17. 2.]
|
|
[ 0. -9. -5.]
|
|
[ 0. -12. -14.]]
|
|
[[ 182. -355. -125.]
|
|
[ 65. -13. 6.]
|
|
[ 195. -243. 66.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyMatrix(&X,&Y,&A);
|
|
TASSERT(fabs((A.v[0])-( 182.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( -355.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( -125.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( 65.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( -13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( 6.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( 195.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( -243.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( 66.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyMatrixLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 11.000000000000000;
|
|
X.v[1] = -13.000000000000000;
|
|
X.v[2] = -4.000000000000000;
|
|
X.v[3] = 13.000000000000000;
|
|
X.v[4] = 2.000000000000000;
|
|
X.v[5] = -18.000000000000000;
|
|
X.v[6] = -15.000000000000000;
|
|
X.v[7] = 4.000000000000000;
|
|
X.v[8] = -10.000000000000000;
|
|
Y.v[0] = -1.000000000000000;
|
|
Y.v[1] = -12.000000000000000;
|
|
Y.v[2] = 4.000000000000000;
|
|
Y.v[3] = -11.000000000000000;
|
|
Y.v[4] = 13.000000000000000;
|
|
Y.v[5] = -8.000000000000000;
|
|
Y.v[6] = 13.000000000000000;
|
|
Y.v[7] = 19.000000000000000;
|
|
Y.v[8] = -14.000000000000000;
|
|
/*
|
|
X
|
|
[[ 11. 13. -15.]
|
|
[-13. 2. 4.]
|
|
[ -4. -18. -10.]]
|
|
Y
|
|
[[ -1. -11. 13.]
|
|
[-12. 13. 19.]
|
|
[ 4. -8. -14.]]
|
|
X
|
|
[[-227. 168. 600.]
|
|
[ 5. 137. -187.]
|
|
[ 180. -110. -254.]]
|
|
*/
|
|
SST_Math_Mat33dMultiplyMatrixLocal(&X,&Y);
|
|
TASSERT(fabs((X.v[0])-( -227.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( 168.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( 600.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 5.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( 137.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( -187.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 180.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( -110.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( -254.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyVector(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Vec3d v; /* 3 vector */
|
|
SST_Vec3d w; /* 3 vector */
|
|
/* Resetting test vectors / mats */
|
|
v.v[0] = 7.000000000000000;
|
|
v.v[1] = -10.000000000000000;
|
|
v.v[2] = 4.000000000000000;
|
|
X.v[0] = 13.000000000000000;
|
|
X.v[1] = -7.000000000000000;
|
|
X.v[2] = -8.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 16.000000000000000;
|
|
X.v[5] = -8.000000000000000;
|
|
X.v[6] = -14.000000000000000;
|
|
X.v[7] = 0.000000000000000;
|
|
X.v[8] = 9.000000000000000;
|
|
/*
|
|
X
|
|
[[ 13. -1. -14.]
|
|
[ -7. 16. 0.]
|
|
[ -8. -8. 9.]]
|
|
v
|
|
[ 7. -10. 4.]
|
|
w
|
|
[ 45. -209. 60.]
|
|
*/
|
|
SST_Math_Mat33dMultiplyVector(&X,&v,&w);
|
|
TASSERT(fabs((w.v[0])-( 45.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[0] failed!");
|
|
TASSERT(fabs((w.v[1])-( -209.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[1] failed!");
|
|
TASSERT(fabs((w.v[2])-( 60.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[2] failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dMultiplyVectorLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Vec3d v; /* 3 vector */
|
|
/* Resetting test vectors / mats */
|
|
v.v[0] = -16.000000000000000;
|
|
v.v[1] = -20.000000000000000;
|
|
v.v[2] = -11.000000000000000;
|
|
X.v[0] = -7.000000000000000;
|
|
X.v[1] = -3.000000000000000;
|
|
X.v[2] = -14.000000000000000;
|
|
X.v[3] = 6.000000000000000;
|
|
X.v[4] = -1.000000000000000;
|
|
X.v[5] = 7.000000000000000;
|
|
X.v[6] = -18.000000000000000;
|
|
X.v[7] = -7.000000000000000;
|
|
X.v[8] = -2.000000000000000;
|
|
/*
|
|
X
|
|
[[ -7. 6. -18.]
|
|
[ -3. -1. -7.]
|
|
[-14. 7. -2.]]
|
|
v
|
|
[-16. -20. -11.]
|
|
v
|
|
[ 190. 145. 106.]
|
|
*/
|
|
SST_Math_Mat33dMultiplyVectorLocal(&X,&v);
|
|
TASSERT(fabs((v.v[0])-( 190.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[0] failed!");
|
|
TASSERT(fabs((v.v[1])-( 145.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[1] failed!");
|
|
TASSERT(fabs((v.v[2])-( 106.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry .v[2] failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dTranspose(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -1.000000000000000;
|
|
X.v[1] = 19.000000000000000;
|
|
X.v[2] = 10.000000000000000;
|
|
X.v[3] = -15.000000000000000;
|
|
X.v[4] = 17.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = 18.000000000000000;
|
|
X.v[7] = 13.000000000000000;
|
|
X.v[8] = -20.000000000000000;
|
|
SST_Math_Mat33dTranspose(&X,&A);
|
|
TASSERT(fabs((A.v[0])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((A.v[3])-( 19.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((A.v[6])-( 10.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((A.v[1])-( -15.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((A.v[4])-( 17.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((A.v[7])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((A.v[2])-( 18.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((A.v[5])-( 13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((A.v[8])-( -20.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dTransposeLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 14.000000000000000;
|
|
X.v[1] = -13.000000000000000;
|
|
X.v[2] = 13.000000000000000;
|
|
X.v[3] = 5.000000000000000;
|
|
X.v[4] = -15.000000000000000;
|
|
X.v[5] = 16.000000000000000;
|
|
X.v[6] = 17.000000000000000;
|
|
X.v[7] = -15.000000000000000;
|
|
X.v[8] = -5.000000000000000;
|
|
SST_Math_Mat33dTransposeLocal(&X);
|
|
TASSERT(fabs((X.v[0])-( 14.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( -13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( 13.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 5.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( -15.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( 16.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 17.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( -15.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( -5.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dCheckOrthonormal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -16.000000000000000;
|
|
X.v[1] = 5.000000000000000;
|
|
X.v[2] = -10.000000000000000;
|
|
X.v[3] = 1.000000000000000;
|
|
X.v[4] = -8.000000000000000;
|
|
X.v[5] = 0.000000000000000;
|
|
X.v[6] = -7.000000000000000;
|
|
X.v[7] = -11.000000000000000;
|
|
X.v[8] = -5.000000000000000;
|
|
Y.v[0] = 8.000000000000000;
|
|
Y.v[1] = 11.000000000000000;
|
|
Y.v[2] = -17.000000000000000;
|
|
Y.v[3] = -6.000000000000000;
|
|
Y.v[4] = 5.000000000000000;
|
|
Y.v[5] = 9.000000000000000;
|
|
Y.v[6] = -9.000000000000000;
|
|
Y.v[7] = -4.000000000000000;
|
|
Y.v[8] = -9.000000000000000;
|
|
/*
|
|
[[-0.81970483 -0.17940169 -0.54396601]
|
|
[ 0.25615776 -0.96424052 -0.06799575]
|
|
[-0.51231552 -0.19507756 0.83634775]]
|
|
[[ 1.00000000e+00 -1.38777878e-17 0.00000000e+00]
|
|
[ -1.38777878e-17 1.00000000e+00 -2.77555756e-17]
|
|
[ 0.00000000e+00 -2.77555756e-17 1.00000000e+00]]
|
|
*/
|
|
/* Set X to orthogonal matrix Q */
|
|
X.v[0] = (double) -0.819704831325696;
|
|
X.v[1] = (double) 0.256157759789280;
|
|
X.v[2] = (double) -0.512315519578560;
|
|
X.v[3] = (double) -0.179401686289200;
|
|
X.v[4] = (double) -0.964240519705837;
|
|
X.v[5] = (double) -0.195077561790198;
|
|
X.v[6] = (double) -0.543966014065129;
|
|
X.v[7] = (double) -0.067995751758141;
|
|
X.v[8] = (double) 0.836347746625135;
|
|
/* Check Positive Test */
|
|
TASSERT(SST_Math_Mat33dCheckOrthonormal(&X),"CheckOrthonormal failed when it should have passed");
|
|
/* Check Negative Test */
|
|
TASSERT(!SST_Math_Mat33dCheckOrthonormal(&Y),"CheckOrthonormal succeeded when it should have failed");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dDeterminant(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -3.000000000000000;
|
|
X.v[1] = 13.000000000000000;
|
|
X.v[2] = 1.000000000000000;
|
|
X.v[3] = 0.000000000000000;
|
|
X.v[4] = 2.000000000000000;
|
|
X.v[5] = -6.000000000000000;
|
|
X.v[6] = 2.000000000000000;
|
|
X.v[7] = -12.000000000000000;
|
|
X.v[8] = 19.000000000000000;
|
|
/* det(X) =
|
|
-58.0
|
|
*/
|
|
double result = SST_Math_Mat33dDeterminant(&X);
|
|
TASSERT(fabs( (result)/( -57.999999999999986) - 1.000000000000000 ) <= 100*DBL_EPSILON,"Determinant failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dInvert(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d B; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -14.000000000000000;
|
|
X.v[1] = -2.000000000000000;
|
|
X.v[2] = 7.000000000000000;
|
|
X.v[3] = 13.000000000000000;
|
|
X.v[4] = 17.000000000000000;
|
|
X.v[5] = 1.000000000000000;
|
|
X.v[6] = 8.000000000000000;
|
|
X.v[7] = 5.000000000000000;
|
|
X.v[8] = -6.000000000000000;
|
|
/*
|
|
[[-0.12907117 0.10373945 -0.08564536]
|
|
[ 0.02774427 0.03377563 0.06513872]
|
|
[-0.14595899 0.12665862 -0.25572979]]
|
|
*/
|
|
SST_Math_Mat33dInvert(&X,&B);
|
|
TASSERT(fabs((B.v[0])-( -0.129071170084439)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((B.v[1])-( 0.027744270205066)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((B.v[2])-( -0.145958986731001)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((B.v[3])-( 0.103739445114596)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((B.v[4])-( 0.033775633293124)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((B.v[5])-( 0.126658624849216)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((B.v[6])-( -0.085645355850422)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((B.v[7])-( 0.065138721351025)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((B.v[8])-( -0.255729794933655)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dInvertLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 17.000000000000000;
|
|
X.v[1] = 9.000000000000000;
|
|
X.v[2] = 15.000000000000000;
|
|
X.v[3] = 7.000000000000000;
|
|
X.v[4] = 6.000000000000000;
|
|
X.v[5] = -11.000000000000000;
|
|
X.v[6] = -15.000000000000000;
|
|
X.v[7] = 3.000000000000000;
|
|
X.v[8] = 3.000000000000000;
|
|
/*
|
|
()
|
|
[[ 0.01332288 0.03761755 0.02899687]
|
|
[ 0.00470219 0.07210031 -0.04858934]
|
|
[-0.04937304 0.07628004 0.01018809]]
|
|
*/
|
|
SST_Math_Mat33dInvertLocal(&X);
|
|
TASSERT(fabs((X.v[0])-( 0.013322884012539)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a11 failed!");
|
|
TASSERT(fabs((X.v[1])-( 0.004702194357367)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a21 failed!");
|
|
TASSERT(fabs((X.v[2])-( -0.049373040752351)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a31 failed!");
|
|
TASSERT(fabs((X.v[3])-( 0.037617554858934)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a12 failed!");
|
|
TASSERT(fabs((X.v[4])-( 0.072100313479624)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a22 failed!");
|
|
TASSERT(fabs((X.v[5])-( 0.076280041797283)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a32 failed!");
|
|
TASSERT(fabs((X.v[6])-( 0.028996865203762)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a13 failed!");
|
|
TASSERT(fabs((X.v[7])-( -0.048589341692790)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a23 failed!");
|
|
TASSERT(fabs((X.v[8])-( 0.010188087774295)) <=100*DBL_EPSILON /* yes this is bad */,"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33dCreateLU(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d LU; /* 3 x 3 matrix */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLU(&X,&LU);
|
|
/*
|
|
[[ 2 -1 -1]
|
|
[ 1 0 -1]
|
|
[ 0 2 1]]
|
|
*/
|
|
/*
|
|
[[ 2. 0. 0. ]
|
|
[ 1. 0.5 0. ]
|
|
[ 0. 2. 3. ]]
|
|
*/
|
|
/*
|
|
[[ 1. -0.5 -0.5]
|
|
[ 0. 1. -1. ]
|
|
[ 0. 0. 1. ]]
|
|
*/
|
|
TASSERT(fabs((LU.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a11 failed!");
|
|
TASSERT(fabs((LU.v[3])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a12 failed!");
|
|
TASSERT(fabs((LU.v[6])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a13 failed!");
|
|
TASSERT(fabs((LU.v[1])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a21 failed!");
|
|
TASSERT(fabs((LU.v[4])-( 0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a22 failed!");
|
|
TASSERT(fabs((LU.v[7])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a23 failed!");
|
|
TASSERT(fabs((LU.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a31 failed!");
|
|
TASSERT(fabs((LU.v[5])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a32 failed!");
|
|
TASSERT(fabs((LU.v[8])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
static const char* testSST_Math_Mat33dCreateLULocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLULocal(&X);
|
|
TASSERT(fabs((X.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( 0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
static const char* testSST_Math_Mat33dApplyLUMat(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d LU; /* 3 x 3 matrix */
|
|
SST_Mat33d I; /* 3 x 3 matrix */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLU(&X,&LU);
|
|
/*
|
|
[[ 2 -1 -1]
|
|
[ 1 0 -1]
|
|
[ 0 2 1]]
|
|
*/
|
|
/*
|
|
[[ 2. 0. 0. ]
|
|
[ 1. 0.5 0. ]
|
|
[ 0. 2. 3. ]]
|
|
*/
|
|
/*
|
|
[[ 1. -0.5 -0.5]
|
|
[ 0. 1. -1. ]
|
|
[ 0. 0. 1. ]]
|
|
*/
|
|
TASSERT(fabs((LU.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a11 failed!");
|
|
TASSERT(fabs((LU.v[3])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a12 failed!");
|
|
TASSERT(fabs((LU.v[6])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a13 failed!");
|
|
TASSERT(fabs((LU.v[1])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a21 failed!");
|
|
TASSERT(fabs((LU.v[4])-( 0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a22 failed!");
|
|
TASSERT(fabs((LU.v[7])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a23 failed!");
|
|
TASSERT(fabs((LU.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a31 failed!");
|
|
TASSERT(fabs((LU.v[5])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a32 failed!");
|
|
TASSERT(fabs((LU.v[8])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a33 failed!");
|
|
SST_Math_Mat33dApplyLUMat(&LU,&X,&I);
|
|
TASSERT(fabs((I.v[0])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a11 failed!");
|
|
TASSERT(fabs((I.v[1])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a21 failed!");
|
|
TASSERT(fabs((I.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a31 failed!");
|
|
TASSERT(fabs((I.v[3])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a12 failed!");
|
|
TASSERT(fabs((I.v[4])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a22 failed!");
|
|
TASSERT(fabs((I.v[5])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a32 failed!");
|
|
TASSERT(fabs((I.v[6])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a13 failed!");
|
|
TASSERT(fabs((I.v[7])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a23 failed!");
|
|
TASSERT(fabs((I.v[8])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"I:Entry I_a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
static const char* testSST_Math_Mat33dApplyLUMatLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d Xinv; /* 3 x 3 matrix */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
Xinv.v[0] = 2.000000000000000;
|
|
Xinv.v[1] = 1.000000000000000;
|
|
Xinv.v[2] = 0.000000000000000;
|
|
Xinv.v[3] = -1.000000000000000;
|
|
Xinv.v[4] = 0.000000000000000;
|
|
Xinv.v[5] = 2.000000000000000;
|
|
Xinv.v[6] = -1.000000000000000;
|
|
Xinv.v[7] = -1.000000000000000;
|
|
Xinv.v[8] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLULocal(&X);
|
|
TASSERT(fabs((X.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a11 failed!");
|
|
TASSERT(fabs((X.v[3])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a12 failed!");
|
|
TASSERT(fabs((X.v[6])-( -0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a13 failed!");
|
|
TASSERT(fabs((X.v[1])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a21 failed!");
|
|
TASSERT(fabs((X.v[4])-( 0.500000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a22 failed!");
|
|
TASSERT(fabs((X.v[7])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"U:Entry B_a23 failed!");
|
|
TASSERT(fabs((X.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a31 failed!");
|
|
TASSERT(fabs((X.v[5])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a32 failed!");
|
|
TASSERT(fabs((X.v[8])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"L:Entry A_a33 failed!");
|
|
SST_Math_Mat33dApplyLUMatLocal(&X,&Xinv);
|
|
TASSERT(fabs((Xinv.v[0])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a11 failed!");
|
|
TASSERT(fabs((Xinv.v[1])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a21 failed!");
|
|
TASSERT(fabs((Xinv.v[2])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a31 failed!");
|
|
TASSERT(fabs((Xinv.v[3])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a12 failed!");
|
|
TASSERT(fabs((Xinv.v[4])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a22 failed!");
|
|
TASSERT(fabs((Xinv.v[5])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a32 failed!");
|
|
TASSERT(fabs((Xinv.v[6])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a13 failed!");
|
|
TASSERT(fabs((Xinv.v[7])-( 0.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a23 failed!");
|
|
TASSERT(fabs((Xinv.v[8])-( 1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"Xinv:Entry Xinv_a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
static const char* testSST_Math_Mat33dApplyLUVec(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d LU; /* 3 x 3 matrix */
|
|
SST_Vec3d b; /* 3 x 3 vector */
|
|
SST_Vec3d x; /* 3 x 3 vector */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
b.v[0] = 2.000000000000000;
|
|
b.v[1] = -1.000000000000000;
|
|
b.v[2] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLU(&X,&LU);
|
|
SST_Math_Mat33dApplyLUVec(&LU,&b,&x);
|
|
TASSERT(fabs((x.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a1 failed!");
|
|
TASSERT(fabs((x.v[1])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a2 failed!");
|
|
TASSERT(fabs((x.v[2])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a3 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
static const char* testSST_Math_Mat33dApplyLUVecLocal(){
|
|
SST_Mat33d X; /* 3 x 3 matrix */
|
|
SST_Mat33d LU; /* 3 x 3 matrix */
|
|
SST_Vec3d b; /* 3 x 3 vector */
|
|
X.v[0] = 2.000000000000000;
|
|
X.v[1] = 1.000000000000000;
|
|
X.v[2] = 0.000000000000000;
|
|
X.v[3] = -1.000000000000000;
|
|
X.v[4] = 0.000000000000000;
|
|
X.v[5] = 2.000000000000000;
|
|
X.v[6] = -1.000000000000000;
|
|
X.v[7] = -1.000000000000000;
|
|
X.v[8] = 1.000000000000000;
|
|
b.v[0] = 2.000000000000000;
|
|
b.v[1] = -1.000000000000000;
|
|
b.v[2] = 1.000000000000000;
|
|
SST_Math_Mat33dCreateLU(&X,&LU);
|
|
SST_Math_Mat33dApplyLUVecLocal(&LU,&b);
|
|
TASSERT(fabs((b.v[0])-( 2.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a1 failed!");
|
|
TASSERT(fabs((b.v[1])-( -1.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a2 failed!");
|
|
TASSERT(fabs((b.v[2])-( 3.000000000000000)) <=100*DBL_EPSILON /* yes this is bad */,"x:Entry x_a3 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|