indentation in strings
This commit is contained in:
@@ -2,8 +2,7 @@
|
|||||||
#include "pimathmatrix.h"
|
#include "pimathmatrix.h"
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
bool cmpSquareMatrixWithValue(PIMathMatrix<double> matrix, Type val, int num)
|
bool cmpSquareMatrixWithValue(PIMathMatrix<double> matrix, Type val, int num) {
|
||||||
{
|
|
||||||
bool b = true;
|
bool b = true;
|
||||||
for(int i = 0; i < num; i++) {
|
for(int i = 0; i < num; i++) {
|
||||||
for(int j = 0; j < num; j++) {
|
for(int j = 0; j < num; j++) {
|
||||||
@@ -15,8 +14,7 @@ bool cmpSquareMatrixWithValue(PIMathMatrix<double> matrix, Type val, int num)
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, identity)
|
TEST(PIMathMatrix_Test, identity) {
|
||||||
{
|
|
||||||
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
if(matrix[i][i] != 1.0){
|
if(matrix[i][i] != 1.0){
|
||||||
@@ -35,8 +33,7 @@ TEST(PIMathMatrix_Test, identity)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, element)
|
TEST(PIMathMatrixT_Test, element) {
|
||||||
{
|
|
||||||
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
||||||
for(uint i = 0; i < 3; i++) {
|
for(uint i = 0; i < 3; i++) {
|
||||||
if(matrix.element(i,i) != 1.0) {
|
if(matrix.element(i,i) != 1.0) {
|
||||||
@@ -55,8 +52,7 @@ TEST(PIMathMatrixT_Test, element)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixRow)
|
TEST(PIMathMatrix_Test, matrixRow) {
|
||||||
{
|
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
auto matrix = PIMathMatrix<double>::matrixRow(vector);
|
auto matrix = PIMathMatrix<double>::matrixRow(vector);
|
||||||
@@ -68,8 +64,7 @@ TEST(PIMathMatrix_Test, matrixRow)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixCol)
|
TEST(PIMathMatrix_Test, matrixCol) {
|
||||||
{
|
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
auto matrix = PIMathMatrix<double>::matrixCol(vector);
|
auto matrix = PIMathMatrix<double>::matrixCol(vector);
|
||||||
@@ -81,8 +76,7 @@ TEST(PIMathMatrix_Test, matrixCol)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, setCol)
|
TEST(PIMathMatrix_Test, setCol) {
|
||||||
{
|
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
auto matrix = PIMathMatrix<double>::matrixCol(vector);
|
auto matrix = PIMathMatrix<double>::matrixCol(vector);
|
||||||
@@ -96,8 +90,7 @@ TEST(PIMathMatrix_Test, setCol)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, setRow)
|
TEST(PIMathMatrix_Test, setRow) {
|
||||||
{
|
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
auto matrix = PIMathMatrix<double>::matrixRow(vector);
|
auto matrix = PIMathMatrix<double>::matrixRow(vector);
|
||||||
@@ -111,15 +104,13 @@ TEST(PIMathMatrix_Test, setRow)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, swapCols)
|
TEST(PIMathMatrix_Test, swapCols) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> origMatr;
|
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;
|
||||||
double a1[3], a2[3], a3[3];
|
double a1[3], a2[3], a3[3];
|
||||||
double b1[3], b2[3], b3[3];
|
double b1[3], b2[3], b3[3];
|
||||||
bool b;
|
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
vector.at(0) = 3.0;
|
vector.at(0) = 3.0;
|
||||||
vector.at(1) = 6.0;
|
vector.at(1) = 6.0;
|
||||||
@@ -145,24 +136,16 @@ TEST(PIMathMatrix_Test, swapCols)
|
|||||||
b2[i] = matrix1.element(i, 1);
|
b2[i] = matrix1.element(i, 1);
|
||||||
b3[i] = matrix1.element(i, 2);
|
b3[i] = matrix1.element(i, 2);
|
||||||
}
|
}
|
||||||
if((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0)) {
|
ASSERT_TRUE((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0));
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
b = false;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, swapRows)
|
TEST(PIMathMatrix_Test, swapRows) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> origMatr;
|
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;
|
||||||
double a1[3], a2[3], a3[3];
|
double a1[3], a2[3], a3[3];
|
||||||
double b1[3], b2[3], b3[3];
|
double b1[3], b2[3], b3[3];
|
||||||
bool b;
|
|
||||||
vector.resize(3, 3.0);
|
vector.resize(3, 3.0);
|
||||||
vector.at(0) = 3.0;
|
vector.at(0) = 3.0;
|
||||||
vector.at(1) = 6.0;
|
vector.at(1) = 6.0;
|
||||||
@@ -188,80 +171,63 @@ TEST(PIMathMatrix_Test, swapRows)
|
|||||||
b2[i] = matrix1.element(1, i);
|
b2[i] = matrix1.element(1, i);
|
||||||
b3[i] = matrix1.element(2, i);
|
b3[i] = matrix1.element(2, i);
|
||||||
}
|
}
|
||||||
if((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0)) {
|
ASSERT_TRUE((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0));
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
b = false;
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(b);
|
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrix_Test, fill)
|
TEST(PIMathMatrix_Test, fill) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 5.0);
|
PIMathMatrix<double> matrix(3, 3, 5.0);
|
||||||
matrix.fill(7.0);
|
matrix.fill(7.0);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix, 7.0, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix, 7.0, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isSquareTrue)
|
TEST(PIMathMatrix_Test, isSquareTrue) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 1.0);
|
PIMathMatrix<double> matrix(3, 3, 1.0);
|
||||||
ASSERT_TRUE(matrix.isSquare());
|
ASSERT_TRUE(matrix.isSquare());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isSquareFalse)
|
TEST(PIMathMatrix_Test, isSquareFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(2, 4, 1.0);
|
PIMathMatrix<double> matrix(2, 4, 1.0);
|
||||||
ASSERT_FALSE(matrix.isSquare());
|
ASSERT_FALSE(matrix.isSquare());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isIdentityTrue)
|
TEST(PIMathMatrix_Test, isIdentityTrue) {
|
||||||
{
|
|
||||||
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
auto matrix = PIMathMatrix<double>::identity(3, 3);
|
||||||
ASSERT_TRUE(matrix.isIdentity());
|
ASSERT_TRUE(matrix.isIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isIdentityFalse)
|
TEST(PIMathMatrix_Test, isIdentityFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 5.0);
|
PIMathMatrix<double> matrix(3, 3, 5.0);
|
||||||
ASSERT_FALSE(matrix.isIdentity());
|
ASSERT_FALSE(matrix.isIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isNullTrue)
|
TEST(PIMathMatrix_Test, isNullTrue) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 0.0);
|
PIMathMatrix<double> matrix(3, 3, 0.0);
|
||||||
ASSERT_TRUE(matrix.isNull());
|
ASSERT_TRUE(matrix.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isNullFalse)
|
TEST(PIMathMatrix_Test, isNullFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 5.0);
|
PIMathMatrix<double> matrix(3, 3, 5.0);
|
||||||
ASSERT_FALSE(matrix.isNull());
|
ASSERT_FALSE(matrix.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isValidTrue)
|
TEST(PIMathMatrix_Test, isValidTrue) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 1.62);
|
PIMathMatrix<double> matrix(3, 3, 1.62);
|
||||||
ASSERT_TRUE(matrix.isValid());
|
ASSERT_TRUE(matrix.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, isValidFalse)
|
TEST(PIMathMatrix_Test, isValidFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix;
|
PIMathMatrix<double> matrix;
|
||||||
ASSERT_FALSE(matrix.isValid());
|
ASSERT_FALSE(matrix.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Assignment)
|
TEST(PIMathMatrix_Test, operator_Assignment) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 5.72);
|
PIMathMatrix<double> matrix1(3, 3, 5.72);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 7.12);
|
PIMathMatrix<double> matrix2(3, 3, 7.12);
|
||||||
matrix1 = matrix2;
|
matrix1 = matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.12, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.12, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_EqualTrue)
|
TEST(PIMathMatrix_Test, operator_EqualTrue) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
||||||
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
||||||
matrix1.element(0, 0) = 5.1;
|
matrix1.element(0, 0) = 5.1;
|
||||||
@@ -275,8 +241,7 @@ TEST(PIMathMatrix_Test, operator_EqualTrue)
|
|||||||
ASSERT_TRUE(matrix1 == matrix2);
|
ASSERT_TRUE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_EqualFalse)
|
TEST(PIMathMatrix_Test, operator_EqualFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
||||||
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
||||||
matrix1.element(0, 0) = 5.1;
|
matrix1.element(0, 0) = 5.1;
|
||||||
@@ -290,8 +255,7 @@ TEST(PIMathMatrix_Test, operator_EqualFalse)
|
|||||||
ASSERT_FALSE(matrix1 == matrix2);
|
ASSERT_FALSE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Not_EqualTrue)
|
TEST(PIMathMatrix_Test, operator_Not_EqualTrue) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
||||||
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
||||||
matrix1.element(0, 0) = 5.1;
|
matrix1.element(0, 0) = 5.1;
|
||||||
@@ -305,8 +269,7 @@ TEST(PIMathMatrix_Test, operator_Not_EqualTrue)
|
|||||||
ASSERT_TRUE(matrix1 != matrix2);
|
ASSERT_TRUE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Not_EqualFalse)
|
TEST(PIMathMatrix_Test, operator_Not_EqualFalse) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
PIMathMatrix<double> matrix1(2, 2, 2.0);
|
||||||
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
PIMathMatrix<double> matrix2(2, 2, 2.0);
|
||||||
matrix1.element(0, 0) = 5.1;
|
matrix1.element(0, 0) = 5.1;
|
||||||
@@ -320,67 +283,58 @@ TEST(PIMathMatrix_Test, operator_Not_EqualFalse)
|
|||||||
ASSERT_FALSE(matrix1 != matrix2);
|
ASSERT_FALSE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Addition_Aassignment)
|
TEST(PIMathMatrix_Test, operator_Addition_Aassignment) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 1.0);
|
PIMathMatrix<double> matrix2(3, 3, 1.0);
|
||||||
matrix1 += matrix2;
|
matrix1 += matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Subtraction_Assignment)
|
TEST(PIMathMatrix_Test, operator_Subtraction_Assignment) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 1.0);
|
PIMathMatrix<double> matrix1(3, 3, 1.0);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 6.72);
|
PIMathMatrix<double> matrix2(3, 3, 6.72);
|
||||||
matrix1 -= matrix2;
|
matrix1 -= matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, -5.72, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, -5.72, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Multiplication_Assignment)
|
TEST(PIMathMatrix_Test, operator_Multiplication_Assignment) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
matrix1 *= 2.0;
|
matrix1 *= 2.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 13.44, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 13.44, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Division_Assignment)
|
TEST(PIMathMatrix_Test, operator_Division_Assignment) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
matrix1 /= 2.0;
|
matrix1 /= 2.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 3.36, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 3.36, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Addition)
|
TEST(PIMathMatrix_Test, operator_Addition) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 8.28);
|
PIMathMatrix<double> matrix2(3, 3, 8.28);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 + matrix2, 15.0, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 + matrix2, 15.0, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Subtraction)
|
TEST(PIMathMatrix_Test, operator_Subtraction) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.0);
|
PIMathMatrix<double> matrix1(3, 3, 6.0);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 - matrix2, 1.0, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 - matrix2, 1.0, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, operator_Multiplication)
|
TEST(PIMathMatrix_Test, operator_Multiplication) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
||||||
matrix2 = matrix1*4.0;
|
matrix2 = matrix1*4.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix2, 26.88, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix2, 26.88, 3));
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrix_Test, operator_Division)
|
TEST(PIMathMatrix_Test, operator_Division) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
PIMathMatrix<double> matrix1(3, 3, 6.72);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
PIMathMatrix<double> matrix2(3, 3, 5.0);
|
||||||
matrix2 = matrix1/4.0;
|
matrix2 = matrix1/4.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix2, 1.68, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix2, 1.68, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, determinantIfSquare)
|
TEST(PIMathMatrix_Test, determinantIfSquare) {
|
||||||
{
|
|
||||||
double d;
|
double d;
|
||||||
double i = 59.0;
|
double i = 59.0;
|
||||||
PIMathMatrix<double> matrix(3, 3, 0.0);
|
PIMathMatrix<double> matrix(3, 3, 0.0);
|
||||||
@@ -402,15 +356,13 @@ TEST(PIMathMatrix_Test, determinantIfSquare)
|
|||||||
ASSERT_DOUBLE_EQ(d, i);
|
ASSERT_DOUBLE_EQ(d, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, determinantIfNotSquare)
|
TEST(PIMathMatrix_Test, determinantIfNotSquare) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 5, 1.0);
|
PIMathMatrix<double> matrix(3, 5, 1.0);
|
||||||
matrix.element(1,1) = 5.0;
|
matrix.element(1,1) = 5.0;
|
||||||
ASSERT_FALSE(matrix.determinant());
|
ASSERT_FALSE(matrix.determinant());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, trace)
|
TEST(PIMathMatrix_Test, trace) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 0.0);
|
PIMathMatrix<double> matrix(3, 3, 0.0);
|
||||||
double t;
|
double t;
|
||||||
double i = 9.0;
|
double i = 9.0;
|
||||||
@@ -432,15 +384,13 @@ TEST(PIMathMatrix_Test, trace)
|
|||||||
ASSERT_DOUBLE_EQ(t, i);
|
ASSERT_DOUBLE_EQ(t, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, traceIfNotSquare)
|
TEST(PIMathMatrix_Test, traceIfNotSquare) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 5, 1.0);
|
PIMathMatrix<double> matrix(3, 5, 1.0);
|
||||||
matrix.element(1,1) = 5.0;
|
matrix.element(1,1) = 5.0;
|
||||||
ASSERT_FALSE(matrix.trace());
|
ASSERT_FALSE(matrix.trace());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, toUpperTriangular)
|
TEST(PIMathMatrix_Test, toUpperTriangular) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix(3, 3, 0.0);
|
PIMathMatrix<double> matrix(3, 3, 0.0);
|
||||||
double d1, d2 = 1;
|
double d1, d2 = 1;
|
||||||
int i;
|
int i;
|
||||||
@@ -467,8 +417,7 @@ TEST(PIMathMatrix_Test, toUpperTriangular)
|
|||||||
ASSERT_DOUBLE_EQ(d1, d2);
|
ASSERT_DOUBLE_EQ(d1, d2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, invert)
|
TEST(PIMathMatrix_Test, invert) {
|
||||||
{
|
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
PIMathMatrix<double> matrix1(3, 3, 0.0);
|
PIMathMatrix<double> matrix1(3, 3, 0.0);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 0.0);
|
PIMathMatrix<double> matrix2(3, 3, 0.0);
|
||||||
@@ -496,8 +445,7 @@ TEST(PIMathMatrix_Test, invert)
|
|||||||
ASSERT_TRUE((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
ASSERT_TRUE((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, inverted)
|
TEST(PIMathMatrix_Test, inverted) {
|
||||||
{
|
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
PIMathMatrix<double> matrix1(3, 3, 0.0);
|
PIMathMatrix<double> matrix1(3, 3, 0.0);
|
||||||
PIMathMatrix<double> matrix2(3, 3, 0.0);
|
PIMathMatrix<double> matrix2(3, 3, 0.0);
|
||||||
@@ -525,8 +473,7 @@ TEST(PIMathMatrix_Test, inverted)
|
|||||||
ASSERT_TRUE((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
ASSERT_TRUE((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, transposed)
|
TEST(PIMathMatrix_Test, transposed) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> origMatr;
|
PIMathMatrix<double> origMatr;
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
PIMathMatrix<double> matrix1;
|
PIMathMatrix<double> matrix1;
|
||||||
@@ -554,15 +501,13 @@ TEST(PIMathMatrix_Test, transposed)
|
|||||||
ASSERT_TRUE((d1 == d2) && (matrix1 == matrix3));
|
ASSERT_TRUE((d1 == d2) && (matrix1 == matrix3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixMultiplication)
|
TEST(PIMathMatrix_Test, matrixMultiplication) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
||||||
PIMathMatrix<double> matrix2(2, 2, 2.5);
|
PIMathMatrix<double> matrix2(2, 2, 2.5);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 7.5, 2));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 7.5, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, matrixAndVectorMultiplication)
|
TEST(PIMathMatrix_Test, matrixAndVectorMultiplication) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(2, 2.5);
|
vector.resize(2, 2.5);
|
||||||
@@ -574,8 +519,7 @@ TEST(PIMathMatrix_Test, matrixAndVectorMultiplication)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, vectorAndMatrixMultiplication)
|
TEST(PIMathMatrix_Test, vectorAndMatrixMultiplication) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
PIMathMatrix<double> matrix1(2, 2, 1.5);
|
||||||
PIMathVector<double> vector;
|
PIMathVector<double> vector;
|
||||||
vector.resize(2, 2.5);
|
vector.resize(2, 2.5);
|
||||||
@@ -587,14 +531,12 @@ TEST(PIMathMatrix_Test, vectorAndMatrixMultiplication)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, valAndMatrixMultiplication)
|
TEST(PIMathMatrix_Test, valAndMatrixMultiplication) {
|
||||||
{
|
|
||||||
PIMathMatrix<double> matrix1(3, 3, 1.5);
|
PIMathMatrix<double> matrix1(3, 3, 1.5);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrix_Test, hermitian)
|
TEST(PIMathMatrix_Test, hermitian) {
|
||||||
{
|
|
||||||
complex<double> val;
|
complex<double> val;
|
||||||
complex<double> res;
|
complex<double> res;
|
||||||
val.imag(1.0);
|
val.imag(1.0);
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ const uint rows = 3;
|
|||||||
const uint cols = 3;
|
const uint cols = 3;
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val, int num)
|
bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val, int num) {
|
||||||
{
|
|
||||||
bool b = true;
|
bool b = true;
|
||||||
for(int i = 0; i < num; i++) {
|
for(int i = 0; i < num; i++) {
|
||||||
for(int j = 0; j < num; j++) {
|
for(int j = 0; j < num; j++) {
|
||||||
@@ -18,8 +17,7 @@ bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, identity)
|
TEST(PIMathMatrixT_Test, identity) {
|
||||||
{
|
|
||||||
auto matrix = PIMathMatrixT<rows, cols, double>::identity();
|
auto matrix = PIMathMatrixT<rows, cols, double>::identity();
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
if(matrix[i][i] != 1.0){
|
if(matrix[i][i] != 1.0){
|
||||||
@@ -38,8 +36,7 @@ TEST(PIMathMatrixT_Test, identity)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, at)
|
TEST(PIMathMatrixT_Test, at) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
||||||
for(uint i = 0; i < rows; i++) {
|
for(uint i = 0; i < rows; i++) {
|
||||||
if(matrix1.at(i,i) != 1.0) {
|
if(matrix1.at(i,i) != 1.0) {
|
||||||
@@ -48,26 +45,22 @@ TEST(PIMathMatrixT_Test, at)
|
|||||||
}
|
}
|
||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrixT_Test, filled)
|
TEST(PIMathMatrixT_Test, filled) {
|
||||||
{
|
|
||||||
auto matr = PIMathMatrixT<rows, cols, double>::filled(1.0);
|
auto matr = PIMathMatrixT<rows, cols, double>::filled(1.0);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matr, 1.0, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matr, 1.0, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, cols)
|
TEST(PIMathMatrixT_Test, cols) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
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;
|
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;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
@@ -89,8 +82,8 @@ TEST(PIMathMatrixT_Test, col)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, row)
|
TEST(PIMathMatrixT_Test, row) {
|
||||||
{ PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
uint g = 2;
|
uint g = 2;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
@@ -111,8 +104,7 @@ TEST(PIMathMatrixT_Test, row)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, setCol)
|
TEST(PIMathMatrixT_Test, setCol) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
vect.at(0) = 1.0;
|
vect.at(0) = 1.0;
|
||||||
@@ -128,8 +120,7 @@ TEST(PIMathMatrixT_Test, setCol)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, setRow)
|
TEST(PIMathMatrixT_Test, setRow) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathVectorT<rows, double> vect;
|
PIMathVectorT<rows, double> vect;
|
||||||
vect.at(0) = 1.0;
|
vect.at(0) = 1.0;
|
||||||
@@ -145,8 +136,7 @@ TEST(PIMathMatrixT_Test, setRow)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, swapCols)
|
TEST(PIMathMatrixT_Test, swapCols) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
int g1 = 1, g2 = 2;
|
int g1 = 1, g2 = 2;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
@@ -171,8 +161,7 @@ TEST(PIMathMatrixT_Test, swapCols)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, swapRows)
|
TEST(PIMathMatrixT_Test, swapRows) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
int g1 = 1, g2 = 2;
|
int g1 = 1, g2 = 2;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
@@ -197,8 +186,7 @@ TEST(PIMathMatrixT_Test, swapRows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, fill)
|
TEST(PIMathMatrixT_Test, fill) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
@@ -211,53 +199,45 @@ TEST(PIMathMatrixT_Test, fill)
|
|||||||
ASSERT_TRUE(matr == matrix1);
|
ASSERT_TRUE(matr == matrix1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isSquareTrue)
|
TEST(PIMathMatrixT_Test, isSquareTrue) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
ASSERT_TRUE(matrix1.isSquare());
|
ASSERT_TRUE(matrix1.isSquare());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isSquareFalse)
|
TEST(PIMathMatrixT_Test, isSquareFalse) {
|
||||||
{
|
|
||||||
const uint new_Cols = 4;
|
const uint new_Cols = 4;
|
||||||
PIMathMatrixT<rows, new_Cols, double> matrix2;
|
PIMathMatrixT<rows, new_Cols, double> matrix2;
|
||||||
ASSERT_FALSE(matrix2.isSquare());
|
ASSERT_FALSE(matrix2.isSquare());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isIdentityTrue)
|
TEST(PIMathMatrixT_Test, isIdentityTrue) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
||||||
ASSERT_TRUE(matrix1.isIdentity());
|
ASSERT_TRUE(matrix1.isIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isIdentityFalse)
|
TEST(PIMathMatrixT_Test, isIdentityFalse) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(2.5);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(2.5);
|
||||||
ASSERT_FALSE(matrix1.isIdentity());
|
ASSERT_FALSE(matrix1.isIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isNullTrue)
|
TEST(PIMathMatrixT_Test, isNullTrue) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
ASSERT_TRUE(matrix1.isNull());
|
ASSERT_TRUE(matrix1.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, isNullFalse)
|
TEST(PIMathMatrixT_Test, isNullFalse) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
|
||||||
ASSERT_FALSE(matrix1.isNull());
|
ASSERT_FALSE(matrix1.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Assignment)
|
TEST(PIMathMatrixT_Test, operator_Assignment) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
matrix1 = matrix2;
|
matrix1 = matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 6.72, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 6.72, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_EqualTrue)
|
TEST(PIMathMatrixT_Test, operator_EqualTrue) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1.at(0, 0) = 5.1;
|
||||||
@@ -271,8 +251,7 @@ TEST(PIMathMatrixT_Test, operator_EqualTrue)
|
|||||||
ASSERT_TRUE(matrix1 == matrix2);
|
ASSERT_TRUE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_EqualFalse)
|
TEST(PIMathMatrixT_Test, operator_EqualFalse) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1.at(0, 0) = 5.1;
|
||||||
@@ -286,8 +265,7 @@ TEST(PIMathMatrixT_Test, operator_EqualFalse)
|
|||||||
ASSERT_FALSE(matrix1 == matrix2);
|
ASSERT_FALSE(matrix1 == matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue)
|
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1.at(0, 0) = 5.1;
|
||||||
@@ -301,8 +279,7 @@ TEST(PIMathMatrixT_Test, operator_Not_EqualTrue)
|
|||||||
ASSERT_TRUE(matrix1 != matrix2);
|
ASSERT_TRUE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse)
|
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix1;
|
PIMathMatrixT<rows, cols, double> matrix1;
|
||||||
PIMathMatrixT<rows, cols, double> matrix2;
|
PIMathMatrixT<rows, cols, double> matrix2;
|
||||||
matrix1.at(0, 0) = 5.1;
|
matrix1.at(0, 0) = 5.1;
|
||||||
@@ -316,63 +293,54 @@ TEST(PIMathMatrixT_Test, operator_Not_EqualFalse)
|
|||||||
ASSERT_FALSE(matrix1 != matrix2);
|
ASSERT_FALSE(matrix1 != matrix2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Addition_Aassignment)
|
TEST(PIMathMatrixT_Test, operator_Addition_ ssignment) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72) ;
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72) ;
|
||||||
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(1.0) ;
|
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(1.0) ;
|
||||||
matrix1 += matrix2;
|
matrix1 += matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment)
|
TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.0);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.0);
|
||||||
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
matrix1 -= matrix2;
|
matrix1 -= matrix2;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, -5.72, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, -5.72, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment)
|
TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
matrix1 *= 2.0;
|
matrix1 *= 2.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 13.44, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 13.44, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Division_Assignment)
|
TEST(PIMathMatrixT_Test, operator_Division_Assignment) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
matrix1 /= 2.0;
|
matrix1 /= 2.0;
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 3.36, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 3.36, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Addition)
|
TEST(PIMathMatrixT_Test, operator_Addition) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(8.28);
|
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(8.28);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 + matrix2, 15.0, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 + matrix2, 15.0, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Subtraction)
|
TEST(PIMathMatrixT_Test, operator_Subtraction) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.0);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.0);
|
||||||
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(5.0);
|
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(5.0);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 - matrix2, 1.0, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 - matrix2, 1.0, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, operator_Multiplication)
|
TEST(PIMathMatrixT_Test, operator_Multiplication) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * 4.0, 26.88, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * 4.0, 26.88, rows));
|
||||||
}
|
}
|
||||||
TEST(PIMathMatrixT_Test, operator_Division)
|
TEST(PIMathMatrixT_Test, operator_Division) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 / 4.0, 1.68, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 / 4.0, 1.68, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, determinantIfSquare)
|
TEST(PIMathMatrixT_Test, determinantIfSquare) {
|
||||||
{
|
|
||||||
double d;
|
double d;
|
||||||
double i = 59.0;
|
double i = 59.0;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
@@ -389,8 +357,7 @@ TEST(PIMathMatrixT_Test, determinantIfSquare)
|
|||||||
ASSERT_DOUBLE_EQ(i, d);
|
ASSERT_DOUBLE_EQ(i, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, determinantIfNotSquare)
|
TEST(PIMathMatrixT_Test, determinantIfNotSquare) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, 5u, double> matr;
|
PIMathMatrixT<rows, 5u, double> matr;
|
||||||
matr.at(0,0) = 3;
|
matr.at(0,0) = 3;
|
||||||
matr.at(0,1) = 6;
|
matr.at(0,1) = 6;
|
||||||
@@ -404,8 +371,7 @@ TEST(PIMathMatrixT_Test, determinantIfNotSquare)
|
|||||||
ASSERT_FALSE(matr.determinant());
|
ASSERT_FALSE(matr.determinant());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, invert)
|
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;
|
||||||
@@ -429,8 +395,7 @@ TEST(PIMathMatrixT_Test, invert)
|
|||||||
ASSERT_TRUE((matrix1 == matrix3) && (d1 == 1/d2));
|
ASSERT_TRUE((matrix1 == matrix3) && (d1 == 1/d2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, inverted)
|
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;
|
||||||
@@ -453,8 +418,7 @@ TEST(PIMathMatrixT_Test, inverted)
|
|||||||
ASSERT_TRUE((matrix1 == matrix3) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
ASSERT_TRUE((matrix1 == matrix3) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, toUpperTriangular)
|
TEST(PIMathMatrixT_Test, toUpperTriangular) {
|
||||||
{
|
|
||||||
PIMathMatrixT<rows, cols, double> matrix;
|
PIMathMatrixT<rows, cols, double> matrix;
|
||||||
double d1, d2 = 1;
|
double d1, d2 = 1;
|
||||||
PIMathMatrixT<rows, cols, double> matr;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
@@ -476,8 +440,7 @@ TEST(PIMathMatrixT_Test, toUpperTriangular)
|
|||||||
ASSERT_DOUBLE_EQ(d1, d2);
|
ASSERT_DOUBLE_EQ(d1, d2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, transposed)
|
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;
|
PIMathMatrixT<rows, cols, double> matr;
|
||||||
@@ -498,22 +461,19 @@ TEST(PIMathMatrixT_Test, transposed)
|
|||||||
ASSERT_TRUE((d1 == d2) && (matr == matrix2));
|
ASSERT_TRUE((d1 == d2) && (matr == matrix2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, scaleX_two)
|
TEST(PIMathMatrixT_Test, scaleX_two) {
|
||||||
{
|
|
||||||
double factor = 5.64;
|
double factor = 5.64;
|
||||||
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleX(factor);
|
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleX(factor);
|
||||||
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (factor == matrix.at(0u,0u)));
|
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (factor == matrix.at(0u,0u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, scaleY_two)
|
TEST(PIMathMatrixT_Test, scaleY_two) {
|
||||||
{
|
|
||||||
double factor = 5.64;
|
double factor = 5.64;
|
||||||
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleY(factor);
|
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleY(factor);
|
||||||
ASSERT_TRUE((factor == matrix.at(1u,1u)) && (1.0 == matrix.at(0u,0u)));
|
ASSERT_TRUE((factor == matrix.at(1u,1u)) && (1.0 == matrix.at(0u,0u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rotation_2x2)
|
TEST(PIMathMatrixT_Test, rotation_2x2) {
|
||||||
{
|
|
||||||
double angle = 1.0;
|
double angle = 1.0;
|
||||||
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle);
|
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle);
|
||||||
double c = cos(angle);
|
double c = cos(angle);
|
||||||
@@ -521,15 +481,13 @@ TEST(PIMathMatrixT_Test, rotation_2x2)
|
|||||||
ASSERT_TRUE((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u)));
|
ASSERT_TRUE((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rotation_3x3)
|
TEST(PIMathMatrixT_Test, rotation_3x3) {
|
||||||
{
|
|
||||||
double angle = 1.0;
|
double angle = 1.0;
|
||||||
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotation(angle);
|
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotation(angle);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix, 0.0, rows));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix, 0.0, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rotationX)
|
TEST(PIMathMatrixT_Test, rotationX) {
|
||||||
{
|
|
||||||
double angle = 1.0;
|
double angle = 1.0;
|
||||||
double c = cos(angle);
|
double c = cos(angle);
|
||||||
double s = sin(angle);
|
double s = sin(angle);
|
||||||
@@ -537,8 +495,7 @@ TEST(PIMathMatrixT_Test, rotationX)
|
|||||||
ASSERT_TRUE((1.0 == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(2u,1u)) && (-s == matrix.at(1u,2u)));
|
ASSERT_TRUE((1.0 == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(2u,1u)) && (-s == matrix.at(1u,2u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rotationY)
|
TEST(PIMathMatrixT_Test, rotationY) {
|
||||||
{
|
|
||||||
double angle = 1.0;
|
double angle = 1.0;
|
||||||
double c = cos(angle);
|
double c = cos(angle);
|
||||||
double s = sin(angle);
|
double s = sin(angle);
|
||||||
@@ -546,8 +503,7 @@ TEST(PIMathMatrixT_Test, rotationY)
|
|||||||
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(0u,2u)) && (-s == matrix.at(2u,0u)));
|
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(0u,2u)) && (-s == matrix.at(2u,0u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, rotationZ)
|
TEST(PIMathMatrixT_Test, rotationZ) {
|
||||||
{
|
|
||||||
double angle = 1.0;
|
double angle = 1.0;
|
||||||
double c = cos(angle);
|
double c = cos(angle);
|
||||||
double s = sin(angle);
|
double s = sin(angle);
|
||||||
@@ -555,22 +511,19 @@ TEST(PIMathMatrixT_Test, rotationZ)
|
|||||||
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (s == matrix.at(1u,0u)) && (-s == matrix.at(0u,1u)));
|
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (s == matrix.at(1u,0u)) && (-s == matrix.at(0u,1u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, scaleX_three)
|
TEST(PIMathMatrixT_Test, scaleX_three) {
|
||||||
{
|
|
||||||
double factor = 23.65;
|
double factor = 23.65;
|
||||||
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleX(factor);
|
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleX(factor);
|
||||||
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (factor == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
|
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (factor == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, scaleY_three)
|
TEST(PIMathMatrixT_Test, scaleY_three) {
|
||||||
{
|
|
||||||
double factor = 23.65;
|
double factor = 23.65;
|
||||||
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleY(factor);
|
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleY(factor);
|
||||||
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (factor == matrix.at(1u,1u)));
|
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (factor == matrix.at(1u,1u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, scaleZ_three)
|
TEST(PIMathMatrixT_Test, scaleZ_three) {
|
||||||
{
|
|
||||||
double factor = 23.65;
|
double factor = 23.65;
|
||||||
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleZ(factor);
|
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleZ(factor);
|
||||||
ASSERT_TRUE((factor == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
|
ASSERT_TRUE((factor == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
|
||||||
@@ -583,8 +536,7 @@ TEST(PIMathMatrixT_Test, matrixMultiplication)
|
|||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 11.25, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 11.25, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication)
|
TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
||||||
auto vector = PIMathVectorT<rows, double>::filled(2.5);
|
auto vector = PIMathVectorT<rows, double>::filled(2.5);
|
||||||
for(uint i = 0; i < 2; i++) {
|
for(uint i = 0; i < 2; i++) {
|
||||||
@@ -595,8 +547,7 @@ TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication)
|
|||||||
ASSERT_TRUE(true);
|
ASSERT_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication)
|
TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
||||||
auto vector = PIMathVectorT<rows, double>::filled(2.5);
|
auto vector = PIMathVectorT<rows, double>::filled(2.5);
|
||||||
for(uint i = 0; i < 2; i++) {
|
for(uint i = 0; i < 2; i++) {
|
||||||
@@ -606,8 +557,7 @@ TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIMathMatrixT_Test, valAndMatrixMultiplication)
|
TEST(PIMathMatrixT_Test, valAndMatrixMultiplication) {
|
||||||
{
|
|
||||||
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
|
||||||
ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3));
|
ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user