<< gpuInterp sciGPGPU gpuLoadFunction >>

sciGPGPU >> sciGPGPU > gpuInterp2d

gpuInterp2d

Cubic spline (2d) evaluation function.

Call sequence

[zp[,dzpdx,dzpdy[,d2zpdxx,d2zpdxy,d2zpdyy]]] = gpuInterp2d(xp,yp,x,y,C [,out_mode])

Parameters

xp, yp

Real vectors or matrices of same size.

Can be :

Real vector or matrix stored in device memory (GPU).

Real vector or matrix stored in host memory (CPU).

x, y, C

Real vector or matrix of same size defining a cubic spline or sub-spline function.(called s in the following)

x and y must be strictly increasing and a size more or equal to 2.

These parameters can be stored in host memory (CPU) or in device memory (GPU).

out_mode

String defining the evaluation of s outside the [x1,xn] interval. (optional)

zp

Vector or matrix of same size than xp and yp, elementwise evaluation of s on these points.

dyp is stored on device memory (GPU)

dzpdx, dzpdy

Vectors or matrices of same size than xp and yp, elementwise evaluation of the first derivatives of s on these points.

dzpdx, dzpdy are stored on device memory (GPU)

d2zpdxx, d2zpdxy, d2zpdyy

Vectors or matrices of same size than xp and yp, elementwise evaluation of the second derivatives of s on these points.

d2zpdxx, d2zpdxy, d2zpdyy are stored on device memory (GPU)

Description

gpuInterp2d performs the same operation as Scilab function interp2d. The out_mode argument is the same as the Scilab function interp2d.

Exemples

n = 7;  // a n x n interpolation grid
x = linspace(0,2*%pi,n); y = x;
z = cos(x')*cos(y);
C = splin2d(x, y, z, "periodic");

// now evaluate on a bigger domain than [0,2pi]x [0,2pi]
m = 80; // discretisation parameter of the evaluation grid
xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
[XX,YY] = ndgrid(xx,yy);

zz1 = interp2d(XX,YY, x, y, C, "C0");
zz2 = interp2d(XX,YY, x, y, C, "by_zero");

gpuzz1 = gpuInterp2d(XX,YY, x, y, C, "C0");
dzz1 = gpuGetData(gpuzz1); gpuFree(gpuzz1);
gpuzz2 = gpuInterp2d(XX,YY, x, y, C, "by_zero");
dzz2 = gpuGetData(gpuzz2); gpuFree(gpuzz2);

//************ show all result ************/
clf()
subplot(2,2,1)
plot3d(xx, yy, zz1, flag=[2 6 4])
xtitle("extrapolation using CPU with the C0 outmode")
subplot(2,2,3)
plot3d(xx, yy, zz2, flag=[2 6 4])
xtitle("extrapolation using CPU with the by_zero outmode")

subplot(2,2,2)
plot3d(xx, yy, dzz1, flag=[2 6 4])
xtitle("extrapolation using GPU with the C0 outmode")
subplot(2,2,4)
plot3d(xx, yy, dzz2, flag=[2 6 4])
xtitle("extrapolation using GPU with the by_zero outmode")

show_window()

See Also

<< gpuInterp sciGPGPU gpuLoadFunction >>