Hello!
I'm having a difficult time with this bit of code
my value index is supposed to be set to the 'row' with the lowest value of "err"
but index is never set to anything higher than 0. no matter my input
'data' is 1 dimensional array taken from a file with 200 rows (numRows) and 6 columns (numCols) of data type double
Thank you for any help!Code:void safeTest(double *testPoint, double *data, int numRows, int numCols) { int r, c, i, index = 0; double sum, err = 0; double oper[numCols-1]; double temp = 1000000; for(i = 0; i < numCols-1; i++) { oper[i] = testPoint[i]; } for(r = 0; r < numRows; r++) { for(c = 0; c < numCols; c++) { oper[c] -= data[r*numCols+c]; oper[c] = oper[c] * oper[c]; sum += oper[c]; } err = sqrt(sum); sum = 0; for(i = 0; i < numCols-1; i++) { oper[i] = testPoint[i]; } if(temp > err) { temp = err; index = r; } } if(data[index*numCols + 5] == 1) { printf("It is SAFE to move on\n"); }else { printf("It is NOT SAFE to move on\n"); } }



LinkBack URL
About LinkBacks



