TransportMaps.Maps.Functionals.LinearSpanTensorizedParametricFunctionalBase

Module Contents

Classes

LinearSpanSemilattice

A DecreasingCoordinateSemilattice is a semilattice \((\mathcal{S}\,\le)\) that is closed under meets,

LinearSpanVertex

A vertex that is CoordinateVertex and SparseVertex.

LinearSpanTensorizedParametricFunctional

Parametric function \(f_{\bf a} = \sum_{{\bf i} \in \mathcal{I}} {\bf a}_{\bf i} \Phi_{\bf i}\)

LinearSpanApproximation

Parametric function \(f_{\bf a} = \sum_{{\bf i} \in \mathcal{I}} {\bf a}_{\bf i} \Phi_{\bf i}\)

class TransportMaps.Maps.Functionals.LinearSpanTensorizedParametricFunctionalBase.LinearSpanSemilattice(*args, **kwargs)[source]

Bases: semilattices.DecreasingCoordinateSemilattice

A DecreasingCoordinateSemilattice is a semilattice \((\mathcal{S}\,\le)\) that is closed under meets, that is it is decreasing: \(x \le y \implies x \in \mathcal{S}\). A decreasing semilattice is often called ‘downward-closed, or ‘admissible’ when the semilattice is interpreted as a multiindex set parameterizing quadrature or interpolation problems

Parameters:
  • dims (int) – semilattice dimension (maximum number of children per vertex)

  • VertexConstructor (class) – type of vertices in the semilattice. It must extend SparseCoordinateVertex

property dof[source]
property coeffs[source]
property n_coeffs[source]
property multi_idxs[source]
_new_vertex_sans_check(**kwargs)[source]

This function should be called to determine and create the the relationships (edges) between a new vertex and other existing vertices in the semilattice, including `edge’ edge with `parent’

_getstate_inner(dd)[source]
_setstate_inner(dd, tmp_vertices)[source]
set_active(v)[source]
set_inactive(v)[source]
is_active(v)[source]
class TransportMaps.Maps.Functionals.LinearSpanTensorizedParametricFunctionalBase.LinearSpanVertex(*args, **kwargs)[source]

Bases: semilattices.SparseCoordinateVertex

A vertex that is CoordinateVertex and SparseVertex.

property data[source]
property coeff[source]
__getstate__()[source]
__setstate__(dd)[source]
class TransportMaps.Maps.Functionals.LinearSpanTensorizedParametricFunctionalBase.LinearSpanTensorizedParametricFunctional(basis_list, q=None, p=1.0, w=None, SemilatticeConstructor=LinearSpanSemilattice, semilattice=None, spantype=None, order_list=None, multi_idxs=None, full_basis_list=None)[source]

Bases: TransportMaps.Maps.Functionals.TensorizedParametricFunctionalBase.TensorizedParametricFunctional

Parametric function \(f_{\bf a} = \sum_{{\bf i} \in \mathcal{I}} {\bf a}_{\bf i} \Phi_{\bf i}\)

The set of multi-indices \(\mathcal{I}\) is generated using the module semilattices. Given a dimension \(d\), a norm \(q\), an order \(p\geq 0\) and weights \(\{w_i \geq 1\}_{i=1}^d\),

\[\mathcal{I} := \left\{ {\bf i} \middle\vert \left\Vert{\bf i}\right\Vert_{\ell^p_W} = \left( \sum_{j=1}^d w_j \left\vert {\bf i}_j \right\vert^p \right)^{1/p} <= q \right\}\]

For example, \(p=1\) and \(w_i=1\) for all \(i\) results in isotropic total order sets (spantype==total in version <3.0). For \(p=\inf\) and \(w_i=1\) for all \(i\) one gets isotropic full order sets (spantype==full in version <3.0).

Parameters:
  • basis_list (list) – list of \(d\) OrthogonalBasis

  • q (float) – norm of the \(\ell^p\) spherical sector enclosing all multi-indices.

  • p (float) – the order \(p\) of the \(\ell^p\) norm.

  • w (semilattices.SpaceWeightDict) – Weightings for the \(\ell^p\) norm. Each dictionary key corresponds to a dimension \(i\) and each corresponding value is the weight \(w_i\). Weights must be >1. Missing values are considered 1.

  • SemilatticeConstructor (class) – constructor for the semilattice. It must be a sub-class of LinearSpanSemilattice.

  • extra_label_keys (iterable of strings) – extra labels to be used to sort vertices in the semilattice.

  • extra_data_keys (iterable of strings) – extra keys referring to data contained in each vertex of the semilattice

  • semilattice (semilattice) – user provided semilattice to be used for handling of the degrees of freedom.

  • spantype (str) – Span type. ‘total’ total order, ‘full’ full order, ‘midx’ multi-indeces specified. Deprecated since version 3.0.

  • order_list (list of int) – list of orders \(\{N_i\}_{i=0}^d\). Deprecated since version 3.0.

  • multi_idxs (list) – list of tuples containing the active multi-indices

  • full_basis_list (list) – full list of Basis. basis_list is a subset of full_basis_list. This may be used to automatically increase the input dimension of the approximation.

property semilattice[source]

The semilattice representing the degrees of freedom of the parametrization.

property n_coeffs[source]

Get the number \(N\) of coefficients \({\bf a}\)

Returns:

(int) – number of coefficients

property coeffs[source]

Get the coefficients \({\bf a}\)

Returns:

(ndarray [\(N\)]) – coefficients

property multi_idxs[source]
property directional_orders[source]

Get the maximum orders of the univariate part of the representation.

Returns:

(list [d] int) – orders

generate_multi_idxs(spantype)[source]

Generate the list of multi-indices

init_coeffs()[source]

Initialize the coefficients \({\bf a}\)

get_default_init_values_regression()[source]
get_multi_idxs()[source]

Get the list of multi indices

Returns:

(list of tuple) – multi indices

set_multi_idxs(multi_idxs)[source]

Set the list of multi indices

Parameters:

multi_idxs (list of tuple) – multi indices

get_directional_orders()[source]

Get the maximum orders of the univariate part of the representation.

Returns:

(list [d] int) – orders

Deprecated since version use: property directional_orders()

__setstate__(state)[source]

Defined to preserve compatibility with stored files where multi_idx is an attribute and not a property.

precomp_Vandermonde_evaluate(x, precomp=None)[source]

Precompute the multi-variate Vandermonde matrices for the evaluation of \(f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray [\(m,N\)]) –

dictionary containing the Vandermonde matrix

evaluate(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1\)]) – function evaluations

precomp_Vandermonde_grad_x(x, precomp=None)[source]

Precompute the multi-variate Vandermonde matrices for the evaluation of \(\nabla_{\bf x} f_{\bf a}\) at x

Parameters:

x (ndarray [\(m,d\)]) – evaluation points

Returns:

(dict with list

[\(d\)] of ndarray [\(m,N\)]) – dictionary containing the list of multi-variate Vandermonde matrices.

grad_x(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf x} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x} f_{\bf a}({\bf x})\)

grad_a_grad_x(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf a} \nabla_{\bf x} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N,d\)]) –

\(\nabla_{\bf a} \nabla_{\bf x} f_{\bf a}({\bf x})\)

precomp_Vandermonde_hess_x(x, precomp=None)[source]

Precompute the multi-variate Vandermonde matrices for the evaluation of \(\nabla^2_{\bf x} f_{\bf a}\) at x

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray

[\(d,d\)] of ndarray [\(m,N\)]) – dictionary containing the matrix of multi-variate Vandermonde matrices

hess_x(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla^2_{\bf x} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,d,d\)]) –

\(\nabla^2_{\bf x} f_{\bf a}({\bf x})\)

grad_a_hess_x(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf a} \nabla^2_{\bf x} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N,d,d\)]) –

\(\nabla_{\bf a} \nabla^2_{\bf x} f_{\bf a}({\bf x})\)

grad_a(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf a} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N\)]) –

\(\nabla_{\bf a} f_{\bf a}({\bf x})\)

grad_a_t(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\left(\nabla_{\bf a} f_{\bf a}\right)^T\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N\)]) –

\(\left(\nabla_{\bf a} f_{\bf a}({\bf x}\right)^T)\)

precomp_VVT_evaluate(x, precomp=None)[source]

Precompute the product \(VV^T\) of the multi-variate Vandermonde matrices for the evaluation of \(f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray [\(m,N\)]) –

dictionary containing the desired product

grad_a_squared(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\left(\nabla_{\bf a} f_{\bf a}\right)\left(\nabla_{\bf a} f_{\bf a}\right)^T\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N,N\)]) –

\(\left(\nabla_{\bf a} f_{\bf a}\right)\left(\nabla_{\bf a} f_{\bf a}\right)^T\)

hess_a(x, precomp=None, idxs_slice=slice(None), *arg, **kwargs)[source]

Evaluate \(\nabla^2_{\bf a} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,1,N,N\)]) –

\(\nabla^2_{\bf a} f_{\bf a}({\bf x})\)

precomp_Vandermonde_partial_xd(x, precomp=None)[source]

Precompute multi-variate Vandermonde matrix for the evaluation of \(\partial_{x_d} f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray [\(m,N\)]) –

dictionary with Vandermonde matrix

partial_xd(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1\)]) –

\(\partial_{x_d} f_{\bf a}({\bf x})\)

precomp_Vandermonde_grad_x_partial_xd(x, precomp=None)[source]

Precompute multi-variate Vandermonde matrices for the evaluation of \(\nabla_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with list [d]

ndarray [\(m,N\)]) – dictionary containing the list of multi-variate Vandermonde matrices.

grad_x_partial_xd(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,d\)]) –

\(\nabla_{\bf x}\partial_{x_d} f_{\bf a}({\bf x})\)

grad_a_grad_x_partial_xd(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf a}\nabla_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N,d\)]) –

\(\nabla_{\bf a}\nabla_{\bf x}\partial_{x_d} f_{\bf a}({\bf x})\)

precomp_Vandermonde_hess_x_partial_xd(x, precomp=None)[source]

Precompute Vandermonde matrices for the evaluation of \(\nabla^2_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray [d,d]

ndarray [\(m,N\)]) – dictionary with list of Vandermonde matrices for the computation of the gradient.

hess_x_partial_xd(x, precomp=None, idxs_slice=slice(None), *args, **kwargs)[source]

Evaluate \(\nabla^2_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,1,d,d\)]) –

\(\nabla^2_{\bf x}\partial_{x_d} f_{\bf a}({\bf x})\)

grad_a_hess_x_partial_xd(x, precomp=None, idxs_slice=slice(None), *args, **kwars)[source]

Evaluate \(\nabla_{\bf a}\nabla^2_{\bf x}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,1,N,d,d\)]) –

\(\nabla_{\bf a}\nabla^2_{\bf x}\partial_{x_d} f_{\bf a}({\bf x})\)

precomp_Vandermonde_partial2_xd(x, precomp=None)[source]

Precompute multi-variate Vandermonde matrix for the evaluation of \(\partial^2_{x_d} f_{\bf a}\) at x.

Enriches the precomp dictionary if necessary.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

Returns:

(dict with ndarray [\(m,N\)]) –

dictionary with Vandermonde matrix

partial2_xd(x, precomp=None, idxs_slice=slice(None))[source]

Evaluate \(\partial^2_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,1\)]) –

\(\partial^2_{x_d} f_{\bf a}({\bf x})\)

grad_a_partial_xd(x, precomp=None, idxs_slice=slice(None), cache=None)[source]

Evaluate \(\nabla_{\bf a}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

  • cache (dict) – cache

Returns:

(ndarray [\(m,1,N\)]) –

\(\nabla_{\bf a}\partial_{x_d} f_{\bf a}({\bf x})\)

hess_a_partial_xd(x, precomp=None, idxs_slice=slice(None), *args, **kwargs)[source]

Evaluate \(\nabla^2_{\bf a}\partial_{x_d} f_{\bf a}\) at x.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,1,N,N\)]) –

\(\nabla^2_{\bf a}\partial_{x_d} f_{\bf a}({\bf x})\)

precomp_regression(x, precomp=None, *args, **kwargs)[source]

Precompute necessary structures for the speed up of regression()

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • precomp (dict) – dictionary to be updated

Returns:

(dict) – dictionary of necessary strucutres

class TransportMaps.Maps.Functionals.LinearSpanTensorizedParametricFunctionalBase.LinearSpanApproximation(*args, **kwargs)[source]

Bases: LinearSpanTensorizedParametricFunctional

Parametric function \(f_{\bf a} = \sum_{{\bf i} \in \mathcal{I}} {\bf a}_{\bf i} \Phi_{\bf i}\)

The set of multi-indices \(\mathcal{I}\) is generated using the module semilattices. Given a dimension \(d\), a norm \(q\), an order \(p\geq 0\) and weights \(\{w_i \geq 1\}_{i=1}^d\),

\[\mathcal{I} := \left\{ {\bf i} \middle\vert \left\Vert{\bf i}\right\Vert_{\ell^p_W} = \left( \sum_{j=1}^d w_j \left\vert {\bf i}_j \right\vert^p \right)^{1/p} <= q \right\}\]

For example, \(p=1\) and \(w_i=1\) for all \(i\) results in isotropic total order sets (spantype==total in version <3.0). For \(p=\inf\) and \(w_i=1\) for all \(i\) one gets isotropic full order sets (spantype==full in version <3.0).

Parameters:
  • basis_list (list) – list of \(d\) OrthogonalBasis

  • q (float) – norm of the \(\ell^p\) spherical sector enclosing all multi-indices.

  • p (float) – the order \(p\) of the \(\ell^p\) norm.

  • w (semilattices.SpaceWeightDict) – Weightings for the \(\ell^p\) norm. Each dictionary key corresponds to a dimension \(i\) and each corresponding value is the weight \(w_i\). Weights must be >1. Missing values are considered 1.

  • SemilatticeConstructor (class) – constructor for the semilattice. It must be a sub-class of LinearSpanSemilattice.

  • extra_label_keys (iterable of strings) – extra labels to be used to sort vertices in the semilattice.

  • extra_data_keys (iterable of strings) – extra keys referring to data contained in each vertex of the semilattice

  • semilattice (semilattice) – user provided semilattice to be used for handling of the degrees of freedom.

  • spantype (str) – Span type. ‘total’ total order, ‘full’ full order, ‘midx’ multi-indeces specified. Deprecated since version 3.0.

  • order_list (list of int) – list of orders \(\{N_i\}_{i=0}^d\). Deprecated since version 3.0.

  • multi_idxs (list) – list of tuples containing the active multi-indices

  • full_basis_list (list) – full list of Basis. basis_list is a subset of full_basis_list. This may be used to automatically increase the input dimension of the approximation.