std::vector<std::vector<double> > ConvergenceTable::GetResultsSoFar() const
{
    std::vector<std::vector<double> > tmp(ResultsSoFar);

    if (PathsDone*2 != StoppingPoint)
    {
        std::vector<std::vector<double> > thisResult(Inner->GetResultsSoFar());
		
        for (unsigned long i=0; i < thisResult.size(); i++)
        {
            thisResult[i].push_back(PathsDone);
            tmp.push_back(thisResult[i]);
        }
    }
    return tmp;
}
std::vector<std::vector<double> >  MCOutput::GetResults() const
{
    std::vector<std::vector<double> > tmp(ResultsSoFar);

    if (MCPaths != Counter)
    {
        std::vector<std::vector<double> > thisResult(Inner->GetResults());

        for (unsigned long i=0; i < thisResult.size(); i++)
        {
            thisResult[i].push_back(MCPaths);
            tmp.push_back(thisResult[i]);
        }
    }
    return tmp;
}
// Return them for every power 2.
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;
}
void ConvergenceTable::DumpOneResult(double result)
{
    Inner -> DumpOneResult(result);// call method of pointed-to onject by wrapper class
    ++PathsDone;
    
    if (PathsDone == StoppingPoint)
    {
        //each time where number of paths is a multiple of 2, add result
        StoppingPoint*=2;
        std::vector<std::vector<double>> thisResult(Inner->GetResultsSoFar());
        
        for (unsigned long i =0; i<thisResult.size(); i++)
        {
            thisResult[i].push_back(PathsDone);
            ResultSoFar.push_back(thisResult[i]); // update ResultSoFar
        }
    }
    return;
}
void MCOutput::StoreValue(double value)
{
    Inner->StoreValue(value);
    ++MCPaths;
    Counter++;

    if (Counter % Factor ==1 && Counter != MCPaths)
    {
        std::vector<std::vector<double> > thisResult(Inner->GetResults());

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

    return;

}