spline example code prepared by Dr. Jiguo Cao