QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
sobolbrownianbridgersg.cpp
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
25#include <ql/math/randomnumbers/sobolbrownianbridgersg.hpp>
26
27namespace QuantLib {
29 Size factors, Size steps,
31 unsigned long seed,
32 SobolRsg::DirectionIntegers directionIntegers)
33 : factors_(factors), steps_(steps), dim_(factors*steps),
34 seq_(sample_type::value_type(factors*steps), 1.0),
35 gen_(factors, steps, ordering, seed, directionIntegers) {
36 }
37
40 gen_.nextPath();
41 std::vector<Real> output(factors_);
42 for (Size i=0; i < steps_; ++i) {
43 gen_.nextStep(output);
44 std::copy(output.begin(), output.end(),
45 seq_.value.begin()+i*factors_);
46 }
47
48 return seq_;
49 }
50
53 return seq_;
54 }
55
57 return dim_;
58 }
59}
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
Real nextStep(std::vector< Real > &) override
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35