diff --git a/SCE/SCE/SCE.cpp b/SCE/SCE/SCE.cpp index 6f9f8d2..8623562 100644 --- a/SCE/SCE/SCE.cpp +++ b/SCE/SCE/SCE.cpp @@ -39,6 +39,6 @@ void cylinder() void lgs() { LGS lgs; - lgs.data_entry(); - cout << lgs.gauss() << endl; + //lgs.data_entry(); + lgs.gauss(); } diff --git a/SCE/SCE/lgs.cpp b/SCE/SCE/lgs.cpp index 1946c1d..8002b99 100644 --- a/SCE/SCE/lgs.cpp +++ b/SCE/SCE/lgs.cpp @@ -1,6 +1,8 @@ #include "lgs.h" #include "time.h" #include +#include +#include using namespace std; void LGS::data_entry() @@ -36,6 +38,7 @@ void LGS::data_entry() void LGS::creat_array() { + x = new long double[variables]; GA = new long double*[variables]; for (int i = 0; i < variables; ++i) GA[i] = new long double[variables+1]; @@ -83,50 +86,57 @@ void LGS::print_exp() } } +float LGS::gauss() +{ + double t1 = clock(); + + int i, j, k; + data_entry(); + for (i = 0; i= 0; i--) //back-substitution + { //x is an array whose values correspond to the values of x,y,z.. + x[i] = GA[i][variables]; //make the variable to be calculated equal to the rhs of the last equation + for (j = i + 1; j