spyrit.misc.walsh_hadamard.ifwalsh_S_torch

spyrit.misc.walsh_hadamard.ifwalsh_S_torch(s, ind=True)[source]

Inverse Fast Walsh S-transform of x

Args:

x (torch.tensor): input signal with shape (*, n), where n+1 should be a power of two.

ind (bool, optional): True for sequency (default)

ind (list, optional): permutation indices. This is faster than True when repeating the sequency-ordered transform multilple times.

Returns:

torch.tensor: -by-n S-transformed signal

Examples:

Example 1: Inverse Walsh-ordered S-transform of a signal of length 7

>>> import spyrit.misc.walsh_hadamard as wh
>>> import torch
>>> x = torch.tensor([12., 9, 9, 16, 4, 5, 9])
>>> s = wh.ifwalsh_S_torch(x)
>>> print(s)
tensor([ 1.,  3., -0., -1.,  7.,  5.,  1.])

Example 2: Check the inverse of the direct transform of a signal of length 7

>>> import spyrit.misc.walsh_hadamard as wh
>>> import torch
>>> x = torch.tensor([12., 9, 9, 16, 4, 5, 9])
>>> s = wh.fwalsh_S_torch(wh.ifwalsh_S_torch(x))
>>> print(s-x)
tensor([0., 0., 0., 0., 0., 0., 0.])

Example 3: Inverse Walsh-ordered S-transform of 2 signals of length 7

>>> import spyrit.misc.walsh_hadamard as wh
>>> import torch
>>> x = torch.tensor([[1, 3, 0, -1, 7, 5, 1],[12., 9, 9, 16, 4, 5, 9]])
>>> s = wh.ifwalsh_S_torch(x)
>>> print(s)
tensor([[ 2.0000,  0.5000,  0.5000,  4.0000, -2.0000, -1.5000,  0.5000],
        [ 1.0000,  3.0000, -0.0000, -1.0000,  7.0000,  5.0000,  1.0000]])