American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
PiecewiseLinear Class Reference

Piecewise linear (affine) function. More...

#include <piecewiselinear.h>

List of all members.

Public Member Functions

int convex () const
coefficient intercept (const size_t k) const
coefficient intersection (const size_t k) const
void negate ()
coefficient operator() (const coefficient x) const
PiecewiseLinearoperator*= (const coefficient value)
PiecewiseLinearoperator= (const line_array &lines)
int operator>= (const PiecewiseLinear &function)
Line operator[] (const size_t k) const
size_t piece (const coefficient x) const
 PiecewiseLinear (const line_array &lines)
 PiecewiseLinear (const Line &line=Line(NAN, NAN))
void restrict_slope (const coefficient lowest, const coefficient highest)
void shift (const coefficient x, const coefficient y)
size_t size () const
coefficient slope (const size_t k) const

Protected Member Functions

void check (const int objective=PIECEWISELINEAR_CHECK_MAXIMUM)

Detailed Description

Piecewise linear (affine) function.

A PiecewiseLinear function is a collection of Line objects, arranged from left to right on the horizontal axis.

Author:
Alet Roux <alet.roux@york.ac.uk>

Constructor & Destructor Documentation

PiecewiseLinear::PiecewiseLinear ( const Line line = Line (NAN, NAN)) [inline]

Default constructor, encapsulates Line.

PiecewiseLinear::PiecewiseLinear ( const line_array lines) [inline]

Constructs PiecewiseLinear from lines, checks for errors in input data and precomputes intersections between lines.


Member Function Documentation

void PiecewiseLinear::check ( const int  objective = PIECEWISELINEAR_CHECK_MAXIMUM) [protected]

Performs sanity check on lines. Removes adjacent parallel lines with eye on objective, and precomputes array of intersections of lines.

  • If objective is CHECK_MAXIMUM, the objective is to maximise the value of the function (and minimize the size of the epigraph).
  • If objective is CHECK_MINIMUM, the objective is to minimise the value of the function (or to maximize the size of the epigraph).
int PiecewiseLinear::convex ( ) const [inline]

Tests whether this function is convex or not.

coefficient PiecewiseLinear::intercept ( const size_t  k) const [inline]

The intercept of line k with the vertical axis.

coefficient PiecewiseLinear::intersection ( const size_t  k) const [inline]

The k -th intersection. This is the left-hand point of line k, and the right-hand point of line k -1.

void PiecewiseLinear::negate ( ) [inline]

Negates both slope and intersection.

coefficient PiecewiseLinear::operator() ( const coefficient  x) const [inline]

Evaluates piecewise linear function at x.

PiecewiseLinear& PiecewiseLinear::operator*= ( const coefficient  value) [inline]

Multiplies all lines and intercepts by value.

PiecewiseLinear& PiecewiseLinear::operator= ( const line_array lines) [inline]

Assignment operator.

int PiecewiseLinear::operator>= ( const PiecewiseLinear function) [inline]

Comparison.

Line PiecewiseLinear::operator[] ( const size_t  k) const [inline]

A copy of the k-th line.

size_t PiecewiseLinear::piece ( const coefficient  x) const [inline]

Finds line piece on which x appears. If x == intersection(k) for some $ k $ then we choose piece(x) to be $ k $.

void PiecewiseLinear::restrict_slope ( const coefficient  lowest,
const coefficient  highest 
)

Restricts slope of line pieces to be between lowest and highest. Has the effect of enlarging the epigraph.

Parameters:
lowestLowest of the gradients
highestHighest of the gradients
void PiecewiseLinear::shift ( const coefficient  x,
const coefficient  y 
) [inline]

Shifts graph of function.

Parameters:
xNumber of units to shift to the right (to the left if negative)
yNumber of units to shift upwards (downwards if negative)
size_t PiecewiseLinear::size ( ) const [inline]

Number of line pieces.

coefficient PiecewiseLinear::slope ( const size_t  k) const [inline]

The slope of line k.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Defines