About News Download Benchmark Documentation FAQ Links

Uniform splines

Spline creation

Each B-spline object type has an associated creation routine, to the user must pass the dimensions of the data, the boundary conditions to use, and a pointer to the mesh data.

Base data types

Each spline creation and evaluation routines have four versions, corresponding to the four support base data types. Following the LAPACK naming convention, these types are specified by single-letter codes:

Grid dimensions

The uniform grid structure, has the following elements, which must be specified:

Boundary conditions

The boundary conditions at the first and last grid point must be specified. They are specifed with BCtype_x structures, where x is one of {s, d, c, z}, as described above. For the real types (s and d) the structure contains the following elements
Type Name Description
bc_code lCode "left" boundary condition code
bc_code lCode "right" boundary condition code
d_type lVal "left" boundary condition value
d_type rVal "right" boundary condition value
BCtype_s and BCtype_d data structure elements
For the complex types, we must specify both the real and imaginary parts:
Type Name Description
bc_code lCode "left" boundary condition code
bc_code lCode "right" boundary condition code
d_type lVal_r "left" boundary condition real part
d_type lVal_i "left" boundary condition imag part
d_type rVal_r "right" boundary condition real part
d_type rVal_i "right" boundary condition imag part
BCtype_s and BCtype_d data structure elements

lCode and lVal specify the boundary conditions at the first grid point (the "left" boundary), while rCode and rVal specify the boundary conditions on the last grid point (the "right" boundary).
bc_code is one of the enumerated value, {PERIODIC, DERIV1, DERIV2, FLAT, NATURAL, ANTIPERIODIC }.
d_type is the the C type corresponding to {s, d, c, z}, i.e. {float, double, complex_float, complex_double}

The codes have the following meaning
Code Meaning
PERIODIC Use periodic boundary conditions. The value, first derivative and second derivative at the left boundary match those at the right boundary.
DERIV1 The value of the first derivative is specified in lVal or rVal.
DERIV2 The value of the second derivative is specified in lVal or rVal.
FLAT The value of the first derivative is set to zero at the boundary.
NATURAL The value of the second derivative is set to zero at the boundary.
ANTIPERIODIC Use anti-periodic boundary conditions. The value, first derivative and second derivative at the left boundary are the negative of those at the right boundary.

Data to be interpolated

The data to be interpolated should have Nx Ny Nz contiguous elements, arranged is row-order (C-style) format. That is, the offset of the (ix,iy,iz) element is (ix*(Ny+iy)*Nz+iz). Complex numbers are stored in the standard format of (real,imaginary) pairs, which the real element first.

Function prototypes:

Single-precision real:
UBspline_1d_s * create_UBspline_1d_s (Ugrid x_grid, BCtype_s xBC, float *data);
UBspline_2d_s * create_UBspline_2d_s (Ugrid x_grid, Ugrid y_grid,
                                      BCtype_s xBC, BCtype_s yBC, float *data);
UBspline_3d_s * create_UBspline_3d_s (Ugrid x_grid,   Ugrid y_grid, Ugrid z_grid,
                                      BCtype_s  xBC,  BCtype_s   yBC, BCtype_s   zBC, float *data);
Single-precision complex:
UBspline_1d_c * create_UBspline_1d_c (Ugrid x_grid, BCtype_c xBC, complex_float *data);
UBspline_2d_c * create_UBspline_2d_c (Ugrid x_grid, Ugrid y_grid,
                                      BCtype_c xBC, BCtype_c yBC, complex_float *data);
UBspline_3d_c * create_UBspline_3d_c (Ugrid x_grid,   Ugrid y_grid, Ugrid z_grid,
                                      BCtype_c  xBC,  BCtype_c   yBC, BCtype_c   zBC, 
                                      complex_float *data);
Double-precision real:
UBspline_1d_d * create_UBspline_1d_d (Ugrid x_grid, BCtype_d xBC, double *data);
UBspline_2d_d * create_UBspline_2d_d (Ugrid x_grid, Ugrid y_grid,
                                      BCtype_d xBC, BCtype_d yBC, double *data);
UBspline_3d_d * create_UBspline_3d_d (Ugrid x_grid,   Ugrid y_grid, Ugrid z_grid,
                                      BCtype_d  xBC,  BCtype_d   yBC, BCtype_d   zBC, double *data);
Double-precision complex:
UBspline_1d_z * create_UBspline_1d_z (Ugrid x_grid, BCtype_z xBC, complex_double *data);
UBspline_2d_z * create_UBspline_2d_z (Ugrid x_grid, Ugrid y_grid,
                                      BCtype_z xBC, BCtype_z yBC, complex_double *data);
UBspline_3d_z * create_UBspline_3d_z (Ugrid x_grid,   Ugrid y_grid, Ugrid z_grid,
                                      BCtype_z  xBC,  BCtype_z   yBC, BCtype_z   zBC, 
                                      complex_double *data);

Spline destruction

The memory used for spline storage can be freed simply by a call to
void
destroy_Bspline (void *spline);
The spline parameter can be a spline of any type and dimension, uniform or nonuniform.

Spline evaluation

For each of the four datatypes, there are four evaluation routines, depending on which quantities need to be computed:
  • Value only
  • Value and gradient
  • Value, gradient, and Laplacian
  • Value, gradient, and Hessian (matrix of 2nd derivatives)
For consistency, all results are returned through pointers passed to the evaluation routines. Currently, no bounds checking is done for the sake of speed. The user is responsible for ensuring that the points passed to the evaluation functions fall within the grids specified at the time of spline creation.

Function prototypes:

Quick Jump Table 1D 2D 3D
Single-precision real 1ds 2ds 3ds
Single-precision complex 1dc 2dc 3dc
Double-precision real 1dd 2dd 3dd
Double-precision complex 1dz 2dz 3dz

Single-precision real:

1D
inline void
eval_UBspline_1d_s     (UBspline_1d_s * restrict spline, 
		        double x, float* restrict val);

inline void
eval_UBspline_1d_s_vg  (UBspline_1d_s * restrict spline, double x, 
  		        float* restrict val, float* restrict grad);

inline void
eval_UBspline_1d_s_vgl (UBspline_1d_s * restrict spline, double x, 
			float* restrict val, float* restrict grad, float* restrict lapl);

inline void /* identical to above routine in 1D */
eval_UBspline_1d_s_vgh (UBspline_1d_s * restrict spline, double x, 
			float* restrict val, float* restrict grad, float* restrict hess);
2D
inline void
eval_UBspline_2d_s     (UBspline_2d_s * restrict spline, double x, double y, 
                        float* restrict val);

inline void
eval_UBspline_2d_s_vg  (UBspline_2d_s * restrict spline, double x, double y, 
  		        float* restrict val, float* restrict grad);

inline void
eval_UBspline_2d_s_vgl (UBspline_2d_s * restrict spline, double x, double y,
			float* restrict val, float* restrict grad, float* restrict lapl);

inline void 
eval_UBspline_2d_s_vgh (UBspline_2d_s * restrict spline, double x, double y,
			float* restrict val, float* restrict grad, float* restrict hess);
3D
inline void
eval_UBspline_3d_s     (UBspline_3d_s * restrict spline, double x, double y, double z,
                        float* restrict val);

inline void
eval_UBspline_3d_s_vg  (UBspline_3d_s * restrict spline, double x, double y, double z,
  		        float* restrict val, float* restrict grad);

inline void
eval_UBspline_3d_s_vgl (UBspline_3d_s * restrict spline, double x, double y, double z,
			float* restrict val, float* restrict grad, float* restrict lapl);

inline void 
eval_UBspline_3d_s_vgh (UBspline_3d_s * restrict spline, double x, double y,
			float* restrict val, float* restrict grad, float* restrict hess);

Single-precision complex:

1D
inline void
eval_UBspline_1d_c     (UBspline_1d_c * restrict spline, 
		        double x, complex_float* restrict val);

inline void
eval_UBspline_1d_c_vg  (UBspline_1d_c * restrict spline, double x, 
  		        complex_float* restrict val, complex_float* restrict grad);

inline void
eval_UBspline_1d_c_vgl (UBspline_1d_c * restrict spline, double x, 
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict lapl);

inline void /* identical to above routine in 1D */
eval_UBspline_1d_c_vgh (UBspline_1d_c * restrict spline, double x, 
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict hess);
2D
inline void
eval_UBspline_2d_c     (UBspline_2d_c * restrict spline, double x, double y, 
                        complex_float* restrict val);

inline void
eval_UBspline_2d_c_vg  (UBspline_2d_c * restrict spline, double x, double y, 
  		        complex_float* restrict val, complex_float* restrict grad);

inline void
eval_UBspline_2d_c_vgl (UBspline_2d_c * restrict spline, double x, double y,
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict lapl);

inline void 
eval_UBspline_2d_c_vgh (UBspline_2d_c * restrict spline, double x, double y,
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict hess);
3D
inline void
eval_UBspline_3d_c     (UBspline_3d_c * restrict spline, double x, double y, double z,
                        complex_float* restrict val);

inline void
eval_UBspline_3d_c_vg  (UBspline_3d_c * restrict spline, double x, double y, double z,
  		        complex_float* restrict val, complex_float* restrict grad);

inline void
eval_UBspline_3d_c_vgl (UBspline_3d_c * restrict spline, double x, double y, double z,
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict lapl);

inline void 
eval_UBspline_3d_c_vgh (UBspline_3d_c * restrict spline, double x, double y,
			complex_float* restrict val, complex_float* restrict grad, complex_float* restrict hess);

Double-precision real:

1D
inline void
eval_UBspline_1d_d     (UBspline_1d_d * restrict spline, 
		        double x, double* restrict val);

inline void
eval_UBspline_1d_d_vg  (UBspline_1d_d * restrict spline, double x, 
  		        double* restrict val, double* restrict grad);

inline void
eval_UBspline_1d_d_vgl (UBspline_1d_d * restrict spline, double x, 
			double* restrict val, double* restrict grad, double* restrict lapl);

inline void /* identical to above routine in 1D */
eval_UBspline_1d_d_vgh (UBspline_1d_d * restrict spline, double x, 
			double* restrict val, double* restrict grad, double* restrict hess);
2D
inline void
eval_UBspline_2d_d     (UBspline_2d_d * restrict spline, double x, double y, 
                        double* restrict val);

inline void
eval_UBspline_2d_d_vg  (UBspline_2d_d * restrict spline, double x, double y, 
  		        double* restrict val, double* restrict grad);

inline void
eval_UBspline_2d_d_vgl (UBspline_2d_d * restrict spline, double x, double y,
			double* restrict val, double* restrict grad, double* restrict lapl);

inline void 
eval_UBspline_2d_d_vgh (UBspline_2d_d * restrict spline, double x, double y,
			double* restrict val, double* restrict grad, double* restrict hess);
3D
inline void
eval_UBspline_3d_d     (UBspline_3d_d * restrict spline, double x, double y, double z,
                        double* restrict val);

inline void
eval_UBspline_3d_d_vg  (UBspline_3d_d * restrict spline, double x, double y, double z,
  		        double* restrict val, double* restrict grad);

inline void
eval_UBspline_3d_d_vgl (UBspline_3d_d * restrict spline, double x, double y, double z,
			double* restrict val, double* restrict grad, double* restrict lapl);

inline void 
eval_UBspline_3d_d_vgh (UBspline_3d_d * restrict spline, double x, double y,
			double* restrict val, double* restrict grad, double* restrict hess);

Double-precision complex:

1D
inline void
eval_UBspline_1d_z     (UBspline_1d_z * restrict spline, 
		        double x, complex_double* restrict val);

inline void
eval_UBspline_1d_z_vg  (UBspline_1d_z * restrict spline, double x, 
  		        complex_double* restrict val, complex_double* restrict grad);

inline void
eval_UBspline_1d_z_vgl (UBspline_1d_z * restrict spline, double x, 
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict lapl);

inline void /* identical to above routine in 1D */
eval_UBspline_1d_z_vgh (UBspline_1d_z * restrict spline, double x, 
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict hess);
2D
inline void
eval_UBspline_2d_z     (UBspline_2d_z * restrict spline, double x, double y, 
                        complex_double* restrict val);

inline void
eval_UBspline_2d_z_vg  (UBspline_2d_z * restrict spline, double x, double y, 
  		        complex_double* restrict val, complex_double* restrict grad);

inline void
eval_UBspline_2d_z_vgl (UBspline_2d_z * restrict spline, double x, double y,
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict lapl);

inline void 
eval_UBspline_2d_z_vgh (UBspline_2d_z * restrict spline, double x, double y,
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict hess);
3D
inline void
eval_UBspline_3d_z     (UBspline_3d_z * restrict spline, double x, double y, double z,
                        complex_double* restrict val);

inline void
eval_UBspline_3d_z_vg  (UBspline_3d_z * restrict spline, double x, double y, double z,
  		        complex_double* restrict val, complex_double* restrict grad);

inline void
eval_UBspline_3d_z_vgl (UBspline_3d_z * restrict spline, double x, double y, double z,
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict lapl);

inline void 
eval_UBspline_3d_z_vgh (UBspline_3d_z * restrict spline, double x, double y,
			complex_double* restrict val, complex_double* restrict grad, complex_double* restrict hess);


SourceForge.net Logo