concrete — Concrete linear operators¶
Basic operators¶
- class Identity(shape: tuple[int, ...], name: str = 'I')[source]¶
Bases:
LinOpIdentity operator of specific shape.
- Parameters:
- asmatrix(like: Array | None = None) Array[source]¶
Return the matrix corresponding to the linear operator.
Applies forward to N unit vectors where N = linop.isize.
- Parameters:
like (Array, optional) – If provided, use its array namespace; otherwise use float64 numpy array. See guide.
- Returns:
2D array of shape
(osize, isize).- Return type:
Array
Notes
Can be very heavy depending on the size of the operator.
- class Diag(diag: Array, name: str = 'D')[source]¶
Bases:
LinOpDiagonal operator.
- Parameters:
diag (Array) – The diagonal values. Input and output have the same shape as diag. The array namespace is inferred from this array.
name (str, optional) – Name of the operator.
- fwadj(point: Array) Array[source]¶
Apply Aᴴ·A to point.
- Parameters:
point (Array) – Input array of shape
ishape.- Returns:
Output array of shape
ishape.- Return type:
Array
- asmatrix(like: Array | None = None) Array[source]¶
Return the matrix corresponding to the linear operator.
Applies forward to N unit vectors where N = linop.isize.
- Parameters:
like (Array, optional) – If provided, use its array namespace; otherwise use float64 numpy array. See guide.
- Returns:
2D array of shape
(osize, isize).- Return type:
Array
Notes
Can be very heavy depending on the size of the operator.
Fourier transforms¶
- class DFT(shape: tuple[int, ...], ndim: int, name: str = 'DFT')[source]¶
Bases:
LinOpDiscrete Fourier Transform on the last N axes.
- Parameters:
Convolutions¶
- class Conv(ir: Array, ishape: tuple[int, ...], dim: int, name: str = 'Conv')[source]¶
Bases:
LinOpND convolution on the last N axes.
Does not assume a periodic or circular boundary condition.
- Parameters:
ir (Array) – The impulse response. Must have at least dim dimensions. The array namespace is inferred from this array.
ishape (tuple of int) – The shape of the input. Images are on the last dim axes.
dim (int) – Number of last axes over which convolution applies.
name (str, optional) – Name of the operator.
- imp_resp¶
The impulse response.
- Type:
Array
- freq_resp¶
The frequency response.
- Type:
Array
Notes
Uses FFT internally for fast computation. The forward method is equivalent to “valid” boundary condition and adjoint is equivalent to “full” boundary condition with zero filling.
Uses the array namespace of the impulse response.
- class DirectConv(ir: Array, ishape: tuple[int, ...], name: str = 'DConv')[source]¶
Bases:
LinOpDirect convolution.
The convolution is performed on the last N axes where N = ir.ndim.
- Parameters:
Notes
Numpy-only. Uses scipy.signal.oaconvolve (Overlap-Add method), which is generally faster than FFT-based convolution when one array is much larger than the other. Requires scipy.
- property ir: Array¶
The impulse response.
- class FreqFilter(ir: Array, ishape: tuple[int, ...], name: str = 'Filter')[source]¶
Bases:
DiagFrequency filter in Fourier space.
- Parameters:
- diag¶
The frequency response of the filter.
- Type:
Array
Notes
Almost like diagonal but assumes a complex Fourier space and is defined by an impulse response. If you have the frequency response, just use Diag.
- class CircConv(imp_resp: Array, shape: tuple[int, ...], name: str = 'CConv')[source]¶
Bases:
LinOpCirculant (periodic) convolution.
- Parameters:
- imp_resp¶
The impulse response.
- Type:
Array
- property freq_resp: Array¶
The frequency response.
- class Diff(axis: int, ishape: tuple[int, ...], name: str = 'Diff')[source]¶
Bases:
LinOpDifference operator.
Compute the first-order differences along an axis.
- Parameters:
Other operators¶
- class Sampling(ishape: tuple[int, ...], index: tuple)[source]¶
Bases:
LinOpSampling operator using numpy fancy indexing.
Numpy-only. Index is a tuple of index arrays as in numpy fancy indexing.
- Parameters:
- class Slice(ishape: tuple[int, ...], idx: tuple)[source]¶
Bases:
LinOpEquivalent to obj[::2, 1, …] etc.
- Parameters:
See also
Samplingwhen you have an array of indices that can handle multiple sampling of the same value.
Notes
Use np.index_exp to build the idx argument.
Examples
>>> s = Slice((10, 10), idx=np.index_exp[::2, 1]) >>> y = s.forward(np.empty((10, 10))) # shape (5,) >>> x = s.adjoint(y) # shape (10, 10)
Wavelet operators¶
- class DWT(shape: tuple[int, ...], level: int | None = None, wavelet: str = 'haar', name: str = 'DWT')[source]¶
Bases:
LinOpUnitary Discrete Wavelet Transform.
- Parameters:
Notes
NumPy-only. Uses pywt internally.
- class Analysis2(shape: tuple[int, int], level: int, wavelet: str = 'haar', name: str = 'A')[source]¶
Bases:
LinOp2D analysis operator with stationary wavelet decomposition.
- Parameters:
Notes
NumPy-only. Uses pywt internally. The output is a 3D array where the first axis is the coefficient axis, with the approximation coefficients at index 0 and the detail coefficients at indices 1 to 3*level. The second and third axes are the spatial axes. See pywt.swt2 documentation for more details on the output format.