Source code for kitpylib.PyMath.spf2d

'''A module for 2d special functions.'''
import numpy as np

[docs] def tri2d(x): '''The 2d triangle function.''' return np.where(abs(x) >= 1, 0, 1-abs(x))
[docs] def ramp2d(x): '''The 2d ramp function.''' return np.where(x > 0, abs(x), 0)
[docs] def rect2d(x): '''The 2d rectangle function.''' return np.where(abs(x) > 0.5, 0, np.where(abs(x) == 0.5, 0.5, 1))
[docs] def sign2d(x): '''The 2d sign function.''' return np.where(x < 0, -1, np.where(x == 0, 0, 1))
[docs] def step2d(x): '''The 2d step function.''' return np.where(x < 0, 0, np.where(x == 0, 0.5, 1))
[docs] def gaus2d(x): '''The 2d Gaussian Function.''' return np.exp(-np.pi*x**2)
[docs] def sinc2d(x): '''The 2d sinc function.''' return np.where(x == 0, 1, np.sin(x)/x)