WalshHadamard2D.py 🚧¢

Source: LION/operators/WalshHadamard2D.py

Warning

This file has not yet received a complete narrative and docstring audit. Its public source-level API is listed automatically below.

Walsh-Hadamard Transform 2D Operator.

class WalshHadamard2D(height: int, width: int, device: str | torch.device | None = None)

Walsh-Hadamard Transform operator.

Parameters β€”β€”β€”- height : int Height of the 2D input vector. Must be a power of two. width : int Width of the 2D input vector. Must be a power of two. device : str or torch.device Device where tensors are placed.

WalshHadamard2D.forward(self, x: torch.Tensor) torch.Tensor

Apply the Walsh-Hadamard Transform.

Note

Prefer calling the instance of the WalshHadamard2D operator as operator(x) over directly calling this method. See this PyTorch discussion.

WalshHadamard2D.adjoint(self, y: torch.Tensor) torch.Tensor

Apply the adjoint of the Walsh-Hadamard Transform.

Parameters β€”β€”β€”- y : torch.Tensor Input vector of shape (N,).

Returns β€”β€”- torch.Tensor Adjoint transformed vector of shape (height, width).

WalshHadamard2D.inverse(self, y: torch.Tensor) torch.Tensor

Apply the pseudo-inverse of the Walsh-Hadamard Transform.

Parameters β€”β€”β€”- y : torch.Tensor Input vector of shape (N,).

Returns β€”β€”- torch.Tensor Pseudo-inverse transformed vector of shape (N,).

WalshHadamard2D.domain_shape(self) tuple[int, ...]

Return the shape of the input domain.

WalshHadamard2D.range_shape(self) tuple[int, ...]

Return the shape of the output range.