Can anyone please help me that how this program works??
i have got this Program on internet and i want it to run.....
#include <cstdlib>
double** gauss(double **matrix, int dimension)
{
double **inverse;
inverse = (double**) malloc(dimension * sizeof (double *));
for (int i = 0; i < dimension; i++)
inverse[i] = (double*) malloc(dimension * sizeof (double));
for (int i = 0; i < dimension; i++)
for (int j = 0; j < dimension; j++)
inverse[i][j] = 0;
for (int i = 0; i < dimension; i++)
inverse[i][i] = 1;
for (int k = 0; k < dimension; k++)
{
for (int i = k; i < dimension; i++)
{
double valInv = 1.0 / matrix[i][k];
for (int j = k; j < dimension; j++)
matrix[i][j] *= valInv;
for (int j = 0; j < dimension; j++)
inverse[i][j] *= valInv;
}
for (int i = k + 1; i < dimension; i++)
{
for (int j = k; j < dimension; j++)
matrix[i][j] -= matrix[k][j];
for (int j = 0; j < dimension; j++)
inverse[i][j] -= inverse[k][j];
}
}
for (int i = dimension - 2; i >= 0; i--)
{
for (int j = dimension - 1; j > i; j--)
{
for (int k = 0; k < dimension; k++)
inverse[i][k] -= matrix[i][j] * inverse[j][k];
for (int k = 0; k < dimension; k++)
matrix[i][k] -= matrix[i][j] * matrix[j][k];
}
}
return inverse;
}