Table of Contents

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

timeGrid TimeGrid

The lattice's time grid.

Exceptions

ArgumentNullException

timeGrid is null.

Properties

TimeGrid

Gets the lattice's time grid.

public TimeGrid TimeGrid { get; }

Property Value

TimeGrid

Methods

Grid(double)

The lattice's values of the underlying variable at a time.

public abstract Vector Grid(double t)

Parameters

t double

The 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

t double

The time.

destination Span<double>

The span the values go to, at least one per node.

Returns

int

The number of values written, one per node.

Exceptions

ArgumentException

destination is shorter than the grid.

Initialize(DiscretizedAsset, double)

Initializes an asset at the given time.

public abstract void Initialize(DiscretizedAsset asset, double time)

Parameters

asset DiscretizedAsset

The asset, which changes.

time double

The 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

asset DiscretizedAsset

The asset, which changes.

to double

The time to roll back to.

PresentValue(DiscretizedAsset)

Computes the present value of an asset.

public abstract double PresentValue(DiscretizedAsset asset)

Parameters

asset DiscretizedAsset

The 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

asset DiscretizedAsset

The asset, which changes.

to double

The time to roll back to.