spyrit.core.meas.FreeformSmatrix.fast_pinv

FreeformSmatrix.fast_pinv(m: tensor, vectorize: bool = False, fill_value: Any = 0) tensor[source]

Apply the pseudo-inverse of the S measurement matrix.

Depending on self.computation, this uses either a dense matrix-vector product with the exact inverse S-matrix, or the fast (inverse) Walsh-Hadamard-based transform (see the class docstring note for the tradeoff).

Args:

m (torch.tensor): Measurement \(m\) of length self.M.

vectorize (bool, optional): If True, returns the flat vector of self.N reconstructed masked pixels. If False (default), returns the reconstruction expanded back to the full self.meas_shape via unvectorize(), with unmasked pixels set to fill_value.

fill_value (Any, optional): Fill value for pixels outside the mask, used only when vectorize is False. Defaults to 0.

Returns:

torch.tensor: The reconstructed signal, either as a flat vector of length self.N (vectorize = True) or expanded to self.meas_shape (vectorize = False).

Note

If the number of measurements is smaller than the number of masked pixels, the measurement vector is zero-padded (dense) or zero-scattered into the correct positions (dyadic) before inversion – the two are mathematically equivalent. As with HadamSmatrix2d.fast_pinv(), this reconstruction is exact only when self.M equals self.N (no subsampling); with subsampling, it is an approximation. This holds for both values of computation.