Skip to content

Instantly share code, notes, and snippets.

@jeb2239
Created October 8, 2014 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeb2239/9789b145f9c7a63dac20 to your computer and use it in GitHub Desktop.
Save jeb2239/9789b145f9c7a63dac20 to your computer and use it in GitHub Desktop.
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