robustfpm.pricing.lattice module

This submodule implements a Lattice class for working with n-dimensional lattices on \(\mathbb{R}^{n}\)

The rationale behind such lattice is that it is much easier to work with integer coordinates than with real ones. Lattice incapsulates such a uniform lattice.

class robustfpm.pricing.lattice.Lattice(delta, logscale=False, center=None, dtype=None, dtype_p=None)

Bases: object

Handler for the uniform or logscale n-dimensional lattice. Provides functionality for mapping integer point coordinates to \(\mathbb{R}^{n}\) and vice versa.

Parameters
  • delta (array_like, size = n x 1) – Lattice steps.

  • logscale (bool, default = False) – If True, the lattice is considered logscale. Default is False.

  • center (array_like, size = n x 1) – Point from \(\mathbb{R}^{n}\) which corresponds to zero coordinates on a lattice.

  • dtype (numeric np.dtype) – Type for points in \(\mathbb{R}^{n}\). Default is np.float64.

  • dtype_p (numeric np.dtype) – Type for lattice coordinates. Default is np.int64.

Notes

The class upholds the following notation: ‘x’ means points from \(\mathbb{R}^{n}\), ‘point’ means points from the lattice.

property dim

Returns lattice’s dimension

Returns

Lattice’s dimesion

Return type

int

get_projection(obj)

Projects a point or \(\mathbb{R}^{n}\), an array of points or a predefined set to lattice coordinates.

Parameters

obj (array_like, size = (n,) or (m,n), or ISetHandler) – A set of points from \(\mathbb{R}^{n}\).

Returns

If obj is an array, returns an array of coordinates. If obj is an ISetHandler instance, the ISetHandler method of lattice-projection will be used to return the projection of the set to the lattice.

Return type

np.ndarray

map2x(point)

Maps the array of lattice coordinates to points in \(\mathbb{R}^{n}\).

This function acts as a sort of inverse to get_projection().

Parameters

point (array_like, size = (n,) or (m,n)) – A set of integer-based coordinates on the lattice.

Returns

An array of points in \(\mathbb{R}^{n}\).

Return type

np.ndarray

Notes

get_projection(map2x(point) = point, but map2x(get_projection(x)) in general is not equal to x (due to mapping accuracy).

xrectangle_points(x_from, x_to)

Returns lattice projection for the parallelotope specified via its corner points.

Parameters
  • x_from (array_like, size = (n,)) – ‘Lower left’ corner of the parallelotope.

  • x_to (array_like, size = (n,)) – ‘Upper right’ corner of the parallelotope.

Returns

An array of lattice coordinates.

Return type

np.ndarray

See also

robustfpm.util.util.cartesian_product()

Function used for generation of points from corner coordinates