5.5 Convergence Table

This forum is to discuss the book "C++ design patterns and derivatives pricing."

5.5 Convergence Table

Postby sjud » Sat Apr 13, 2013 2:28 pm

Good Morning, I'm currently studying the book and I have some difficulties on how ConvergenceTable is built.
Especially, how the methods "DumpOneResult" and "GetResultsSoFar" of this class are made and what are the concepts behind it. In Listing 5.8:

void ConvergenceTable::DumpOneResult(double result)
{
Inner->DumpOneResult(result);

++PathsDone;

if (PathsDone == StoppingPoint)
{
StoppingPoint*=2;
std::vector<std::vector<double> > thisResult(Inner->GetResultsSoFar());

for (unsigned long i=0; i < thisResult.size(); i++)
{
thisResult[i].push_back(PathsDone);
ResultsSoFar.push_back(thisResult[i]);
}
}
return;
}

Why do you increment "PathsDone" again by ++ "PathsDone" since the code just above does it already?
Does the container vector has a default copy constructor when you call "std::vector<std::vector<double> > thisResult(Inner->GetResultsSoFar())" ?
What is the type of thisResult[i]? And why do you add "PathsDone" at the end of it?
If I well understand "ResultsSoFar" is an array of all the "PathsDone"?

I think If once I ll understand this method it will be easier for me to get the "GetResultsSoFar".

Thank you very much for your help.
sjud
 
Posts: 1
Joined: Sat Apr 13, 2013 2:10 pm

Return to C++ design patterns and derivatives pricing

Who is online

Users browsing this forum: No registered users and 1 guest

cron