spyrit.misc.walsh_hadamard.walsh2_S_fold_torch

spyrit.misc.walsh_hadamard.walsh2_S_fold_torch(x)[source]

Fold a signal to get a ā€œ2dā€ s-transformed representation

Note: the top left (first) pixel is arbitrarily set to zero

Args:

x (torch.tensor): input signal with shape (*, n). n is such that n+1 = N*N, where N is a power of two. n = 2**(2b) - 1, where b is an integer.

Returns:

torch.tensor: output matrix with shape (*, N, N)

Example 1:
>>> import spyrit.misc.walsh_hadamard as wh
>>> import torch
>>> S = wh.walsh2_S_matrix(4)
>>> X = torch.from_numpy(S[2:4,:])
>>> Y = wh.walsh2_S_fold_torch(X)
>>> print(Y)
tensor(..., dtype=torch.float64)