Go to the documentation of this file.
55 int zeroCount = Lno.
cols() - 1;
56 for (
int i = 0; i < Lno.
rows(); i++) {
57 for (
int j = 0; j < Lno.
cols(); j++)
59 if (j > Lno.
cols() - zeroCount - 1)
62 else if (j == Lno.
cols() - zeroCount - 1)
65 else if(j < Lno.
cols() - zeroCount - 1)
66 Lno(i,j) = LUno.
LU(i,j);
73 for (
int i = 0; i< Uno.
rows(); i++) {
74 for (
int j = 0; j < Uno.
cols(); j++)
77 Uno(i,j) = LUno.
LU(i,j);
79 else if (j < zeroCount)
88 for (
int i = 0; i < Pno.
rows(); i++)
89 for (
int j = 0; j < Pno.
cols(); j++)
90 if ((j == iCount) && (i == iCount)) {
97 for (
int i = 0; i < LUno.
Pivot.
size(); i++)
103 gnsstk::Matrix<double> L1Temp(2,2), U1Temp(2,2), L2Temp(3,3), U2Temp(3,3), L3Temp(4,4), U3Temp(4,4);
107 L1 = L1Temp;
U1 = U1Temp;
L2 = L2Temp;
U2 = U2Temp;
L3 = L3Temp;
U3 = U3Temp;
109 P1 = P1Temp;
P2 = P2Temp;
P3 = P3Temp;
136 gnsstk::TestUtil testFramework(
"Matrix LU",
"LU initialize", __FILE__, __LINE__);
139 failMesg =
"Able to perform LU decomposition on non-square matrix";
148 gnsstk::TestUtil testFramework(
"Matrix LU",
"LU Determinant", __FILE__, __LINE__);
150 failMesg =
"The LU decomposition's determinant is not equivalent to the determinant of the data matrix";
160 gnsstk::TestUtil testFramework(
"Matrix LU",
"P * (L * U) = A", __FILE__, __LINE__);
162 std::cout<<
U1<<
"\n\n"<<
A1<<std::endl;
166 for(
int i = 0; i <
A1.
rows(); i++)
167 for(
int j = 0; j <
A1.
cols(); j++)
169 failDescriptionStream <<
"Check if LU decomposition of A1 returns the right matrix. " << badCount <<
" of the elements are incorrect.";
174 for(
int i = 0; i <
A2.
rows(); i++)
175 for(
int j = 0; j <
A2.
cols(); j++)
177 failDescriptionStream <<
"Check if LU decomposition of A2 returns the right matrix. " << badCount <<
" of the elements are incorrect.";
182 for(
int i = 0; i <
A3.
rows(); i++)
183 for(
int j = 0; j <
A3.
cols(); j++)
185 failDescriptionStream <<
"Check if LU decomposition of A3 returns the right matrix. " << badCount <<
" of the elements are incorrect.";
195 gnsstk::TestUtil testFramework(
"Matrix LU",
"LU Determinant", __FILE__, __LINE__);
208 double temp1[2]= {-45,19};
209 double temp2[3]= {17./3,-31./3,7./3};
210 double temp3[4]= {-132,-65,15,89};
211 CompareA1sol = temp1;
212 CompareA2sol = temp2;
213 CompareA3sol = temp3;
217 for(
int i = 0; i < A1sol.size(); i++)
219 failMesg =
"The solution calculated from back subsitution of LU decomposition is incorrect";
220 if (std::abs(CompareA1sol[i] - A1sol[i]) >
eps) {badCount++;}
225 for(
int i = 0; i < A2sol.size(); i++)
227 failMesg =
"The solution calculated from back subsitution of LU decomposition is incorrect";
228 if (std::abs(CompareA2sol[i] - A2sol[i]) >
eps) {badCount++;}
233 for(
int i = 0; i < A3sol.
size(); i++)
235 failMesg =
"The solution calculated from back subsitution of LU decomposition is incorrect";
236 if (std::abs(CompareA3sol[i] - A3sol[i]) >
eps) {badCount++; std::cout<<(CompareA3sol[i]-A3sol[i])<<std::endl;}
246 int check, errorCounter = 0;
250 errorCounter += check;
255 errorCounter += check;
258 errorCounter += check;
261 errorCounter += check;
263 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;
gnsstk::Matrix< double > CompareLUA1
Vector< int > Pivot
The pivot array.
gnsstk::LUDecomp< double > LUA1
void assert(bool testExpression, const std::string &testMsg, const int lineNumber)
gnsstk::Matrix< double > L1
gnsstk::LUDecomp< double > LUA2
std::stringstream failDescriptionStream
void UMatrixGeneration(gnsstk::Matrix< double > &Uno, gnsstk::LUDecomp< double > LUno)
gnsstk::Matrix< double > CompareLUA2
BaseClass & swapRows(size_t row1, size_t row2)
void LMatrixGeneration(gnsstk::Matrix< double > &Lno, gnsstk::LUDecomp< double > LUno)
gnsstk::Vector< double > B2
size_t cols() const
The number of columns in the matrix.
size_t rows() const
The number of rows in the matrix.
std::string failDescriptionString
gnsstk::Matrix< double > P1
T det(const ConstMatrixBase< T, BaseClass > &m)
gnsstk::Matrix< double > CompareLUA3
gnsstk::LUDecomp< double > LUA3
gnsstk::Vector< double > B3
gnsstk::Matrix< double > P2
void LUDecompInitializer(void)
gnsstk::Matrix< double > U1
void PermuationMatrixGeneration(gnsstk::Matrix< double > &Pno, gnsstk::LUDecomp< double > &LUno)
int LUinitializationTest(void)
gnsstk::Matrix< double > A3
gnsstk::Matrix< double > L3
gnsstk::LUDecomp< double > LUA4
gnsstk::Matrix< double > U3
size_t size() const
STL size.
int LUdeterminantTest(void)
gnsstk::Matrix< double > A2
gnsstk::Matrix< double > U2
gnsstk::Vector< double > B1
gnsstk::Matrix< double > L2
gnsstk::Matrix< double > A1
gnsstk::Matrix< double > P3
gnsstk::Matrix< double > A4
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39