BABAR C++ Course Running the Examples - HEPHY
BABAR C++ Course Running the Examples - HEPHY
BABAR C++ Course Running the Examples - HEPHY
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Line fit continuedCharacter StringsPart 2 (ch2/linefit.C)// Compute coefficientsdouble sx_over_n = sx / n;double stt = 0.0;double b = 0.0;for (i = 0; i < n; i++) {double ti = x[i] - sx_over_n;Character strings are special case of array andarray initializationchar hello1[] = { ’H’, ’i’ };The above is too tedious, so use double quoteschar hello2[] = "Hi";}stt += ti * ti;b += ti * y[i];}b /= stt;double a = (sy - sx * b) / n;delete [] x;delete [] y;cout