American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
piecewiselinear.cpp File Reference
#include "piecewiselinear.h"
#include "../config.h"
#include <iostream>

Functions

coefficient crossing (const Line &line, const PiecewiseLinear &function, const coefficient x, const int direction)
PiecewiseLinear maximum (PiecewiseLinear &first, PiecewiseLinear &second)
ostream & operator<< (ostream &output, const PiecewiseLinear &line)
void print_convex_conjugate (const PiecewiseLinear &line)
void untangle_maximum (const PiecewiseLinear &f, const vector< PiecewiseLinear > &g, const coefficient y, coefficient &w, vector< coefficient > &p, vector< coefficient > &x)

Detailed Description

Implementation of class and utility functions in piecewiselinear.h.


Function Documentation

coefficient crossing ( const Line line,
const PiecewiseLinear function,
const coefficient  x,
const int  direction 
)

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
ostream& operator<< ( 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