Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
MultiPathGeneratorMersenneTwister Class Reference

Instantiation of MultiPathGenerator with standard PseudoRandom traits. More...

#include <qle/methods/multipathgeneratorbase.hpp>

+ Inheritance diagram for MultiPathGeneratorMersenneTwister:
+ Collaboration diagram for MultiPathGeneratorMersenneTwister:

Public Member Functions

 MultiPathGeneratorMersenneTwister (const QuantLib::ext::shared_ptr< StochasticProcess > &, const TimeGrid &, BigNatural seed=0, bool antitheticSampling=false)
 
const Sample< MultiPath > & next () const override
 
void reset () override
 
- Public Member Functions inherited from MultiPathGeneratorBase
virtual ~MultiPathGeneratorBase ()
 
virtual const Sample< MultiPath > & next () const =0
 
virtual void reset ()=0
 

Private Attributes

const QuantLib::ext::shared_ptr< StochasticProcessprocess_
 
TimeGrid grid_
 
BigNatural seed_
 
QuantLib::ext::shared_ptr< MultiPathGenerator< PseudoRandom::rsg_type > > pg_
 
QuantLib::ext::shared_ptr< PathGenerator< PseudoRandom::rsg_type > > pg1D_
 
bool antitheticSampling_
 
bool antitheticVariate_
 
Sample< MultiPath > next_
 

Detailed Description

Instantiation of MultiPathGenerator with standard PseudoRandom traits.

Definition at line 59 of file multipathgeneratorbase.hpp.

Constructor & Destructor Documentation

◆ MultiPathGeneratorMersenneTwister()

MultiPathGeneratorMersenneTwister ( const QuantLib::ext::shared_ptr< StochasticProcess > &  process,
const TimeGrid &  grid,
BigNatural  seed = 0,
bool  antitheticSampling = false 
)

Member Function Documentation

◆ next()

const Sample< MultiPath > & next ( ) const
overridevirtual

Implements MultiPathGeneratorBase.

Definition at line 44 of file multipathgeneratorbase.cpp.

44 {
47 if (pg_) {
48 return antitheticVariate_ ? pg_->antithetic() : pg_->next();
49 } else {
50 next_.value.at(0) = antitheticVariate_ ? pg1D_->antithetic().value : pg1D_->next().value;
51 return next_;
52 }
53 } else {
54 if (pg_)
55 return pg_->next();
56 else {
57 next_.value.at(0) = pg1D_->next().value;
58 return next_;
59 }
60 }
61}
QuantLib::ext::shared_ptr< PathGenerator< PseudoRandom::rsg_type > > pg1D_
QuantLib::ext::shared_ptr< MultiPathGenerator< PseudoRandom::rsg_type > > pg_
+ Here is the caller graph for this function:

◆ reset()

void reset ( )
overridevirtual

Implements MultiPathGeneratorBase.

Definition at line 34 of file multipathgeneratorbase.cpp.

34 {
35 PseudoRandom::rsg_type rsg = PseudoRandom::make_sequence_generator(process_->factors() * (grid_.size() - 1), seed_);
36 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<StochasticProcess1D>(process_)) {
37 pg1D_ = QuantLib::ext::make_shared<PathGenerator<PseudoRandom::rsg_type>>(tmp, grid_, rsg, false);
38 } else {
39 pg_ = QuantLib::ext::make_shared<MultiPathGenerator<PseudoRandom::rsg_type>>(process_, grid_, rsg, false);
40 }
41 antitheticVariate_ = true;
42}
+ Here is the caller graph for this function:

Member Data Documentation

◆ process_

const QuantLib::ext::shared_ptr<StochasticProcess> process_
private

Definition at line 67 of file multipathgeneratorbase.hpp.

◆ grid_

TimeGrid grid_
private

Definition at line 68 of file multipathgeneratorbase.hpp.

◆ seed_

BigNatural seed_
private

Definition at line 69 of file multipathgeneratorbase.hpp.

◆ pg_

QuantLib::ext::shared_ptr<MultiPathGenerator<PseudoRandom::rsg_type> > pg_
private

Definition at line 71 of file multipathgeneratorbase.hpp.

◆ pg1D_

QuantLib::ext::shared_ptr<PathGenerator<PseudoRandom::rsg_type> > pg1D_
private

Definition at line 72 of file multipathgeneratorbase.hpp.

◆ antitheticSampling_

bool antitheticSampling_
private

Definition at line 73 of file multipathgeneratorbase.hpp.

◆ antitheticVariate_

bool antitheticVariate_
mutableprivate

Definition at line 74 of file multipathgeneratorbase.hpp.

◆ next_

Sample<MultiPath> next_
mutableprivate

Definition at line 75 of file multipathgeneratorbase.hpp.