720 lines
20 KiB
C++
720 lines
20 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./MatrixNxN.py n = 3, TYPE = int */
|
|
|
|
#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_Mat33iAdd();
|
|
static const char* testSST_Math_Mat33iAddLocal();
|
|
static const char* testSST_Math_Mat33iSubtract();
|
|
static const char* testSST_Math_Mat33iSubtractLocal();
|
|
static const char* testSST_Math_Mat33iMultiplyElementwise();
|
|
static const char* testSST_Math_Mat33iMultiplyElementwiseLocal();
|
|
static const char* testSST_Math_Mat33iMultiplyScalar();
|
|
static const char* testSST_Math_Mat33iMultiplyScalarLocal();
|
|
static const char* testSST_Math_Mat33iMultiplyMatrix();
|
|
static const char* testSST_Math_Mat33iMultiplyMatrixLocal();
|
|
static const char* testSST_Math_Mat33iMultiplyVector();
|
|
static const char* testSST_Math_Mat33iMultiplyVectorLocal();
|
|
static const char* testSST_Math_Mat33iTranspose();
|
|
static const char* testSST_Math_Mat33iTransposeLocal();
|
|
static const char* testSST_Math_Mat33iDeterminant();
|
|
static const char* testSST_Math_Mat33iCheckOrthonormal();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Mat33iUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Mat33iAdd " , testSST_Math_Mat33iAdd },
|
|
{ "testSST_Math_Mat33iAddLocal " , testSST_Math_Mat33iAddLocal },
|
|
{ "testSST_Math_Mat33iSubtract " , testSST_Math_Mat33iSubtract },
|
|
{ "testSST_Math_Mat33iSubtractLocal " , testSST_Math_Mat33iSubtractLocal },
|
|
{ "testSST_Math_Mat33iMultiplyElementwise " , testSST_Math_Mat33iMultiplyElementwise },
|
|
{ "testSST_Math_Mat33iMultiplyElementwiseLocal " , testSST_Math_Mat33iMultiplyElementwiseLocal },
|
|
{ "testSST_Math_Mat33iMultiplyScalar " , testSST_Math_Mat33iMultiplyScalar },
|
|
{ "testSST_Math_Mat33iMultiplyScalarLocal " , testSST_Math_Mat33iMultiplyScalarLocal },
|
|
{ "testSST_Math_Mat33iMultiplyMatrix " , testSST_Math_Mat33iMultiplyMatrix },
|
|
{ "testSST_Math_Mat33iMultiplyMatrixLocal " , testSST_Math_Mat33iMultiplyMatrixLocal },
|
|
{ "testSST_Math_Mat33iMultiplyVector " , testSST_Math_Mat33iMultiplyVector },
|
|
{ "testSST_Math_Mat33iMultiplyVectorLocal " , testSST_Math_Mat33iMultiplyVectorLocal },
|
|
{ "testSST_Math_Mat33iDeterminant " , testSST_Math_Mat33iDeterminant },
|
|
{ "testSST_Math_Mat33iCheckOrthonormal " , testSST_Math_Mat33iCheckOrthonormal },
|
|
{ "testSST_Math_Mat33iTranspose " , testSST_Math_Mat33iTranspose },
|
|
{ "testSST_Math_Mat33iTransposeLocal " , testSST_Math_Mat33iTransposeLocal }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Mat33i)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iAdd(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -17;
|
|
X.v[1] = 4;
|
|
X.v[2] = -20;
|
|
X.v[3] = -10;
|
|
X.v[4] = 8;
|
|
X.v[5] = -5;
|
|
X.v[6] = 13;
|
|
X.v[7] = -5;
|
|
X.v[8] = 7;
|
|
Y.v[0] = 1;
|
|
Y.v[1] = -7;
|
|
Y.v[2] = -9;
|
|
Y.v[3] = 2;
|
|
Y.v[4] = -13;
|
|
Y.v[5] = -20;
|
|
Y.v[6] = -10;
|
|
Y.v[7] = -16;
|
|
Y.v[8] = -4;
|
|
/*
|
|
[[-17 -10 13]
|
|
[ 4 8 -5]
|
|
[-20 -5 7]]
|
|
[[ 1 2 -10]
|
|
[ -7 -13 -16]
|
|
[ -9 -20 -4]]
|
|
[[-16 -8 3]
|
|
[ -3 -5 -21]
|
|
[-29 -25 3]]
|
|
*/
|
|
SST_Math_Mat33iAdd(&X,&Y,&A);
|
|
TASSERT((A.v[0])==(-16),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(-8),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(3),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(-3),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(-5),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(-21),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(-29),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(-25),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(3),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iAddLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 15;
|
|
X.v[1] = -6;
|
|
X.v[2] = 0;
|
|
X.v[3] = 13;
|
|
X.v[4] = -15;
|
|
X.v[5] = -16;
|
|
X.v[6] = 18;
|
|
X.v[7] = -16;
|
|
X.v[8] = 9;
|
|
Y.v[0] = 5;
|
|
Y.v[1] = 11;
|
|
Y.v[2] = -12;
|
|
Y.v[3] = 2;
|
|
Y.v[4] = 7;
|
|
Y.v[5] = -1;
|
|
Y.v[6] = -9;
|
|
Y.v[7] = 11;
|
|
Y.v[8] = -1;
|
|
/*
|
|
[[ 15 13 18]
|
|
[ -6 -15 -16]
|
|
[ 0 -16 9]]
|
|
[[ 5 2 -9]
|
|
[ 11 7 11]
|
|
[-12 -1 -1]]
|
|
[[ 20 15 9]
|
|
[ 5 -8 -5]
|
|
[-12 -17 8]]
|
|
*/
|
|
SST_Math_Mat33iAddLocal(&X,&Y); /* for accuracy */
|
|
TASSERT((X.v[0])==(20),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(15),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(9),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(5),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(-8),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(-5),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(-12),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(-17),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(8),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iSubtract(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 9;
|
|
X.v[1] = -2;
|
|
X.v[2] = 19;
|
|
X.v[3] = -12;
|
|
X.v[4] = 14;
|
|
X.v[5] = 18;
|
|
X.v[6] = -9;
|
|
X.v[7] = 17;
|
|
X.v[8] = -15;
|
|
Y.v[0] = -16;
|
|
Y.v[1] = 11;
|
|
Y.v[2] = 3;
|
|
Y.v[3] = -18;
|
|
Y.v[4] = 12;
|
|
Y.v[5] = -11;
|
|
Y.v[6] = 16;
|
|
Y.v[7] = -19;
|
|
Y.v[8] = 3;
|
|
/*
|
|
[[ 9 -12 -9]
|
|
[ -2 14 17]
|
|
[ 19 18 -15]]
|
|
[[-16 -18 16]
|
|
[ 11 12 -19]
|
|
[ 3 -11 3]]
|
|
[[ 25 6 -25]
|
|
[-13 2 36]
|
|
[ 16 29 -18]]
|
|
*/
|
|
SST_Math_Mat33iSubtract(&X,&Y,&A);
|
|
TASSERT((A.v[0])==(25),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(6),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(-25),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(-13),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(2),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(36),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(16),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(29),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(-18),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iSubtractLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -1;
|
|
X.v[1] = 3;
|
|
X.v[2] = 11;
|
|
X.v[3] = 18;
|
|
X.v[4] = -1;
|
|
X.v[5] = -17;
|
|
X.v[6] = -8;
|
|
X.v[7] = -10;
|
|
X.v[8] = -13;
|
|
Y.v[0] = -6;
|
|
Y.v[1] = 6;
|
|
Y.v[2] = -20;
|
|
Y.v[3] = -19;
|
|
Y.v[4] = 8;
|
|
Y.v[5] = -10;
|
|
Y.v[6] = 15;
|
|
Y.v[7] = 9;
|
|
Y.v[8] = 1;
|
|
/*
|
|
[[ -1 18 -8]
|
|
[ 3 -1 -10]
|
|
[ 11 -17 -13]]
|
|
[[ -6 -19 15]
|
|
[ 6 8 9]
|
|
[-20 -10 1]]
|
|
[[ 5 37 -23]
|
|
[ -3 -9 -19]
|
|
[ 31 -7 -14]]
|
|
*/
|
|
SST_Math_Mat33iSubtractLocal(&X,&Y); /* for accuracy */
|
|
TASSERT((X.v[0])==(5),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(37),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(-23),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(-3),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(-9),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(-19),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(31),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(-7),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(-14),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyElementwise(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -1;
|
|
X.v[1] = 16;
|
|
X.v[2] = 16;
|
|
X.v[3] = -17;
|
|
X.v[4] = 1;
|
|
X.v[5] = 1;
|
|
X.v[6] = 8;
|
|
X.v[7] = 2;
|
|
X.v[8] = -7;
|
|
Y.v[0] = 5;
|
|
Y.v[1] = -14;
|
|
Y.v[2] = 17;
|
|
Y.v[3] = -13;
|
|
Y.v[4] = 19;
|
|
Y.v[5] = -15;
|
|
Y.v[6] = 19;
|
|
Y.v[7] = -7;
|
|
Y.v[8] = 2;
|
|
/*
|
|
[[ -1 -17 8]
|
|
[ 16 1 2]
|
|
[ 16 1 -7]]
|
|
[[ 5 -13 19]
|
|
[-14 19 -7]
|
|
[ 17 -15 2]]
|
|
[[ -5 221 152]
|
|
[-224 19 -14]
|
|
[ 272 -15 -14]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyElementwise(&X, &Y, &A);
|
|
TASSERT((A.v[0])==(-5),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(221),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(152),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(-224),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(19),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(-14),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(272),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(-15),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(-14),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyElementwiseLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -14;
|
|
X.v[1] = -2;
|
|
X.v[2] = 4;
|
|
X.v[3] = -18;
|
|
X.v[4] = -9;
|
|
X.v[5] = 0;
|
|
X.v[6] = -10;
|
|
X.v[7] = 17;
|
|
X.v[8] = -20;
|
|
Y.v[0] = -8;
|
|
Y.v[1] = -9;
|
|
Y.v[2] = 3;
|
|
Y.v[3] = 15;
|
|
Y.v[4] = -15;
|
|
Y.v[5] = 2;
|
|
Y.v[6] = 3;
|
|
Y.v[7] = 2;
|
|
Y.v[8] = -4;
|
|
/*
|
|
[[-14 -18 -10]
|
|
[ -2 -9 17]
|
|
[ 4 0 -20]]
|
|
[[ -8 15 3]
|
|
[ -9 -15 2]
|
|
[ 3 2 -4]]
|
|
[[ 112 -270 -30]
|
|
[ 18 135 34]
|
|
[ 12 0 80]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyElementwiseLocal(&X,&Y);
|
|
TASSERT((X.v[0])==(112),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(-270),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(-30),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(18),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(135),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(34),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(12),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(0),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(80),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyScalar(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 12;
|
|
X.v[1] = -10;
|
|
X.v[2] = -13;
|
|
X.v[3] = -16;
|
|
X.v[4] = -5;
|
|
X.v[5] = -5;
|
|
X.v[6] = -5;
|
|
X.v[7] = 15;
|
|
X.v[8] = 16;
|
|
/*
|
|
[[ 12 -16 -5]
|
|
[-10 -5 15]
|
|
[-13 -5 16]]
|
|
[[ 24 -32 -10]
|
|
[-20 -10 30]
|
|
[-26 -10 32]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyScalar(&X,2,&A);
|
|
TASSERT((A.v[0])==(24),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(-32),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(-10),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(-20),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(-10),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(30),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(-26),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(-10),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(32),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyScalarLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 0;
|
|
X.v[1] = -4;
|
|
X.v[2] = 13;
|
|
X.v[3] = -9;
|
|
X.v[4] = -20;
|
|
X.v[5] = -15;
|
|
X.v[6] = 1;
|
|
X.v[7] = 2;
|
|
X.v[8] = 9;
|
|
/*
|
|
[[ 0 -9 1]
|
|
[ -4 -20 2]
|
|
[ 13 -15 9]]
|
|
[[ 0 -18 2]
|
|
[ -8 -40 4]
|
|
[ 26 -30 18]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyScalarLocal(&X,2);
|
|
TASSERT((X.v[0])==(0),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(-18),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(2),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(-8),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(-40),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(4),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(26),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(-30),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(18),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyMatrix(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -8;
|
|
X.v[1] = 7;
|
|
X.v[2] = -9;
|
|
X.v[3] = 1;
|
|
X.v[4] = 10;
|
|
X.v[5] = -15;
|
|
X.v[6] = -6;
|
|
X.v[7] = 1;
|
|
X.v[8] = 4;
|
|
Y.v[0] = -15;
|
|
Y.v[1] = 11;
|
|
Y.v[2] = -10;
|
|
Y.v[3] = 12;
|
|
Y.v[4] = 11;
|
|
Y.v[5] = 16;
|
|
Y.v[6] = 0;
|
|
Y.v[7] = -14;
|
|
Y.v[8] = -5;
|
|
/*
|
|
X
|
|
[[ -8 1 -6]
|
|
[ 7 10 1]
|
|
[ -9 -15 4]]
|
|
Y
|
|
[[-15 12 0]
|
|
[ 11 11 -14]
|
|
[-10 16 -5]]
|
|
[[ 191 -181 16]
|
|
[ -5 210 -145]
|
|
[ -70 -209 190]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyMatrix(&X,&Y,&A);
|
|
TASSERT((A.v[0])==(191),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(-181),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(16),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(-5),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(210),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(-145),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(-70),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(-209),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(190),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyMatrixLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -20;
|
|
X.v[1] = 13;
|
|
X.v[2] = 14;
|
|
X.v[3] = -4;
|
|
X.v[4] = 19;
|
|
X.v[5] = -3;
|
|
X.v[6] = 16;
|
|
X.v[7] = 19;
|
|
X.v[8] = -9;
|
|
Y.v[0] = -19;
|
|
Y.v[1] = -8;
|
|
Y.v[2] = -5;
|
|
Y.v[3] = -19;
|
|
Y.v[4] = -2;
|
|
Y.v[5] = -10;
|
|
Y.v[6] = -16;
|
|
Y.v[7] = 17;
|
|
Y.v[8] = -9;
|
|
/*
|
|
X
|
|
[[-20 -4 16]
|
|
[ 13 19 19]
|
|
[ 14 -3 -9]]
|
|
Y
|
|
[[-19 -19 -16]
|
|
[ -8 -2 17]
|
|
[ -5 -10 -9]]
|
|
X
|
|
[[ 332 228 108]
|
|
[-494 -475 -56]
|
|
[-197 -170 -194]]
|
|
*/
|
|
SST_Math_Mat33iMultiplyMatrixLocal(&X,&Y);
|
|
TASSERT((X.v[0])==(332),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(228),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(108),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(-494),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(-475),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(-56),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(-197),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(-170),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(-194),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyVector(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Vec3i v; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors / mats */
|
|
v.v[0] = 7;
|
|
v.v[1] = 11;
|
|
v.v[2] = -14;
|
|
X.v[0] = 2;
|
|
X.v[1] = 2;
|
|
X.v[2] = -11;
|
|
X.v[3] = -6;
|
|
X.v[4] = 12;
|
|
X.v[5] = -13;
|
|
X.v[6] = -4;
|
|
X.v[7] = -20;
|
|
X.v[8] = 15;
|
|
/*
|
|
X
|
|
[[ 2 -6 -4]
|
|
[ 2 12 -20]
|
|
[-11 -13 15]]
|
|
v
|
|
[ 7 11 -14]
|
|
w
|
|
[ 4 426 -430]
|
|
*/
|
|
SST_Math_Mat33iMultiplyVector(&X,&v,&w);
|
|
TASSERT((w.v[0])==(4),"Entry .v[0] failed!");
|
|
TASSERT((w.v[1])==(426),"Entry .v[1] failed!");
|
|
TASSERT((w.v[2])==(-430),"Entry .v[2] failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iMultiplyVectorLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Vec3i v; /* 3 vector */
|
|
/* Resetting test vectors / mats */
|
|
v.v[0] = 19;
|
|
v.v[1] = 2;
|
|
v.v[2] = -20;
|
|
X.v[0] = -13;
|
|
X.v[1] = 14;
|
|
X.v[2] = 2;
|
|
X.v[3] = 10;
|
|
X.v[4] = 19;
|
|
X.v[5] = 11;
|
|
X.v[6] = 15;
|
|
X.v[7] = -10;
|
|
X.v[8] = -7;
|
|
/*
|
|
X
|
|
[[-13 10 15]
|
|
[ 14 19 -10]
|
|
[ 2 11 -7]]
|
|
v
|
|
[ 19 2 -20]
|
|
v
|
|
[-527 504 200]
|
|
*/
|
|
SST_Math_Mat33iMultiplyVectorLocal(&X,&v);
|
|
TASSERT((v.v[0])==(-527),"Entry .v[0] failed!");
|
|
TASSERT((v.v[1])==(504),"Entry .v[1] failed!");
|
|
TASSERT((v.v[2])==(200),"Entry .v[2] failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iTranspose(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i A; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 8;
|
|
X.v[1] = -13;
|
|
X.v[2] = 2;
|
|
X.v[3] = 1;
|
|
X.v[4] = -17;
|
|
X.v[5] = -16;
|
|
X.v[6] = -16;
|
|
X.v[7] = -5;
|
|
X.v[8] = 13;
|
|
SST_Math_Mat33iTranspose(&X,&A);
|
|
TASSERT((A.v[0])==(8),"Entry _a11 failed!");
|
|
TASSERT((A.v[3])==(-13),"Entry _a12 failed!");
|
|
TASSERT((A.v[6])==(2),"Entry _a13 failed!");
|
|
TASSERT((A.v[1])==(1),"Entry _a21 failed!");
|
|
TASSERT((A.v[4])==(-17),"Entry _a22 failed!");
|
|
TASSERT((A.v[7])==(-16),"Entry _a23 failed!");
|
|
TASSERT((A.v[2])==(-16),"Entry _a31 failed!");
|
|
TASSERT((A.v[5])==(-5),"Entry _a32 failed!");
|
|
TASSERT((A.v[8])==(13),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iTransposeLocal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = -19;
|
|
X.v[1] = -4;
|
|
X.v[2] = 14;
|
|
X.v[3] = -2;
|
|
X.v[4] = 18;
|
|
X.v[5] = -4;
|
|
X.v[6] = -2;
|
|
X.v[7] = 2;
|
|
X.v[8] = 10;
|
|
SST_Math_Mat33iTransposeLocal(&X);
|
|
TASSERT((X.v[0])==(-19),"Entry _a11 failed!");
|
|
TASSERT((X.v[3])==(-4),"Entry _a12 failed!");
|
|
TASSERT((X.v[6])==(14),"Entry _a13 failed!");
|
|
TASSERT((X.v[1])==(-2),"Entry _a21 failed!");
|
|
TASSERT((X.v[4])==(18),"Entry _a22 failed!");
|
|
TASSERT((X.v[7])==(-4),"Entry _a23 failed!");
|
|
TASSERT((X.v[2])==(-2),"Entry _a31 failed!");
|
|
TASSERT((X.v[5])==(2),"Entry _a32 failed!");
|
|
TASSERT((X.v[8])==(10),"Entry _a33 failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iCheckOrthonormal(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
SST_Mat33i Y; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 14;
|
|
X.v[1] = 1;
|
|
X.v[2] = 8;
|
|
X.v[3] = 12;
|
|
X.v[4] = -9;
|
|
X.v[5] = -1;
|
|
X.v[6] = -16;
|
|
X.v[7] = 11;
|
|
X.v[8] = 3;
|
|
Y.v[0] = -19;
|
|
Y.v[1] = 6;
|
|
Y.v[2] = 12;
|
|
Y.v[3] = 2;
|
|
Y.v[4] = -1;
|
|
Y.v[5] = -1;
|
|
Y.v[6] = -11;
|
|
Y.v[7] = -8;
|
|
Y.v[8] = 19;
|
|
X.v[0] = (int)1;
|
|
X.v[1] = (int)0;
|
|
X.v[2] = (int)0;
|
|
X.v[3] = (int)0;
|
|
X.v[4] = (int)1;
|
|
X.v[5] = (int)0;
|
|
X.v[6] = (int)0;
|
|
X.v[7] = (int)0;
|
|
X.v[8] = (int)1;
|
|
Y.v[0] = (int)1;
|
|
Y.v[1] = (int)0;
|
|
Y.v[2] = (int)0;
|
|
Y.v[3] = (int)0;
|
|
Y.v[4] = (int)1;
|
|
Y.v[5] = (int)0;
|
|
Y.v[6] = (int)0;
|
|
Y.v[7] = (int)0;
|
|
Y.v[8] = (int)1;
|
|
Y.v[2] = (int)1; /* Will cause Y to be fail */
|
|
/* Check Positive Test */
|
|
TASSERT(SST_Math_Mat33iCheckOrthonormal(&X),"CheckOrthonormal failed when it should have passed");
|
|
/* Check Negative Test */
|
|
TASSERT(!SST_Math_Mat33iCheckOrthonormal(&Y),"CheckOrthonormal succeeded when it should have failed");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Mat33iDeterminant(){
|
|
SST_Mat33i X; /* 3 x 3 matrix */
|
|
/* Resetting test vectors / mats */
|
|
X.v[0] = 16;
|
|
X.v[1] = 9;
|
|
X.v[2] = -17;
|
|
X.v[3] = -20;
|
|
X.v[4] = 13;
|
|
X.v[5] = 6;
|
|
X.v[6] = -6;
|
|
X.v[7] = -20;
|
|
X.v[8] = 10;
|
|
/* det(X) =
|
|
-2650.0
|
|
*/
|
|
int result = SST_Math_Mat33iDeterminant(&X);
|
|
TASSERT(abs( (result)/(-2650) - 1 ) <= 100*0,"Determinant failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|