Skip to content

Commit d270ed2

Browse files
shyams2pavanky
authored andcommitted
Added interp1d
1 parent 0216e82 commit d270ed2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

arrayfire/signal.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,40 @@ def approx2(signal, pos0, pos1, method=INTERP.LINEAR, off_grid=0.0):
9494
pos0.arr, pos1.arr, method.value, c_float_t(off_grid)))
9595
return output
9696

97+
def interp1d(x_interpolated, x_input, signal_input, method=INTERP.LINEAR, off_grid=0.0):
98+
"""
99+
One-dimensional linear interpolation.Interpolation is performed along axis 0.
100+
101+
Parameters
102+
----------
103+
104+
x : af.Array
105+
The x-coordinates of the interpolated values. The interpolation function
106+
is queried at these set of points.
107+
108+
x : af.Array
109+
The x-coordinates of the data points
110+
111+
signal_input: af.Array
112+
Input signal array(uniform data)
113+
114+
method: optional: af.INTERP. default: af.INTERP.LINEAR.
115+
Interpolation method.
116+
117+
off_grid: optional: scalar. default: 0.0.
118+
The value used for positions outside the range.
119+
120+
Returns
121+
-------
122+
123+
output: af.Array
124+
Values calculated at interpolation points.
125+
"""
126+
dx = sum(x_input[1, 0, 0, 0] - x_input[0, 0, 0, 0])
127+
pos0 = (x_interpolated - sum(x_input[0, 0, 0, 0]))/dx
128+
129+
return approx1(signal_input, pos0, method, off_grid)
130+
97131
def fft(signal, dim0 = None , scale = None):
98132
"""
99133
Fast Fourier Transform: 1D

0 commit comments

Comments
 (0)