/*
	AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
	Please change MatrixNxN.py and re-run it
*/
/* Generated with ./MatrixNxN.py n = 2, TYPE = int */

#include "ZUnitTest.hpp"
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <SST/SST_Mat22.h>
#include <SST/SST_Vec2.h>




static const char* testSST_Math_Mat22iAdd();
static const char* testSST_Math_Mat22iAddLocal();
static const char* testSST_Math_Mat22iSubtract();
static const char* testSST_Math_Mat22iSubtractLocal();
static const char* testSST_Math_Mat22iMultiplyElementwise();
static const char* testSST_Math_Mat22iMultiplyElementwiseLocal();
static const char* testSST_Math_Mat22iMultiplyScalar();
static const char* testSST_Math_Mat22iMultiplyScalarLocal();
static const char* testSST_Math_Mat22iMultiplyMatrix();
static const char* testSST_Math_Mat22iMultiplyMatrixLocal();
static const char* testSST_Math_Mat22iMultiplyVector();
static const char* testSST_Math_Mat22iMultiplyVectorLocal();
static const char* testSST_Math_Mat22iTranspose();
static const char* testSST_Math_Mat22iTransposeLocal();
static const char* testSST_Math_Mat22iDeterminant();
static const char* testSST_Math_Mat22iCheckOrthonormal();
// List of unit tests 
ZUnitTest SST_Math_Mat22iUnitTests[] = 
{
{ "testSST_Math_Mat22iAdd                       " , testSST_Math_Mat22iAdd                        },
{ "testSST_Math_Mat22iAddLocal                  " , testSST_Math_Mat22iAddLocal                   },
{ "testSST_Math_Mat22iSubtract                  " , testSST_Math_Mat22iSubtract                   },
{ "testSST_Math_Mat22iSubtractLocal             " , testSST_Math_Mat22iSubtractLocal              },
{ "testSST_Math_Mat22iMultiplyElementwise       " , testSST_Math_Mat22iMultiplyElementwise        },
{ "testSST_Math_Mat22iMultiplyElementwiseLocal  " , testSST_Math_Mat22iMultiplyElementwiseLocal   },
{ "testSST_Math_Mat22iMultiplyScalar            " , testSST_Math_Mat22iMultiplyScalar             },
{ "testSST_Math_Mat22iMultiplyScalarLocal       " , testSST_Math_Mat22iMultiplyScalarLocal        },
{ "testSST_Math_Mat22iMultiplyMatrix            " , testSST_Math_Mat22iMultiplyMatrix             },
{ "testSST_Math_Mat22iMultiplyMatrixLocal       " , testSST_Math_Mat22iMultiplyMatrixLocal        },
{ "testSST_Math_Mat22iMultiplyVector            " , testSST_Math_Mat22iMultiplyVector             },
{ "testSST_Math_Mat22iMultiplyVectorLocal       " , testSST_Math_Mat22iMultiplyVectorLocal        },
{ "testSST_Math_Mat22iDeterminant               " , testSST_Math_Mat22iDeterminant                },
{ "testSST_Math_Mat22iCheckOrthonormal          " , testSST_Math_Mat22iCheckOrthonormal           },
{ "testSST_Math_Mat22iTranspose                 " , testSST_Math_Mat22iTranspose                  },
{ "testSST_Math_Mat22iTransposeLocal            " , testSST_Math_Mat22iTransposeLocal             }
};
DECLARE_ZTESTBLOCK(SST_Math_Mat22i)

/******************************************************************************/

static const char* testSST_Math_Mat22iAdd(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 15;
    X.v[1] = -18;
    X.v[2] = -14;
    X.v[3] = -20;
    Y.v[0] = -7;
    Y.v[1] = 7;
    Y.v[2] = 4;
    Y.v[3] = 14;
/*
[[ 15 -14]
 [-18 -20]]
[[-7  4]
 [ 7 14]]
[[  8 -10]
 [-11  -6]]
*/
    SST_Math_Mat22iAdd(&X,&Y,&A);
    TASSERT((A.v[0])==(8),"Entry _a11 failed!");
    TASSERT((A.v[2])==(-10),"Entry _a12 failed!");
    TASSERT((A.v[1])==(-11),"Entry _a21 failed!");
    TASSERT((A.v[3])==(-6),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iAddLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 14;
    X.v[1] = -8;
    X.v[2] = -19;
    X.v[3] = 11;
    Y.v[0] = -20;
    Y.v[1] = -10;
    Y.v[2] = 13;
    Y.v[3] = 17;
/*
[[ 14 -19]
 [ -8  11]]
[[-20  13]
 [-10  17]]
[[ -6  -6]
 [-18  28]]
*/
    SST_Math_Mat22iAddLocal(&X,&Y); /* for accuracy */
    TASSERT((X.v[0])==(-6),"Entry _a11 failed!");
    TASSERT((X.v[2])==(-6),"Entry _a12 failed!");
    TASSERT((X.v[1])==(-18),"Entry _a21 failed!");
    TASSERT((X.v[3])==(28),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iSubtract(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 14;
    X.v[1] = -16;
    X.v[2] = -9;
    X.v[3] = -14;
    Y.v[0] = 13;
    Y.v[1] = 11;
    Y.v[2] = 9;
    Y.v[3] = -7;
/*
[[ 14  -9]
 [-16 -14]]
[[13  9]
 [11 -7]]
[[  1 -18]
 [-27  -7]]
*/
    SST_Math_Mat22iSubtract(&X,&Y,&A);
    TASSERT((A.v[0])==(1),"Entry _a11 failed!");
    TASSERT((A.v[2])==(-18),"Entry _a12 failed!");
    TASSERT((A.v[1])==(-27),"Entry _a21 failed!");
    TASSERT((A.v[3])==(-7),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iSubtractLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 19;
    X.v[1] = 18;
    X.v[2] = -16;
    X.v[3] = -13;
    Y.v[0] = 12;
    Y.v[1] = 6;
    Y.v[2] = 2;
    Y.v[3] = -6;
/*
[[ 19 -16]
 [ 18 -13]]
[[12  2]
 [ 6 -6]]
[[  7 -18]
 [ 12  -7]]
*/
    SST_Math_Mat22iSubtractLocal(&X,&Y); /* for accuracy */
    TASSERT((X.v[0])==(7),"Entry _a11 failed!");
    TASSERT((X.v[2])==(-18),"Entry _a12 failed!");
    TASSERT((X.v[1])==(12),"Entry _a21 failed!");
    TASSERT((X.v[3])==(-7),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyElementwise(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 13;
    X.v[1] = -2;
    X.v[2] = -20;
    X.v[3] = 18;
    Y.v[0] = 2;
    Y.v[1] = 14;
    Y.v[2] = -5;
    Y.v[3] = 16;
/*
[[ 13 -20]
 [ -2  18]]
[[ 2 -5]
 [14 16]]
[[ 26 100]
 [-28 288]]
*/
    SST_Math_Mat22iMultiplyElementwise(&X, &Y, &A);
    TASSERT((A.v[0])==(26),"Entry _a11 failed!");
    TASSERT((A.v[2])==(100),"Entry _a12 failed!");
    TASSERT((A.v[1])==(-28),"Entry _a21 failed!");
    TASSERT((A.v[3])==(288),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyElementwiseLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = -11;
    X.v[1] = 10;
    X.v[2] = 12;
    X.v[3] = -3;
    Y.v[0] = -19;
    Y.v[1] = 2;
    Y.v[2] = 7;
    Y.v[3] = -4;
/*
[[-11  12]
 [ 10  -3]]
[[-19   7]
 [  2  -4]]
[[209  84]
 [ 20  12]]
*/
    SST_Math_Mat22iMultiplyElementwiseLocal(&X,&Y);
    TASSERT((X.v[0])==(209),"Entry _a11 failed!");
    TASSERT((X.v[2])==(84),"Entry _a12 failed!");
    TASSERT((X.v[1])==(20),"Entry _a21 failed!");
    TASSERT((X.v[3])==(12),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyScalar(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = -1;
    X.v[1] = -17;
    X.v[2] = -14;
    X.v[3] = -8;
/*
[[ -1 -14]
 [-17  -8]]
[[ -2 -28]
 [-34 -16]]
*/
    SST_Math_Mat22iMultiplyScalar(&X,2,&A);
    TASSERT((A.v[0])==(-2),"Entry _a11 failed!");
    TASSERT((A.v[2])==(-28),"Entry _a12 failed!");
    TASSERT((A.v[1])==(-34),"Entry _a21 failed!");
    TASSERT((A.v[3])==(-16),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyScalarLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 9;
    X.v[1] = -1;
    X.v[2] = -9;
    X.v[3] = 4;
/*
[[ 9 -9]
 [-1  4]]
[[ 18 -18]
 [ -2   8]]
*/
    SST_Math_Mat22iMultiplyScalarLocal(&X,2);
    TASSERT((X.v[0])==(18),"Entry _a11 failed!");
    TASSERT((X.v[2])==(-18),"Entry _a12 failed!");
    TASSERT((X.v[1])==(-2),"Entry _a21 failed!");
    TASSERT((X.v[3])==(8),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyMatrix(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = -20;
    X.v[1] = 0;
    X.v[2] = -1;
    X.v[3] = -1;
    Y.v[0] = -9;
    Y.v[1] = -10;
    Y.v[2] = 18;
    Y.v[3] = -1;
/*
X
[[-20  -1]
 [  0  -1]]
Y
[[ -9  18]
 [-10  -1]]
[[ 190 -359]
 [  10    1]]
*/
    SST_Math_Mat22iMultiplyMatrix(&X,&Y,&A);
    TASSERT((A.v[0])==(190),"Entry _a11 failed!");
    TASSERT((A.v[2])==(-359),"Entry _a12 failed!");
    TASSERT((A.v[1])==(10),"Entry _a21 failed!");
    TASSERT((A.v[3])==(1),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyMatrixLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 19;
    X.v[1] = 18;
    X.v[2] = 5;
    X.v[3] = -14;
    Y.v[0] = -18;
    Y.v[1] = 19;
    Y.v[2] = -14;
    Y.v[3] = 4;
/*
X
[[ 19   5]
 [ 18 -14]]
Y
[[-18 -14]
 [ 19   4]]
X
[[-247 -246]
 [-590 -308]]
*/
    SST_Math_Mat22iMultiplyMatrixLocal(&X,&Y);
    TASSERT((X.v[0])==(-247),"Entry _a11 failed!");
    TASSERT((X.v[2])==(-246),"Entry _a12 failed!");
    TASSERT((X.v[1])==(-590),"Entry _a21 failed!");
    TASSERT((X.v[3])==(-308),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyVector(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Vec2i v; /* 2 vector */
    SST_Vec2i w; /* 2 vector */
/* Resetting test vectors / mats */
    v.v[0] = -9;
    v.v[1] = 16;
    X.v[0] = -2;
    X.v[1] = -3;
    X.v[2] = -17;
    X.v[3] = 5;
/*
X
[[ -2 -17]
 [ -3   5]]
v
[-9 16]
w
[-254  107]
*/
    SST_Math_Mat22iMultiplyVector(&X,&v,&w);
    TASSERT((w.v[0])==(-254),"Entry .v[0] failed!");
    TASSERT((w.v[1])==(107),"Entry .v[1] failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iMultiplyVectorLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Vec2i v; /* 2 vector */
/* Resetting test vectors / mats */
    v.v[0] = -2;
    v.v[1] = -4;
    X.v[0] = 10;
    X.v[1] = 5;
    X.v[2] = 13;
    X.v[3] = 8;
/*
X
[[10 13]
 [ 5  8]]
v
[-2 -4]
v
[-72 -42]
*/
    SST_Math_Mat22iMultiplyVectorLocal(&X,&v);
    TASSERT((v.v[0])==(-72),"Entry .v[0] failed!");
    TASSERT((v.v[1])==(-42),"Entry .v[1] failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iTranspose(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i A; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 5;
    X.v[1] = -17;
    X.v[2] = 3;
    X.v[3] = 1;
    SST_Math_Mat22iTranspose(&X,&A);
    TASSERT((A.v[0])==(5),"Entry _a11 failed!");
    TASSERT((A.v[2])==(-17),"Entry _a12 failed!");
    TASSERT((A.v[1])==(3),"Entry _a21 failed!");
    TASSERT((A.v[3])==(1),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iTransposeLocal(){
    SST_Mat22i X; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = -11;
    X.v[1] = -17;
    X.v[2] = -11;
    X.v[3] = 17;
    SST_Math_Mat22iTransposeLocal(&X);
    TASSERT((X.v[0])==(-11),"Entry _a11 failed!");
    TASSERT((X.v[2])==(-17),"Entry _a12 failed!");
    TASSERT((X.v[1])==(-11),"Entry _a21 failed!");
    TASSERT((X.v[3])==(17),"Entry _a22 failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iCheckOrthonormal(){
    SST_Mat22i X; /* 2 x 2 matrix */
    SST_Mat22i Y; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 6;
    X.v[1] = -11;
    X.v[2] = 15;
    X.v[3] = 2;
    Y.v[0] = 15;
    Y.v[1] = -3;
    Y.v[2] = 18;
    Y.v[3] = 0;
X.v[0] = (int)1;
X.v[1] = (int)0;
X.v[2] = (int)0;
X.v[3] = (int)1;
Y.v[0] = (int)1;
Y.v[1] = (int)0;
Y.v[2] = (int)0;
Y.v[3] = (int)1;
Y.v[1] = (int)1; /* Will cause Y to be fail */
/* Check Positive Test */
    TASSERT(SST_Math_Mat22iCheckOrthonormal(&X),"CheckOrthonormal failed when it should have passed");
/* Check Negative Test */
    TASSERT(!SST_Math_Mat22iCheckOrthonormal(&Y),"CheckOrthonormal succeeded when it should have failed");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

static const char* testSST_Math_Mat22iDeterminant(){
    SST_Mat22i X; /* 2 x 2 matrix */
/* Resetting test vectors / mats */
    X.v[0] = 10;
    X.v[1] = -7;
    X.v[2] = -6;
    X.v[3] = 3;
/* det(X) = 
-12.0
 */
    int result = SST_Math_Mat22iDeterminant(&X);
    TASSERT(abs( (result)/(-12) - 1 ) <= 100*0,"Determinant failed!");
    return ZTEST_SUCCESS;
}

/******************************************************************************/

