QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
optimization
spherecylinder.hpp
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) 2007 Mark Joshi
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 spherecylinder.hpp
21
\brief Find closest point of the intersection of a sphere and cylinder to a
22
given point
23
*/
24
25
#ifndef quantlib_optimization_sphere_cylinder_hpp
26
#define quantlib_optimization_sphere_cylinder_hpp
27
28
#include <
ql/types.hpp
>
29
#include <vector>
30
31
namespace
QuantLib
{
32
33
/*! - we are in r^3 sphere centred at O radius r
34
- vertical cylinder centred at (alpha,0) radius s
35
- Z some point in R3
36
- find point on intersection that is closest to Z
37
38
the intersection may be empty!
39
*/
40
class
SphereCylinderOptimizer
{
41
public
:
42
SphereCylinderOptimizer
(
Real
r
,
43
Real
s
,
44
Real
alpha
,
45
Real
z1,
46
Real
z2,
47
Real
z3,
48
Real
zweight =1.0);
49
bool
isIntersectionNonEmpty
()
const
;
50
void
findClosest
(
Size
maxIterations,
51
Real
tolerance,
52
Real
& y1,
53
Real
& y2,
54
Real
& y3)
const
;
55
bool
findByProjection
(
56
Real
& y1,
57
Real
& y2,
58
Real
& y3)
const
;
59
private
:
60
Real
r_
,
s_
,
alpha_
,
z1_
,
z2_
,
z3_
;
61
Real
objectiveFunction
(
Real
x2)
const
;
62
Real
topValue_
;
63
Real
bottomValue_
;
64
bool
nonEmpty_
;
65
Real
zweight_
;
66
};
67
68
std::vector<Real>
sphereCylinderOptimizerClosest
(
Real
r
,
69
Real
s
,
70
Real
alpha
,
71
Real
z1,
72
Real
z2,
73
Real
z3,
74
Natural
maxIterations,
75
Real
tolerance,
76
Real
finalWeight = 1.0);
77
78
}
79
80
#endif
QuantLib::SphereCylinderOptimizer
Definition:
spherecylinder.hpp:40
QuantLib::SphereCylinderOptimizer::zweight_
Real zweight_
Definition:
spherecylinder.hpp:65
QuantLib::SphereCylinderOptimizer::findClosest
void findClosest(Size maxIterations, Real tolerance, Real &y1, Real &y2, Real &y3) const
Definition:
spherecylinder.cpp:114
QuantLib::SphereCylinderOptimizer::z3_
Real z3_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::topValue_
Real topValue_
Definition:
spherecylinder.hpp:62
QuantLib::SphereCylinderOptimizer::s_
Real s_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::objectiveFunction
Real objectiveFunction(Real x2) const
Definition:
spherecylinder.cpp:130
QuantLib::SphereCylinderOptimizer::r_
Real r_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::z2_
Real z2_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::bottomValue_
Real bottomValue_
Definition:
spherecylinder.hpp:63
QuantLib::SphereCylinderOptimizer::nonEmpty_
bool nonEmpty_
Definition:
spherecylinder.hpp:64
QuantLib::SphereCylinderOptimizer::alpha_
Real alpha_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::z1_
Real z1_
Definition:
spherecylinder.hpp:60
QuantLib::SphereCylinderOptimizer::isIntersectionNonEmpty
bool isIntersectionNonEmpty() const
Definition:
spherecylinder.cpp:110
QuantLib::SphereCylinderOptimizer::findByProjection
bool findByProjection(Real &y1, Real &y2, Real &y3) const
Definition:
spherecylinder.cpp:147
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib::Natural
unsigned QL_INTEGER Natural
positive integer
Definition:
types.hpp:43
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
QuantLib
Definition:
any.hpp:35
QuantLib::sphereCylinderOptimizerClosest
std::vector< Real > sphereCylinderOptimizerClosest(Real r, Real s, Real alpha, Real z1, Real z2, Real z3, Natural maxIterations, Real tolerance, Real zweight)
Definition:
spherecylinder.cpp:176
s
Real s
Definition:
perturbativebarrieroptionengine.cpp:1488
r
ext::shared_ptr< YieldTermStructure > r
Definition:
perturbativebarrieroptionengine.cpp:1454
alpha
Real alpha
Definition:
sabr.cpp:200
types.hpp
Custom types.
Generated by
Doxygen
1.9.5