pyffs.util

Helper functions.

ffs_sample(T, N_FS, T_c, N_s, mod=None)[source]

Signal sample positions for ffs().

Return the coordinates at which a signal must be sampled to use ffs().

Parameters
  • T (float) – Function period.

  • N_FS (int) – Function bandwidth.

  • T_c (float) – Period mid-point.

  • N_s (int) – Number of samples.

  • mod (func) – Module to be used to process array (numpy or cupy).

Returns

  • sample_point (ndarray) – (N_s,) coordinates at which to sample a signal (in the right order).

  • idx (ndarray) – (N_s,) index array; could be used to reorder samples.

Examples

Let \(\phi: \mathbb{R} \to \mathbb{C}\) be a bandlimited periodic function of period \(T = 1\), bandwidth \(N_{FS} = 5\), and with one period centered at \(T_{c} = \pi\). The sampling points \(t[n] \in \mathbb{R}\) at which \(\phi\) must be evaluated to compute the Fourier Series coefficients \(\left\{ \phi_{k}^{FS}, k = -2, \ldots, 2 \right\}\) with ffs() are obtained as follows:

# Ideally choose N_s to be highly-composite for ffs().
>>> sample_points, idx = ffs_sample(T=1, N_FS=5, T_c=np.pi, N_s=8)
>>> np.around(sample_points, 2)  # Notice points are not sorted.
array([3.2 , 3.33, 3.45, 3.58, 2.7 , 2.83, 2.95, 3.08])
>>> idx
array([4, 5, 6, 7, 0, 1, 2, 3])

See also

ffs()

ffsn_sample(T, N_FS, T_c, N_s, mod=None)[source]

Signal sample positions for ffsn().

Return the coordinates at which a signal must be sampled to use ffsn().

Parameters
  • T (list(float)) – Function period along each dimension.

  • N_FS (list(int)) – Function bandwidth along each dimension.

  • T_c (list(float)) – Period mid-point for each dimension.

  • N_s (list(int)) – Number of sample points for each dimension.

  • mod (func) – Module to be used to process array (numpy or cupy).

Returns

  • S0, …, SD (list(ndarray)) – (N_D,) coordinates at which to sample a signal in the d-th dimension (in the right order).

  • i1, …, iD (list(ndarray)) – (N_D,) sample indices in the d-th dimension. May be useful to reorder samples.

Examples

Let \(\phi: \mathbb{R}^2 \to \mathbb{C}\) be a bandlimited periodic function with periods \(T_x = 1\) and \(T_y = 1\), bandwidths \(N_{FS,x} = 3\) and \(N_{FS,y} = 3\), and with one period centered at \((T_{c,x}, T_{c,y}) = (0, 0)\). The sampling points \([x[m], y[n]] \in \mathbb{R}^2\) at which \(\phi\) must be evaluated to compute the Fourier Series coefficients \(\left\{ \phi_{k_x, k_y}^{FS}, k_x, k_y = -1, \ldots, 1 \right\}\) with ffsn() are obtained as follows:

# Ideally choose number of samples to be highly-composite for ffsn().
>>> sample_points, idx = ffsn_sample(T=[1, 1], N_FS=[3, 3], T_c=[0, 0], N_s=[4, 3])
>>> assert_array_equal(sample_points[0][:, 0], np.array([0.125, 0.375, -0.375, -0.125]))
>>> assert_array_equal(sample_points[1][0, :], np.array([0, 1 / 3, -1 / 3]))
>>> assert_array_equal(idx[0][:, 0], np.array([2, 3, 0, 1]))
>>> assert_array_equal(idx[1][0, :], np.array([1, 2, 0]))

See also

ffsn()