Class Lattice
- Namespace
- NanoQL
- Assembly
- NanoQL.dll
The lattice (tree, finite-differences) base class: a numerical method that rolls discretized assets back.
public abstract class Lattice
- Inheritance
-
Lattice
- Derived
- Inherited Members
Remarks
A lattice is immutable once built, and thread-safe, so one lattice can be built once and passed to many calculations. The assets it rolls back are working types (DiscretizedAsset), owned by one calculation: the lattice's members change the asset they are given, never the lattice.
The numerical method interface is used by discretized assets and implemented by developers writing numerical methods; users call the corresponding members of DiscretizedAsset instead. An extension point, as in QuantLib: the tree lattices derive from it.
Constructors
Lattice(TimeGrid)
Initializes a new instance of the Lattice class.
protected Lattice(TimeGrid timeGrid)
Parameters
timeGridTimeGridThe lattice's time grid.
Exceptions
- ArgumentNullException
timeGridis null.
Properties
TimeGrid
Gets the lattice's time grid.
public TimeGrid TimeGrid { get; }
Property Value
Methods
Grid(double)
The lattice's values of the underlying variable at a time.
public abstract Vector Grid(double t)
Parameters
tdoubleThe time.
Returns
- Vector
A new vector, one value per node.
Grid(double, Span<double>)
The lattice's values of the underlying variable at a time, written into the caller's span, so that a working asset reads them at each step without allocating. This default copies Grid(double); a lattice that can write its nodes directly overrides it.
public virtual int Grid(double t, Span<double> destination)
Parameters
Returns
- int
The number of values written, one per node.
Exceptions
- ArgumentException
destinationis shorter than the grid.
Initialize(DiscretizedAsset, double)
Initializes an asset at the given time.
public abstract void Initialize(DiscretizedAsset asset, double time)
Parameters
assetDiscretizedAssetThe asset, which changes.
timedoubleThe time.
PartialRollback(DiscretizedAsset, double)
Rolls an asset back until the given time, but doesn't perform the final adjustment.
public abstract void PartialRollback(DiscretizedAsset asset, double to)
Parameters
assetDiscretizedAssetThe asset, which changes.
todoubleThe time to roll back to.
PresentValue(DiscretizedAsset)
Computes the present value of an asset.
public abstract double PresentValue(DiscretizedAsset asset)
Parameters
assetDiscretizedAssetThe asset.
Returns
- double
The present value.
Rollback(DiscretizedAsset, double)
Rolls an asset back until the given time, performing any needed adjustment.
public abstract void Rollback(DiscretizedAsset asset, double to)
Parameters
assetDiscretizedAssetThe asset, which changes.
todoubleThe time to roll back to.