|
Hi all
line 122 and 128 of multipathgenerator.hpp: sqrt_dt is defined and assigned
a value but it is never
used. Should I be worried?
Sorry I don't have time enough to read and understand the full code now...
ciao -- Nando
===========================
template <class SG>
inline const typename MultiPathGenerator<SG>::sample_type&
MultiPathGenerator<SG>::next() const {
typedef typename SG::sample_type sequence_type;
const sequence_type& sequence_ = generator_.nextSequence();
Array asset(numAssets_);
Array temp(numAssets_);
next_.weight = sequence_.weight;
for (Size j = 0; j < numAssets_; j++) {
asset[j] = diffusionProcs_[j]->x0();
}
TimeGrid timeGrid = next_.value[0].timeGrid();
double dt;
double sqrt_dt;
Time t;
for (Size i = 0; i < next_.value[0].size(); i++) {
Size offset = i*numAssets_;
t = timeGrid[i+1];
dt = timeGrid.dt(i);
sqrt_dt = QL_SQRT(dt);
std::copy(sequence_.value.begin()+offset,
sequence_.value.begin()+offset+numAssets_,
temp.begin());
temp = sqrtCorrelation_ * temp;
for (Size j=0; j<numAssets_; j++) {
next_.value[j].drift()[i] = dt * diffusionProcs_[j]->drift(t,
asset[j]);
next_.value[j].diffusion()[i] = - temp[j] *
QL_SQRT(diffusionProcs_[j]->variance(t, asset[j], dt));
asset[j] *= QL_EXP(next_.value[j].drift()[i] +
next_.value[j].diffusion()[i]);
}
}
return next_;
}
|