Closed albop closed 5 years ago
Regarding the allocation of output, it's probably best to not worry about it or implement it with a keyword interp(x,y,u,out=)
. That way the function can be generalized naturally to many dimensions with scalar or vector values: interp(x1,x2,x3,y,u)
and interp(x1,x2,x3,y,u, out=...)
This could be implemented in a new file
splines/linear.py
.Proposed api would be
interp(x,y,u)
(similar to scipy's version). It would interpolate the function given byy=f(x)
at pointu
. Ifu
is a scalar the output is a scalar. Ifu
is a vector then output is a vector too.One could extend it to vector valued function: if
y
is a 2d array, the function to interpolate would be such thatf(x[i])=y[i,:]
. Consequently the outputout
would be a vector ifu
is a scalar (without.shape[0]==y.shape[1]
) and a matrix if u is a vector (without.shape==(u.shape[0],y.shape[1])
)Maybe it would be a good idea to implement first an inplace version
interp(x,y,u,out)
that doesn't allocate output.