#include #include #include #include #include "nr.h" using namespace std; // Driver for routine ludcmp int main(void) { int j,k,l,m,n,dum; string txt; DP d; ifstream fp("matrx1.dat"); if (fp.fail()) NR::nrerror("Data file matrx1.dat not found"); cout << fixed << setprecision(6); getline(fp,txt); while (!fp.eof()) { getline(fp,txt); fp >> n >> m; getline(fp,txt); Vec_INT indx(n),jndx(n); Mat_DP a(n,n),xl(n,n),xu(n,n),x(n,n); getline(fp,txt); for (k=0;k> a[k][l]; getline(fp,txt); getline(fp,txt); for (l=0;l> x[k][l]; getline(fp,txt); getline(fp,txt); // Print out a-matrix for comparison with product of // lower and upper decomposition matrices cout << "original matrix:" << endl; for (k=0;k k) { xu[k][l]=a[k][l]; xl[k][l]=0.0; } else if (l < k) { xu[k][l]=0.0; xl[k][l]=a[k][l]; } else { xu[k][l]=a[k][l]; xl[k][l]=1.0; } } } // Compute product of lower and upper matrices for // comparison with original matrix for (k=0;k