/*****************************************************************
Author: Neville Andrade
Date: 3 Dec 2012
Description: (Factory Method Pattern)
This exercise has to do
with section 9.8.1 of the MC Book (and in particular Figure 9.9)
where we model a class hierarchy for interest rate models
as well as factory classes for instantiation.
To this end, we direct you to Exercise 3 in section 9.10. There we
describe the exercise in full.
Here we need to implement the prototype pattern.
******************************************************************/
// TestIrSde.cpp
//
// Testing 1-factor IR SDEs
//
// 2008-3-28 DD kick off
//
// (C) Datasim Education BV 2008
#include "UtilitiesDJD\IRModels\IrSdeFactory.hpp"
#include "UtilitiesDJD\Vectorsandmatrices\Vector.cpp"
#include "UtilitiesDJD\RNG\NormalGenerator.hpp"
#include "UtilitiesDJD\Vectorsandmatrices\ArrayMechanisms.cpp"
#include
using namespace std;
Vector Simulation(const IrSde& irsde, Vector mesh)
{ // Simulate a short-rate using explicit Euler method
long N = mesh.Size();
Vector result(N, mesh.MinIndex());
// Step size
double k = irsde.Interval().spread()/double(N - 1);
double sk = sqrt(k);
double rOld;
// Generate array of normal random numbers
TerribleRandGenerator myTerrible; // rand()
NormalGenerator* myNormal = new BoxMuller(myTerrible);
Vector arr2 = myNormal->getNormalVector(N);
//cout CreateIrSde();
//mySde2->setkappa(cin >> kappa);
//Here I need to create another SDE which clones mySde
//IrSde* mySde2(mySde);
// Now simulate a path using Euler method
cout > N;
Vector myMesh = mySde->Interval().mesh(N);
CIRSde *derivedPtr = dynamic_cast (mySde2);
//Change kappa setting
if (derivedPtr != 0)
{
double oldKappa = derivedPtr->getKappa();
cout