/* Solve the system of N linear equations Ax = b by using Gaussian elimination with partial pivoting to factor A = PLU where P is a permutation matrix, L is a lower-triagular matrix with 1's on the diagonal and U is an upper triangular matrix. Then forward and back substituting to find x. */ #include #include #define N 5 double A[N][N] = { { -3, 1, -6, 5, -5 }, { 0, -5, -6, 3, 9 }, { -6, -6, 6, 8, -6 }, { 9, -3, -5, 2, -4 }, { -6, 8, -7, -9, -8 }}; double b[N] = { 1, 2, 3, 4, 5 }; double y[N] = { -0.2235509997469, -1.1348946469248, -0.42091400911162, -0.67584946848899, -0.46360098709188 }; void LUfact(double *P[N],double A[N][N]){ for(int i=0;i=0;i--){ double r=0; for(int j=i+1;j