documentation correction and tests in PIMathVector.h
This commit is contained in:
@@ -8,7 +8,7 @@ bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, double v
|
||||
bool b = true;
|
||||
for(int i = 0; i < num; i++) {
|
||||
for(int j = 0; j < num; j++) {
|
||||
if(matrix.at(i, j) - val >= double(1E-200)) {
|
||||
if(matrix[i][j] - val >= double(1E-200)) {
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
@@ -63,15 +63,15 @@ TEST(PIMathMatrixT_Test, col) {
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
uint g = 2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
vect = matr.col(g);
|
||||
for(uint i = 0; i < matr.cols(); i++) {
|
||||
if(matr.at(i, g) != vect.at(i)) {
|
||||
@@ -85,15 +85,15 @@ TEST(PIMathMatrixT_Test, row) {
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
uint g = 2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
vect = matr.row(g);
|
||||
for(uint i = 0; i < matr.rows(); i++) {
|
||||
if(matr.at(g, i) != vect.at(i)) {
|
||||
@@ -138,15 +138,15 @@ TEST(PIMathMatrixT_Test, setRow) {
|
||||
TEST(PIMathMatrixT_Test, swapCols) {
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
int g1 = 1, g2 = 2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
const PIMathVectorT<rows, double> before_Vect1 = matr.col(g1);
|
||||
const PIMathVectorT<rows, double> before_Vect2 = matr.col(g2);
|
||||
matr.swapCols(g1, g2);
|
||||
@@ -163,15 +163,15 @@ TEST(PIMathMatrixT_Test, swapCols) {
|
||||
TEST(PIMathMatrixT_Test, swapRows) {
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
int g1 = 1, g2 = 2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
const PIMathVectorT<rows, double> before_Vect1 = matr.row(g1);
|
||||
const PIMathVectorT<rows, double> before_Vect2 = matr.row(g2);
|
||||
matr.swapRows(g1, g2);
|
||||
@@ -192,7 +192,7 @@ TEST(PIMathMatrixT_Test, fill) {
|
||||
matr.fill(g);
|
||||
for(uint i = 0; i < cols; i++) {
|
||||
for(uint j = 0; j < rows; j++) {
|
||||
matrix1.at(j,i) = g;
|
||||
matrix1[j][i] = g;
|
||||
}
|
||||
}
|
||||
ASSERT_TRUE(matr == matrix1);
|
||||
@@ -239,56 +239,56 @@ TEST(PIMathMatrixT_Test, operator_Assignment) {
|
||||
TEST(PIMathMatrixT_Test, operator_EqualTrue) {
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
matrix1.at(0, 0) = 5.1;
|
||||
matrix1.at(0, 1) = 1.21;
|
||||
matrix1.at(1, 1) = 0.671;
|
||||
matrix1.at(1, 0) = 2.623;
|
||||
matrix2.at(0, 0) = 5.1;
|
||||
matrix2.at(0, 1) = 1.21;
|
||||
matrix2.at(1, 1) = 0.671;
|
||||
matrix2.at(1, 0) = 2.623;
|
||||
matrix1[0][0] = 5.1;
|
||||
matrix1[0][1] = 1.21;
|
||||
matrix1[1][1] = 0.671;
|
||||
matrix1[1][0] = 2.623;
|
||||
matrix2[0][0] = 5.1;
|
||||
matrix2[0][1] = 1.21;
|
||||
matrix2[1][1] = 0.671;
|
||||
matrix2[1][0] = 2.623;
|
||||
ASSERT_TRUE(matrix1 == matrix2);
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, operator_EqualFalse) {
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
matrix1.at(0, 0) = 5.1;
|
||||
matrix1.at(0, 1) = 1.21;
|
||||
matrix1.at(1, 1) = 0.671;
|
||||
matrix1.at(1, 0) = 2.623;
|
||||
matrix2.at(0, 0) = 5.1;
|
||||
matrix2.at(0, 1) = 1.21;
|
||||
matrix2.at(1, 1) = 665.671;
|
||||
matrix2.at(1, 0) = 2.623;
|
||||
matrix1[0][0] = 5.1;
|
||||
matrix1[0][1] = 1.21;
|
||||
matrix1[1][1] = 0.671;
|
||||
matrix1[1][0] = 2.623;
|
||||
matrix2[0][0] = 5.1;
|
||||
matrix2[0][1] = 1.21;
|
||||
matrix2[1][1] = 665.671;
|
||||
matrix2[1][0] = 2.623;
|
||||
ASSERT_FALSE(matrix1 == matrix2);
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue) {
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
matrix1.at(0, 0) = 5.1;
|
||||
matrix1.at(0, 1) = 1.21;
|
||||
matrix1.at(1, 1) = 0.671;
|
||||
matrix1.at(1, 0) = 2.623;
|
||||
matrix2.at(0, 0) = 5.1;
|
||||
matrix2.at(0, 1) = 1.21;
|
||||
matrix2.at(1, 1) = 665.671;
|
||||
matrix2.at(1, 0) = 2.623;
|
||||
matrix1[0][0] = 5.1;
|
||||
matrix1[0][1] = 1.21;
|
||||
matrix1[1][1] = 0.671;
|
||||
matrix1[1][0] = 2.623;
|
||||
matrix2[0][0] = 5.1;
|
||||
matrix2[0][1] = 1.21;
|
||||
matrix2[1][1] = 665.671;
|
||||
matrix2[1][0] = 2.623;
|
||||
ASSERT_TRUE(matrix1 != matrix2);
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse) {
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
matrix1.at(0, 0) = 5.1;
|
||||
matrix1.at(0, 1) = 1.21;
|
||||
matrix1.at(1, 1) = 0.671;
|
||||
matrix1.at(1, 0) = 2.623;
|
||||
matrix2.at(0, 0) = 5.1;
|
||||
matrix2.at(0, 1) = 1.21;
|
||||
matrix2.at(1, 1) = 0.671;
|
||||
matrix2.at(1, 0) = 2.623;
|
||||
matrix1[0][0] = 5.1;
|
||||
matrix1[0][1] = 1.21;
|
||||
matrix1[1][1] = 0.671;
|
||||
matrix1[1][0] = 2.623;
|
||||
matrix2[0][0] = 5.1;
|
||||
matrix2[0][1] = 1.21;
|
||||
matrix2[1][1] = 0.671;
|
||||
matrix2[1][0] = 2.623;
|
||||
ASSERT_FALSE(matrix1 != matrix2);
|
||||
}
|
||||
|
||||
@@ -343,30 +343,30 @@ TEST(PIMathMatrixT_Test, determinantIfSquare) {
|
||||
double d;
|
||||
double i = 59.0;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
d = matr.determinant();
|
||||
ASSERT_DOUBLE_EQ(i, d);
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, determinantIfNotSquare) {
|
||||
PIMathMatrixT<rows, 5u, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
ASSERT_FALSE(matr.determinant());
|
||||
}
|
||||
|
||||
@@ -376,15 +376,15 @@ TEST(PIMathMatrixT_Test, invert) {
|
||||
PIMathMatrixT<rows, cols, double> matrix3;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
matrix2 = matr;
|
||||
matr.invert();
|
||||
d1 = matr.determinant();
|
||||
@@ -401,15 +401,15 @@ TEST(PIMathMatrixT_Test, inverted) {
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
matrix1 = matr.identity();
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
matrix2 = matr.inverted();
|
||||
d1 = matr.determinant();
|
||||
d2 = matrix2.determinant();
|
||||
@@ -421,15 +421,15 @@ TEST(PIMathMatrixT_Test, toUpperTriangular) {
|
||||
PIMathMatrixT<rows, cols, double> matrix;
|
||||
double d1, d2 = 1;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
matrix = matr.toUpperTriangular();
|
||||
d1 = matrix.determinant();
|
||||
for(uint i = 0; i < cols; i++)
|
||||
@@ -444,15 +444,15 @@ TEST(PIMathMatrixT_Test, transposed) {
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
matr.at(1,0) = 2;
|
||||
matr.at(1,1) = 1;
|
||||
matr.at(1,2) = 4;
|
||||
matr.at(2,0) = 6;
|
||||
matr.at(2,1) = 2;
|
||||
matr.at(2,2) = 5;
|
||||
matr[0][0] = 3;
|
||||
matr[0][1] = 6;
|
||||
matr[0][2] = 8;
|
||||
matr[1][0] = 2;
|
||||
matr[1][1] = 1;
|
||||
matr[1][2] = 4;
|
||||
matr[2][0] = 6;
|
||||
matr[2][1] = 2;
|
||||
matr[2][2] = 5;
|
||||
d1 = matr.determinant();
|
||||
matrix1 = matr.transposed();
|
||||
d2 = matrix1.determinant();
|
||||
|
||||
Reference in New Issue
Block a user