Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Gaussian Elimination #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Gaussian Elimination/Gaussian Elimination.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*Gaussian_Elimination..
This program needs as a input, the original matrix and the number of rows and columns.
You are able to change the MAX value if you need to work with a bigger matrix*/

#include <iostream>
#define MAX 2000

void Gaussian_Elimination (double matrix[][MAX],int total_row,int total_column)
{
//Some variables for make my loops
int i,j,row,column;
int swap_row = 0;

//This array will divide the row that is procesing
double divider[MAX];

for (row = 0; row < total_row; t++)
{
//This make a matrix that will multiply the current row
for (column = 1+swap_row; column < total_row; column++)
divider[column] = (double)m[column][row] / m[row][row];

//Now the divider's matrix will modify the original matrix
for (i = 1+swap_row; i<total_row; i++)

for (j=0; j<total_column; j++)
matrix[i][j] = matrix[i][j] - matrix[row][j]*divider[i];
swap_row++;
}
}