# odak.learn.wave.custom¶

A definition to calculate convolution based Fresnel approximation for beam propagation.

Parameters:

Name Type Description Default
field torch.complex

Complex field (MxN).

required
kernel torch.complex

Custom complex kernel for beam propagation.

required

Returns:

Type Description
torch.complex

Final complex field (MxN).

Source code in odak/learn/wave/classical.py
def custom(field, kernel, zero_padding = False):
"""
A definition to calculate convolution based Fresnel approximation for beam propagation.

Parameters
----------
field            : torch.complex
Complex field (MxN).
kernel           : torch.complex
Custom complex kernel for beam propagation.

Returns
-------
result           : torch.complex
Final complex field (MxN).

"""
if type(kernel) == type(None):
H = torch.zeros(field.shape).to(field.device)
else:
H = kernel
U1 = torch.fft.fftshift(torch.fft.fft2(torch.fft.fftshift(field)))

Unless you know what you are doing, we do not suggest you to use this function directly. Rather stick to odak.learn.wave.propagate_beam for your beam propagation code. Note that this function can also be used as convolution operation between two complex arrays.