summaryrefslogtreecommitdiff
path: root/gsl-1.9/interpolation
diff options
context:
space:
mode:
Diffstat (limited to 'gsl-1.9/interpolation')
-rw-r--r--gsl-1.9/interpolation/ChangeLog98
-rw-r--r--gsl-1.9/interpolation/Makefile.am18
-rw-r--r--gsl-1.9/interpolation/Makefile.in549
-rw-r--r--gsl-1.9/interpolation/TODO10
-rw-r--r--gsl-1.9/interpolation/accel.c82
-rw-r--r--gsl-1.9/interpolation/akima.c389
-rw-r--r--gsl-1.9/interpolation/bsearch.c47
-rw-r--r--gsl-1.9/interpolation/bsearch.h80
-rw-r--r--gsl-1.9/interpolation/cspline.c475
-rw-r--r--gsl-1.9/interpolation/gsl_interp.h202
-rw-r--r--gsl-1.9/interpolation/gsl_spline.h101
-rw-r--r--gsl-1.9/interpolation/integ_eval.h36
-rw-r--r--gsl-1.9/interpolation/interp.c244
-rw-r--r--gsl-1.9/interpolation/linear.c198
-rw-r--r--gsl-1.9/interpolation/poly.c173
-rw-r--r--gsl-1.9/interpolation/spline.c193
-rw-r--r--gsl-1.9/interpolation/test.c949
17 files changed, 3844 insertions, 0 deletions
diff --git a/gsl-1.9/interpolation/ChangeLog b/gsl-1.9/interpolation/ChangeLog
new file mode 100644
index 0000000..ce3a5dd
--- /dev/null
+++ b/gsl-1.9/interpolation/ChangeLog
@@ -0,0 +1,98 @@
+2005-12-24 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c (cspline_init_periodic): fix invalid memory access of
+ xa[3] for sys_size=2
+
+2005-12-22 Brian Gough <bjg@network-theory.co.uk>
+
+ * test.c (test_cspline2): added extra test of cspline
+ (test_cspline3): added extra test of cspline
+
+2004-11-28 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c (cspline_init): support case of degenerate x[i] values
+ (cspline_init_periodic): support case of degenerate x[i] values
+
+ * integ_eval.h (integ_eval): improve numerical stability of
+ integration formula
+
+2004-03-15 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c (cspline_init): handle the case N=1 specially
+
+2003-07-24 Brian Gough <bjg@network-theory.co.uk>
+
+ * gsl_interp.h: removed duplicate declaration of
+ gsl_interp_accel_find
+
+Sat Apr 27 20:57:22 2002 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c (cspline_init_periodic): handle boundary effects
+ correctly
+
+Sun Dec 2 22:48:23 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * poly.c: added polynomial interpolation based on divided
+ differences from Dan, Ho-Jin.
+
+Tue Jul 3 12:10:53 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * interp.c (DISCARD_STATUS): discard error status values using a
+ macro for configurability
+
+Sun Jul 1 21:41:27 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c: added const to state in appropriate places
+
+Tue Jun 26 11:57:55 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * spline.c: added missing #include <string.h> for memcpy
+
+Mon Jun 25 19:58:45 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * standardized to gsl conventions, added high-level 'spline'
+ interface
+
+Mon Apr 30 13:29:34 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * renamed gsl_interp_obj to gsl_interp
+
+Mon Apr 23 10:29:51 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * unified error handling conventions to _e for error handling
+ functions and no suffix for plain functions, so _impl functions
+ are no longer needed.
+
+ * removed tests for EFAULT, since EFAULT should only apply to
+ invalid non-null pointers.
+
+
+Tue Apr 11 19:56:25 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * cspline.c (cspline_calc_periodic): changed occurrence of gsl_la
+ name to new gsl_linalg prefix, gsl_linalg_solve_symm_cyc_tridiag
+ (cspline_calc_natural): ditto
+
+Mon Aug 30 11:31:00 1999 Brian Gough <bjg@network-theory.co.uk>
+
+ * bsearch.c: made gsl_interp_bsearch (formerly interp_bsearch) an
+ exported function, since it is needed by the inline version of
+ gsl_interp_accel_find in gsl_interp.h
+
+Tue Nov 17 16:52:00 1998 Brian Gough <bjg@vvv.lanl.gov>
+
+ * added #include <config.h> to all top-level source files
+
+ * renamed test_interp.c to test.c
+
+ * test_interp.c: got rid of unused function alloc_xy_table
+
+Fri Nov 13 16:50:05 1998 Brian Gough <bjg@vvv.lanl.gov>
+
+ * clean up for make strict, use size_t instead of unsigned int
+
+1998-11-06 <bjg@ancho.lanl.gov>
+
+ * added const to several declarations where needed.
+
+
diff --git a/gsl-1.9/interpolation/Makefile.am b/gsl-1.9/interpolation/Makefile.am
new file mode 100644
index 0000000..8889430
--- /dev/null
+++ b/gsl-1.9/interpolation/Makefile.am
@@ -0,0 +1,18 @@
+noinst_LTLIBRARIES = libgslinterpolation.la
+
+check_PROGRAMS = test
+
+pkginclude_HEADERS = gsl_interp.h gsl_spline.h
+
+libgslinterpolation_la_SOURCES = accel.c akima.c bsearch.c cspline.c interp.c linear.c integ_eval.h spline.c poly.c
+
+noinst_HEADERS = bsearch.h
+
+INCLUDES= -I$(top_builddir)
+
+TESTS = $(check_PROGRAMS)
+
+test_LDADD = libgslinterpolation.la ../poly/libgslpoly.la ../linalg/libgsllinalg.la ../permutation/libgslpermutation.la ../blas/libgslblas.la ../matrix/libgslmatrix.la ../vector/libgslvector.la ../block/libgslblock.la ../complex/libgslcomplex.la ../cblas/libgslcblas.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la
+
+test_SOURCES = test.c
+
diff --git a/gsl-1.9/interpolation/Makefile.in b/gsl-1.9/interpolation/Makefile.in
new file mode 100644
index 0000000..b580609
--- /dev/null
+++ b/gsl-1.9/interpolation/Makefile.in
@@ -0,0 +1,549 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+check_PROGRAMS = test$(EXEEXT)
+subdir = interpolation
+DIST_COMMON = $(noinst_HEADERS) $(pkginclude_HEADERS) \
+ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog TODO
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libgslinterpolation_la_LIBADD =
+am_libgslinterpolation_la_OBJECTS = accel.lo akima.lo bsearch.lo \
+ cspline.lo interp.lo linear.lo spline.lo poly.lo
+libgslinterpolation_la_OBJECTS = $(am_libgslinterpolation_la_OBJECTS)
+am_test_OBJECTS = test.$(OBJEXT)
+test_OBJECTS = $(am_test_OBJECTS)
+test_DEPENDENCIES = libgslinterpolation.la ../poly/libgslpoly.la \
+ ../linalg/libgsllinalg.la ../permutation/libgslpermutation.la \
+ ../blas/libgslblas.la ../matrix/libgslmatrix.la \
+ ../vector/libgslvector.la ../block/libgslblock.la \
+ ../complex/libgslcomplex.la ../cblas/libgslcblas.la \
+ ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la \
+ ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp =
+am__depfiles_maybe =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libgslinterpolation_la_SOURCES) $(test_SOURCES)
+DIST_SOURCES = $(libgslinterpolation_la_SOURCES) $(test_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkgincludedir)"
+pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(noinst_HEADERS) $(pkginclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GSL_CFLAGS = @GSL_CFLAGS@
+GSL_LIBS = @GSL_LIBS@
+GSL_LT_CBLAS_VERSION = @GSL_LT_CBLAS_VERSION@
+GSL_LT_VERSION = @GSL_LT_VERSION@
+HAVE_AIX_IEEE_INTERFACE = @HAVE_AIX_IEEE_INTERFACE@
+HAVE_DARWIN86_IEEE_INTERFACE = @HAVE_DARWIN86_IEEE_INTERFACE@
+HAVE_DARWIN_IEEE_INTERFACE = @HAVE_DARWIN_IEEE_INTERFACE@
+HAVE_EXTENDED_PRECISION_REGISTERS = @HAVE_EXTENDED_PRECISION_REGISTERS@
+HAVE_FREEBSD_IEEE_INTERFACE = @HAVE_FREEBSD_IEEE_INTERFACE@
+HAVE_GNUM68K_IEEE_INTERFACE = @HAVE_GNUM68K_IEEE_INTERFACE@
+HAVE_GNUPPC_IEEE_INTERFACE = @HAVE_GNUPPC_IEEE_INTERFACE@
+HAVE_GNUSPARC_IEEE_INTERFACE = @HAVE_GNUSPARC_IEEE_INTERFACE@
+HAVE_GNUX86_IEEE_INTERFACE = @HAVE_GNUX86_IEEE_INTERFACE@
+HAVE_HPUX11_IEEE_INTERFACE = @HAVE_HPUX11_IEEE_INTERFACE@
+HAVE_HPUX_IEEE_INTERFACE = @HAVE_HPUX_IEEE_INTERFACE@
+HAVE_IEEE_COMPARISONS = @HAVE_IEEE_COMPARISONS@
+HAVE_IEEE_DENORMALS = @HAVE_IEEE_DENORMALS@
+HAVE_INLINE = @HAVE_INLINE@
+HAVE_IRIX_IEEE_INTERFACE = @HAVE_IRIX_IEEE_INTERFACE@
+HAVE_NETBSD_IEEE_INTERFACE = @HAVE_NETBSD_IEEE_INTERFACE@
+HAVE_OPENBSD_IEEE_INTERFACE = @HAVE_OPENBSD_IEEE_INTERFACE@
+HAVE_OS2EMX_IEEE_INTERFACE = @HAVE_OS2EMX_IEEE_INTERFACE@
+HAVE_PRINTF_LONGDOUBLE = @HAVE_PRINTF_LONGDOUBLE@
+HAVE_SOLARIS_IEEE_INTERFACE = @HAVE_SOLARIS_IEEE_INTERFACE@
+HAVE_SUNOS4_IEEE_INTERFACE = @HAVE_SUNOS4_IEEE_INTERFACE@
+HAVE_TRU64_IEEE_INTERFACE = @HAVE_TRU64_IEEE_INTERFACE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+RELEASED = @RELEASED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__leading_dot = @am__leading_dot@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+noinst_LTLIBRARIES = libgslinterpolation.la
+pkginclude_HEADERS = gsl_interp.h gsl_spline.h
+libgslinterpolation_la_SOURCES = accel.c akima.c bsearch.c cspline.c interp.c linear.c integ_eval.h spline.c poly.c
+noinst_HEADERS = bsearch.h
+INCLUDES = -I$(top_builddir)
+TESTS = $(check_PROGRAMS)
+test_LDADD = libgslinterpolation.la ../poly/libgslpoly.la ../linalg/libgsllinalg.la ../permutation/libgslpermutation.la ../blas/libgslblas.la ../matrix/libgslmatrix.la ../vector/libgslvector.la ../block/libgslblock.la ../complex/libgslcomplex.la ../cblas/libgslcblas.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la
+test_SOURCES = test.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps interpolation/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu --ignore-deps interpolation/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgslinterpolation.la: $(libgslinterpolation_la_OBJECTS) $(libgslinterpolation_la_DEPENDENCIES)
+ $(LINK) $(libgslinterpolation_la_LDFLAGS) $(libgslinterpolation_la_OBJECTS) $(libgslinterpolation_la_LIBADD) $(LIBS)
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES)
+ @rm -f test$(EXEEXT)
+ $(LINK) $(test_LDFLAGS) $(test_OBJECTS) $(test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+.c.o:
+ $(COMPILE) -c $<
+
+.c.obj:
+ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-pkgincludeHEADERS: $(pkginclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
+ @list='$(pkginclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
+ done
+
+uninstall-pkgincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkginclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list='$(TESTS)'; \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *" $$tst "*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *" $$tst "*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ echo "SKIP: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all tests failed"; \
+ else \
+ banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ skipped="($$skip tests were not run)"; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgincludedir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pkgincludeHEADERS
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-pkgincludeHEADERS
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-exec install-exec-am \
+ install-info install-info-am install-man \
+ install-pkgincludeHEADERS install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-info-am \
+ uninstall-pkgincludeHEADERS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/gsl-1.9/interpolation/TODO b/gsl-1.9/interpolation/TODO
new file mode 100644
index 0000000..3bf369f
--- /dev/null
+++ b/gsl-1.9/interpolation/TODO
@@ -0,0 +1,10 @@
+1. need to add a test for the akima splines
+
+2. [DOCUMENTATION] From: Conrad Curry <cwcurry@orca.st.usm.edu>
+
+ I would suggest adding more about cspline and Akima similiar to what
+ is given for 'polynomial', particularly under what conditions one
+ would be prefered over the other.
+
+3. add akima splines without the Wodicka modification, so that the spline
+is a smooth curve without corners.
diff --git a/gsl-1.9/interpolation/accel.c b/gsl-1.9/interpolation/accel.c
new file mode 100644
index 0000000..72d9345
--- /dev/null
+++ b/gsl-1.9/interpolation/accel.c
@@ -0,0 +1,82 @@
+/* interpolation/accel.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_interp.h>
+
+gsl_interp_accel *
+gsl_interp_accel_alloc (void)
+{
+ gsl_interp_accel *a = (gsl_interp_accel *) malloc (sizeof (gsl_interp_accel));
+ if (a == 0)
+ {
+ GSL_ERROR_NULL("could not allocate space for gsl_interp_accel", GSL_ENOMEM);
+ }
+
+ a->cache = 0;
+ a->hit_count = 0;
+ a->miss_count = 0;
+
+ return a;
+}
+
+int
+gsl_interp_accel_reset (gsl_interp_accel * a)
+{
+ a->cache = 0;
+ a->hit_count = 0;
+ a->miss_count = 0;
+
+ return GSL_SUCCESS;
+}
+
+#ifndef HIDE_INLINE_STATIC
+size_t
+gsl_interp_accel_find (gsl_interp_accel * a, const double xa[], size_t len, double x)
+{
+ size_t x_index = a->cache;
+
+ if (x < xa[x_index])
+ {
+ a->miss_count++;
+ a->cache = gsl_interp_bsearch (xa, x, 0, x_index);
+ }
+ else if (x > xa[x_index + 1])
+ {
+ a->miss_count++;
+ a->cache = gsl_interp_bsearch (xa, x, x_index, len - 1);
+ }
+ else
+ {
+ a->hit_count++;
+ }
+
+ return a->cache;
+}
+#endif
+
+void
+gsl_interp_accel_free (gsl_interp_accel * a)
+{
+ free (a);
+}
diff --git a/gsl-1.9/interpolation/akima.c b/gsl-1.9/interpolation/akima.c
new file mode 100644
index 0000000..452432f
--- /dev/null
+++ b/gsl-1.9/interpolation/akima.c
@@ -0,0 +1,389 @@
+/* interpolation/akima.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <math.h>
+#include <gsl/gsl_errno.h>
+#include "integ_eval.h"
+#include <gsl/gsl_interp.h>
+
+typedef struct
+{
+ double * b;
+ double * c;
+ double * d;
+ double * _m;
+} akima_state_t;
+
+
+/* common creation */
+static void *
+akima_alloc (size_t size)
+{
+ akima_state_t *state = (akima_state_t *) malloc (sizeof (akima_state_t));
+
+ if (state == NULL)
+ {
+ GSL_ERROR_NULL("failed to allocate space for state", GSL_ENOMEM);
+ }
+
+ state->b = (double *) malloc (size * sizeof (double));
+
+ if (state->b == NULL)
+ {
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for b", GSL_ENOMEM);
+ }
+
+ state->c = (double *) malloc (size * sizeof (double));
+
+ if (state->c == NULL)
+ {
+ free (state->b);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for c", GSL_ENOMEM);
+ }
+
+ state->d = (double *) malloc (size * sizeof (double));
+
+ if (state->d == NULL)
+ {
+ free (state->c);
+ free (state->b);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for d", GSL_ENOMEM);
+ }
+
+ state->_m = (double *) malloc ((size + 4) * sizeof (double));
+
+ if (state->_m == NULL)
+ {
+ free (state->d);
+ free (state->c);
+ free (state->b);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for _m", GSL_ENOMEM);
+ }
+
+ return state;
+}
+
+
+/* common calculation */
+static void
+akima_calc (const double x_array[], double b[], double c[], double d[], size_t size, double m[])
+{
+ size_t i;
+
+ for (i = 0; i < (size - 1); i++)
+ {
+ const double NE = fabs (m[i + 1] - m[i]) + fabs (m[i - 1] - m[i - 2]);
+ if (NE == 0.0)
+ {
+ b[i] = m[i];
+ c[i] = 0.0;
+ d[i] = 0.0;
+ }
+ else
+ {
+ const double h_i = x_array[i + 1] - x_array[i];
+ const double NE_next = fabs (m[i + 2] - m[i + 1]) + fabs (m[i] - m[i - 1]);
+ const double alpha_i = fabs (m[i - 1] - m[i - 2]) / NE;
+ double alpha_ip1;
+ double tL_ip1;
+ if (NE_next == 0.0)
+ {
+ tL_ip1 = m[i];
+ }
+ else
+ {
+ alpha_ip1 = fabs (m[i] - m[i - 1]) / NE_next;
+ tL_ip1 = (1.0 - alpha_ip1) * m[i] + alpha_ip1 * m[i + 1];
+ }
+ b[i] = (1.0 - alpha_i) * m[i - 1] + alpha_i * m[i];
+ c[i] = (3.0 * m[i] - 2.0 * b[i] - tL_ip1) / h_i;
+ d[i] = (b[i] + tL_ip1 - 2.0 * m[i]) / (h_i * h_i);
+ }
+ }
+}
+
+
+static int
+akima_init (void * vstate, const double x_array[], const double y_array[],
+ size_t size)
+{
+ akima_state_t *state = (akima_state_t *) vstate;
+
+ double * m = state->_m + 2; /* offset so we can address the -1,-2
+ components */
+
+ size_t i;
+ for (i = 0; i <= size - 2; i++)
+ {
+ m[i] = (y_array[i + 1] - y_array[i]) / (x_array[i + 1] - x_array[i]);
+ }
+
+ /* non-periodic boundary conditions */
+ m[-2] = 3.0 * m[0] - 2.0 * m[1];
+ m[-1] = 2.0 * m[0] - m[1];
+ m[size - 1] = 2.0 * m[size - 2] - m[size - 3];
+ m[size] = 3.0 * m[size - 2] - 2.0 * m[size - 3];
+
+ akima_calc (x_array, state->b, state->c, state->d, size, m);
+
+ return GSL_SUCCESS;
+}
+
+
+static int
+akima_init_periodic (void * vstate,
+ const double x_array[],
+ const double y_array[],
+ size_t size)
+{
+ akima_state_t *state = (akima_state_t *) vstate;
+
+ double * m = state->_m + 2; /* offset so we can address the -1,-2
+ components */
+
+ size_t i;
+ for (i = 0; i <= size - 2; i++)
+ {
+ m[i] = (y_array[i + 1] - y_array[i]) / (x_array[i + 1] - x_array[i]);
+ }
+
+ /* periodic boundary conditions */
+ m[-2] = m[size - 1 - 2];
+ m[-1] = m[size - 1 - 1];
+ m[size - 1] = m[0];
+ m[size] = m[1];
+
+ akima_calc (x_array, state->b, state->c, state->d, size, m);
+
+ return GSL_SUCCESS;
+}
+
+static void
+akima_free (void * vstate)
+{
+ akima_state_t *state = (akima_state_t *) vstate;
+
+ free (state->b);
+ free (state->c);
+ free (state->d);
+ free (state->_m);
+ free (state);
+}
+
+
+static
+int
+akima_eval (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *y)
+{
+ const akima_state_t *state = (const akima_state_t *) vstate;
+
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ {
+ const double x_lo = x_array[index];
+ const double delx = x - x_lo;
+ const double b = state->b[index];
+ const double c = state->c[index];
+ const double d = state->d[index];
+ *y = y_array[index] + delx * (b + delx * (c + d * delx));
+ return GSL_SUCCESS;
+ }
+}
+
+
+static int
+akima_eval_deriv (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *dydx)
+{
+ const akima_state_t *state = (const akima_state_t *) vstate;
+
+ size_t index;
+
+ DISCARD_POINTER(y_array); /* prevent warning about unused parameter */
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ {
+ double x_lo = x_array[index];
+ double delx = x - x_lo;
+ double b = state->b[index];
+ double c = state->c[index];
+ double d = state->d[index];
+ *dydx = b + delx * (2.0 * c + 3.0 * d * delx);
+ return GSL_SUCCESS;
+ }
+}
+
+
+static
+int
+akima_eval_deriv2 (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *y_pp)
+{
+ const akima_state_t *state = (const akima_state_t *) vstate;
+
+ size_t index;
+
+ DISCARD_POINTER(y_array); /* prevent warning about unused parameter */
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ {
+ const double x_lo = x_array[index];
+ const double delx = x - x_lo;
+ const double c = state->c[index];
+ const double d = state->d[index];
+ *y_pp = 2.0 * c + 6.0 * d * delx;
+ return GSL_SUCCESS;
+ }
+}
+
+
+static
+int
+akima_eval_integ (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ gsl_interp_accel * acc,
+ double a, double b,
+ double * result)
+{
+ const akima_state_t *state = (const akima_state_t *) vstate;
+
+ size_t i, index_a, index_b;
+
+ if (acc != 0)
+ {
+ index_a = gsl_interp_accel_find (acc, x_array, size, a);
+ index_b = gsl_interp_accel_find (acc, x_array, size, b);
+ }
+ else
+ {
+ index_a = gsl_interp_bsearch (x_array, a, 0, size - 1);
+ index_b = gsl_interp_bsearch (x_array, b, 0, size - 1);
+ }
+
+ *result = 0.0;
+
+ /* interior intervals */
+
+ for(i=index_a; i<=index_b; i++) {
+ const double x_hi = x_array[i + 1];
+ const double x_lo = x_array[i];
+ const double y_lo = y_array[i];
+ const double dx = x_hi - x_lo;
+ if(dx != 0.0) {
+
+ if (i == index_a || i == index_b)
+ {
+ double x1 = (i == index_a) ? a : x_lo;
+ double x2 = (i == index_b) ? b : x_hi;
+ *result += integ_eval (y_lo, state->b[i], state->c[i], state->d[i],
+ x_lo, x1, x2);
+ }
+ else
+ {
+ *result += dx * (y_lo
+ + dx*(0.5*state->b[i]
+ + dx*(state->c[i]/3.0
+ + 0.25*state->d[i]*dx)));
+ }
+ }
+ else {
+ *result = 0.0;
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+static const gsl_interp_type akima_type =
+{
+ "akima",
+ 5,
+ &akima_alloc,
+ &akima_init,
+ &akima_eval,
+ &akima_eval_deriv,
+ &akima_eval_deriv2,
+ &akima_eval_integ,
+ &akima_free
+};
+
+const gsl_interp_type * gsl_interp_akima = &akima_type;
+
+static const gsl_interp_type akima_periodic_type =
+{
+ "akima-periodic",
+ 5,
+ &akima_alloc,
+ &akima_init_periodic,
+ &akima_eval,
+ &akima_eval_deriv,
+ &akima_eval_deriv2,
+ &akima_eval_integ,
+ &akima_free
+};
+
+const gsl_interp_type * gsl_interp_akima_periodic = &akima_periodic_type;
diff --git a/gsl-1.9/interpolation/bsearch.c b/gsl-1.9/interpolation/bsearch.c
new file mode 100644
index 0000000..81692db
--- /dev/null
+++ b/gsl-1.9/interpolation/bsearch.c
@@ -0,0 +1,47 @@
+/* interpolation/bsearch.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_interp.h>
+
+#ifndef HIDE_INLINE_STATIC
+size_t
+gsl_interp_bsearch (
+ const double x_array[], double x,
+ size_t index_lo,
+ size_t index_hi
+ )
+{
+ size_t ilo = index_lo;
+ size_t ihi = index_hi;
+ while (ihi > ilo + 1)
+ {
+ size_t i = (ihi + ilo) / 2;
+ if (x_array[i] > x)
+ ihi = i;
+ else
+ ilo = i;
+ }
+
+ return ilo;
+}
+#endif
diff --git a/gsl-1.9/interpolation/bsearch.h b/gsl-1.9/interpolation/bsearch.h
new file mode 100644
index 0000000..0379d81
--- /dev/null
+++ b/gsl-1.9/interpolation/bsearch.h
@@ -0,0 +1,80 @@
+/* interpolation/bsearch.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#ifndef __GSL_INTERP_BSEARCH_H__
+#define __GSL_INTERP_BSEARCH_H__
+
+
+/* Perform a binary search of an array of values.
+ *
+ * The parameters index_lo and index_hi provide an initial bracket,
+ * and it is assumed that index_lo < index_hi. The resulting index
+ * is guaranteed to be strictly less than index_hi and greater than
+ * or equal to index_lo, so that the implicit bracket [index, index+1]
+ * always corresponds to a region within the implicit value range of
+ * the value array.
+ *
+ * Note that this means the relationship of 'x' to x_array[index]
+ * and x_array[index+1] depends on the result region, i.e. the
+ * behaviour at the boundaries may not correspond to what you
+ * expect. We have the following complete specification of the
+ * behaviour.
+ * Suppose the input is x_array[] = { x0, x1, ..., xN }
+ * if ( x == x0 ) then index == 0
+ * if ( x > x0 && x <= x1 ) then index == 0, and sim. for other interior pts
+ * if ( x == xN ) then index == N-1
+ * if ( x > xN ) then index == N-1
+ * if ( x < x0 ) then index == 0
+ */
+size_t
+gsl_interp_bsearch(
+ const double x_array[], double x,
+ size_t index_lo,
+ size_t index_hi
+ );
+
+
+#ifdef HAVE_INLINE
+extern
+inline
+size_t
+gsl_interp_bsearch(
+ const double x_array[], double x,
+ size_t index_lo,
+ size_t index_hi
+ )
+{
+ size_t ilo = index_lo;
+ size_t ihi = index_hi;
+ while(ihi > ilo + 1) {
+ size_t i = (ihi + ilo)/2;
+ if(x_array[i] > x)
+ ihi = i;
+ else
+ ilo = i;
+ }
+
+ return ilo;
+}
+#endif /* HAVE_INLINE */
+
+
+#endif /* __GSL_INTERP_BSEARCH_H__ */
diff --git a/gsl-1.9/interpolation/cspline.c b/gsl-1.9/interpolation/cspline.c
new file mode 100644
index 0000000..6207b16
--- /dev/null
+++ b/gsl-1.9/interpolation/cspline.c
@@ -0,0 +1,475 @@
+/* interpolation/cspline.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_linalg.h>
+#include <gsl/gsl_vector.h>
+#include "integ_eval.h"
+#include <gsl/gsl_interp.h>
+
+typedef struct
+{
+ double * c;
+ double * g;
+ double * diag;
+ double * offdiag;
+} cspline_state_t;
+
+
+/* common initialization */
+static void *
+cspline_alloc (size_t size)
+{
+ cspline_state_t * state = (cspline_state_t *) malloc (sizeof (cspline_state_t));
+
+ if (state == NULL)
+ {
+ GSL_ERROR_NULL("failed to allocate space for state", GSL_ENOMEM);
+ }
+
+ state->c = (double *) malloc (size * sizeof (double));
+
+ if (state->c == NULL)
+ {
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for c", GSL_ENOMEM);
+ }
+
+ state->g = (double *) malloc (size * sizeof (double));
+
+ if (state->g == NULL)
+ {
+ free (state->c);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for g", GSL_ENOMEM);
+ }
+
+ state->diag = (double *) malloc (size * sizeof (double));
+
+ if (state->diag == NULL)
+ {
+ free (state->g);
+ free (state->c);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for diag", GSL_ENOMEM);
+ }
+
+ state->offdiag = (double *) malloc (size * sizeof (double));
+
+ if (state->offdiag == NULL)
+ {
+ free (state->diag);
+ free (state->g);
+ free (state->c);
+ free (state);
+ GSL_ERROR_NULL("failed to allocate space for offdiag", GSL_ENOMEM);
+ }
+
+ return state;
+}
+
+
+/* natural spline calculation
+ * see [Engeln-Mullges + Uhlig, p. 254]
+ */
+static int
+cspline_init (void * vstate, const double xa[], const double ya[],
+ size_t size)
+{
+ cspline_state_t *state = (cspline_state_t *) vstate;
+
+ size_t i;
+ size_t num_points = size;
+ size_t max_index = num_points - 1; /* Engeln-Mullges + Uhlig "n" */
+ size_t sys_size = max_index - 1; /* linear system is sys_size x sys_size */
+
+ state->c[0] = 0.0;
+ state->c[max_index] = 0.0;
+
+ for (i = 0; i < sys_size; i++)
+ {
+ const double h_i = xa[i + 1] - xa[i];
+ const double h_ip1 = xa[i + 2] - xa[i + 1];
+ const double ydiff_i = ya[i + 1] - ya[i];
+ const double ydiff_ip1 = ya[i + 2] - ya[i + 1];
+ const double g_i = (h_i != 0.0) ? 1.0 / h_i : 0.0;
+ const double g_ip1 = (h_ip1 != 0.0) ? 1.0 / h_ip1 : 0.0;
+ state->offdiag[i] = h_ip1;
+ state->diag[i] = 2.0 * (h_ip1 + h_i);
+ state->g[i] = 3.0 * (ydiff_ip1 * g_ip1 - ydiff_i * g_i);
+ }
+
+ if (sys_size == 1)
+ {
+ state->c[1] = state->g[0] / state->diag[0];
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ gsl_vector_view g_vec = gsl_vector_view_array(state->g, sys_size);
+ gsl_vector_view diag_vec = gsl_vector_view_array(state->diag, sys_size);
+ gsl_vector_view offdiag_vec = gsl_vector_view_array(state->offdiag, sys_size - 1);
+ gsl_vector_view solution_vec = gsl_vector_view_array ((state->c) + 1, sys_size);
+
+ int status = gsl_linalg_solve_symm_tridiag(&diag_vec.vector,
+ &offdiag_vec.vector,
+ &g_vec.vector,
+ &solution_vec.vector);
+ return status;
+ }
+}
+
+
+/* periodic spline calculation
+ * see [Engeln-Mullges + Uhlig, p. 256]
+ */
+static int
+cspline_init_periodic (void * vstate, const double xa[], const double ya[],
+ size_t size)
+{
+ cspline_state_t *state = (cspline_state_t *) vstate;
+
+ size_t i;
+ size_t num_points = size;
+ size_t max_index = num_points - 1; /* Engeln-Mullges + Uhlig "n" */
+ size_t sys_size = max_index; /* linear system is sys_size x sys_size */
+
+ if (sys_size == 2) {
+ /* solve 2x2 system */
+
+ const double h0 = xa[1] - xa[0];
+ const double h1 = xa[2] - xa[1];
+
+ const double A = 2.0*(h0 + h1);
+ const double B = h0 + h1;
+ double g[2];
+ double det;
+
+ g[0] = 3.0 * ((ya[2] - ya[1]) / h1 - (ya[1] - ya[0]) / h0);
+ g[1] = 3.0 * ((ya[1] - ya[2]) / h0 - (ya[2] - ya[1]) / h1);
+
+ det = 3.0 * (h0 + h1) * (h0 + h1);
+ state->c[1] = ( A * g[0] - B * g[1])/det;
+ state->c[2] = (-B * g[0] + A * g[1])/det;
+ state->c[0] = state->c[2];
+
+ return GSL_SUCCESS;
+ } else {
+
+ for (i = 0; i < sys_size-1; i++) {
+ const double h_i = xa[i + 1] - xa[i];
+ const double h_ip1 = xa[i + 2] - xa[i + 1];
+ const double ydiff_i = ya[i + 1] - ya[i];
+ const double ydiff_ip1 = ya[i + 2] - ya[i + 1];
+ const double g_i = (h_i != 0.0) ? 1.0 / h_i : 0.0;
+ const double g_ip1 = (h_ip1 != 0.0) ? 1.0 / h_ip1 : 0.0;
+ state->offdiag[i] = h_ip1;
+ state->diag[i] = 2.0 * (h_ip1 + h_i);
+ state->g[i] = 3.0 * (ydiff_ip1 * g_ip1 - ydiff_i * g_i);
+ }
+
+ i = sys_size - 1;
+
+ {
+ const double h_i = xa[i + 1] - xa[i];
+ const double h_ip1 = xa[1] - xa[0];
+ const double ydiff_i = ya[i + 1] - ya[i];
+ const double ydiff_ip1 = ya[1] - ya[0];
+ const double g_i = (h_i != 0.0) ? 1.0 / h_i : 0.0;
+ const double g_ip1 = (h_ip1 != 0.0) ? 1.0 / h_ip1 : 0.0;
+ state->offdiag[i] = h_ip1;
+ state->diag[i] = 2.0 * (h_ip1 + h_i);
+ state->g[i] = 3.0 * (ydiff_ip1 * g_ip1 - ydiff_i * g_i);
+ }
+
+ {
+ gsl_vector_view g_vec = gsl_vector_view_array(state->g, sys_size);
+ gsl_vector_view diag_vec = gsl_vector_view_array(state->diag, sys_size);
+ gsl_vector_view offdiag_vec = gsl_vector_view_array(state->offdiag, sys_size);
+ gsl_vector_view solution_vec = gsl_vector_view_array ((state->c) + 1, sys_size);
+
+ int status = gsl_linalg_solve_symm_cyc_tridiag(&diag_vec.vector,
+ &offdiag_vec.vector,
+ &g_vec.vector,
+ &solution_vec.vector);
+ state->c[0] = state->c[max_index];
+
+ return status;
+ }
+ }
+}
+
+
+static
+void
+cspline_free (void * vstate)
+{
+ cspline_state_t *state = (cspline_state_t *) vstate;
+
+ free (state->c);
+ free (state->g);
+ free (state->diag);
+ free (state->offdiag);
+ free (state);
+}
+
+/* function for common coefficient determination
+ */
+static inline void
+coeff_calc (const double c_array[], double dy, double dx, size_t index,
+ double * b, double * c, double * d)
+{
+ const double c_i = c_array[index];
+ const double c_ip1 = c_array[index + 1];
+ *b = (dy / dx) - dx * (c_ip1 + 2.0 * c_i) / 3.0;
+ *c = c_i;
+ *d = (c_ip1 - c_i) / (3.0 * dx);
+}
+
+
+static
+int
+cspline_eval (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *y)
+{
+ const cspline_state_t *state = (const cspline_state_t *) vstate;
+
+ double x_lo, x_hi;
+ double dx;
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ x_hi = x_array[index + 1];
+ x_lo = x_array[index];
+ dx = x_hi - x_lo;
+ if (dx > 0.0)
+ {
+ const double y_lo = y_array[index];
+ const double y_hi = y_array[index + 1];
+ const double dy = y_hi - y_lo;
+ double delx = x - x_lo;
+ double b_i, c_i, d_i;
+ coeff_calc(state->c, dy, dx, index, &b_i, &c_i, &d_i);
+ *y = y_lo + delx * (b_i + delx * (c_i + delx * d_i));
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ *y = 0.0;
+ return GSL_EINVAL;
+ }
+}
+
+
+static
+int
+cspline_eval_deriv (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *dydx)
+{
+ const cspline_state_t *state = (const cspline_state_t *) vstate;
+
+ double x_lo, x_hi;
+ double dx;
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ x_hi = x_array[index + 1];
+ x_lo = x_array[index];
+ dx = x_hi - x_lo;
+ if (dx > 0.0)
+ {
+ const double y_lo = y_array[index];
+ const double y_hi = y_array[index + 1];
+ const double dy = y_hi - y_lo;
+ double delx = x - x_lo;
+ double b_i, c_i, d_i;
+ coeff_calc(state->c, dy, dx, index, &b_i, &c_i, &d_i);
+ *dydx = b_i + delx * (2.0 * c_i + 3.0 * d_i * delx);
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ *dydx = 0.0;
+ return GSL_FAILURE;
+ }
+}
+
+
+static
+int
+cspline_eval_deriv2 (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double * y_pp)
+{
+ const cspline_state_t *state = (const cspline_state_t *) vstate;
+
+ double x_lo, x_hi;
+ double dx;
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ x_hi = x_array[index + 1];
+ x_lo = x_array[index];
+ dx = x_hi - x_lo;
+ if (dx > 0.0)
+ {
+ const double y_lo = y_array[index];
+ const double y_hi = y_array[index + 1];
+ const double dy = y_hi - y_lo;
+ double delx = x - x_lo;
+ double b_i, c_i, d_i;
+ coeff_calc(state->c, dy, dx, index, &b_i, &c_i, &d_i);
+ *y_pp = 2.0 * c_i + 6.0 * d_i * delx;
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ *y_pp = 0.0;
+ return GSL_FAILURE;
+ }
+}
+
+
+static
+int
+cspline_eval_integ (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ gsl_interp_accel * acc,
+ double a, double b,
+ double * result)
+{
+ const cspline_state_t *state = (const cspline_state_t *) vstate;
+
+ size_t i, index_a, index_b;
+
+ if (acc != 0)
+ {
+ index_a = gsl_interp_accel_find (acc, x_array, size, a);
+ index_b = gsl_interp_accel_find (acc, x_array, size, b);
+ }
+ else
+ {
+ index_a = gsl_interp_bsearch (x_array, a, 0, size - 1);
+ index_b = gsl_interp_bsearch (x_array, b, 0, size - 1);
+ }
+
+ *result = 0.0;
+
+ /* interior intervals */
+ for(i=index_a; i<=index_b; i++) {
+ const double x_hi = x_array[i + 1];
+ const double x_lo = x_array[i];
+ const double y_lo = y_array[i];
+ const double y_hi = y_array[i + 1];
+ const double dx = x_hi - x_lo;
+ const double dy = y_hi - y_lo;
+ if(dx != 0.0) {
+ double b_i, c_i, d_i;
+ coeff_calc(state->c, dy, dx, i, &b_i, &c_i, &d_i);
+
+ if (i == index_a || i == index_b)
+ {
+ double x1 = (i == index_a) ? a : x_lo;
+ double x2 = (i == index_b) ? b : x_hi;
+ *result += integ_eval(y_lo, b_i, c_i, d_i, x_lo, x1, x2);
+ }
+ else
+ {
+ *result += dx * (y_lo + dx*(0.5*b_i + dx*(c_i/3.0 + 0.25*d_i*dx)));
+ }
+ }
+ else {
+ *result = 0.0;
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+static const gsl_interp_type cspline_type =
+{
+ "cspline",
+ 3,
+ &cspline_alloc,
+ &cspline_init,
+ &cspline_eval,
+ &cspline_eval_deriv,
+ &cspline_eval_deriv2,
+ &cspline_eval_integ,
+ &cspline_free
+};
+
+const gsl_interp_type * gsl_interp_cspline = &cspline_type;
+
+static const gsl_interp_type cspline_periodic_type =
+{
+ "cspline-periodic",
+ 2,
+ &cspline_alloc,
+ &cspline_init_periodic,
+ &cspline_eval,
+ &cspline_eval_deriv,
+ &cspline_eval_deriv2,
+ &cspline_eval_integ,
+ &cspline_free
+};
+
+const gsl_interp_type * gsl_interp_cspline_periodic = &cspline_periodic_type;
+
+
diff --git a/gsl-1.9/interpolation/gsl_interp.h b/gsl-1.9/interpolation/gsl_interp.h
new file mode 100644
index 0000000..d4757ca
--- /dev/null
+++ b/gsl-1.9/interpolation/gsl_interp.h
@@ -0,0 +1,202 @@
+/* interpolation/gsl_interp.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#ifndef __GSL_INTERP_H__
+#define __GSL_INTERP_H__
+#include <stdlib.h>
+#include <gsl/gsl_types.h>
+
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS /* empty */
+#endif
+
+__BEGIN_DECLS
+
+/* evaluation accelerator */
+typedef struct {
+ size_t cache; /* cache of index */
+ size_t miss_count; /* keep statistics */
+ size_t hit_count;
+}
+gsl_interp_accel;
+
+
+/* interpolation object type */
+typedef struct {
+ const char * name;
+ unsigned int min_size;
+ void * (*alloc) (size_t size);
+ int (*init) (void *, const double xa[], const double ya[], size_t size);
+ int (*eval) (const void *, const double xa[], const double ya[], size_t size, double x, gsl_interp_accel *, double * y);
+ int (*eval_deriv) (const void *, const double xa[], const double ya[], size_t size, double x, gsl_interp_accel *, double * y_p);
+ int (*eval_deriv2) (const void *, const double xa[], const double ya[], size_t size, double x, gsl_interp_accel *, double * y_pp);
+ int (*eval_integ) (const void *, const double xa[], const double ya[], size_t size, gsl_interp_accel *, double a, double b, double * result);
+ void (*free) (void *);
+
+} gsl_interp_type;
+
+
+/* general interpolation object */
+typedef struct {
+ const gsl_interp_type * type;
+ double xmin;
+ double xmax;
+ size_t size;
+ void * state;
+} gsl_interp;
+
+
+/* available types */
+GSL_VAR const gsl_interp_type * gsl_interp_linear;
+GSL_VAR const gsl_interp_type * gsl_interp_polynomial;
+GSL_VAR const gsl_interp_type * gsl_interp_cspline;
+GSL_VAR const gsl_interp_type * gsl_interp_cspline_periodic;
+GSL_VAR const gsl_interp_type * gsl_interp_akima;
+GSL_VAR const gsl_interp_type * gsl_interp_akima_periodic;
+
+gsl_interp_accel *
+gsl_interp_accel_alloc(void);
+
+size_t
+gsl_interp_accel_find(gsl_interp_accel * a, const double x_array[], size_t size, double x);
+
+int
+gsl_interp_accel_reset (gsl_interp_accel * a);
+
+void
+gsl_interp_accel_free(gsl_interp_accel * a);
+
+gsl_interp *
+gsl_interp_alloc(const gsl_interp_type * T, size_t n);
+
+int
+gsl_interp_init(gsl_interp * obj, const double xa[], const double ya[], size_t size);
+
+const char * gsl_interp_name(const gsl_interp * interp);
+unsigned int gsl_interp_min_size(const gsl_interp * interp);
+
+
+int
+gsl_interp_eval_e(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a, double * y);
+
+double
+gsl_interp_eval(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a);
+
+int
+gsl_interp_eval_deriv_e(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a,
+ double * d);
+
+double
+gsl_interp_eval_deriv(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a);
+
+int
+gsl_interp_eval_deriv2_e(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a,
+ double * d2);
+
+double
+gsl_interp_eval_deriv2(const gsl_interp * obj,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a);
+
+int
+gsl_interp_eval_integ_e(const gsl_interp * obj,
+ const double xa[], const double ya[],
+ double a, double b,
+ gsl_interp_accel * acc,
+ double * result);
+
+double
+gsl_interp_eval_integ(const gsl_interp * obj,
+ const double xa[], const double ya[],
+ double a, double b,
+ gsl_interp_accel * acc);
+
+void
+gsl_interp_free(gsl_interp * interp);
+
+size_t gsl_interp_bsearch(const double x_array[], double x,
+ size_t index_lo, size_t index_hi);
+
+#ifdef HAVE_INLINE
+extern inline size_t
+gsl_interp_bsearch(const double x_array[], double x,
+ size_t index_lo, size_t index_hi);
+
+extern inline size_t
+gsl_interp_bsearch(const double x_array[], double x,
+ size_t index_lo, size_t index_hi)
+{
+ size_t ilo = index_lo;
+ size_t ihi = index_hi;
+ while(ihi > ilo + 1) {
+ size_t i = (ihi + ilo)/2;
+ if(x_array[i] > x)
+ ihi = i;
+ else
+ ilo = i;
+ }
+
+ return ilo;
+}
+#endif
+
+#ifdef HAVE_INLINE
+extern inline size_t
+gsl_interp_accel_find(gsl_interp_accel * a, const double xa[], size_t len, double x)
+{
+ size_t x_index = a->cache;
+
+ if(x < xa[x_index]) {
+ a->miss_count++;
+ a->cache = gsl_interp_bsearch(xa, x, 0, x_index);
+ }
+ else if(x > xa[x_index + 1]) {
+ a->miss_count++;
+ a->cache = gsl_interp_bsearch(xa, x, x_index, len-1);
+ }
+ else {
+ a->hit_count++;
+ }
+
+ return a->cache;
+}
+#endif /* HAVE_INLINE */
+
+
+__END_DECLS
+
+#endif /* __GSL_INTERP_H__ */
diff --git a/gsl-1.9/interpolation/gsl_spline.h b/gsl-1.9/interpolation/gsl_spline.h
new file mode 100644
index 0000000..7eb40e9
--- /dev/null
+++ b/gsl-1.9/interpolation/gsl_spline.h
@@ -0,0 +1,101 @@
+/* interpolation/gsl_spline.h
+ *
+ * Copyright (C) 2001 Brian Gough
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GSL_SPLINE_H__
+#define __GSL_SPLINE_H__
+#include <stdlib.h>
+#include <gsl/gsl_interp.h>
+
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS /* empty */
+#endif
+
+__BEGIN_DECLS
+
+
+/* general interpolation object */
+typedef struct {
+ gsl_interp * interp;
+ double * x;
+ double * y;
+ size_t size;
+} gsl_spline;
+
+gsl_spline *
+gsl_spline_alloc(const gsl_interp_type * T, size_t size);
+
+int
+gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size);
+
+const char * gsl_spline_name(const gsl_spline * spline);
+unsigned int gsl_spline_min_size(const gsl_spline * spline);
+
+
+int
+gsl_spline_eval_e(const gsl_spline * spline, double x,
+ gsl_interp_accel * a, double * y);
+
+double
+gsl_spline_eval(const gsl_spline * spline, double x, gsl_interp_accel * a);
+
+int
+gsl_spline_eval_deriv_e(const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a,
+ double * y);
+
+double
+gsl_spline_eval_deriv(const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a);
+
+int
+gsl_spline_eval_deriv2_e(const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a,
+ double * y);
+
+double
+gsl_spline_eval_deriv2(const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a);
+
+int
+gsl_spline_eval_integ_e(const gsl_spline * spline,
+ double a, double b,
+ gsl_interp_accel * acc,
+ double * y);
+
+double
+gsl_spline_eval_integ(const gsl_spline * spline,
+ double a, double b,
+ gsl_interp_accel * acc);
+
+void
+gsl_spline_free(gsl_spline * spline);
+
+__END_DECLS
+
+#endif /* __GSL_INTERP_H__ */
diff --git a/gsl-1.9/interpolation/integ_eval.h b/gsl-1.9/interpolation/integ_eval.h
new file mode 100644
index 0000000..4cc21f0
--- /dev/null
+++ b/gsl-1.9/interpolation/integ_eval.h
@@ -0,0 +1,36 @@
+/* interpolation/integ_eval_macro.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* function for doing the spline integral evaluation
+ which is common to both the cspline and akima methods
+ */
+
+static inline double
+integ_eval (double ai, double bi, double ci, double di, double xi, double a,
+ double b)
+{
+ const double r1 = a - xi;
+ const double r2 = b - xi;
+ const double r12 = r1 + r2;
+ const double bterm = 0.5 * bi * r12;
+ const double cterm = (1.0 / 3.0) * ci * (r1 * r1 + r2 * r2 + r1 * r2);
+ const double dterm = 0.25 * di * r12 * (r1 * r1 + r2 * r2);
+
+ return (b - a) * (ai + bterm + cterm + dterm);
+}
diff --git a/gsl-1.9/interpolation/interp.c b/gsl-1.9/interpolation/interp.c
new file mode 100644
index 0000000..0361730
--- /dev/null
+++ b/gsl-1.9/interpolation/interp.c
@@ -0,0 +1,244 @@
+/* interpolation/interp.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_math.h>
+#include <gsl/gsl_interp.h>
+
+#define DISCARD_STATUS(s) if ((s) != GSL_SUCCESS) { GSL_ERROR_VAL("interpolation error", (s), GSL_NAN); }
+
+gsl_interp *
+gsl_interp_alloc (const gsl_interp_type * T, size_t size)
+{
+ gsl_interp * interp;
+
+ if (size < T->min_size)
+ {
+ GSL_ERROR_NULL ("insufficient number of points for interpolation type",
+ GSL_EINVAL);
+ }
+
+ interp = (gsl_interp *) malloc (sizeof(gsl_interp));
+
+ if (interp == NULL)
+ {
+ GSL_ERROR_NULL ("failed to allocate space for interp struct",
+ GSL_ENOMEM);
+ }
+
+ interp->type = T;
+ interp->size = size;
+
+ if (interp->type->alloc == NULL)
+ {
+ interp->state = NULL;
+ return interp;
+ }
+
+ interp->state = interp->type->alloc(size);
+
+ if (interp->state == NULL)
+ {
+ free (interp);
+ GSL_ERROR_NULL ("failed to allocate space for interp state", GSL_ENOMEM);
+ };
+
+ return interp;
+}
+
+int
+gsl_interp_init (gsl_interp * interp, const double x_array[], const double y_array[], size_t size)
+{
+ if (size != interp->size)
+ {
+ GSL_ERROR ("data must match size of interpolation object", GSL_EINVAL);
+ }
+
+ interp->xmin = x_array[0];
+ interp->xmax = x_array[size - 1];
+
+ {
+ int status = interp->type->init(interp->state, x_array, y_array, size);
+ return status;
+ }
+}
+
+const char *
+gsl_interp_name(const gsl_interp * interp)
+{
+ return interp->type->name;
+}
+
+unsigned int
+gsl_interp_min_size(const gsl_interp * interp)
+{
+ return interp->type->min_size;
+}
+
+void
+gsl_interp_free (gsl_interp * interp)
+{
+ if (interp->type->free)
+ interp->type->free (interp->state);
+ free (interp);
+}
+
+
+
+int
+gsl_interp_eval_e (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a, double *y)
+{
+ if (x < interp->xmin)
+ {
+ *y = ya[0];
+ return GSL_EDOM;
+ }
+ else if (x > interp->xmax)
+ {
+ *y = ya[interp->size - 1];
+ return GSL_EDOM;
+ }
+
+ return interp->type->eval (interp->state, xa, ya, interp->size, x, a, y);
+}
+
+double
+gsl_interp_eval (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a)
+{
+ double y;
+ int status = interp->type->eval (interp->state, xa, ya, interp->size, x, a, &y);
+
+ DISCARD_STATUS(status);
+
+ return y;
+}
+
+
+int
+gsl_interp_eval_deriv_e (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a,
+ double *dydx)
+{
+ if (x < interp->xmin)
+ {
+ *dydx = 0.0;
+ return GSL_EDOM;
+ }
+ else if (x > interp->xmax)
+ {
+ *dydx = 0.0;
+ return GSL_EDOM;
+ }
+
+ return interp->type->eval_deriv (interp->state, xa, ya, interp->size, x, a, dydx);
+}
+
+double
+gsl_interp_eval_deriv (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a)
+{
+ double dydx;
+ int status = interp->type->eval_deriv (interp->state, xa, ya, interp->size, x, a, &dydx);
+
+ DISCARD_STATUS(status);
+
+ return dydx;
+}
+
+
+int
+gsl_interp_eval_deriv2_e (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a,
+ double * d2)
+{
+ if (x < interp->xmin)
+ {
+ *d2 = 0.0;
+ return GSL_EDOM;
+ }
+ else if (x > interp->xmax)
+ {
+ *d2 = 0.0;
+ return GSL_EDOM;
+ }
+
+ return interp->type->eval_deriv2 (interp->state, xa, ya, interp->size, x, a, d2);
+}
+
+double
+gsl_interp_eval_deriv2 (const gsl_interp * interp,
+ const double xa[], const double ya[], double x,
+ gsl_interp_accel * a)
+{
+ double d2;
+ int status = interp->type->eval_deriv2 (interp->state, xa, ya, interp->size, x, a, &d2);
+
+ DISCARD_STATUS(status);
+
+ return d2;
+}
+
+
+int
+gsl_interp_eval_integ_e (const gsl_interp * interp,
+ const double xa[], const double ya[],
+ double a, double b,
+ gsl_interp_accel * acc,
+ double * result)
+{
+ if (a > b || a < interp->xmin || b > interp->xmax)
+ {
+ *result = 0.0;
+ return GSL_EDOM;
+ }
+ else if(a == b)
+ {
+ *result = 0.0;
+ return GSL_SUCCESS;
+ }
+
+ return interp->type->eval_integ (interp->state, xa, ya, interp->size, acc, a, b, result);
+}
+
+
+double
+gsl_interp_eval_integ (const gsl_interp * interp,
+ const double xa[], const double ya[],
+ double a, double b,
+ gsl_interp_accel * acc)
+{
+ double result;
+ int status = interp->type->eval_integ (interp->state, xa, ya, interp->size, acc, a, b, &result);
+
+ DISCARD_STATUS(status);
+
+ return result;
+}
+
+
diff --git a/gsl-1.9/interpolation/linear.c b/gsl-1.9/interpolation/linear.c
new file mode 100644
index 0000000..aa9ec00
--- /dev/null
+++ b/gsl-1.9/interpolation/linear.c
@@ -0,0 +1,198 @@
+/* interpolation/linear.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_interp.h>
+
+static int
+linear_init (void * vstate,
+ const double x_array[],
+ const double y_array[],
+ size_t size)
+{
+ return GSL_SUCCESS;
+}
+
+static
+int
+linear_eval (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *y)
+{
+ double x_lo, x_hi;
+ double y_lo, y_hi;
+ double dx;
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ x_lo = x_array[index];
+ x_hi = x_array[index + 1];
+ y_lo = y_array[index];
+ y_hi = y_array[index + 1];
+ dx = x_hi - x_lo;
+ if (dx > 0.0)
+ {
+ *y = y_lo + (x - x_lo) / dx * (y_hi - y_lo);
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ *y = 0.0;
+ return GSL_EINVAL;
+ }
+}
+
+
+static
+int
+linear_eval_deriv (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *dydx)
+{
+ double x_lo, x_hi;
+ double y_lo, y_hi;
+ double dx;
+ double dy;
+ size_t index;
+
+ if (a != 0)
+ {
+ index = gsl_interp_accel_find (a, x_array, size, x);
+ }
+ else
+ {
+ index = gsl_interp_bsearch (x_array, x, 0, size - 1);
+ }
+
+ /* evaluate */
+ x_lo = x_array[index];
+ x_hi = x_array[index + 1];
+ y_lo = y_array[index];
+ y_hi = y_array[index + 1];
+ dx = x_hi - x_lo;
+ dy = y_hi - y_lo;
+ if (dx > 0.0)
+ {
+ *dydx = dy / dx;;
+ return GSL_SUCCESS;
+ }
+ else
+ {
+ *dydx = 0.0;
+ return GSL_EINVAL;
+ }
+}
+
+
+static
+int
+linear_eval_deriv2 (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ double x,
+ gsl_interp_accel * a,
+ double *y_pp)
+{
+ *y_pp = 0.0;
+
+ return GSL_SUCCESS;
+}
+
+
+static
+int
+linear_eval_integ (const void * vstate,
+ const double x_array[], const double y_array[], size_t size,
+ gsl_interp_accel * acc,
+ double a, double b,
+ double * result)
+{
+ size_t i, index_a, index_b;
+
+ if (acc != 0)
+ {
+ index_a = gsl_interp_accel_find (acc, x_array, size, a);
+ index_b = gsl_interp_accel_find (acc, x_array, size, b);
+ }
+ else
+ {
+ index_a = gsl_interp_bsearch (x_array, a, 0, size - 1);
+ index_b = gsl_interp_bsearch (x_array, b, 0, size - 1);
+ }
+
+ /* endpoints span more than one interval */
+
+ *result = 0.0;
+
+ /* interior intervals */
+ for(i=index_a; i<=index_b; i++) {
+ const double x_hi = x_array[i + 1];
+ const double x_lo = x_array[i];
+ const double y_lo = y_array[i];
+ const double y_hi = y_array[i + 1];
+ const double dx = x_hi - x_lo;
+
+ if(dx != 0.0) {
+ if (i == index_a || i == index_b)
+ {
+ double x1 = (i == index_a) ? a : x_lo;
+ double x2 = (i == index_b) ? b : x_hi;
+ const double D = (y_hi-y_lo)/dx;
+ *result += (x2-x1) * (y_lo + 0.5*D*((x2-x_lo)+(x1-x_lo)));
+ }
+ else
+ {
+ *result += 0.5 * dx * (y_lo + y_hi);
+ }
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+static const gsl_interp_type linear_type =
+{
+ "linear",
+ 2,
+ NULL, /* alloc, not applicable */
+ &linear_init,
+ &linear_eval,
+ &linear_eval_deriv,
+ &linear_eval_deriv2,
+ &linear_eval_integ,
+ NULL, /* free, not applicable */
+};
+
+const gsl_interp_type * gsl_interp_linear = &linear_type;
diff --git a/gsl-1.9/interpolation/poly.c b/gsl-1.9/interpolation/poly.c
new file mode 100644
index 0000000..a0cd68a
--- /dev/null
+++ b/gsl-1.9/interpolation/poly.c
@@ -0,0 +1,173 @@
+/* interpolation/interp_poly.c
+ *
+ * Copyright (C) 2001 DAN, HO-JIN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <math.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_poly.h>
+#include <gsl/gsl_interp.h>
+
+typedef struct
+{
+ double *d;
+ double *coeff;
+ double *work;
+}
+polynomial_state_t;
+
+static void *
+polynomial_alloc (size_t size)
+{
+ polynomial_state_t *state =
+ (polynomial_state_t *) malloc (sizeof (polynomial_state_t));
+
+ if (state == 0)
+ {
+ GSL_ERROR_NULL ("failed to allocate space for polynomial state",
+ GSL_ENOMEM);
+ }
+
+ state->d = (double *) malloc (sizeof (double) * size);
+
+ if (state->d == 0)
+ {
+ free (state);
+ GSL_ERROR_NULL ("failed to allocate space for d", GSL_ENOMEM);
+ }
+
+ state->coeff = (double *) malloc (sizeof (double) * size);
+
+ if (state->coeff == 0)
+ {
+ free (state->d);
+ free (state);
+ GSL_ERROR_NULL ("failed to allocate space for d", GSL_ENOMEM);
+ }
+
+ state->work = (double *) malloc (sizeof (double) * size);
+
+ if (state->work == 0)
+ {
+ free (state->coeff);
+ free (state->d);
+ free (state);
+ GSL_ERROR_NULL ("failed to allocate space for d", GSL_ENOMEM);
+ }
+
+ return state;
+}
+
+static int
+polynomial_init (void *vstate,
+ const double xa[], const double ya[], size_t size)
+{
+ polynomial_state_t *state = (polynomial_state_t *) vstate;
+
+ int status = gsl_poly_dd_init (state->d, xa, ya, size);
+
+ return status;
+}
+
+static int
+polynomial_eval (const void *vstate,
+ const double xa[], const double ya[], size_t size, double x,
+ gsl_interp_accel * acc, double *y)
+{
+ const polynomial_state_t *state = (const polynomial_state_t *) vstate;
+
+ *y = gsl_poly_dd_eval (state->d, xa, size, x);
+
+ return GSL_SUCCESS;
+}
+
+
+static int
+polynomial_deriv (const void *vstate,
+ const double xa[], const double ya[], size_t size, double x,
+ gsl_interp_accel * acc, double *y)
+{
+ const polynomial_state_t *state = (const polynomial_state_t *) vstate;
+
+ gsl_poly_dd_taylor (state->coeff, x, state->d, xa, size, state->work);
+
+ *y = state->coeff[1];
+
+ return GSL_SUCCESS;
+}
+
+static int
+polynomial_deriv2 (const void *vstate,
+ const double xa[], const double ya[], size_t size,
+ double x, gsl_interp_accel * acc, double *y)
+{
+ const polynomial_state_t *state = (const polynomial_state_t *) vstate;
+
+ gsl_poly_dd_taylor (state->coeff, x, state->d, xa, size, state->work);
+
+ *y = 2.0 * state->coeff[2];
+
+ return GSL_SUCCESS;
+}
+
+static int
+polynomial_integ (const void *vstate, const double xa[], const double ya[],
+ size_t size, gsl_interp_accel * acc, double a, double b,
+ double *result)
+{
+ const polynomial_state_t *state = (const polynomial_state_t *) vstate;
+ size_t i;
+ double sum;
+
+ gsl_poly_dd_taylor (state->coeff, 0.0, state->d, xa, size, state->work);
+
+ sum = state->coeff[0] * (b - a);
+
+ for (i = 1; i < size; i++)
+ {
+ sum += state->coeff[i] * (pow (b, i + 1) - pow (a, i + 1)) / (i + 1.0);
+ }
+
+ *result = sum;
+
+ return GSL_SUCCESS;
+}
+
+static void
+polynomial_free (void *vstate)
+{
+ polynomial_state_t *state = (polynomial_state_t *) vstate;
+ free (state->d);
+ free (state->coeff);
+ free (state->work);
+ free (state);
+}
+
+static const gsl_interp_type polynomial_type = {
+ "polynomial",
+ 3,
+ &polynomial_alloc,
+ &polynomial_init,
+ &polynomial_eval,
+ &polynomial_deriv,
+ &polynomial_deriv2,
+ &polynomial_integ,
+ &polynomial_free,
+};
+
+const gsl_interp_type *gsl_interp_polynomial = &polynomial_type;
diff --git a/gsl-1.9/interpolation/spline.c b/gsl-1.9/interpolation/spline.c
new file mode 100644
index 0000000..d5b5a0f
--- /dev/null
+++ b/gsl-1.9/interpolation/spline.c
@@ -0,0 +1,193 @@
+/* interpolation/spline.c
+ *
+ * Copyright (C) 2001 Brian Gough
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_interp.h>
+#include <gsl/gsl_spline.h>
+
+gsl_spline *
+gsl_spline_alloc (const gsl_interp_type * T, size_t size)
+{
+ gsl_spline * spline = (gsl_spline *) malloc (sizeof(gsl_spline));
+
+ if (spline == NULL)
+ {
+ GSL_ERROR_NULL ("failed to allocate space for spline struct",
+ GSL_ENOMEM);
+ }
+
+ spline->interp = gsl_interp_alloc (T, size);
+
+ if (spline->interp == NULL)
+ {
+ free (spline);
+ GSL_ERROR_NULL ("failed to allocate space for interp", GSL_ENOMEM);
+ };
+
+ spline->x = (double *) malloc (size * sizeof(double));
+
+ if (spline->x == NULL)
+ {
+ gsl_interp_free(spline->interp);
+ free(spline);
+ GSL_ERROR_NULL ("failed to allocate space for x", GSL_ENOMEM);
+ }
+
+ spline->y = (double *) malloc (size * sizeof(double));
+
+ if (spline->y == NULL)
+ {
+ free(spline->x);
+ gsl_interp_free(spline->interp);
+ free(spline);
+ GSL_ERROR_NULL ("failed to allocate space for y", GSL_ENOMEM);
+ }
+
+ spline->size = size;
+
+ return spline;
+}
+
+int
+gsl_spline_init (gsl_spline * spline, const double x_array[], const double y_array[], size_t size)
+{
+ if (size != spline->size)
+ {
+ GSL_ERROR ("data must match size of spline object", GSL_EINVAL);
+ }
+
+ memcpy (spline->x, x_array, size * sizeof(double));
+ memcpy (spline->y, y_array, size * sizeof(double));
+
+ {
+ int status = gsl_interp_init (spline->interp, x_array, y_array, size);
+ return status;
+ }
+}
+
+const char *
+gsl_spline_name(const gsl_spline * spline)
+{
+ return gsl_interp_name(spline->interp);
+}
+
+unsigned int
+gsl_spline_min_size(const gsl_spline * spline)
+{
+ return gsl_interp_min_size(spline->interp);
+}
+
+void
+gsl_spline_free (gsl_spline * spline)
+{
+ gsl_interp_free (spline->interp);
+ free (spline->x);
+ free (spline->y);
+ free (spline);
+}
+
+int
+gsl_spline_eval_e (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a, double *y)
+{
+ return gsl_interp_eval_e (spline->interp,
+ spline->x, spline->y,
+ x, a, y);
+}
+
+double
+gsl_spline_eval (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a)
+{
+ return gsl_interp_eval (spline->interp,
+ spline->x, spline->y,
+ x, a);
+}
+
+
+int
+gsl_spline_eval_deriv_e (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a,
+ double *dydx)
+{
+ return gsl_interp_eval_deriv_e (spline->interp,
+ spline->x, spline->y,
+ x, a, dydx);
+}
+
+double
+gsl_spline_eval_deriv (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a)
+{
+ return gsl_interp_eval_deriv (spline->interp,
+ spline->x, spline->y,
+ x, a);
+}
+
+
+int
+gsl_spline_eval_deriv2_e (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a,
+ double * d2)
+{
+ return gsl_interp_eval_deriv2_e (spline->interp,
+ spline->x, spline->y,
+ x, a, d2);
+}
+
+double
+gsl_spline_eval_deriv2 (const gsl_spline * spline,
+ double x,
+ gsl_interp_accel * a)
+{
+ return gsl_interp_eval_deriv2 (spline->interp,
+ spline->x, spline->y,
+ x, a);
+}
+
+
+int
+gsl_spline_eval_integ_e (const gsl_spline * spline,
+ double a, double b,
+ gsl_interp_accel * acc,
+ double * result)
+{
+ return gsl_interp_eval_integ_e (spline->interp,
+ spline->x, spline->y,
+ a, b, acc, result);
+}
+
+
+double
+gsl_spline_eval_integ (const gsl_spline * spline,
+ double a, double b,
+ gsl_interp_accel * acc)
+{
+ return gsl_interp_eval_integ (spline->interp,
+ spline->x, spline->y,
+ a, b, acc);
+}
+
diff --git a/gsl-1.9/interpolation/test.c b/gsl-1.9/interpolation/test.c
new file mode 100644
index 0000000..feb01d5
--- /dev/null
+++ b/gsl-1.9/interpolation/test.c
@@ -0,0 +1,949 @@
+/* interpolation/test.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+/* Author: G. Jungman
+ */
+#include <config.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <gsl/gsl_test.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_interp.h>
+#include <gsl/gsl_ieee_utils.h>
+
+int
+test_bsearch(void)
+{
+ double x_array[5] = { 0.0, 1.0, 2.0, 3.0, 4.0 };
+ size_t index_result;
+ int status = 0;
+ int s;
+
+ /* check an interior point */
+ index_result = gsl_interp_bsearch(x_array, 1.5, 0, 4);
+ s = (index_result != 1);
+ status += s;
+ gsl_test (s, "simple bsearch");
+
+ /* check that we get the last interval if x == last value */
+ index_result = gsl_interp_bsearch(x_array, 4.0, 0, 4);
+ s = (index_result != 3);
+ status += s;
+ gsl_test (s, "upper endpoint bsearch");
+
+ /* check that we get the first interval if x == first value */
+ index_result = gsl_interp_bsearch(x_array, 0.0, 0, 4);
+ s = (index_result != 0);
+ status += s;
+ gsl_test (s, "lower endpoint bsearch");
+
+ /* check that we get correct interior boundary behaviour */
+ index_result = gsl_interp_bsearch(x_array, 2.0, 0, 4);
+ s = (index_result != 2);
+ status += s;
+ gsl_test (s, "degenerate bsearch");
+
+ /* check out of bounds above */
+ index_result = gsl_interp_bsearch(x_array, 10.0, 0, 4);
+ s = (index_result != 3);
+ status += s;
+ gsl_test (s, "out of bounds bsearch +");
+
+ /* check out of bounds below */
+ index_result = gsl_interp_bsearch(x_array, -10.0, 0, 4);
+ s = (index_result != 0);
+ status += s;
+ gsl_test (s, "out of bounds bsearch -");
+
+ return status;
+}
+
+
+
+typedef double TEST_FUNC (double);
+typedef struct _xy_table xy_table;
+
+struct _xy_table
+ {
+ double * x;
+ double * y;
+ size_t n;
+ };
+
+xy_table make_xy_table (double x[], double y[], size_t n);
+
+xy_table
+make_xy_table (double x[], double y[], size_t n)
+{
+ xy_table t;
+ t.x = x;
+ t.y = y;
+ t.n = n;
+ return t;
+}
+
+static int
+test_interp (
+ const xy_table * data_table,
+ const gsl_interp_type * T,
+ xy_table * test_table,
+ xy_table * test_d_table,
+ xy_table * test_i_table
+ )
+{
+ int status = 0, s1, s2, s3;
+ size_t i;
+
+ gsl_interp_accel *a = gsl_interp_accel_alloc ();
+ gsl_interp *interp = gsl_interp_alloc (T, data_table->n);
+
+ gsl_interp_init (interp, data_table->x, data_table->y, data_table->n);
+
+ for (i = 0; i < test_table->n; i++)
+ {
+ double x = test_table->x[i];
+ double y;
+ double deriv;
+ double integ;
+ double diff_y, diff_deriv, diff_integ;
+ s1 = gsl_interp_eval_e (interp, data_table->x, data_table->y, x, a, &y);
+ s2 = gsl_interp_eval_deriv_e (interp, data_table->x, data_table->y, x, a, &deriv);
+ s3 = gsl_interp_eval_integ_e (interp, data_table->x, data_table->y, test_table->x[0], x, a, &integ);
+
+ gsl_test (s1, "gsl_interp_eval_e %s", gsl_interp_name(interp));
+ gsl_test (s2, "gsl_interp_eval_deriv_e %s", gsl_interp_name(interp));
+ gsl_test (s3, "gsl_interp_eval_integ_e %s", gsl_interp_name(interp));
+
+ gsl_test_abs (y, test_table->y[i], 1e-10, "%s %d", gsl_interp_name(interp), i);
+ gsl_test_abs (deriv, test_d_table->y[i], 1e-10, "%s deriv %d", gsl_interp_name(interp), i);
+ gsl_test_abs (integ, test_i_table->y[i], 1e-10, "%s integ %d", gsl_interp_name(interp), i);
+
+ diff_y = y - test_table->y[i];
+ diff_deriv = deriv - test_d_table->y[i];
+ diff_integ = integ - test_i_table->y[i];
+ if (fabs (diff_y) > 1.e-10 || fabs(diff_deriv) > 1.0e-10 || fabs(diff_integ) > 1.0e-10) {
+ status++;
+ }
+ }
+
+ gsl_interp_accel_free (a);
+ gsl_interp_free (interp);
+
+ return status;
+}
+
+static int
+test_linear (void)
+{
+ int s;
+
+ double data_x[4] = { 0.0, 1.0, 2.0, 3.0 };
+ double data_y[4] = { 0.0, 1.0, 2.0, 3.0 };
+ double test_x[6] = { 0.0, 0.5, 1.0, 1.5, 2.5, 3.0 };
+ double test_y[6] = { 0.0, 0.5, 1.0, 1.5, 2.5, 3.0 };
+ double test_dy[6] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
+ double test_iy[6] = { 0.0, 0.125, 0.5, 9.0/8.0, 25.0/8.0, 9.0/2.0 };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 4);
+ xy_table test_table = make_xy_table(test_x, test_y, 6);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 6);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 6);
+
+ s = test_interp (&data_table, gsl_interp_linear, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "linear interpolation");
+ return s;
+}
+
+static int
+test_polynomial (void)
+{
+ int s;
+
+ double data_x[4] = { 0.0, 1.0, 2.0, 3.0 };
+ double data_y[4] = { 0.0, 1.0, 2.0, 3.0 };
+ double test_x[6] = { 0.0, 0.5, 1.0, 1.5, 2.5, 3.0 };
+ double test_y[6] = { 0.0, 0.5, 1.0, 1.5, 2.5, 3.0 };
+ double test_dy[6] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
+ double test_iy[6] = { 0.0, 0.125, 0.5, 9.0/8.0, 25.0/8.0, 9.0/2.0 };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 4);
+ xy_table test_table = make_xy_table(test_x, test_y, 6);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 6);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 6);
+
+ s = test_interp (&data_table, gsl_interp_polynomial, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "polynomial interpolation");
+ return s;
+}
+
+
+static int
+test_cspline (void)
+{
+ int s;
+
+ double data_x[3] = { 0.0, 1.0, 2.0 };
+ double data_y[3] = { 0.0, 1.0, 2.0 };
+ double test_x[4] = { 0.0, 0.5, 1.0, 2.0 };
+ double test_y[4] = { 0.0, 0.5, 1.0, 2.0 };
+ double test_dy[4] = { 1.0, 1.0, 1.0, 1.0 };
+ double test_iy[4] = { 0.0, 0.125, 0.5, 2.0 };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 3);
+ xy_table test_table = make_xy_table(test_x, test_y, 4);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 4);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 4);
+
+ s = test_interp (&data_table, gsl_interp_cspline, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "cspline interpolation");
+ return s;
+}
+
+static int
+test_cspline2 (void)
+{
+ /* Test taken from Young & Gregory, A Survey of Numerical
+ Mathematics, Vol 1 Chapter 6.8 */
+
+ int s;
+
+ double data_x[6] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
+
+ double data_y[6] = { 1.0,
+ 0.961538461538461, 0.862068965517241,
+ 0.735294117647059, 0.609756097560976,
+ 0.500000000000000 } ;
+
+ double test_x[50] = {
+ 0.00, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18,
+ 0.20, 0.22, 0.24, 0.26, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38,
+ 0.40, 0.42, 0.44, 0.46, 0.48, 0.50, 0.52, 0.54, 0.56, 0.58,
+ 0.60, 0.62, 0.64, 0.66, 0.68, 0.70, 0.72, 0.74, 0.76, 0.78,
+ 0.80, 0.82, 0.84, 0.86, 0.88, 0.90, 0.92, 0.94, 0.96, 0.98 };
+
+ double test_y[50] = {
+ 1.000000000000000, 0.997583282975581, 0.995079933416512,
+ 0.992403318788142, 0.989466806555819, 0.986183764184894,
+ 0.982467559140716, 0.978231558888635, 0.973389130893999,
+ 0.967853642622158, 0.961538461538461, 0.954382579685350,
+ 0.946427487413627, 0.937740299651188, 0.928388131325928,
+ 0.918438097365742, 0.907957312698524, 0.897012892252170,
+ 0.885671950954575, 0.874001603733634, 0.862068965517241,
+ 0.849933363488199, 0.837622973848936, 0.825158185056786,
+ 0.812559385569085, 0.799846963843167, 0.787041308336369,
+ 0.774162807506023, 0.761231849809467, 0.748268823704033,
+ 0.735294117647059, 0.722328486073082, 0.709394147325463,
+ 0.696513685724764, 0.683709685591549, 0.671004731246381,
+ 0.658421407009825, 0.645982297202442, 0.633709986144797,
+ 0.621627058157454, 0.609756097560976, 0.598112015427308,
+ 0.586679029833925, 0.575433685609685, 0.564352527583445,
+ 0.553412100584061, 0.542588949440392, 0.531859618981294,
+ 0.521200654035625, 0.510588599432241};
+
+ double test_dy[50] = {
+ -0.120113913432180, -0.122279726798445, -0.128777166897241,
+ -0.139606233728568, -0.154766927292426, -0.174259247588814,
+ -0.198083194617734, -0.226238768379184, -0.258725968873165,
+ -0.295544796099676, -0.336695250058719, -0.378333644186652,
+ -0.416616291919835, -0.451543193258270, -0.483114348201955,
+ -0.511329756750890, -0.536189418905076, -0.557693334664512,
+ -0.575841504029200, -0.590633926999137, -0.602070603574326,
+ -0.611319695518765, -0.619549364596455, -0.626759610807396,
+ -0.632950434151589, -0.638121834629033, -0.642273812239728,
+ -0.645406366983674, -0.647519498860871, -0.648613207871319,
+ -0.648687494015019, -0.647687460711257, -0.645558211379322,
+ -0.642299746019212, -0.637912064630930, -0.632395167214473,
+ -0.625749053769843, -0.617973724297039, -0.609069178796061,
+ -0.599035417266910, -0.587872439709585, -0.576731233416743,
+ -0.566762785681043, -0.557967096502484, -0.550344165881066,
+ -0.543893993816790, -0.538616580309654, -0.534511925359660,
+ -0.531580028966807, -0.529820891131095};
+
+ double test_iy[50] = {
+ 0.000000000000000, 0.019975905023535, 0.039902753768792,
+ 0.059777947259733, 0.079597153869625, 0.099354309321042,
+ 0.119041616685866, 0.138649546385285, 0.158166836189794,
+ 0.177580491219196, 0.196875783942601, 0.216036382301310,
+ 0.235045759060558, 0.253888601161251, 0.272550937842853,
+ 0.291020140643388, 0.309284923399436, 0.327335342246135,
+ 0.345162795617181, 0.362760024244829, 0.380121111159890,
+ 0.397241442753010, 0.414117280448683, 0.430745332379281,
+ 0.447122714446318, 0.463246950320456, 0.479115971441505,
+ 0.494728117018421, 0.510082134029305, 0.525177177221407,
+ 0.540012809111123, 0.554589001813881, 0.568906157172889,
+ 0.582965126887879, 0.596767214344995, 0.610314174616794,
+ 0.623608214462242, 0.636651992326715, 0.649448618342004,
+ 0.662001654326309, 0.674315113784241, 0.686393423540581,
+ 0.698241001711602, 0.709861835676399, 0.721259443710643,
+ 0.732436874986582, 0.743396709573044, 0.754141058435429,
+ 0.764671563435718, 0.774989397332469 };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 6);
+ xy_table test_table = make_xy_table(test_x, test_y, 50);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 50);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 50);
+
+ s = test_interp (&data_table, gsl_interp_cspline, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "cspline 1/(1+x^2) interpolation");
+ return s;
+}
+
+static int
+test_cspline3 (void)
+{
+ /* This data has been chosen to be random (uneven spacing in x and y)
+ and the exact cubic spine solution computed using Octave */
+
+ int s;
+
+ double data_x[7] = {
+ -1.2139767065644265,
+ -0.792590494453907,
+ -0.250954683125019,
+ 0.665867809951305,
+ 0.735655088722706,
+ 0.827622053027153,
+ 1.426592227816582
+ };
+
+ double data_y[7] = {
+ -0.00453877449035645,
+ 0.49763182550668716,
+ 0.17805472016334534,
+ 0.40514493733644485,
+ -0.21595209836959839,
+ 0.47405586764216423,
+ 0.46561462432146072
+ } ;
+
+ double test_x[19] = {
+ -1.2139767065644265,
+ -1.0735146358609200,
+ -0.9330525651574135,
+ -0.7925904944539071,
+ -0.6120452240109444,
+ -0.4314999535679818,
+ -0.2509546831250191,
+ 0.0546528145670890,
+ 0.3602603122591972,
+ 0.6658678099513053,
+ 0.6891302362084388,
+ 0.7123926624655723,
+ 0.7356550887227058,
+ 0.7663107434908548,
+ 0.7969663982590039,
+ 0.8276220530271530,
+ 1.0272787779569625,
+ 1.2269355028867721,
+ 1.4265922278165817,
+ };
+
+ double test_y[19] = {
+ -0.00453877449035645,
+ 0.25816917628390590,
+ 0.44938881397673230,
+ 0.49763182550668716,
+ 0.31389980410075147,
+ 0.09948951681196887,
+ 0.17805472016334534,
+ 1.27633142487980233,
+ 2.04936553432792001,
+ 0.40514493733644485,
+ 0.13322324792901385,
+ -0.09656315924697809,
+ -0.21595209836959839,
+ -0.13551147728045118,
+ 0.13466779030061801,
+ 0.47405586764216423,
+ 1.68064089899304370,
+ 1.43594739539458649,
+ 0.46561462432146072
+ };
+
+ double test_dy[19] = {
+ 1.955137555965937,
+ 1.700662049790549,
+ 0.937235531264386,
+ -0.335141999612553,
+ -1.401385073563169,
+ -0.674982149482761,
+ 1.844066772628670,
+ 4.202528085784793,
+ -0.284432022227558,
+ -11.616813551408383,
+ -11.272731243226174,
+ -7.994209291156876,
+ -1.781247695200491,
+ 6.373970868827501,
+ 10.597456848997197,
+ 10.889210245308570,
+ 1.803124267866902,
+ -3.648527318598099,
+ -5.465744514086432,
+ };
+
+ double test_iy[19] = {
+ 0.000000000000000,
+ 0.018231117234914,
+ 0.069178822023139,
+ 0.137781019634897,
+ 0.213936442847744,
+ 0.249280997744777,
+ 0.267492946016120,
+ 0.471372708120518,
+ 1.014473660088477,
+ 1.477731933018837,
+ 1.483978291717981,
+ 1.484256847945450,
+ 1.480341742628893,
+ 1.474315901028282,
+ 1.473972210647307,
+ 1.483279773396950,
+ 1.728562698140330,
+ 2.057796448999396,
+ 2.253662886537457,
+ };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 7);
+ xy_table test_table = make_xy_table(test_x, test_y, 19);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 19);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 19);
+
+ s = test_interp (&data_table, gsl_interp_cspline, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "cspline arbitrary data interpolation");
+ return s;
+}
+
+static int
+test_csplinep (void)
+{
+ /* This data has been chosen to be random (uneven spacing in x and y)
+ and the exact cubic spine solution computed using Octave */
+
+ int s;
+
+ double data_x[11] = {
+ 0.000000000000000,
+ 0.130153674349869,
+ 0.164545962312740,
+ 0.227375461261537,
+ 0.256465324353657,
+ 0.372545206874658,
+ 0.520820016781720,
+ 0.647654717733075,
+ 0.753429306654340,
+ 0.900873984827658,
+ 1.000000000000000,
+ };
+
+ double data_y[11] = {
+ 0.000000000000000,
+ 0.729629261832041,
+ 0.859286331568207,
+ 0.989913099419008,
+ 0.999175006262120,
+ 0.717928599519215,
+ -0.130443237213363,
+ -0.800267961158980,
+ -0.999767873040527,
+ -0.583333769240853,
+ -0.000000000000000,
+ } ;
+
+ double test_x[31] = {
+ 0.000000000000000,
+ 0.043384558116623,
+ 0.086769116233246,
+ 0.130153674349869,
+ 0.141617770337492,
+ 0.153081866325116,
+ 0.164545962312740,
+ 0.185489128629005,
+ 0.206432294945271,
+ 0.227375461261537,
+ 0.237072082292243,
+ 0.246768703322951,
+ 0.256465324353657,
+ 0.295158618527324,
+ 0.333851912700991,
+ 0.372545206874658,
+ 0.421970143510346,
+ 0.471395080146033,
+ 0.520820016781720,
+ 0.563098250432172,
+ 0.605376484082623,
+ 0.647654717733075,
+ 0.682912914040164,
+ 0.718171110347252,
+ 0.753429306654340,
+ 0.802577532712113,
+ 0.851725758769885,
+ 0.900873984827658,
+ 0.933915989885105,
+ 0.966957994942553,
+ 1.000000000000000
+ };
+
+ double test_y[31] = {
+ 0.000000000000000,
+ 0.268657574670719,
+ 0.517940878523929,
+ 0.729629261832041,
+ 0.777012551497867,
+ 0.820298314554859,
+ 0.859286331568207,
+ 0.918833991960315,
+ 0.962624749226346,
+ 0.989913099419008,
+ 0.996756196601349,
+ 0.999858105635752,
+ 0.999175006262120,
+ 0.959248551766306,
+ 0.863713527741856,
+ 0.717928599519215,
+ 0.470065187871106,
+ 0.177694938589523,
+ -0.130443237213363,
+ -0.385093922365765,
+ -0.613840011545983,
+ -0.800267961158980,
+ -0.912498361131651,
+ -0.980219217412290,
+ -0.999767873040528,
+ -0.943635958253643,
+ -0.800314354800596,
+ -0.583333769240853,
+ -0.403689914131666,
+ -0.206151346799382,
+ -0.000000000000000
+ };
+
+ double test_dy[31] = {
+ 6.275761975917336,
+ 6.039181349093287,
+ 5.382620652895025,
+ 4.306079887322550,
+ 3.957389777282752,
+ 3.591234754612763,
+ 3.207614819312586,
+ 2.473048186927024,
+ 1.702885029353488,
+ 0.897125346591982,
+ 0.513561009477969,
+ 0.125477545550710,
+ -0.267125045189792,
+ -1.773533414873785,
+ -3.141450982859891,
+ -4.370877749148106,
+ -5.562104227060234,
+ -6.171864888961167,
+ -6.200159734850907,
+ -5.781556055213110,
+ -4.974725570010514,
+ -3.779668279243120,
+ -2.569220222282655,
+ -1.254891157670244,
+ 0.163318914594122,
+ 2.074985916277011,
+ 3.711348850147548,
+ 5.072407716205733,
+ 5.754438923510391,
+ 6.155557010080926,
+ 6.275761975917336
+ };
+
+ double test_iy[31] = {
+ 0.000000000000000,
+ 0.005864903144198,
+ 0.023030998930796,
+ 0.050262495763030,
+ 0.058902457844100,
+ 0.068062330564832,
+ 0.077693991819461,
+ 0.096340576055474,
+ 0.116070578226521,
+ 0.136546192283223,
+ 0.146181187290769,
+ 0.155864434185569,
+ 0.165559443629720,
+ 0.203636318965633,
+ 0.239075190181586,
+ 0.269828050745236,
+ 0.299428805999600,
+ 0.315560685785616,
+ 0.316734151903742,
+ 0.305773798930857,
+ 0.284537037103156,
+ 0.254466034797342,
+ 0.224146112780097,
+ 0.190643050847000,
+ 0.155590744566140,
+ 0.107448508851745,
+ 0.064263083957312,
+ 0.029987183298960,
+ 0.013618510529526,
+ 0.003506827320794,
+ 0.000090064010007,
+ };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 11);
+ xy_table test_table = make_xy_table(test_x, test_y, 31);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 31);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 31);
+
+ s = test_interp (&data_table, gsl_interp_cspline_periodic, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "cspline periodic sine interpolation");
+ return s;
+}
+
+static int
+test_csplinep2 (void)
+{
+ /* This data tests the periodic case n=3 */
+
+ int s;
+
+ double data_x[3] = {
+ 0.123,
+ 0.423,
+ 1.123
+ };
+
+ double data_y[3] = {
+ 0.456000000000000,
+ 1.407056516295154,
+ 0.456000000000000
+ } ;
+
+ double test_x[61] = {
+ 0.123000000000000,
+ 0.133000000000000,
+ 0.143000000000000,
+ 0.153000000000000,
+ 0.163000000000000,
+ 0.173000000000000,
+ 0.183000000000000,
+ 0.193000000000000,
+ 0.203000000000000,
+ 0.213000000000000,
+ 0.223000000000000,
+ 0.233000000000000,
+ 0.243000000000000,
+ 0.253000000000000,
+ 0.263000000000000,
+ 0.273000000000000,
+ 0.283000000000000,
+ 0.293000000000000,
+ 0.303000000000000,
+ 0.313000000000000,
+ 0.323000000000000,
+ 0.333000000000000,
+ 0.343000000000000,
+ 0.353000000000000,
+ 0.363000000000000,
+ 0.373000000000000,
+ 0.383000000000000,
+ 0.393000000000000,
+ 0.403000000000000,
+ 0.413000000000000,
+ 0.423000000000000,
+ 0.446333333333333,
+ 0.469666666666667,
+ 0.493000000000000,
+ 0.516333333333333,
+ 0.539666666666667,
+ 0.563000000000000,
+ 0.586333333333333,
+ 0.609666666666667,
+ 0.633000000000000,
+ 0.656333333333333,
+ 0.679666666666667,
+ 0.703000000000000,
+ 0.726333333333333,
+ 0.749666666666667,
+ 0.773000000000000,
+ 0.796333333333333,
+ 0.819666666666667,
+ 0.843000000000000,
+ 0.866333333333333,
+ 0.889666666666667,
+ 0.913000000000000,
+ 0.936333333333333,
+ 0.959666666666667,
+ 0.983000000000000,
+ 1.006333333333333,
+ 1.029666666666667,
+ 1.053000000000000,
+ 1.076333333333333,
+ 1.099666666666667,
+ 1.123000000000000
+ };
+
+ double test_y[61] = {
+ 0.456000000000000,
+ 0.475443822110923,
+ 0.497423794931967,
+ 0.521758764840979,
+ 0.548267578215809,
+ 0.576769081434305,
+ 0.607082120874316,
+ 0.639025542913690,
+ 0.672418193930275,
+ 0.707078920301921,
+ 0.742826568406475,
+ 0.779479984621787,
+ 0.816858015325704,
+ 0.854779506896076,
+ 0.893063305710751,
+ 0.931528258147577,
+ 0.969993210584403,
+ 1.008277009399078,
+ 1.046198500969450,
+ 1.083576531673367,
+ 1.120229947888679,
+ 1.155977595993233,
+ 1.190638322364879,
+ 1.224030973381464,
+ 1.255974395420838,
+ 1.286287434860848,
+ 1.314788938079344,
+ 1.341297751454174,
+ 1.365632721363187,
+ 1.387612694184230,
+ 1.407056516295154,
+ 1.442092968697928,
+ 1.463321489456714,
+ 1.471728359403224,
+ 1.468299859369172,
+ 1.454022270186272,
+ 1.429881872686237,
+ 1.396864947700781,
+ 1.355957776061616,
+ 1.308146638600458,
+ 1.254417816149018,
+ 1.195757589539010,
+ 1.133152239602149,
+ 1.067588047170148,
+ 1.000051293074719,
+ 0.931528258147577,
+ 0.863005223220435,
+ 0.795468469125006,
+ 0.729904276693004,
+ 0.667298926756143,
+ 0.608638700146136,
+ 0.554909877694696,
+ 0.507098740233537,
+ 0.466191568594372,
+ 0.433174643608916,
+ 0.409034246108881,
+ 0.394756656925981,
+ 0.391328156891929,
+ 0.399735026838439,
+ 0.420963547597225,
+ 0.456000000000000
+ };
+
+ double test_dy[61] = {
+ 1.8115362215145774,
+ 2.0742089736341924,
+ 2.3187663635386602,
+ 2.5452083912279826,
+ 2.7535350567021584,
+ 2.9437463599611897,
+ 3.1158423010050744,
+ 3.2698228798338147,
+ 3.4056880964474079,
+ 3.5234379508458549,
+ 3.6230724430291570,
+ 3.7045915729973125,
+ 3.7679953407503231,
+ 3.8132837462881874,
+ 3.8404567896109061,
+ 3.8495144707184790,
+ 3.8404567896109061,
+ 3.8132837462881874,
+ 3.7679953407503231,
+ 3.7045915729973125,
+ 3.6230724430291565,
+ 3.5234379508458549,
+ 3.4056880964474074,
+ 3.2698228798338147,
+ 3.1158423010050749,
+ 2.9437463599611897,
+ 2.7535350567021584,
+ 2.5452083912279830,
+ 2.3187663635386597,
+ 2.0742089736341924,
+ 1.8115362215145772,
+ 1.1986331332354823,
+ 0.6279992234583869,
+ 0.0996344921833026,
+ -0.3864610605897765,
+ -0.8302874348608467,
+ -1.2318446306299125,
+ -1.5911326478969707,
+ -1.9081514866620208,
+ -2.1829011469250670,
+ -2.4153816286861041,
+ -2.6055929319451341,
+ -2.7535350567021584,
+ -2.8592080029571765,
+ -2.9226117707101862,
+ -2.9437463599611893,
+ -2.9226117707101862,
+ -2.8592080029571760,
+ -2.7535350567021593,
+ -2.6055929319451354,
+ -2.4153816286861045,
+ -2.1829011469250656,
+ -1.9081514866620242,
+ -1.5911326478969716,
+ -1.2318446306299160,
+ -0.8302874348608498,
+ -0.3864610605897769,
+ 0.0996344921832995,
+ 0.6279992234583824,
+ 1.1986331332354769,
+ 1.8115362215145772
+ };
+
+ double test_iy[61] = {
+ 0.000000000000000,
+ 0.004655030170954,
+ 0.009517330277919,
+ 0.014611356059886,
+ 0.019959751719625,
+ 0.025583349923681,
+ 0.031501171802382,
+ 0.037730426949832,
+ 0.044286513423914,
+ 0.051183017746288,
+ 0.058431714902395,
+ 0.066042568341453,
+ 0.074023729976459,
+ 0.082381540184189,
+ 0.091120527805195,
+ 0.100243410143811,
+ 0.109751092968147,
+ 0.119642670510092,
+ 0.129915425465314,
+ 0.140564828993259,
+ 0.151584540717153,
+ 0.162966408723997,
+ 0.174700469564574,
+ 0.186774948253444,
+ 0.199176258268946,
+ 0.211889001553197,
+ 0.224895968512091,
+ 0.238178138015305,
+ 0.251714677396289,
+ 0.265482942452275,
+ 0.279458477444273,
+ 0.312726362409309,
+ 0.346648754292945,
+ 0.380914974633193,
+ 0.415237358187469,
+ 0.449351252932597,
+ 0.483015020064806,
+ 0.516010033999735,
+ 0.548140682372425,
+ 0.579234366037328,
+ 0.609141499068300,
+ 0.637735508758604,
+ 0.664912835620912,
+ 0.690592933387298,
+ 0.714718269009247,
+ 0.737254322657649,
+ 0.758189587722801,
+ 0.777535570814405,
+ 0.795326791761572,
+ 0.811620783612819,
+ 0.826498092636068,
+ 0.840062278318649,
+ 0.852439913367300,
+ 0.863780583708163,
+ 0.874256888486789,
+ 0.884064440068133,
+ 0.893421864036559,
+ 0.902570799195836,
+ 0.911775897569142,
+ 0.921324824399059,
+ 0.931528258147577
+ };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 3);
+ xy_table test_table = make_xy_table(test_x, test_y, 61);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 61);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 61);
+
+ s = test_interp (&data_table, gsl_interp_cspline_periodic, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "cspline periodic 3pt interpolation");
+ return s;
+}
+
+
+
+static int
+test_akima (void)
+{
+ int s;
+
+ double data_x[5] = { 0.0, 1.0, 2.0, 3.0, 4.0 };
+ double data_y[5] = { 0.0, 1.0, 2.0, 3.0, 4.0 };
+ double test_x[4] = { 0.0, 0.5, 1.0, 2.0 };
+ double test_y[4] = { 0.0, 0.5, 1.0, 2.0 };
+ double test_dy[4] = { 1.0, 1.0, 1.0, 1.0 };
+ double test_iy[4] = { 0.0, 0.125, 0.5, 2.0 };
+
+ xy_table data_table = make_xy_table(data_x, data_y, 5);
+ xy_table test_table = make_xy_table(test_x, test_y, 4);
+ xy_table test_d_table = make_xy_table(test_x, test_dy, 4);
+ xy_table test_i_table = make_xy_table(test_x, test_iy, 4);
+
+ s = test_interp (&data_table, gsl_interp_akima, &test_table, &test_d_table, &test_i_table);
+ gsl_test (s, "akima interpolation");
+ return s;
+}
+
+
+int
+main (int argc, char **argv)
+{
+ int status = 0;
+
+ gsl_ieee_env_setup ();
+
+ argc = 0; /* prevent warnings about unused parameters */
+ argv = 0;
+
+ status += test_bsearch();
+ status += test_linear();
+ status += test_polynomial();
+ status += test_cspline();
+ status += test_cspline2();
+ status += test_cspline3();
+ status += test_csplinep();
+ status += test_csplinep2();
+ status += test_akima();
+
+ exit (gsl_test_summary());
+}