QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
sobolbrownianbridgersg.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2012 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file brownianbridgersg.hpp
21 \brief interface class to map the functionality of SobolBrownianGenerator
22 to the "conventional" sequence generator interface
23*/
24
26
27namespace QuantLib {
28
29 namespace {
30 void setNextSequence(SobolBrownianGeneratorBase& gen, std::vector<Real>& seq) {
31 gen.nextPath();
32 std::vector<Real> output(gen.numberOfFactors());
33 for (Size i = 0; i < gen.numberOfSteps(); ++i) {
34 gen.nextStep(output);
35 std::copy(output.begin(), output.end(), seq.begin() + i * gen.numberOfFactors());
36 }
37 }
38 }
39
41 Size steps,
43 unsigned long seed,
44 SobolRsg::DirectionIntegers directionIntegers)
45 : seq_(sample_type::value_type(factors * steps), 1.0),
46 gen_(factors, steps, ordering, seed, directionIntegers) {}
47
50 setNextSequence(gen_, seq_.value);
51 return seq_;
52
53 }
54
57 return seq_;
58 }
59
62 }
63
65 Size factors,
66 Size steps,
68 unsigned long seed,
69 SobolRsg::DirectionIntegers directionIntegers,
70 unsigned long scrambleSeed)
71 : seq_(sample_type::value_type(factors * steps), 1.0),
72 gen_(factors, steps, ordering, seed, directionIntegers, scrambleSeed) {}
73
76 setNextSequence(gen_, seq_.value);
77 return seq_;
78 }
79
82 return seq_;
83 }
84
87 }
88
89}
Burley2020SobolBrownianBridgeRsg(Size factors, Size steps, SobolBrownianGenerator::Ordering ordering=SobolBrownianGenerator::Diagonal, unsigned long seed=42, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::JoeKuoD7, unsigned long scrambleSeed=43)
const sample_type & nextSequence() const
SobolBrownianBridgeRsg(Size factors, Size steps, SobolBrownianGenerator::Ordering ordering=SobolBrownianGenerator::Diagonal, unsigned long seed=0, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::JoeKuoD7)
const sample_type & lastSequence() const
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
interface class to map the functionality of SobolBrownianGenerator to the "conventional" sequence gen...