CFL
Public Member Functions | List of all members

Representation of random payoffs in the library. More...

#include <cfl/Slice.hpp>

Public Member Functions

 Slice (const IModel *pModel=0, unsigned iEventTime=0, double dValue=0)
 
 Slice (const IModel &rModel, unsigned iEventTime, const std::vector< unsigned > &rDependence, const std::valarray< double > &rValues)
 
Slice apply (double(*f)(double)) const
 
void assign (const IModel &rModel, unsigned iEventTime, const std::vector< unsigned > &rDependence, const std::valarray< double > &rValues)
 
void assign (unsigned iEventTime, const std::vector< unsigned > &rDependence, const std::valarray< double > &rValues)
 
void assign (const std::vector< unsigned > &rDependence, const std::valarray< double > &rValues)
 
void assign (const std::valarray< double > &rValues)
 
void assign (const IModel &rModel)
 
const std::vector< unsigned > & dependence () const
 
Sliceoperator*= (double dValue)
 
Sliceoperator*= (const Slice &rSlice)
 
Sliceoperator+= (double dValue)
 
Sliceoperator+= (const Slice &rSlice)
 
Sliceoperator-= (double dValue)
 
Sliceoperator-= (const Slice &rSlice)
 
Sliceoperator/= (double dValue)
 
Sliceoperator/= (const Slice &rSlice)
 
Sliceoperator= (const Slice &rSlice)
 
Sliceoperator= (double dValue)
 
const IModelptrToModel () const
 
void rollback (unsigned iEventTime)
 
unsigned timeIndex () const
 
const std::valarray< double > & values () const
 

Detailed Description

This class models random payoffs defined at a particular event time of a model. More precisely, Slice is a random variable determined by the current values of the state processes.

See also
IModel

Constructor & Destructor Documentation

cfl::Slice::Slice ( const IModel pModel = 0,
unsigned  iEventTime = 0,
double  dValue = 0 
)
explicit

Constructs a payoff with constant value dValue at the event time with index iEventTime in the framework of the financial model defined by an implementation of the interface class IModel.

Parameters
pModelA pointer to an implementation of the interface class IModel.
iEventTimeThe index of current event time.
dValueThe current constant value of the payoff.
cfl::Slice::Slice ( const IModel rModel,
unsigned  iEventTime,
const std::vector< unsigned > &  rDependence,
const std::valarray< double > &  rValues 
)

Constructs a random payoff at given event time.

Parameters
rModelA constant reference to the underlying model which implements the interface class IModel.
iEventTimeThe index of the current time in the vector of event times of the underlying model.
rDependenceA constant reference to the vector of indexes of state processes of underlying model which determine the values of *this.
rValuesAn array of values of the random payoff represented by *this. The size of this array should be equal the result of rModel.numberOfNodes(iEventTime, rDependence).

Member Function Documentation

Slice cfl::Slice::apply ( double(*)(double)  f) const

Returns payoff in the form f(*this).

Parameters
fThe transformation function.
Returns
The payoff in the form f(*this) .
void cfl::Slice::assign ( const IModel rModel,
unsigned  iEventTime,
const std::vector< unsigned > &  rDependence,
const std::valarray< double > &  rValues 
)

Replaces the underlying model, the index of event times, the vector of indexes of state processes, and array of values with rModel, iEventTime, rDependence, and rValues.

Parameters
rModelThe reference to an implementation of interface class IModel.
iEventTimeThe index of new event time for *this.
rDependenceThe new vector of indexes of state processes.
rValuesThe new array of values.
void cfl::Slice::assign ( unsigned  iEventTime,
const std::vector< unsigned > &  rDependence,
const std::valarray< double > &  rValues 
)

Replaces the index of event times, the vector of indexes of state processes, and array of values with iEventTime, rDependence, and rValues.

Parameters
iEventTimeThe index of new event time for *this.
rDependenceThe new vector of indexes of state processes.
rValuesThe new array of values.
void cfl::Slice::assign ( const std::vector< unsigned > &  rDependence,
const std::valarray< double > &  rValues 
)

Replaces vector of indexes of state processes and array of values with rDependence and rValues.

Parameters
rDependenceThe new vector of indexes of state processes.
rValuesThe new array of values.
void cfl::Slice::assign ( const std::valarray< double > &  rValues)

Replaces the array of values with rValues

Parameters
rValuesThe new array of values.
void cfl::Slice::assign ( const IModel rModel)

Replaces underlying model with rModel.

Parameters
rModelThe reference to an implementation of interface class IModel.
const std::vector<unsigned>& cfl::Slice::dependence ( ) const

Accessor function to the vector of indexes of state processes which determine the random variable represented by *this.

Returns
Constant reference to the vector of indexes on state processes that participate in the construction of the given Slice object.
Slice& cfl::Slice::operator*= ( double  dValue)

Multiplies *this on the number dValue.

Parameters
dValueThe constant multiplier.
Returns
Reference to *this.
Slice& cfl::Slice::operator*= ( const Slice rSlice)

Multiplies *this on the value of payoff represented by rSlice. Both objects *this and rSlice should be defined on the same model and at the same event time.

Parameters
rSliceThe multiplier.
Returns
Reference to *this.
Slice& cfl::Slice::operator+= ( double  dValue)

Adds to *this the number dValue.

Parameters
dValueThe constant value that will be added to *this.
Returns
Reference to *this.
Slice& cfl::Slice::operator+= ( const Slice rSlice)

Adds to *this the value of the payoff represented by rSlice. Both objects *this and rSlice should be defined on the same model and at the same event time.

Parameters
rSliceThe payoff that will be added to *this.
Returns
Reference to *this.
Slice& cfl::Slice::operator-= ( double  dValue)

Subtracts from *this the number dValue.

Parameters
dValueThe constant value that will be subtracted from *this.
Returns
Reference to *this.
Slice& cfl::Slice::operator-= ( const Slice rSlice)

Subtracts from *this the value of payoff represented by rSlice. Both objects *this and rSlice should be defined on the same model and at the same event time.

Parameters
rSliceThe payoff that will be subtracted from *this.
Returns
Reference to *this.
Slice& cfl::Slice::operator/= ( double  dValue)

Divides *this on the number dValue.

Parameters
dValueThe constant divisor.
Returns
Reference to *this.
Slice& cfl::Slice::operator/= ( const Slice rSlice)

Divides *this on the value of payoff represented by rSlice. Both objects *this and rSlice should be defined on the same model and at the same event time.

Parameters
rSliceThe divisor.
Returns
Reference to *this.
Slice& cfl::Slice::operator= ( const Slice rSlice)

Assignment operator. Replaces *this with a copy of rSlice.

Parameters
rSliceObject that will be copied.
Returns
Reference to *this.
Slice& cfl::Slice::operator= ( double  dValue)

Assignment operator. Replaces *this with the Slice object defined at the same event time and having constant value dValue.

Parameters
dValueThe constant value that will be assigned to *this.
Returns
Reference to *this.
const IModel* cfl::Slice::ptrToModel ( ) const

Accessor function to the implementation of IModel that was used to support current Slice object.

Returns
The pointer to the underlying model.
void cfl::Slice::rollback ( unsigned  iEventTime)

This member function is usually used if *this represents the value of a (derivative) security. It assigns to *this the equivalent value of this security at event time with smaller index iEventTime.

Parameters
iEventTimeThe index of the target event time. It should be smaller or equal the initial index of event time for *this.
unsigned cfl::Slice::timeIndex ( ) const

Accessor function to the index of event time where *this is defined.

Returns
Index of event time where *this is defined.
const std::valarray<double>& cfl::Slice::values ( ) const

Accessor function to the values of *this.

Returns
The array of values of the given Slice object.

The documentation for this class was generated from the following file: