Anti-thetic sampling via decoration

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

Anti-thetic sampling via decoration

Postby Zhen » Mon Mar 03, 2014 12:21 am

Hi everyone

I am reading the section on anti-thetic sampling (section 6.5) and have got a question regarding the implementation of the constructor of the class AntiThetic.
In the constructor, it reads

AntiThetic::AntiThetic(const Wrapper<RandomBase>& innerGenerator )
: RandomBase(*innerGenerator),
InnerGenerator(innerGenerator)
{
InnerGenerator->Reset();
OddEven =true;
NextVariates.resize(GetDimensionality());
}

I am having problem with the initialization RandomBase(*innerGenerator). If I remember correctly, the base class RandomBase does not have a constructor taking *Wrapper<RandomBase> as an input.
Did i miss something somewhere in order to make sense of the above code? Thanks a lot.
Zhen
 
Posts: 2
Joined: Mon Mar 03, 2014 12:17 am

Re: Anti-thetic sampling via decoration

Postby mj » Mon Mar 03, 2014 12:46 am

*innerGenerator

will be a reference of type RandomBase which is enough.
mj
Site Admin
 
Posts: 1380
Joined: Fri Jul 27, 2007 7:21 am

Re: Anti-thetic sampling via decoration

Postby DavidZhou » Sat Aug 09, 2014 12:25 pm

AntiThetic::AntiThetic(const Wrapper<RandomBase>& innerGenerator )
: RandomBase(*innerGenerator),
InnerGenerator(innerGenerator)
{
InnerGenerator->Reset();
OddEven =true;
NextVariates.resize(GetDimensionality());
}
*innerGenerator calls *deference operator and returns *DataPtr which is a RandomParkMiller object.DataPtr is a RandomBase pointer showing to RandomParkMiller object.
now RandomBase(*innerObject) is equivalent to RandomBase(RandomBase),but RandomBase does not have a accordingly constructor,which implies that
compiler will "pull out" his default copy constructor to attain object's base part copy?
thanks a lot for your reply!
DavidZhou
 
Posts: 3
Joined: Sat Aug 09, 2014 12:04 pm
Location: Mainland China

Re: Anti-thetic sampling via decoration

Postby mj » Fri Aug 15, 2014 5:42 am

the default copy constructor of RandomBase will be called.
mj
Site Admin
 
Posts: 1380
Joined: Fri Jul 27, 2007 7:21 am


Return to C++ design patterns and derivatives pricing

Who is online

Users browsing this forum: No registered users and 1 guest

cron