American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
piecewiselinear.h File Reference
#include <vector>
#include "line.h"

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< Lineline_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)

Detailed Description

PiecewiseLinear and utility functions.


Define Documentation

#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 Documentation

typedef std::vector<Line> line_array

STL container used to hold lines.


Function Documentation

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.

Parameters:
firstThe first function
secondThe 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.

Parameters:
firstThe first function
secondThe 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 $ g_0,\ldots,g_n $ (not checked) and a number y such that $ f^L(w) \le -y \le f^R(w)$ for some number w, where superscripts $^L$ and $^R$ refer to left and right derivatives. This function returns this number w, numbers $ p_1,\ldots,p_n $ in the interval $[0,1]$ together with numbers $ x_0,\ldots,x_n $ such that $ f(w) = \sum_{k=0}^np_kg_k(w)$, $-y = \sum_{k=0}^np_kx_k $, $ f^L(w) \le -y \le f^R(w)$ and $ g_k^L(w) \le -x_k \le g_k^R(w)$ for all $ k = 0,\ldots,n $. Any input value for w is considered as a first guess for w (but this input value is checked for correctness).

 All Classes Namespaces Files Functions Variables Typedefs Defines