American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
|
Go to the source code of this file.
Classes | |
class | PiecewiseLinear |
Piecewise linear (affine) function. More... | |
Defines | |
#define | PIECEWISELINEAR_CHECK_MAXIMUM 1 |
#define | PIECEWISELINEAR_CHECK_MINIMUM 2 |
#define | PIECEWISELINEAR_CROSSING_LEFT -1 |
#define | PIECEWISELINEAR_CROSSING_RIGHT 1 |
Typedefs | |
typedef std::vector< Line > | line_array |
Functions | |
coefficient | crossing (const Line &line, const PiecewiseLinear &function, const coefficient x=-INFINITY, const int direction=PIECEWISELINEAR_CROSSING_RIGHT) |
PiecewiseLinear | maximum (PiecewiseLinear &first, PiecewiseLinear &second) |
PiecewiseLinear | minimum (PiecewiseLinear &first, PiecewiseLinear &second) |
std::ostream & | operator<< (std::ostream &output, const PiecewiseLinear &line) |
void | print_convex_conjugate (const PiecewiseLinear &line) |
void | untangle_maximum (const PiecewiseLinear &f, const std::vector< PiecewiseLinear > &g, const coefficient y, coefficient &w, std::vector< coefficient > &p, std::vector< coefficient > &x) |
PiecewiseLinear and utility functions.
#define PIECEWISELINEAR_CHECK_MAXIMUM 1 |
Removes parallel lines by using maximum as objective (makes epigraph as small as possible).
#define PIECEWISELINEAR_CHECK_MINIMUM 2 |
Removes parallel lines by using minimum as objective (makes epigraph as large as possible).
#define PIECEWISELINEAR_CROSSING_LEFT -1 |
Search to the left for a crossing point between a line and a piecewise linear function.
#define PIECEWISELINEAR_CROSSING_RIGHT 1 |
Search to the right for a crossing point between a line and a piecewise linear function.
typedef std::vector<Line> line_array |
STL container used to hold lines.
coefficient crossing | ( | const Line & | line, |
const PiecewiseLinear & | function, | ||
const coefficient | x = -INFINITY , |
||
const int | direction = PIECEWISELINEAR_CROSSING_RIGHT |
||
) |
Finds a crossing point between line and function, starting at x and searching in the given direction. Returns NAN if it cannot be found. Intersections between lines and piecewise linear functions are not necessarily unique, and by no means guaranteed.
PiecewiseLinear maximum | ( | PiecewiseLinear & | first, |
PiecewiseLinear & | second | ||
) |
Maximum of two piecewise linear functions. The original functions are not touched, the absence of const is for technical reasons. It is safe to assign the returned function to either of the functions that was passed as a parameter.
first | The first function |
second | The second function |
PiecewiseLinear minimum | ( | PiecewiseLinear & | first, |
PiecewiseLinear & | second | ||
) | [inline] |
Minimum of two piecewise linear functions. The original functions are not touched, the absence of const is for technical reasons. It is safe to assign the returned function to either of the functions that was passed as a parameter. This function is currently a wrapper around maximum.
first | The first function |
second | The second function |
std::ostream& operator<< | ( | std::ostream & | output, |
const PiecewiseLinear & | line | ||
) |
Outputs line in format that can be copied and pasted into Gnuplot (http://www.gnuplot.info/).
void print_convex_conjugate | ( | const PiecewiseLinear & | line | ) |
Computes and prints convex conjugate of line.
void untangle_maximum | ( | const PiecewiseLinear & | f, |
const std::vector< PiecewiseLinear > & | g, | ||
const coefficient | y, | ||
coefficient & | w, | ||
std::vector< coefficient > & | p, | ||
std::vector< coefficient > & | x | ||
) |
Service method. Suppose given a function f that is the maximum of convex functions (not checked) and a number y such that
for some number w, where superscripts
and
refer to left and right derivatives. This function returns this number w, numbers
in the interval
together with numbers
such that
,
,
and
for all
. Any input value for w is considered as a first guess for w (but this input value is checked for correctness).