spyrit.core.meas.HadamSplit2d.measure_H

HadamSplit2d.measure_H(x: tensor)[source]

Simulate noiseless measurements from matrix H.

It computes

\[m =\mathcal{S}\left(HXH^T\right),\]

where \(\mathcal{S} \colon\, \mathbb{R}^{h\times h} \to \mathbb{R}^{M}\) is the subsampling operator, \(H \colon\, \mathbb{R}^{h\times h}\) is the Hadamard matrix, \(X \in \mathbb{R}^{h\times h}\) is the (2D) image.

Args:

x (torch.tensor): Image \(X\) whose dimensions self.meas_dims must have shape shape self.meas_shape.

Returns:

Measurement vector \(m \in \mathbb{R}^{M}\).

Examples:

Example 1: No subsampling

>>> import torch
>>> import spyrit.core.meas as meas
>>> h = 32
>>> meas_op = meas.HadamSplit2d(h)
>>> x = torch.empty(h, h).uniform_(0, 1)
>>> y = meas_op.measure(x)
>>> print(y.shape)
torch.Size([2048])

Example 2: With subsampling

>>> import torch
>>> import spyrit.core.meas as meas
>>> h = 32
>>> meas_op = meas.HadamSplit2d(h, 49)
>>> x = torch.empty(8, 2, h, h).uniform_(0, 1)
>>> y = meas_op.measure(x)
>>> print(y.shape)
torch.Size([8, 2, 98])