spyrit.misc.walsh_hadamard.iwalsh_S
- spyrit.misc.walsh_hadamard.iwalsh_S(s, T=None)[source]
Return the inverse Walsh S-transform of the signal x
- Args:
x(np.ndarray): signals of shape (*,n), where n+1 must be a power of two.H(np.ndarray, optional): Inverse S-matrix of order n.- Returns:
np.ndarray: S-transformed signal of shape (*,n).
- Examples:
Example 1: Inverse Walsh-ordered S-transform of a signal of length 7
>>> import spyrit.misc.walsh_hadamard as wh >>> s = np.array([12, 9, 9, 16, 4, 5, 9]) >>> x = wh.iwalsh_S(s) >>> print(x) [ 1. 3. 0. -1. 7. 5. 1.]
Example 2: Walsh-ordered S-transform of two signals of length 7
>>> s = np.array([[12, 9, 9, 16, 4, 5, 9],[12, 4, 8, 12, 6, 6, 8]]) >>> x = wh.iwalsh_S(s) >>> print(x) [[ 1. 3. 0. -1. 7. 5. 1.] [ 2. 1. -1. 0. 4. 5. 3.]]
Example 3: Foroward and inverse S-transform of two signals of length 4095
>>> import spyrit.misc.walsh_hadamard as wh >>> import numpy as np >>> x = np.random.rand(2,4095) >>> s = wh.walsh_S(x) >>> y = wh.iwalsh_S(s) >>> err = np.linalg.norm(1-y/x) >>> print(f'Error: {err}') Error: ...e-... >>> print(err < 1e-5) True