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 lengthself.M.vectorize(bool, optional): If True, returns the flat vector ofself.Nreconstructed masked pixels. If False (default), returns the reconstruction expanded back to the fullself.meas_shapeviaunvectorize(), with unmasked pixels set tofill_value.fill_value(Any, optional): Fill value for pixels outside the mask, used only whenvectorizeis False. Defaults to 0.- Returns:
torch.tensor: The reconstructed signal, either as a flat vector of lengthself.N(vectorize= True) or expanded toself.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 whenself.Mequalsself.N(no subsampling); with subsampling, it is an approximation. This holds for both values ofcomputation.