conv¶
- dnois.fourier.conv(f1: Tensor, f2: Tensor, dims: Sequence[int] = None, spacing: float | Tensor | Sequence[float | Tensor] = None, out: Literal['full', 'same', 'valid'] = 'full', padding: int | Sequence[int] | str = 'linear', simpson: bool = False, real: bool = None) Tensor ¶
Computes continuous convolution for two tensors \(f_1\) and \(f_2\) utilizing FFT. See
dconv()
for more details.This function may use Simpson’s rule to improve accuracy. Specifically, the weights of elements are \(1/3, 4/3, 2/3, 4/3, 2/3, \cdots, 4/3, 1/3\) if the length is odd. If it is even, an additional 1 is appended. It is applied in all involved dimensions of
f1
.See Convolution for examples.
See also
This function is equivalent to
dconv()
whenspacing
isNone
andsimpson
isFalse
.- Parameters:
f1 (Tensor) – The first tensor \(f_1\).
f2 (Tensor) – The second tensor \(f_2\).
dims (Sequence[int]) – The dimensions to be convolved.Default: the last
ndim
dimensions wherendim
is the fewer number of dimensions off1
andf2
spacing (float, Tensor or Sequence[float, Tensor]) – Grid spacings in each dimension. Each element of
spacing
can be a float, a 0D tensor or a tensor broadcastable withf1
andf2
. If not aSequence
, it serves as the spacings for all dimensions. Default: omitted.out (str) – See
dconv()
.padding (int, Sequence[int] or str) – See
dconv()
.simpson (bool) – Whether to apply Simpson’s rule. Default:
True
.real (bool) – See
dconv()
.
- Returns:
Convolution between
f1
andf2
. Complex if eitherf1
orf2
is complex orreal=False
, real-valued otherwise.- Return type:
Tensor