StepExpansion#

class cuqi.geometry.StepExpansion(grid, n_steps=3, fun2par_projection='mean', **kwargs)#

Class representation of step functions (piecewise constant functions) with n_steps equidistant steps on the interval [x0, xn], with both endpoints included. The function par2fun maps the parameters p (which are the step magnitudes) to the corresponding step function evaluated on the spatial grid (grid) of nodes x0, x1, …xn.

For example, if n_steps is 3 and grid is a uniform grid on [0, L] with nodes x0=0, x1=0.1L, …, xn=L, then the resulting function evaluated on the grid will be p[0], if x<=L/3, p[1], if L/3<x<=2L/3, p[2], if 2L/3<x<=L.

Parameters:
  • grid (ndarray) –

    Regular grid points for the step expansion to be evaluated at. The number of grid points should be equal to or larger than n_steps. The latter setting can be useful, for example, when using the StepExpansion geometry as a domain geometry for a cuqipy Model that expects the input to be interpolated on a (possibly fine) grid (grid). The interval endpoints, [x0, xn], should be included in the grid.

  • n_steps (int) –

    Number of equidistant steps.

  • fun2par_projection (str, default 'mean') –

    Projection of the step function (evaluated on the grid) on the parameter space. The supported projections are
    ’mean’: the parameter p[i] value will be the average of the function values at the nodes that falls in the interval I=(x0+i*L/n_steps, x0+(i+1)*L/n_steps].
    ’max’: the parameter p[i] value will be the maximum of the function values in I.
    ’min’: the parameter p[i] value will be the minimum of the function values in I.

  • kwargs (keyword arguments) –

    keyword arguments are passed to the initializer of Continuous1D

__init__(grid, n_steps=3, fun2par_projection='mean', **kwargs)#

Methods

__init__(grid[, n_steps, fun2par_projection])

fun2par(f)

The function to parameter map used to map function values back to parameters, if available.

fun2vec(funvals)

Maps function values to a vector representation of the function values, if available.

par2fun(p)

The parameter to function map used to map parameters to function values in e.g. plotting.

plot(values[, is_par, plot_par])

Plots a function over the set defined by the geometry object.

plot_envelope(lo_values, hi_values[, ...])

Plots an envelope from lower and upper bounds over the set defined by the geometry object.

vec2fun(funvec)

Maps function vector representation, if available, to function values.

Attributes

fun_dim

The dimension of the geometry (function space).

fun_is_array

Flag to indicate whether the function value is an array.

fun_shape

The shape of the geometry (function space).

funvec_dim

The dimension of the geometry (dimension of the vector representation of the function value).

funvec_shape

The shape of the geometry (shape of the vector representation of the function value).

grid

n_steps

Number of equidistant steps.

par_dim

The dimension of the geometry (parameter space).

par_shape

Shape of the parameter space.

variables