spyrit.core.meas.HadamSplit2d.measure
- HadamSplit2d.measure(x: tensor) tensor[source]
Simulate noiseless measurements from matrix A.
It computes
\[y =\mathcal{S}\left(AXA^T\right),\]where \(\mathcal{S} \colon\, \mathbb{R}^{2h\times 2h} \to \mathbb{R}^{2M}\) is the subsampling operator, \(A \colon\, \mathbb{R}_+^{2h\times h}\) is the acquisition matrix that contains the positive and negative component of 2D Hadamard patterns, \(X \in \mathbb{R}^{h\times h}\) is the (2D) image, \(2M\) is the number of DMD patterns, and \(h\) is the image size.
- Args:
x(torch.tensor): Image \(X\) whose dimensionsself.meas_dimsmust have shape shapeself.meas_shape.- Returns:
Measurement vector \(y \in \mathbb{R}^{2M}\).
- Examples:
Example 1: No subsampling
>>> import torch >>> import spyrit.core.meas as meas >>> h = 32 >>> Ord = torch.randn(h, h) >>> meas_op = meas.HadamSplit2d(h) >>> x = torch.empty(10, h, h).uniform_(0, 1) >>> y = meas_op.measure(x) >>> print(y.shape) torch.Size([10, 2048])
Example 2: With subsampling
>>> import torch >>> import spyrit.core.meas as meas >>> h = 32 >>> Ord = torch.randn(h, h) >>> meas_op = meas.HadamSplit2d(h, 49) >>> x = torch.empty(8, 2, h, h).uniform_(0, 1) >>> y = meas_op.measure_H(x) >>> print(y.shape) torch.Size([8, 2, 49])