spyrit.core.meas.Linear.measure

Linear.measure(x: tensor) tensor[source]

Simulate noiseless measurements

\[m = Hx,\]

where \(H\in\mathbb{R}^{M\times N}\) is the acquisition matrix, \(x \in \mathbb{R}^N\) is the signal of interest, \(M\) is the number of measurements, and \(N\) is the dimension of the signal.

Note

This method does not degrade measurement with noise. To do so, see forward()

Args:

x (torch.tensor): A batch of signals \(x\). The dimensions indexed by self.meas_dims must match the measurement shape self.meas_shape.

Returns:

torch.tensor: A batch of measurement of shape \((*, M)\) where * denotes all the dimensions of the input tensor that are not included in self.meas_dims.

Example:

(3, 4) signals of length 15 are measured with an acquisition matrix of shape (10, 15). This produces (3, 4) measurements of length 10.

>>> H = torch.randn(10, 15)
>>> meas_op = Linear(H)
>>> x = torch.randn(3, 4, 15)
>>> y = meas_op.measure(x)
>>> print(y.shape)
torch.Size([3, 4, 10])

3 signals of length (15, 4) are measured with an acquisition matrix of shape (10, 60). This produces 3 measurements of length 10. The acquisition matrix applies to both dimensions -2 and -1.

>>> H = torch.randn(10, 60)
>>> meas_op = Linear(H, meas_shape=(15, 4))
>>> x = torch.randn(3, 15, 4)
>>> y = meas_op.measure(x)
>>> print(y.shape)
torch.Size([3, 10])
>>> print(meas_op.meas_dims)
torch.Size([-2, -1])