EZspline Toolbox SourceForge.net Logo

  1. Overview
  2. Download
  3. Installation
  4. User's Guide
  5. References


Overview

The EZspline Toolbox is a free open source MEX-based Toolbox for MATLAB(R) that does quick interpolation of 1D, 2D & 3D points, clouds and grids. For the most part, it's a MATLAB(R) port of the EZspline Fortran 90 interface by Alex Pletzer. The computational routines used are from the PSPLINE Fortran module library from the National Transport Code Collaboration (NTCC) developed at the Princeton Plasma Physics Laboratory (PPPL) by Doug McCune.

Like the original EZspline interface, NetCDF is a supported data format; MATLAB(R)'s binary MAT data format is available as well.

Runtimes and errors are compared below between the EZspline Toolbox and MATLAB's Spline Toolbox v. 3.2. The test was run with a P4 1.8 GHz, 1 Gb RAM, Lahey/Fujitsu Opt. F95 compiler and MATLAB 6.5.1. Here's what the test looks like (ezspline_time.m).

2D Runtime and Error Comparison 2D Runtime and Error Comparison

2D Grid (left) and Cloud (right) Interpolation Benchmarks

3D Runtime and Error Comparison 3D Runtime and Error Comparison

3D Grid (left) and Cloud (right) Interpolation Benchmarks


Download

Source Code: ezsplinetoolbox-0.0.tar.gz

Binary Distribution: ezsplinetoolbox-0.0-lx-i386.tar.gz (Skip: steps 2-4 below; make 'all' in step 5)

Alternatively, the latest version can be checked out through anonymous (pserver) CVS with the following instruction set. When prompted for a password for anonymous, simply press the Enter key.

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ezsplinetoolbox login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ezsplinetoolbox co ezsplinetoolbox-0.0 


Installation

  1. (Optional) Download and install the NetCDF Toolbox for MATLAB.
  2. Download and install the PSPLINE module.
  3. Download the EZspline Toolbox source code from SourceForge. If you got the compressed tar file, decompress with
    tar -zxvf ezsplinetoolbox-0.0.tar.gz
    
  4. Modify make.m in the directory you decompressed in so that it
  5. Start MATLAB from within the same directory and execute
    make 'all'
    make 'install'
    make 'clean'
    
  6. Add the toolbox to your MATLAB PATH based on the PREFIX you defined above, such as
    addpath('/home/rsz/ezspline/bin');
    
  7. Test the installation from the source directory with
    cd test
    ezspline_test
    
    Only errors will produce output.


User's Guide

  1. Interpolating 1D Points and Arrays
  2. Interpolating 2D Points, Cloud of Points, and Grids
  3. Interpolating 3D Points, Cloud of Points, and Grids
  4. Saving and loading (the computed spline coefficients)

Interpolating 1D Points and Arrays

nx = 31;
xmin = 0; xmax = 1;

x = linspace(xmin, xmax, nx);

f = x.^3;
% compute the spline coefficients
[ez, ier] = ezspline_setup(f, [[0 0]]);
% single point & interp
P = [.1111];
[V, ier] = ezspline_interp(ez, P);
% array of points & interp
P = [.1111,.2222,.3333];
[V, ier] = ezspline_interp(ez, P');

% optional - check if grid is strictly increasing
ier = ezspline_isgridreg(ez);
% optional - check if point is in domain
P = [.111, .111];
ier = ezspline_isindom(ez, P);

Interpolating 2D Points, Cloud of Points and Grids

nx = 31;
xmin = 0; xmax = 1;
ny = 41;
ymin = 0; ymax = 1;

x = linspace(xmin, xmax, nx);
y = linspace(ymin, ymax, ny);

[xx, yy] = ndgrid(x,y);
f = xx.^3 + 2 * yy.^3;

% compute the spline coefficients
[ez, ier] = ezspline_setup(f, [[0 0], [0 0]]);
% single point & interp
P = [.1111, .1111];
[V, ier] = ezspline_interp(ez, P);
% cloud of points & interp
P = [.1111,.1111; .2222 .2222; .3333 .3333];
[V, ier] = ezspline_interp(ez, P);
% array of points & interp
P1 = .1111: .1111 : .3333;
P2 = P1;
[V, ier] = ezspline_interp(ez, P1, P2);


% optional - check if grid is strictly increasing
ier = ezspline_isgridreg(ez);
% optional - check if point is in domain
P = [.111, .111];
ier = ezspline_isindom(ez, P);

Interpolating 3D Points, Cloud of Points, and Grids

nx = 31;
xmin = 0; xmax = 1;
ny = 41;
ymin = 0; ymax = 1;
nz = 5;
zmin = 0; zmax = 1;

x = linspace(xmin, xmax, nx);
y = linspace(ymin, ymax, ny);
z = linspace(zmin, zmax, nz);

[xx, yy, zz] = ndgrid(x,y,z);
f = xx.^3 + 2 * yy.^3 + 3 * zz.^3;

% compute the spline coefficients
[ez, ier] = ezspline_setup(f, [[0 0], [0 0], [0 0]]);
% single point & interp
P = [.1111, .1111, .1111];
[V, ier] = ezspline_interp(ez, P);
% cloud of points & interp
P = [.1111, .1111, .1111; .2222, .2222, .2222];
[V, ier] = ezspline_interp(ez, P);
% array of points & interp
P1 = .1111: .1111 : .3333;
P2 = P1;
P3 = P1;
[V, ier] = ezspline_interp(ez, P1, P2, P3);


% optional - check if grid is strictly increasing
ier = ezspline_isgridreg(ez);
% optional - check if point is in domain
P = [.111, .111, .111];
ier = ezspline_isindom(ez, P);

Saving and Loading the spline coefficients object

% save with NetCDF format
ier = ezspline_save(ez, 'file.nc');
% load with NetCDF format
ez = ezspline_load('file.nc');

% save with MATLAB MAT format
ier = ezspline_save(ez, 'file.mat', 'mat');
% load with MATLAB MAT format
ez = ezspline_load('file.mat', 'mat');


References

  1. EZspline Toolbox Project Development Page
  2. NTCC PSPLINE Module
  3. NetCDF Data Format
  4. NetCDF Toolbox for MATLAB