Skip to the content.

Specification of the Implemented Fastsum Functions and Classes

Back to: Main Page, Overview of Fast Kernel Summation

We describe all attributes of the basic classes and functions from the fastsum-related objects.

simple_torch_NFFT.Fastsum

The Fastsum class inherits from torch.nn.Module. A Fastsum object can be created with

from simple_torch_NFFT import Fastsum

fastsum = Fastsum(dim, kernel="Gauss", kernel_params=dict(), slicing_mode="iid", n_ft=None, nfft=None, x_range=0.3, batch_size_P=None, batch_size_nfft=None, device="cuda" if torch.cuda.is_available() else "cpu", no_compile=False, batched_autodiff=True)

with required argument

and optional keyword arguments

The forward method is given by

s = fastsum(x, y, x_weights, scale, xis_or_P) # coincides with fastsum.forward(x, y, x_weights, scale, xis_or_P)

with required arguments:

and output

Finally, the Fastsum object has a method

s = fastsum.naive(x, y, x_weights, scale)

where the arguments x, y, x_weights and scale and the output s are the same as in the forward method. It computes the kernel sum naively. If it is installed, the package pykeops is used (otherwise a naive torch implementation).

simple_torch_NFFT.fastsum.get_median_distance

A small helper function for computing kernel parameters by the median rule. The function can be called by

from simple_torch_NFFT.fastsum import get_median_distance

median = get_median_distance(x, y, batch_size=1000)

It computes the median distance $\|x_n-y_m\|$ for the given input points x and y. Since this can be very expansive when the number of points is large, we first subsample batch_size points from x and y and compute the median distance based on this subset. More precisely, we have the following input arguments: