QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
latticersg.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4Copyright (C) 2007 Mark Joshi
5
6This file is part of QuantLib, a free-software/open-source library
7for financial quantitative analysts and developers - http://quantlib.org/
8
9QuantLib is free software: you can redistribute it and/or modify it
10under the terms of the QuantLib license. You should have received a
11copy 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
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file latticersg.cpp
21\brief lattice rule code for low discrepancy numbers
22*/
23
25#include <utility>
26namespace QuantLib {
27
28 LatticeRsg::LatticeRsg(Size dimensionality, std::vector<Real> z, Size N)
29 : dimensionality_(dimensionality), N_(N), z_(std::move(z)),
30 sequence_(std::vector<Real>(dimensionality), 1.0) {}
31 /*! skip to the n-th sample in the low-discrepancy sequence */
32 void LatticeRsg::skipTo(unsigned long n)
33 {
34 i_+=n;
35 }
36
38 {
39 for (Size j=0; j < dimensionality_; ++j)
40 {
41 Real theta = i_*z_[j]/N_;
42 sequence_.value[j]= std::fmod(theta,1.0);
43 }
44 ++i_;
45
46 return sequence_;
47
48 }
49
50}
const LatticeRsg::sample_type & nextSequence()
Definition: latticersg.cpp:37
std::vector< Real > z_
Definition: latticersg.hpp:48
sample_type sequence_
Definition: latticersg.hpp:50
void skipTo(unsigned long n)
Definition: latticersg.cpp:32
LatticeRsg(Size dimensionality, std::vector< Real > z, Size N)
Definition: latticersg.cpp:28
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Real theta
lattice rule code for low discrepancy numbers
Definition: any.hpp:35
STL namespace.