package com.imsl.test.example.math; import java.text.*; import com.imsl.math.*; /** *

* Computes the Kochanek-Bartels cubic spline.

* * This example interpolates to a set of points with a Kochanek-Bartels cubic * spline. At \(x\) = 3, the continuity and tension parameters are \(-1\). At * all other points, they are zero. Interpolated values are then printed. * * @see Code * @see Output * */ public class CsTCBEx1 { public static void main(String args[]) { double[] xdata = {0., 1., 2., 3., 4., 5.}; double[] ydata = {5., 2., 3., 5., 1., 2.}; double[] continuity = {0., 0., 0., -1., 0., 0.}; double[] tension = {0., 0., 0., -1., 0., 0.}; CsTCB cs = new CsTCB(xdata, ydata); cs.setContinuity(continuity); cs.setTension(tension); cs.compute(); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4); nf.setMinimumFractionDigits(4); System.out.println(" x " + " value "); for (int k = 0; k < 11; k++) { double x = (double) k / 2.0; double y = cs.value(x); System.out.println(" " + nf.format(x) + " " + nf.format(y)); } } }