American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
|
Piecewise linear (affine) function. More...
#include <piecewiselinear.h>
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 |
PiecewiseLinear & | operator*= (const coefficient value) |
PiecewiseLinear & | operator= (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) |
Piecewise linear (affine) function.
A PiecewiseLinear function is a collection of Line objects, arranged from left to right on the horizontal axis.
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.
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.
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 then we choose piece(x) to be
.
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.
lowest | Lowest of the gradients |
highest | Highest of the gradients |
void PiecewiseLinear::shift | ( | const coefficient | x, |
const coefficient | y | ||
) | [inline] |
Shifts graph of function.
x | Number of units to shift to the right (to the left if negative) |
y | Number 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.