int _stklen=100000; #include #include #include #include #define MAXI 200 #define MAXJ 200 float m[MAXI][MAXJ]; float m2[MAXI][MAXJ]; float b[MAXI], x[MAXI]; float b2[MAXI]; float p; int di, dj; int n; void inits(); void readmats(); void checkmats(); void printmats(); void printx(); void invertmats(); void inits() { int i,j; di=dj=0; x[0] = 0; x[1] = 0; return; } void readmats() { int i, j; float t; di = dj = 4; m[0][0] = 7.0; m[0][1] = 2.0; m[0][2] = 1.0; m[1][0] = 2.0; m[1][1] = 4.0; m[1][2] = 1.0; m[2][0] = 1.0; m[2][1] = -1.0; m[2][2] = 60.0; b[0] = 2.0; b[1] = 5.0; b[2] = 0.3; randomize(); /* n = 5; */ di = dj = n; for (i=0; in; i--) { /* Make zeros starting at the lowest row. */ y = &m[n][n]; /* The pointer stuff is because of a definate */ p1 = *y; /* compiler bug, it actually hangs my whole */ y = &m[i][n]; /* when doing a 2d array assignent to a var */ d1 = *y; /* bad, bad. This works, though */ d1 /= p1; /* This is the factor to multiply the eq with */ for (j=n; j0; n--) { /* sweep clear the upper tri */ for (i=n-1; i>=0; i--) { /* vertical stripes of zeros */ y = &m[n][n]; p1 = *y; y = &m[i][n]; d1 = *y; d1 /= p1; m[i][n] -= d1*p1; /* make use of the existing zeros */ b[i] = b[i] - d1 * b[n]; /* and the right hand side of course */ } if (0) printmats(" "); } /* Now we have a diagonal matrix */ for (i=0; i