53 double temp1[4] = {-7,-5,3,2};
54 double temp2[9] = {7./3,2./3,2./3,-17./3,-1./3,-4./3,2./3,1./3,1./3};
55 double temp3[16] = {18, -35, -28, 1, 9, -18, -14, 1, -2, 4, 3, 0, -12, 24, 19, -1};
64 for(
int i = 0; i < A1inv.rows(); i++)
65 for(
int j = 0; j < A1inv.cols(); j++)
66 if (std::abs(A1inv(i,j) - CompareA1inv(i,j)) >
eps) {badCount++;}
67 failDescriptionStream <<
"Check if gnsstk::inverse(A1) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
72 for(
int i = 0; i < A2inv.rows(); i++)
73 for(
int j = 0; j < A2inv.cols(); j++)
74 if (std::abs(A2inv(i,j) - CompareA2inv(i,j)) >
eps) {badCount++;}
75 failDescriptionStream <<
"Check if gnsstk::inverse(A2) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
80 for(
int i = 0; i < A3inv.rows(); i++)
81 for(
int j = 0; j < A3inv.cols(); j++)
82 if (std::abs(A3inv(i,j) - CompareA3inv(i,j)) >
eps) {badCount++;}
83 failDescriptionStream <<
"Check if gnsstk::inverse(A3) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
102 double temp4[4] = {2,-3,5,-7};
103 double temp5[9] = {1,3,-5,0,1,-1,-2,-2,9};
104 double temp6[16] = {2,1,0,0,3,0,2,2,1,3,-3,3,5,1,2,1};
105 double temp7[20] = {8,7,1,-78,5,-9,7,24,18,5,10,20,-2,0,11,-68,1.5,7,47,0};
115 for(
int i = 0; i < A1T.rows(); i++)
116 for(
int j = 0; j < A1T.cols(); j++)
117 if (A1T(i,j) != CompareA1T(i,j)) {badCount++;}
118 failDescriptionStream <<
"Check if gnsstk::transpose(A1) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
123 for(
int i = 0; i < A2T.rows(); i++)
124 for(
int j = 0; j < A2T.cols(); j++)
125 if (A2T(i,j) != CompareA2T(i,j)) {badCount++;}
126 failDescriptionStream <<
"Check if gnsstk::transpose(A2) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
131 for(
int i = 0; i < A3T.rows(); i++)
132 for(
int j = 0; j < A3T.cols(); j++)
133 if (A3T(i,j) != CompareA3T(i,j)) {badCount++;}
134 failDescriptionStream <<
"Check if gnsstk::transpose(A3) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
139 for(
int i = 0; i < A4T.
rows(); i++)
140 for(
int j = 0; j < A4T.
cols(); j++)
141 if (A4T(i,j) != CompareA4T(i,j)) {badCount++;}
142 failDescriptionStream <<
"Check if gnsstk::transpose(A4) returns the right matrix. " << badCount <<
" of the elements are incorrect.";
164 double temp8[2]= {-45,19};
165 double temp9[3]= {17./3,-31./3,7./3};
166 double temp10[4]= {-132,-65,15,89};
167 CompareA1sol = temp8;
168 CompareA2sol = temp9;
169 CompareA3sol = temp10;
174 for(
int i = 0; i < A1sol.size(); i++)
176 failMesg =
"The solution calculated from A1inverse * b is incorrect";
177 if (std::abs(CompareA1sol[i] - A1sol[i]) >
eps) {badCount++;}
182 for(
int i = 0; i < A2sol.size(); i++)
184 failMesg =
"The solution calculated from A2inverse * b is incorrect";
185 if (std::abs(CompareA2sol[i] - A2sol[i]) >
eps) {badCount++;}
190 for(
int i = 0; i < A3sol.
size(); i++)
192 failMesg =
"The solution calculated from A3inverse * b is incorrect";
193 if (std::abs(CompareA3sol[i] - A3sol[i]) >
eps) {badCount++; std::cout<<(CompareA3sol[i]-A3sol[i])<<std::endl;}
204 gnsstk::TestUtil testFramework(
"Matrix",
"Determinant", __FILE__, __LINE__);
206 double CompareDetA1 = 1.0;
207 double CompareDetA2 = 3.0;
208 double CompareDetA3 = 1.0;
210 failMesg =
"The calculated determinant is incorrect";
221 int check, errorCounter = 0;
225 errorCounter += check;
228 errorCounter += check;
231 errorCounter += check;
234 errorCounter += check;
236 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;