Tests update
This commit is contained in:
@@ -1,18 +1,44 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "pimathmatrix.h"
|
#include "pimathmatrix.h"
|
||||||
|
|
||||||
using namespace std;
|
bool cmpMatrixWithValue(PIMathMatrix<double> matrix, double val)
|
||||||
|
{
|
||||||
PIMathMatrix<double> origMatr;
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
int k = 0;
|
||||||
|
bool b;
|
||||||
|
while(i < 9)
|
||||||
|
{
|
||||||
|
if(k < 3)
|
||||||
|
{
|
||||||
|
if(matrix.element(j,k) == val)
|
||||||
|
{
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
if(k == 3)
|
||||||
|
{
|
||||||
|
j++;
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, identity)
|
TEST(PIMathMatrix_Test, identity)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
int i;
|
int i;
|
||||||
double d;
|
bool b;
|
||||||
bool a, b;
|
|
||||||
matrix = origMatr.identity(3, 3);
|
matrix = origMatr.identity(3, 3);
|
||||||
d = matrix.determinant();
|
|
||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if(matrix[i][i] == 1.0)
|
if(matrix[i][i] == 1.0)
|
||||||
@@ -25,19 +51,12 @@ TEST(PIMathMatrix_Test, identity)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(d == 1.0)
|
ASSERT_TRUE(b);
|
||||||
{
|
|
||||||
a = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a = false;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(a && b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixRow)
|
TEST(PIMathMatrix_Test, matrixRow)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i;
|
uint i;
|
||||||
@@ -62,6 +81,7 @@ TEST(PIMathMatrix_Test, matrixRow)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixCol)
|
TEST(PIMathMatrix_Test, matrixCol)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i;
|
uint i;
|
||||||
@@ -86,6 +106,7 @@ TEST(PIMathMatrix_Test, matrixCol)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, setCol)
|
TEST(PIMathMatrix_Test, setCol)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i;
|
uint i;
|
||||||
@@ -112,6 +133,7 @@ TEST(PIMathMatrix_Test, setCol)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, setRow)
|
TEST(PIMathMatrix_Test, setRow)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i;
|
uint i;
|
||||||
@@ -138,6 +160,7 @@ TEST(PIMathMatrix_Test, setRow)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, swapCols)
|
TEST(PIMathMatrix_Test, swapCols)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i1 = 0; uint i2 = 1;
|
uint i1 = 0; uint i2 = 1;
|
||||||
@@ -184,6 +207,7 @@ TEST(PIMathMatrix_Test, swapCols)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, swapRows)
|
TEST(PIMathMatrix_Test, swapRows)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
uint i1 = 0; uint i2 = 1;
|
uint i1 = 0; uint i2 = 1;
|
||||||
@@ -229,41 +253,18 @@ TEST(PIMathMatrix_Test, swapRows)
|
|||||||
}
|
}
|
||||||
TEST(PIMathMatrix_Test, fill)
|
TEST(PIMathMatrix_Test, fill)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
bool b;
|
bool b;
|
||||||
matrix = origMatr.identity(3, 3);
|
matrix = origMatr.identity(3, 3);
|
||||||
matrix.fill(5.0);
|
matrix.fill(5.0);
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix, 5.0);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix.element(j,k) == 5.0)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isSquare)
|
TEST(PIMathMatrix_Test, isSquare)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -282,6 +283,7 @@ TEST(PIMathMatrix_Test, isSquare)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, isIdentity)
|
TEST(PIMathMatrix_Test, isIdentity)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -301,6 +303,7 @@ TEST(PIMathMatrix_Test, isIdentity)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, isNull)
|
TEST(PIMathMatrix_Test, isNull)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -321,6 +324,7 @@ TEST(PIMathMatrix_Test, isNull)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, isValid)
|
TEST(PIMathMatrix_Test, isValid)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -338,43 +342,21 @@ TEST(PIMathMatrix_Test, isValid)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Assignment)
|
TEST(PIMathMatrix_Test, operator_Assignment)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
bool b;
|
bool b;
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1 = matrix2;
|
matrix1 = matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 6.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.element(j,k) == 6.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Equal)
|
TEST(PIMathMatrix_Test, operator_Equal)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
PIMathMatrix<double> matrix3;
|
PIMathMatrix<double> matrix3;
|
||||||
@@ -418,6 +400,7 @@ TEST(PIMathMatrix_Test, operator_Equal)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Not_Equal)
|
TEST(PIMathMatrix_Test, operator_Not_Equal)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
PIMathMatrix<double> matrix3;
|
PIMathMatrix<double> matrix3;
|
||||||
@@ -461,189 +444,75 @@ TEST(PIMathMatrix_Test, operator_Not_Equal)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Addition_Aassignment)
|
TEST(PIMathMatrix_Test, operator_Addition_Aassignment)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1.fill(1.0);
|
matrix1.fill(1.0);
|
||||||
matrix1 += matrix2;
|
matrix1 += matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 7.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.element(j,k) == 7.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Subtraction_Assignment)
|
TEST(PIMathMatrix_Test, operator_Subtraction_Assignment)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1.fill(1.0);
|
matrix1.fill(1.0);
|
||||||
matrix1 -= matrix2;
|
matrix1 -= matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, -5.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.element(j,k) == -5.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Multiplication_Assignment)
|
TEST(PIMathMatrix_Test, operator_Multiplication_Assignment)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix1 *= 2.0;
|
matrix1 *= 2.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 13.44);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.element(j,k) == 13.44)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Division_Assignment)
|
TEST(PIMathMatrix_Test, operator_Division_Assignment)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix1 /= 2.0;
|
matrix1 /= 2.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 3.36);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.element(j,k) == 3.36)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Addition)
|
TEST(PIMathMatrix_Test, operator_Addition)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2.fill(8.28);
|
matrix2.fill(8.28);
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1 + matrix2, 15.0);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if((matrix1+matrix2).element(j,k) == 15.0)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Subtraction)
|
TEST(PIMathMatrix_Test, operator_Subtraction)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -666,79 +535,34 @@ TEST(PIMathMatrix_Test, operator_Subtraction)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Multiplication)
|
TEST(PIMathMatrix_Test, operator_Multiplication)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2 = matrix1*4.0;
|
matrix2 = matrix1*4.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix2, 26.88);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix2.element(j,k) == 26.88)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrix_Test, operator_Division)
|
TEST(PIMathMatrix_Test, operator_Division)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
PIMathMatrix<double> matrix2;
|
PIMathMatrix<double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1 = origMatr.identity(3,3);
|
matrix1 = origMatr.identity(3,3);
|
||||||
matrix2 = origMatr.identity(3,3);
|
matrix2 = origMatr.identity(3,3);
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2 = matrix1/4.0;
|
matrix2 = matrix1/4.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix2, 1.68);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix2.element(j,k) == 1.68)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, determinant)
|
TEST(PIMathMatrix_Test, determinant)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double d;
|
double d;
|
||||||
double i = 59.0;
|
double i = 59.0;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
@@ -763,6 +587,7 @@ TEST(PIMathMatrix_Test, determinant)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, trace)
|
TEST(PIMathMatrix_Test, trace)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double t;
|
double t;
|
||||||
double i = 9.0;
|
double i = 9.0;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
@@ -787,6 +612,7 @@ TEST(PIMathMatrix_Test, trace)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, toUpperTriangular)
|
TEST(PIMathMatrix_Test, toUpperTriangular)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double d1, d2 = 1;
|
double d1, d2 = 1;
|
||||||
int i;
|
int i;
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
@@ -816,6 +642,7 @@ TEST(PIMathMatrix_Test, toUpperTriangular)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, invert)
|
TEST(PIMathMatrix_Test, invert)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
@@ -857,6 +684,7 @@ TEST(PIMathMatrix_Test, invert)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, inverted)
|
TEST(PIMathMatrix_Test, inverted)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
@@ -898,6 +726,7 @@ TEST(PIMathMatrix_Test, inverted)
|
|||||||
|
|
||||||
TEST(PIMathMatrix_Test, transposed)
|
TEST(PIMathMatrix_Test, transposed)
|
||||||
{
|
{
|
||||||
|
PIMathMatrix<double> origMatr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
@@ -932,5 +761,3 @@ TEST(PIMathMatrix_Test, transposed)
|
|||||||
}
|
}
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,42 @@
|
|||||||
|
|
||||||
const uint rows = 3;
|
const uint rows = 3;
|
||||||
const uint cols = 3;
|
const uint cols = 3;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
|
||||||
PIMathVectorT<rows, double> vect;
|
bool cmpMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, double val)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
int k = 0;
|
||||||
|
bool b;
|
||||||
|
while(i < 9)
|
||||||
|
{
|
||||||
|
if(k < 3)
|
||||||
|
{
|
||||||
|
if(matrix.at(j,k) == val)
|
||||||
|
{
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
if(k == 3)
|
||||||
|
{
|
||||||
|
j++;
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, identity)
|
TEST(PIMathMatrixT_Test, identity)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix;
|
PIMathMatrixT<rows, cols, double> matrix;
|
||||||
double d;
|
double d;
|
||||||
double i = 1.0;
|
double i = 1.0;
|
||||||
@@ -38,6 +69,7 @@ TEST(PIMathMatrixT_Test, at)
|
|||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
bool b;
|
bool b;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1 = matr.identity();
|
matrix1 = matr.identity();
|
||||||
@@ -60,6 +92,8 @@ TEST(PIMathMatrixT_Test, filled)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
|
PIMathVectorT<rows, double> vect;
|
||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
matrix2 = matr.fill(g);
|
matrix2 = matr.fill(g);
|
||||||
uint j = 0, i = 0;
|
uint j = 0, i = 0;
|
||||||
@@ -75,16 +109,20 @@ TEST(PIMathMatrixT_Test, filled)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, cols)
|
TEST(PIMathMatrixT_Test, cols)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
ASSERT_EQ(cols,matr.cols());
|
ASSERT_EQ(cols,matr.cols());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rows)
|
TEST(PIMathMatrixT_Test, rows)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
ASSERT_EQ(rows,matr.rows());
|
ASSERT_EQ(rows,matr.rows());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, col)
|
TEST(PIMathMatrixT_Test, col)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
|
PIMathVectorT<rows, double> vect;
|
||||||
uint i;
|
uint i;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -115,6 +153,8 @@ TEST(PIMathMatrixT_Test, col)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, row)
|
TEST(PIMathMatrixT_Test, row)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
|
PIMathVectorT<rows, double> vect;
|
||||||
uint i;
|
uint i;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -145,6 +185,8 @@ TEST(PIMathMatrixT_Test, row)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, setCol)
|
TEST(PIMathMatrixT_Test, setCol)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
|
PIMathVectorT<rows, double> vect;
|
||||||
vect.at(0) = 1.0;
|
vect.at(0) = 1.0;
|
||||||
vect.at(1) = 3.0;
|
vect.at(1) = 3.0;
|
||||||
vect.at(2) = 5.0;
|
vect.at(2) = 5.0;
|
||||||
@@ -169,6 +211,8 @@ TEST(PIMathMatrixT_Test, setCol)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, setRow)
|
TEST(PIMathMatrixT_Test, setRow)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
|
PIMathVectorT<rows, double> vect;
|
||||||
vect.at(0) = 1.0;
|
vect.at(0) = 1.0;
|
||||||
vect.at(1) = 3.0;
|
vect.at(1) = 3.0;
|
||||||
vect.at(2) = 5.0;
|
vect.at(2) = 5.0;
|
||||||
@@ -193,6 +237,7 @@ TEST(PIMathMatrixT_Test, setRow)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, swapCols)
|
TEST(PIMathMatrixT_Test, swapCols)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> before_Vect1;
|
PIMathVectorT<rows, double> before_Vect1;
|
||||||
PIMathVectorT<rows, double> before_Vect2;
|
PIMathVectorT<rows, double> before_Vect2;
|
||||||
PIMathVectorT<rows, double> after_Vect1;
|
PIMathVectorT<rows, double> after_Vect1;
|
||||||
@@ -226,6 +271,7 @@ TEST(PIMathMatrixT_Test, swapCols)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, swapRows)
|
TEST(PIMathMatrixT_Test, swapRows)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> before_Vect1;
|
PIMathVectorT<rows, double> before_Vect1;
|
||||||
PIMathVectorT<rows, double> before_Vect2;
|
PIMathVectorT<rows, double> before_Vect2;
|
||||||
PIMathVectorT<rows, double> after_Vect1;
|
PIMathVectorT<rows, double> after_Vect1;
|
||||||
@@ -259,6 +305,7 @@ TEST(PIMathMatrixT_Test, swapRows)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, fill)
|
TEST(PIMathMatrixT_Test, fill)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
matr.fill(g);
|
matr.fill(g);
|
||||||
@@ -275,6 +322,7 @@ TEST(PIMathMatrixT_Test, fill)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isSquare)
|
TEST(PIMathMatrixT_Test, isSquare)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
const uint new_Cols = 4;
|
const uint new_Cols = 4;
|
||||||
PIMathMatrixT<rows, new_Cols, double> matrix2;
|
PIMathMatrixT<rows, new_Cols, double> matrix2;
|
||||||
@@ -292,6 +340,7 @@ TEST(PIMathMatrixT_Test, isSquare)
|
|||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isIdentity)
|
TEST(PIMathMatrixT_Test, isIdentity)
|
||||||
{
|
{
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -312,6 +361,7 @@ TEST(PIMathMatrixT_Test, isNull)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
bool b;
|
bool b;
|
||||||
matrix2 = matr.filled(3.67);
|
matrix2 = matr.filled(3.67);
|
||||||
if((matrix1.isNull() == true) && (matrix2.isNull() == false))
|
if((matrix1.isNull() == true) && (matrix2.isNull() == false))
|
||||||
@@ -329,34 +379,11 @@ TEST(PIMathMatrixT_Test, operator_Assignment)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
int i = 0;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
bool b;
|
bool b;
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1 = matrix2;
|
matrix1 = matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 6.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.at(j,k) == 6.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +391,7 @@ TEST(PIMathMatrixT_Test, operator_Equal)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
bool b;
|
bool b;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
matr.at(0,1) = 6;
|
matr.at(0,1) = 6;
|
||||||
@@ -393,6 +421,7 @@ TEST(PIMathMatrixT_Test, operator_Not_Equal)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
matr.at(0,1) = 6;
|
matr.at(0,1) = 6;
|
||||||
matr.at(0,2) = 8;
|
matr.at(0,2) = 8;
|
||||||
@@ -421,34 +450,10 @@ TEST(PIMathMatrixT_Test, operator_Addition_Aassignment)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1.fill(1.0);
|
matrix1.fill(1.0);
|
||||||
matrix1 += matrix2;
|
matrix1 += matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 7.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.at(j,k) == 7.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,34 +462,10 @@ TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix2.fill(6.72);
|
matrix2.fill(6.72);
|
||||||
matrix1.fill(1.0);
|
matrix1.fill(1.0);
|
||||||
matrix1 -= matrix2;
|
matrix1 -= matrix2;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, -5.72);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.at(j,k) == -5.72)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,33 +473,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix1 *= 2.0;
|
matrix1 *= 2.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 13.44);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.at(j,k) == 13.44)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,33 +483,9 @@ TEST(PIMathMatrixT_Test, operator_Division_Assignment)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix1 /= 2.0;
|
matrix1 /= 2.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1, 3.36);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix1.at(j,k) == 3.36)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,33 +494,9 @@ TEST(PIMathMatrixT_Test, operator_Addition)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2.fill(8.28);
|
matrix2.fill(8.28);
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix1 + matrix2, 15.0);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if((matrix1 + matrix2).at(j,k) == 15.0)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,33 +505,9 @@ TEST(PIMathMatrixT_Test, operator_Subtraction)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
matrix1.fill(6.0);
|
||||||
int j = 0;
|
matrix2.fill(5.0);
|
||||||
int k = 0;
|
b = cmpMatrixWithValue(matrix1 - matrix2, 1.0);
|
||||||
matrix1.fill(6.72);
|
|
||||||
matrix2.fill(8.28);
|
|
||||||
while(i < 9)
|
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(round((matrix1 - matrix2).at(j,k) * 10000) / 10000 == -1.56)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,33 +516,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2 = matrix1*4.0;
|
matrix2 = matrix1*4.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix2, 26.88);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix2.at(j,k) == 26.88)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrixT_Test, operator_Division)
|
TEST(PIMathMatrixT_Test, operator_Division)
|
||||||
@@ -665,33 +526,9 @@ TEST(PIMathMatrixT_Test, operator_Division)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
bool b;
|
bool b;
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int k = 0;
|
|
||||||
matrix1.fill(6.72);
|
matrix1.fill(6.72);
|
||||||
matrix2 = matrix1/4.0;
|
matrix2 = matrix1/4.0;
|
||||||
while(i < 9)
|
b = cmpMatrixWithValue(matrix2, 1.68);
|
||||||
{
|
|
||||||
if(k < 3)
|
|
||||||
{
|
|
||||||
if(matrix2.at(j,k) == 1.68)
|
|
||||||
{
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
if(k == 3)
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
ASSERT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,6 +537,7 @@ TEST(PIMathMatrixT_Test, determinant)
|
|||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
double i = 59.0;
|
double i = 59.0;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
matr.at(0,1) = 6;
|
matr.at(0,1) = 6;
|
||||||
matr.at(0,2) = 8;
|
matr.at(0,2) = 8;
|
||||||
@@ -718,6 +556,7 @@ TEST(PIMathMatrixT_Test, invert)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
PIMathMatrixT<rows, cols, double> matrix3;
|
PIMathMatrixT<rows, cols, double> matrix3;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
matrix1 = matr.identity();
|
matrix1 = matr.identity();
|
||||||
@@ -752,6 +591,7 @@ TEST(PIMathMatrixT_Test, inverted)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
PIMathMatrixT<rows, cols, double> matrix3;
|
PIMathMatrixT<rows, cols, double> matrix3;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
matrix1 = matr.identity();
|
matrix1 = matr.identity();
|
||||||
@@ -784,6 +624,7 @@ TEST(PIMathMatrixT_Test, toUpperTriangular)
|
|||||||
PIMathMatrixT<rows, cols, double> matrix;
|
PIMathMatrixT<rows, cols, double> matrix;
|
||||||
double d1, d2 = 1;
|
double d1, d2 = 1;
|
||||||
uint i;
|
uint i;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
matr.at(0,1) = 6;
|
matr.at(0,1) = 6;
|
||||||
matr.at(0,2) = 8;
|
matr.at(0,2) = 8;
|
||||||
@@ -806,6 +647,7 @@ TEST(PIMathMatrixT_Test, transposed)
|
|||||||
{
|
{
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
bool b;
|
bool b;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
|
|||||||
Reference in New Issue
Block a user