komm.sampling_rate_expand
Performs sampling rate expansion (upsampling). For a given input $x[n]$, the output is $$ y[n] = \begin{cases} x[n \operatorname{div} L] & \text{if } n \bmod L = \Delta, \\ 0, & \text{otherwise} \end{cases} $$ where $L$ is the expansion factor and $\Delta \in [0:L)$ is the offset for the first output element. In words, the expander inserts $L-1$ zeros between each element of the input array along the specified axis, starting from the offset $\Delta$. For more details, see OS99, Sec. 4.6.2.
Parameters:
-
input
(ArrayLike
) –The input array $x[n]$ to be expanded.
-
factor
(int
) –The expansion factor $L$.
-
offset
(int
) –The offset $\Delta$. Must satisfy $\Delta \in [0:L)$.
-
axis
(int
) –The axis along which to insert zeros. Default is the last axis.
Returns:
-
output
(NDArray[Any]
) –The expanded array $y[n]$.
Examples:
>>> komm.sampling_rate_expand([[1, 2], [3, 4]], factor=3)
array([[1, 0, 0, 2, 0, 0],
[3, 0, 0, 4, 0, 0]])
>>> komm.sampling_rate_expand([[1, 2], [3, 4]], factor=3, offset=1)
array([[0, 1, 0, 0, 2, 0],
[0, 3, 0, 0, 4, 0]])
>>> komm.sampling_rate_expand([[1, 2], [3, 4]], factor=3, axis=0)
array([[1, 2],
[0, 0],
[0, 0],
[3, 4],
[0, 0],
[0, 0]])