Created
October 8, 2014 02:17
-
-
Save jeb2239/9789b145f9c7a63dac20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void gaussElim(int n, int m, double** A,double* x) { | |
int k, i, j,s=0; | |
//double x; | |
for (k = 0; k <n-1; k++) { | |
for (i = k + 1; i < n; i++) { | |
for (j = k+1; j < n; j++) { | |
A[i][j] = A[i][j] - (A[i][k]/A[k][k] * (A[k][j])); | |
//printf("%lf\n",A[i][j]); | |
A[i][n] = A[i][n]-((A[i][k] / A[k][k]) * (A[k][n])); | |
} | |
} | |
A[k+1][k]=0; | |
} | |
for(i=n-1;i!=0;i--){ | |
s=0; | |
for(j=k+1;j < n;j++){ | |
s+=A[i][j]*x[j]; | |
} | |
x[i]=(A[i][n]-s)/A[i][i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment