Dimension creation functions

Dimension creation functions#

dim(name: str, n: int, d_pos: float, pos_min: float, freq_min: float, *, dynamically_traced_coords: bool = False) Dimension[source]#

Initialize a Dimension firectly from the parameters which are stored internally.

Parameters:
  • name (str) – Name of the dimension.

  • n (int) – Number of grid points.

  • d_pos (float) – Distance between two neighboring position grid points.

  • pos_min (float) – Smallest position grid point.

  • freq_min (float) – Smallest frequency grid point

  • dynamically_traced_coords (bool, optional) – Only relevant for use with JAX tracing. Whether the coordinate values should be dynamically traced such that the grid can be altered inside a jitted function, by default False. See also Working with JAX.

Returns:

Initialized Dimension.

Return type:

Dimension

See also

Dimension

dim_from_constraints(name: str, *, n: int | Literal['power_of_two', 'even'] = 'power_of_two', d_pos: float | None = None, d_freq: float | None = None, pos_min: float | None = None, pos_max: float | None = None, pos_middle: float | None = None, pos_extent: float | None = None, freq_min: float | None = None, freq_max: float | None = None, freq_extent: float | None = None, freq_middle: float | None = None, loose_params: str | List[str] | None = None, dynamically_traced_coords: bool = False) Dimension[source]#

Creates a Dimension from an arbitrary subset of all possible grid parameters using the z3 constraint solver. Note that the specified grid parameters must lead to a unique solution that fulfill the following constraints:

pos_extent = pos_max - pos_min
pos_middle = 0.5 * (pos_min + pos_max + d_pos)
d_pos = pos_extent/(n-1)

freq_extent = freq_max - freq_min
freq_middle = 0.5 * (freq_max + freq_min + d_freq)
d_freq = freq_extent/(n-1)

d_freq * d_pos * n = 1.

If n is not directly specified an exact solution of this constraint system leads in general to a n which is not a natural number. In that case n is rounded up according to the rounding mode. In order to do this some other constraint has to be improved. The constraints which are allowed to change for rounding up are given in loose_params. The value of d_pos, d_freq, pos_min and freq_min would be made smaller while the value of pos_max, pos_extent, freq_max and freq_extent would be made larger. pos_middle and freq_middle do not influence n and are therefore not allowed as parameters in loose_prams.

Parameters:
  • name (str) – Name identifying the dimension.

  • n (int | Literal['power_of_two', 'even']) – Number of grid points, either a natural number or the rounding mode, by default “power_of_two”

  • d_pos (float | None) – Distance between two neighboring position grid points, by default None

  • d_freq (float | None) – Distance between two neighboring frequency grid points, by default None

  • pos_min (float | None) – Smallest position grid point, by default None

  • pos_max (float | None) – Largest position grid point, by default None

  • pos_middle (float | None) – Middle of the position grid, by default None

  • pos_extent (float | None) – Length of the position grid, by default None

  • freq_min (float | None) – Smallest frequency grid point, by default None

  • freq_max (float | None) – Largest frequency grid point, by default None

  • freq_extent (float | None) – Length of the frequency grid, by default None

  • freq_middle (float | None) – Middle of the frequency grid, by default None

  • loose_params (str | List[str] | None) – List of loose grid parameters (parameters that can be changed by the constraint solver when rounding up n to be even or a power of two), by default None

  • dynamically_traced_coords (bool) – Only relevant for use with JAX tracing. Whether the coordinate values should be dynamically traced such that the grid can be altered inside a jitted function, for more details see Working with JAX, by default False

Returns:

Dimension initialized using the constraints solved via the z3 constraint solver.

Return type:

Dimension

See also

Dimension