|
From: Luigi B. <lui...@gm...> - 2009-01-07 11:21:33
|
On Sat, 2009-01-03 at 01:24 -0800, thusi wrote: > Could some one please tell me the purpose of the ------for loop ------------ > in the code below. > > The code is in the test-suite of quantlib. The cpp file is > pathgenerator.cpp. > > ------------------------------------------ > for (i=0; i<100; i++) > generator.next(); > > sample_type sample = generator.next(); > Real calculated = sample.value.back(); > Real error = std::fabs(calculated-expected); > > -------------------------------------------- > What I don't understand is why does it generate hundred samples, and then do > the calculation of the variable ---Calculated---. Does it do some kind of > averaging of all these paths? No average---it just checks the value of the 101th sample against its expected value. As a test, it's as good as any... Luigi -- Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan |