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() when spacing is None and simpson is False.

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 where ndim is the fewer number of dimensions of f1 and f2

  • 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 with f1 and f2. If not a Sequence, 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 and f2. Complex if either f1 or f2 is complex or real=False, real-valued otherwise.

Return type:

Tensor