spyrit.core.prep.Unsplit.forward

static Unsplit.forward(y: tensor, mode: str = 'sub') tensor[source]

Preprocess measurements simulated using split measurement operator.

Given measurements \(y\in\mathbb{R}^{2M}\), it computes either \(y_+ - y_-\) or \(y_+ + y_-\). The positive and negative measurements \(y_+\in\mathbb{R}^{M}\) and \(y_-\in\mathbb{R}^{M}\) are given by

\[\begin{split}y_+ = \begin{bmatrix} y[0]\\ y[2]\\ y[2M-2]\\ \end{bmatrix} \quad\text{and}\quad y_- = \begin{bmatrix} y[1]\\ y[3]\\ y[2M-1]\\ \end{bmatrix}.\end{split}\]
Args:

y (torch.tensor): Measurement of shape \((*, 2M)\)

mode (str, optional): ‘sub’ or ‘add’. If ‘sub’, \(y_+ - y_-\) is returned. If ‘add’, \(y_+ + y_-\) is returned. Defaults to ‘sub’.

Returns:

torch.tensor: Preprocessed measurements of shape \((*, M)\).

Example:
>>> import torch
>>> import spyrit.core.meas as meas
>>> import spyrit.core.prep as prep
>>> H = torch.rand([400,32])
>>> img = torch.rand([10,32])
>>> meas_op = meas.LinearSplit(H)
>>> split_op = prep.Unsplit()
>>> y = meas_op(img)
>>> m = split_op(y)
>>> print(y.shape)
torch.Size([10, 800])
>>> print(m.shape)
torch.Size([10, 400])