summaryrefslogtreecommitdiff
path: root/gsl-1.9/sort
diff options
context:
space:
mode:
Diffstat (limited to 'gsl-1.9/sort')
-rw-r--r--gsl-1.9/sort/ChangeLog58
-rw-r--r--gsl-1.9/sort/Makefile.am16
-rw-r--r--gsl-1.9/sort/Makefile.in546
-rw-r--r--gsl-1.9/sort/TODO36
-rw-r--r--gsl-1.9/sort/gsl_heapsort.h44
-rw-r--r--gsl-1.9/sort/gsl_sort.h20
-rw-r--r--gsl-1.9/sort/gsl_sort_char.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_double.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_float.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_int.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_long.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_long_double.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_short.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_uchar.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_uint.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_ulong.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_ushort.h50
-rw-r--r--gsl-1.9/sort/gsl_sort_vector.h20
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_char.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_double.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_float.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_int.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_long.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_long_double.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_short.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_uchar.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_uint.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_ulong.h51
-rw-r--r--gsl-1.9/sort/gsl_sort_vector_ushort.h51
-rw-r--r--gsl-1.9/sort/sort.c114
-rw-r--r--gsl-1.9/sort/sortind.c101
-rw-r--r--gsl-1.9/sort/sortvec.c90
-rw-r--r--gsl-1.9/sort/sortvec_source.c93
-rw-r--r--gsl-1.9/sort/sortvecind.c90
-rw-r--r--gsl-1.9/sort/sortvecind_source.c106
-rw-r--r--gsl-1.9/sort/subset.c86
-rw-r--r--gsl-1.9/sort/subset_source.c146
-rw-r--r--gsl-1.9/sort/subsetind.c86
-rw-r--r--gsl-1.9/sort/subsetind_source.c146
-rw-r--r--gsl-1.9/sort/test.c140
-rw-r--r--gsl-1.9/sort/test_heapsort.c183
-rw-r--r--gsl-1.9/sort/test_source.c292
42 files changed, 3524 insertions, 0 deletions
diff --git a/gsl-1.9/sort/ChangeLog b/gsl-1.9/sort/ChangeLog
new file mode 100644
index 0000000..1eff586
--- /dev/null
+++ b/gsl-1.9/sort/ChangeLog
@@ -0,0 +1,58 @@
+2005-08-31 Brian Gough <bjg@network-theory.co.uk>
+
+ * test_source.c: free index memory as well
+
+2005-04-08 Brian Gough <bjg@network-theory.co.uk>
+
+ * sortvecind_source.c sortvec_source.c: write tests in such a way
+ as to avoid an infinite loop if nan, by always comparing in the
+ same direction (note that nan < x and nan > x are both false)
+
+Tue Jun 26 12:06:58 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * subset_source. subsetind_source.c: make prototypes match header
+ file
+
+Sun Jan 21 18:36:04 2001 Brian Gough <bjg@network-theory.co.uk>
+
+ * subset.c, subsetind.c: added functions for selecting subsets
+ (k-th smallest or largest values)
+
+Mon Mar 13 13:57:33 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * sortind.c (gsl_heapsort_index): changed to use an array of
+ size_t's directly instead of gsl_permutation
+
+Mon Feb 28 20:30:06 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * renamed gsl_sort to gsl_heapsort, since this is more meaningful
+ and gsl_sort, gsl_sort_float, ... is now used for sorting of
+ arrays.
+
+ * added support for sorting of arrays, without going through a
+ gsl_vector object (gsl_sort_vector is now implemented in terms of
+ these functions)
+
+Sat Feb 26 14:47:36 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * added support for indirect sorting of objects
+
+ * fixed bug in indirect sorting from use of BASE type instead of
+ size_t for index.
+
+ * reorganized directory
+
+Fri Feb 25 19:30:08 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * sortind_source.c: changed return type of indirect sort to int,
+ to allow error return code in case where permutation and vector
+ sizes do not match
+
+Sat Feb 19 12:18:28 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * sortind_source.c: added indirect sorting
+
+Fri Feb 18 10:48:24 2000 Brian Gough <bjg@network-theory.co.uk>
+
+ * initial GPL sources from Thomas Walter
+ <walter@pctc.chemie.uni-erlangen.de>
diff --git a/gsl-1.9/sort/Makefile.am b/gsl-1.9/sort/Makefile.am
new file mode 100644
index 0000000..ddd010d
--- /dev/null
+++ b/gsl-1.9/sort/Makefile.am
@@ -0,0 +1,16 @@
+noinst_LTLIBRARIES = libgslsort.la
+
+pkginclude_HEADERS = gsl_heapsort.h gsl_sort.h gsl_sort_char.h gsl_sort_double.h gsl_sort_float.h gsl_sort_int.h gsl_sort_long.h gsl_sort_long_double.h gsl_sort_short.h gsl_sort_uchar.h gsl_sort_uint.h gsl_sort_ulong.h gsl_sort_ushort.h gsl_sort_vector.h gsl_sort_vector_char.h gsl_sort_vector_double.h gsl_sort_vector_float.h gsl_sort_vector_int.h gsl_sort_vector_long.h gsl_sort_vector_long_double.h gsl_sort_vector_short.h gsl_sort_vector_uchar.h gsl_sort_vector_uint.h gsl_sort_vector_ulong.h gsl_sort_vector_ushort.h
+
+INCLUDES= -I$(top_builddir) -I$(top_srcdir)
+
+libgslsort_la_SOURCES = sort.c sortind.c sortvec.c sortvecind.c subset.c subsetind.c
+noinst_HEADERS = sortvec_source.c sortvecind_source.c subset_source.c subsetind_source.c test_source.c test_heapsort.c
+
+TESTS = $(check_PROGRAMS)
+
+check_PROGRAMS = test
+
+test_SOURCES = test.c
+test_LDADD = libgslsort.la ../permutation/libgslpermutation.la ../vector/libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la
+
diff --git a/gsl-1.9/sort/Makefile.in b/gsl-1.9/sort/Makefile.in
new file mode 100644
index 0000000..f9fd060
--- /dev/null
+++ b/gsl-1.9/sort/Makefile.in
@@ -0,0 +1,546 @@
+# 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 = sort
+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)
+libgslsort_la_LIBADD =
+am_libgslsort_la_OBJECTS = sort.lo sortind.lo sortvec.lo sortvecind.lo \
+ subset.lo subsetind.lo
+libgslsort_la_OBJECTS = $(am_libgslsort_la_OBJECTS)
+am_test_OBJECTS = test.$(OBJEXT)
+test_OBJECTS = $(am_test_OBJECTS)
+test_DEPENDENCIES = libgslsort.la ../permutation/libgslpermutation.la \
+ ../vector/libgslvector.la ../block/libgslblock.la \
+ ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la \
+ ../test/libgsltest.la ../sys/libgslsys.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 = $(libgslsort_la_SOURCES) $(test_SOURCES)
+DIST_SOURCES = $(libgslsort_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 = libgslsort.la
+pkginclude_HEADERS = gsl_heapsort.h gsl_sort.h gsl_sort_char.h gsl_sort_double.h gsl_sort_float.h gsl_sort_int.h gsl_sort_long.h gsl_sort_long_double.h gsl_sort_short.h gsl_sort_uchar.h gsl_sort_uint.h gsl_sort_ulong.h gsl_sort_ushort.h gsl_sort_vector.h gsl_sort_vector_char.h gsl_sort_vector_double.h gsl_sort_vector_float.h gsl_sort_vector_int.h gsl_sort_vector_long.h gsl_sort_vector_long_double.h gsl_sort_vector_short.h gsl_sort_vector_uchar.h gsl_sort_vector_uint.h gsl_sort_vector_ulong.h gsl_sort_vector_ushort.h
+INCLUDES = -I$(top_builddir) -I$(top_srcdir)
+libgslsort_la_SOURCES = sort.c sortind.c sortvec.c sortvecind.c subset.c subsetind.c
+noinst_HEADERS = sortvec_source.c sortvecind_source.c subset_source.c subsetind_source.c test_source.c test_heapsort.c
+TESTS = $(check_PROGRAMS)
+test_SOURCES = test.c
+test_LDADD = libgslsort.la ../permutation/libgslpermutation.la ../vector/libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la
+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 sort/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu --ignore-deps sort/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
+libgslsort.la: $(libgslsort_la_OBJECTS) $(libgslsort_la_DEPENDENCIES)
+ $(LINK) $(libgslsort_la_LDFLAGS) $(libgslsort_la_OBJECTS) $(libgslsort_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/sort/TODO b/gsl-1.9/sort/TODO
new file mode 100644
index 0000000..4312ed6
--- /dev/null
+++ b/gsl-1.9/sort/TODO
@@ -0,0 +1,36 @@
+* Routines for selecting the k largest or smallest values could use
+heapsort for speed O(N log k) rather than insertion O(N k).
+
+* Sorting of complex arrarys without using additional memory. We try
+to avoid allocating memory internally in GSL, so internally computing
+the magnitudes and storing them in a temporary array is undesirable.
+
+Obviously a complex array can be sorted using sqrt(x*x + y*y) <=>
+sqrt(u*u + v*v) (written in a numerically stable way) for every
+comparison, but this may be unacceptably slow. Maybe not? It is just a
+constant factor. The square roots could sometimes be avoided by
+optimization,
+
+ (x,y) = (MAX(|x|,|y|), MIN(|x|,|y|))
+ (u,v) = (MAX(|u|,|v|), MIN(|u|,|v|))
+
+ if (x < u/sqrt(2)) /* This part is optional optimization */
+ return -1
+ if (x > u*sqrt(2))
+ return +1
+
+ if (x == 0 && u == 0) ...
+ if (x == 0) ...
+ if (u == 0) ...
+
+ t = u*sqrt((1+(v/u)^2)/(1+(y/x)^2))
+
+ if (x < t)
+ return -1
+ if (x > t)
+ return +1
+ else
+ return 0
+
+but this does depend on the data having sufficient range for the
+optimization to be worthwhile, otherwise it is an extra cost.
diff --git a/gsl-1.9/sort/gsl_heapsort.h b/gsl-1.9/sort/gsl_heapsort.h
new file mode 100644
index 0000000..29a9b79
--- /dev/null
+++ b/gsl-1.9/sort/gsl_heapsort.h
@@ -0,0 +1,44 @@
+/* sort/gsl_heapsort.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_HEAPSORT_H__
+#define __GSL_HEAPSORT_H__
+
+#include <gsl/gsl_permutation.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
+
+typedef int (*gsl_comparison_fn_t) (const void *, const void *);
+
+void gsl_heapsort (void * array, size_t count, size_t size, gsl_comparison_fn_t compare);
+int gsl_heapsort_index (size_t * p, const void * array, size_t count, size_t size, gsl_comparison_fn_t compare);
+
+__END_DECLS
+
+#endif /* __GSL_HEAPSORT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort.h b/gsl-1.9/sort/gsl_sort.h
new file mode 100644
index 0000000..b1496c2
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort.h
@@ -0,0 +1,20 @@
+#ifndef __GSL_SORT_H__
+#define __GSL_SORT_H__
+
+#include <gsl/gsl_sort_long_double.h>
+#include <gsl/gsl_sort_double.h>
+#include <gsl/gsl_sort_float.h>
+
+#include <gsl/gsl_sort_ulong.h>
+#include <gsl/gsl_sort_long.h>
+
+#include <gsl/gsl_sort_uint.h>
+#include <gsl/gsl_sort_int.h>
+
+#include <gsl/gsl_sort_ushort.h>
+#include <gsl/gsl_sort_short.h>
+
+#include <gsl/gsl_sort_uchar.h>
+#include <gsl/gsl_sort_char.h>
+
+#endif /* __GSL_SORT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_char.h b/gsl-1.9/sort/gsl_sort_char.h
new file mode 100644
index 0000000..0ea3060
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_char.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_char.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_CHAR_H__
+#define __GSL_SORT_CHAR_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_char (char * data, const size_t stride, const size_t n);
+void gsl_sort_char_index (size_t * p, const char * data, const size_t stride, const size_t n);
+
+int gsl_sort_char_smallest (char * dest, const size_t k, const char * src, const size_t stride, const size_t n);
+int gsl_sort_char_smallest_index (size_t * p, const size_t k, const char * src, const size_t stride, const size_t n);
+
+int gsl_sort_char_largest (char * dest, const size_t k, const char * src, const size_t stride, const size_t n);
+int gsl_sort_char_largest_index (size_t * p, const size_t k, const char * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_CHAR_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_double.h b/gsl-1.9/sort/gsl_sort_double.h
new file mode 100644
index 0000000..aa35bc3
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_double.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_double.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_DOUBLE_H__
+#define __GSL_SORT_DOUBLE_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort (double * data, const size_t stride, const size_t n);
+void gsl_sort_index (size_t * p, const double * data, const size_t stride, const size_t n);
+
+int gsl_sort_smallest (double * dest, const size_t k, const double * src, const size_t stride, const size_t n);
+int gsl_sort_smallest_index (size_t * p, const size_t k, const double * src, const size_t stride, const size_t n);
+
+int gsl_sort_largest (double * dest, const size_t k, const double * src, const size_t stride, const size_t n);
+int gsl_sort_largest_index (size_t * p, const size_t k, const double * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_DOUBLE_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_float.h b/gsl-1.9/sort/gsl_sort_float.h
new file mode 100644
index 0000000..80ab4a8
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_float.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_float.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_FLOAT_H__
+#define __GSL_SORT_FLOAT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_float (float * data, const size_t stride, const size_t n);
+void gsl_sort_float_index (size_t * p, const float * data, const size_t stride, const size_t n);
+
+int gsl_sort_float_smallest (float * dest, const size_t k, const float * src, const size_t stride, const size_t n);
+int gsl_sort_float_smallest_index (size_t * p, const size_t k, const float * src, const size_t stride, const size_t n);
+
+int gsl_sort_float_largest (float * dest, const size_t k, const float * src, const size_t stride, const size_t n);
+int gsl_sort_float_largest_index (size_t * p, const size_t k, const float * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_FLOAT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_int.h b/gsl-1.9/sort/gsl_sort_int.h
new file mode 100644
index 0000000..350e54c
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_int.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_int.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_INT_H__
+#define __GSL_SORT_INT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_int (int * data, const size_t stride, const size_t n);
+void gsl_sort_int_index (size_t * p, const int * data, const size_t stride, const size_t n);
+
+int gsl_sort_int_smallest (int * dest, const size_t k, const int * src, const size_t stride, const size_t n);
+int gsl_sort_int_smallest_index (size_t * p, const size_t k, const int * src, const size_t stride, const size_t n);
+
+int gsl_sort_int_largest (int * dest, const size_t k, const int * src, const size_t stride, const size_t n);
+int gsl_sort_int_largest_index (size_t * p, const size_t k, const int * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_INT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_long.h b/gsl-1.9/sort/gsl_sort_long.h
new file mode 100644
index 0000000..2d79914
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_long.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_long.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_LONG_H__
+#define __GSL_SORT_LONG_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_long (long * data, const size_t stride, const size_t n);
+void gsl_sort_long_index (size_t * p, const long * data, const size_t stride, const size_t n);
+
+int gsl_sort_long_smallest (long * dest, const size_t k, const long * src, const size_t stride, const size_t n);
+int gsl_sort_long_smallest_index (size_t * p, const size_t k, const long * src, const size_t stride, const size_t n);
+
+int gsl_sort_long_largest (long * dest, const size_t k, const long * src, const size_t stride, const size_t n);
+int gsl_sort_long_largest_index (size_t * p, const size_t k, const long * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_LONG_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_long_double.h b/gsl-1.9/sort/gsl_sort_long_double.h
new file mode 100644
index 0000000..8ba3418
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_long_double.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_long_double.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_LONG_DOUBLE_H__
+#define __GSL_SORT_LONG_DOUBLE_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_long_double (long double * data, const size_t stride, const size_t n);
+void gsl_sort_long_double_index (size_t * p, const long double * data, const size_t stride, const size_t n);
+
+int gsl_sort_long_double_smallest (long double * dest, const size_t k, const long double * src, const size_t stride, const size_t n);
+int gsl_sort_long_double_smallest_index (size_t * p, const size_t k, const long double * src, const size_t stride, const size_t n);
+
+int gsl_sort_long_double_largest (long double * dest, const size_t k, const long double * src, const size_t stride, const size_t n);
+int gsl_sort_long_double_largest_index (size_t * p, const size_t k, const long double * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_LONG_DOUBLE_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_short.h b/gsl-1.9/sort/gsl_sort_short.h
new file mode 100644
index 0000000..f0af319
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_short.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_short.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_SHORT_H__
+#define __GSL_SORT_SHORT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_short (short * data, const size_t stride, const size_t n);
+void gsl_sort_short_index (size_t * p, const short * data, const size_t stride, const size_t n);
+
+int gsl_sort_short_smallest (short * dest, const size_t k, const short * src, const size_t stride, const size_t n);
+int gsl_sort_short_smallest_index (size_t * p, const size_t k, const short * src, const size_t stride, const size_t n);
+
+int gsl_sort_short_largest (short * dest, const size_t k, const short * src, const size_t stride, const size_t n);
+int gsl_sort_short_largest_index (size_t * p, const size_t k, const short * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_SHORT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_uchar.h b/gsl-1.9/sort/gsl_sort_uchar.h
new file mode 100644
index 0000000..f3159a6
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_uchar.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_uchar.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_UCHAR_H__
+#define __GSL_SORT_UCHAR_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_uchar (unsigned char * data, const size_t stride, const size_t n);
+void gsl_sort_uchar_index (size_t * p, const unsigned char * data, const size_t stride, const size_t n);
+
+int gsl_sort_uchar_smallest (unsigned char * dest, const size_t k, const unsigned char * src, const size_t stride, const size_t n);
+int gsl_sort_uchar_smallest_index (size_t * p, const size_t k, const unsigned char * src, const size_t stride, const size_t n);
+
+int gsl_sort_uchar_largest (unsigned char * dest, const size_t k, const unsigned char * src, const size_t stride, const size_t n);
+int gsl_sort_uchar_largest_index (size_t * p, const size_t k, const unsigned char * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_UCHAR_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_uint.h b/gsl-1.9/sort/gsl_sort_uint.h
new file mode 100644
index 0000000..2397b9e
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_uint.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_uint.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_UINT_H__
+#define __GSL_SORT_UINT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_uint (unsigned int * data, const size_t stride, const size_t n);
+void gsl_sort_uint_index (size_t * p, const unsigned int * data, const size_t stride, const size_t n);
+
+int gsl_sort_uint_smallest (unsigned int * dest, const size_t k, const unsigned int * src, const size_t stride, const size_t n);
+int gsl_sort_uint_smallest_index (size_t * p, const size_t k, const unsigned int * src, const size_t stride, const size_t n);
+
+int gsl_sort_uint_largest (unsigned int * dest, const size_t k, const unsigned int * src, const size_t stride, const size_t n);
+int gsl_sort_uint_largest_index (size_t * p, const size_t k, const unsigned int * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_UINT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_ulong.h b/gsl-1.9/sort/gsl_sort_ulong.h
new file mode 100644
index 0000000..36b2158
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_ulong.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_ulong.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_ULONG_H__
+#define __GSL_SORT_ULONG_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_ulong (unsigned long * data, const size_t stride, const size_t n);
+void gsl_sort_ulong_index (size_t * p, const unsigned long * data, const size_t stride, const size_t n);
+
+int gsl_sort_ulong_smallest (unsigned long * dest, const size_t k, const unsigned long * src, const size_t stride, const size_t n);
+int gsl_sort_ulong_smallest_index (size_t * p, const size_t k, const unsigned long * src, const size_t stride, const size_t n);
+
+int gsl_sort_ulong_largest (unsigned long * dest, const size_t k, const unsigned long * src, const size_t stride, const size_t n);
+int gsl_sort_ulong_largest_index (size_t * p, const size_t k, const unsigned long * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_ULONG_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_ushort.h b/gsl-1.9/sort/gsl_sort_ushort.h
new file mode 100644
index 0000000..a5f56c9
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_ushort.h
@@ -0,0 +1,50 @@
+/* sort/gsl_sort_ushort.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_USHORT_H__
+#define __GSL_SORT_USHORT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.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
+
+void gsl_sort_ushort (unsigned short * data, const size_t stride, const size_t n);
+void gsl_sort_ushort_index (size_t * p, const unsigned short * data, const size_t stride, const size_t n);
+
+int gsl_sort_ushort_smallest (unsigned short * dest, const size_t k, const unsigned short * src, const size_t stride, const size_t n);
+int gsl_sort_ushort_smallest_index (size_t * p, const size_t k, const unsigned short * src, const size_t stride, const size_t n);
+
+int gsl_sort_ushort_largest (unsigned short * dest, const size_t k, const unsigned short * src, const size_t stride, const size_t n);
+int gsl_sort_ushort_largest_index (size_t * p, const size_t k, const unsigned short * src, const size_t stride, const size_t n);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_USHORT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector.h b/gsl-1.9/sort/gsl_sort_vector.h
new file mode 100644
index 0000000..d65a9ee
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector.h
@@ -0,0 +1,20 @@
+#ifndef __GSL_SORT_VECTOR_H__
+#define __GSL_SORT_VECTOR_H__
+
+#include <gsl/gsl_sort_vector_long_double.h>
+#include <gsl/gsl_sort_vector_double.h>
+#include <gsl/gsl_sort_vector_float.h>
+
+#include <gsl/gsl_sort_vector_ulong.h>
+#include <gsl/gsl_sort_vector_long.h>
+
+#include <gsl/gsl_sort_vector_uint.h>
+#include <gsl/gsl_sort_vector_int.h>
+
+#include <gsl/gsl_sort_vector_ushort.h>
+#include <gsl/gsl_sort_vector_short.h>
+
+#include <gsl/gsl_sort_vector_uchar.h>
+#include <gsl/gsl_sort_vector_char.h>
+
+#endif /* __GSL_SORT_VECTOR_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_char.h b/gsl-1.9/sort/gsl_sort_vector_char.h
new file mode 100644
index 0000000..c602856
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_char.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_char.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_CHAR_H__
+#define __GSL_SORT_VECTOR_CHAR_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_char.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
+
+void gsl_sort_vector_char (gsl_vector_char * v);
+int gsl_sort_vector_char_index (gsl_permutation * p, const gsl_vector_char * v);
+
+int gsl_sort_vector_char_smallest (char * dest, const size_t k, const gsl_vector_char * v);
+int gsl_sort_vector_char_largest (char * dest, const size_t k, const gsl_vector_char * v);
+
+int gsl_sort_vector_char_smallest_index (size_t * p, const size_t k, const gsl_vector_char * v);
+int gsl_sort_vector_char_largest_index (size_t * p, const size_t k, const gsl_vector_char * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_CHAR_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_double.h b/gsl-1.9/sort/gsl_sort_vector_double.h
new file mode 100644
index 0000000..92662f4
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_double.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_double.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_DOUBLE_H__
+#define __GSL_SORT_VECTOR_DOUBLE_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_double.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
+
+void gsl_sort_vector (gsl_vector * v);
+int gsl_sort_vector_index (gsl_permutation * p, const gsl_vector * v);
+
+int gsl_sort_vector_smallest (double * dest, const size_t k, const gsl_vector * v);
+int gsl_sort_vector_largest (double * dest, const size_t k, const gsl_vector * v);
+
+int gsl_sort_vector_smallest_index (size_t * p, const size_t k, const gsl_vector * v);
+int gsl_sort_vector_largest_index (size_t * p, const size_t k, const gsl_vector * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_DOUBLE_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_float.h b/gsl-1.9/sort/gsl_sort_vector_float.h
new file mode 100644
index 0000000..a90ae3e
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_float.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_float.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_FLOAT_H__
+#define __GSL_SORT_VECTOR_FLOAT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_float.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
+
+void gsl_sort_vector_float (gsl_vector_float * v);
+int gsl_sort_vector_float_index (gsl_permutation * p, const gsl_vector_float * v);
+
+int gsl_sort_vector_float_smallest (float * dest, const size_t k, const gsl_vector_float * v);
+int gsl_sort_vector_float_largest (float * dest, const size_t k, const gsl_vector_float * v);
+
+int gsl_sort_vector_float_smallest_index (size_t * p, const size_t k, const gsl_vector_float * v);
+int gsl_sort_vector_float_largest_index (size_t * p, const size_t k, const gsl_vector_float * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_FLOAT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_int.h b/gsl-1.9/sort/gsl_sort_vector_int.h
new file mode 100644
index 0000000..9c52cbe
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_int.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_int.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_INT_H__
+#define __GSL_SORT_VECTOR_INT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_int.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
+
+void gsl_sort_vector_int (gsl_vector_int * v);
+int gsl_sort_vector_int_index (gsl_permutation * p, const gsl_vector_int * v);
+
+int gsl_sort_vector_int_smallest (int * dest, const size_t k, const gsl_vector_int * v);
+int gsl_sort_vector_int_largest (int * dest, const size_t k, const gsl_vector_int * v);
+
+int gsl_sort_vector_int_smallest_index (size_t * p, const size_t k, const gsl_vector_int * v);
+int gsl_sort_vector_int_largest_index (size_t * p, const size_t k, const gsl_vector_int * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_INT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_long.h b/gsl-1.9/sort/gsl_sort_vector_long.h
new file mode 100644
index 0000000..df6eb36
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_long.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_long.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_LONG_H__
+#define __GSL_SORT_VECTOR_LONG_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_long.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
+
+void gsl_sort_vector_long (gsl_vector_long * v);
+int gsl_sort_vector_long_index (gsl_permutation * p, const gsl_vector_long * v);
+
+int gsl_sort_vector_long_smallest (long * dest, const size_t k, const gsl_vector_long * v);
+int gsl_sort_vector_long_largest (long * dest, const size_t k, const gsl_vector_long * v);
+
+int gsl_sort_vector_long_smallest_index (size_t * p, const size_t k, const gsl_vector_long * v);
+int gsl_sort_vector_long_largest_index (size_t * p, const size_t k, const gsl_vector_long * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_LONG_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_long_double.h b/gsl-1.9/sort/gsl_sort_vector_long_double.h
new file mode 100644
index 0000000..b2a23a9
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_long_double.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_long_double.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_LONG_DOUBLE_H__
+#define __GSL_SORT_VECTOR_LONG_DOUBLE_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_long_double.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
+
+void gsl_sort_vector_long_double (gsl_vector_long_double * v);
+int gsl_sort_vector_long_double_index (gsl_permutation * p, const gsl_vector_long_double * v);
+
+int gsl_sort_vector_long_double_smallest (long double * dest, const size_t k, const gsl_vector_long_double * v);
+int gsl_sort_vector_long_double_largest (long double * dest, const size_t k, const gsl_vector_long_double * v);
+
+int gsl_sort_vector_long_double_smallest_index (size_t * p, const size_t k, const gsl_vector_long_double * v);
+int gsl_sort_vector_long_double_largest_index (size_t * p, const size_t k, const gsl_vector_long_double * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_LONG_DOUBLE_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_short.h b/gsl-1.9/sort/gsl_sort_vector_short.h
new file mode 100644
index 0000000..0037754
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_short.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_short.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_SHORT_H__
+#define __GSL_SORT_VECTOR_SHORT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_short.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
+
+void gsl_sort_vector_short (gsl_vector_short * v);
+int gsl_sort_vector_short_index (gsl_permutation * p, const gsl_vector_short * v);
+
+int gsl_sort_vector_short_smallest (short * dest, const size_t k, const gsl_vector_short * v);
+int gsl_sort_vector_short_largest (short * dest, const size_t k, const gsl_vector_short * v);
+
+int gsl_sort_vector_short_smallest_index (size_t * p, const size_t k, const gsl_vector_short * v);
+int gsl_sort_vector_short_largest_index (size_t * p, const size_t k, const gsl_vector_short * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_SHORT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_uchar.h b/gsl-1.9/sort/gsl_sort_vector_uchar.h
new file mode 100644
index 0000000..975f624
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_uchar.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_uchar.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_UCHAR_H__
+#define __GSL_SORT_VECTOR_UCHAR_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_uchar.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
+
+void gsl_sort_vector_uchar (gsl_vector_uchar * v);
+int gsl_sort_vector_uchar_index (gsl_permutation * p, const gsl_vector_uchar * v);
+
+int gsl_sort_vector_uchar_smallest (unsigned char * dest, const size_t k, const gsl_vector_uchar * v);
+int gsl_sort_vector_uchar_largest (unsigned char * dest, const size_t k, const gsl_vector_uchar * v);
+
+int gsl_sort_vector_uchar_smallest_index (size_t * p, const size_t k, const gsl_vector_uchar * v);
+int gsl_sort_vector_uchar_largest_index (size_t * p, const size_t k, const gsl_vector_uchar * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_UCHAR_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_uint.h b/gsl-1.9/sort/gsl_sort_vector_uint.h
new file mode 100644
index 0000000..df9e25f
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_uint.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_uint.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_UINT_H__
+#define __GSL_SORT_VECTOR_UINT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_uint.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
+
+void gsl_sort_vector_uint (gsl_vector_uint * v);
+int gsl_sort_vector_uint_index (gsl_permutation * p, const gsl_vector_uint * v);
+
+int gsl_sort_vector_uint_smallest (unsigned int * dest, const size_t k, const gsl_vector_uint * v);
+int gsl_sort_vector_uint_largest (unsigned int * dest, const size_t k, const gsl_vector_uint * v);
+
+int gsl_sort_vector_uint_smallest_index (size_t * p, const size_t k, const gsl_vector_uint * v);
+int gsl_sort_vector_uint_largest_index (size_t * p, const size_t k, const gsl_vector_uint * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_UINT_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_ulong.h b/gsl-1.9/sort/gsl_sort_vector_ulong.h
new file mode 100644
index 0000000..a1fee7e
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_ulong.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_ulong.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_ULONG_H__
+#define __GSL_SORT_VECTOR_ULONG_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_ulong.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
+
+void gsl_sort_vector_ulong (gsl_vector_ulong * v);
+int gsl_sort_vector_ulong_index (gsl_permutation * p, const gsl_vector_ulong * v);
+
+int gsl_sort_vector_ulong_smallest (unsigned long * dest, const size_t k, const gsl_vector_ulong * v);
+int gsl_sort_vector_ulong_largest (unsigned long * dest, const size_t k, const gsl_vector_ulong * v);
+
+int gsl_sort_vector_ulong_smallest_index (size_t * p, const size_t k, const gsl_vector_ulong * v);
+int gsl_sort_vector_ulong_largest_index (size_t * p, const size_t k, const gsl_vector_ulong * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_ULONG_H__ */
diff --git a/gsl-1.9/sort/gsl_sort_vector_ushort.h b/gsl-1.9/sort/gsl_sort_vector_ushort.h
new file mode 100644
index 0000000..6b4bc16
--- /dev/null
+++ b/gsl-1.9/sort/gsl_sort_vector_ushort.h
@@ -0,0 +1,51 @@
+/* sort/gsl_sort_vector_ushort.h
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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_SORT_VECTOR_USHORT_H__
+#define __GSL_SORT_VECTOR_USHORT_H__
+
+#include <stdlib.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector_ushort.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
+
+void gsl_sort_vector_ushort (gsl_vector_ushort * v);
+int gsl_sort_vector_ushort_index (gsl_permutation * p, const gsl_vector_ushort * v);
+
+int gsl_sort_vector_ushort_smallest (unsigned short * dest, const size_t k, const gsl_vector_ushort * v);
+int gsl_sort_vector_ushort_largest (unsigned short * dest, const size_t k, const gsl_vector_ushort * v);
+
+int gsl_sort_vector_ushort_smallest_index (size_t * p, const size_t k, const gsl_vector_ushort * v);
+int gsl_sort_vector_ushort_largest_index (size_t * p, const size_t k, const gsl_vector_ushort * v);
+
+__END_DECLS
+
+#endif /* __GSL_SORT_VECTOR_USHORT_H__ */
diff --git a/gsl-1.9/sort/sort.c b/gsl-1.9/sort/sort.c
new file mode 100644
index 0000000..9e86ab0
--- /dev/null
+++ b/gsl-1.9/sort/sort.c
@@ -0,0 +1,114 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ *
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_heapsort.h>
+
+static inline void swap (void *base, size_t size, size_t i, size_t j);
+static inline void downheap (void *data, const size_t size, const size_t N, size_t k, gsl_comparison_fn_t compare);
+
+/* Inline swap function for moving objects around */
+
+static inline void
+swap (void *base, size_t size, size_t i, size_t j)
+{
+ register char *a = size * i + (char *) base;
+ register char *b = size * j + (char *) base;
+ register size_t s = size;
+
+ if (i == j)
+ return;
+
+ do
+ {
+ char tmp = *a;
+ *a++ = *b;
+ *b++ = tmp;
+ }
+ while (--s > 0);
+}
+
+#define CMP(data,size,j,k) (compare((char *)(data) + (size) * (j), (char *)(data) + (size) * (k)))
+
+static inline void
+downheap (void *data, const size_t size, const size_t N, size_t k, gsl_comparison_fn_t compare)
+{
+ while (k <= N / 2)
+ {
+ size_t j = 2 * k;
+
+ if (j < N && CMP (data, size, j, j + 1) < 0)
+ {
+ j++;
+ }
+
+ if (CMP (data, size, k, j) < 0)
+ {
+ swap (data, size, j, k);
+ }
+ else
+ {
+ break;
+ }
+
+ k = j;
+ }
+}
+
+void
+gsl_heapsort (void *data, size_t count, size_t size, gsl_comparison_fn_t compare)
+{
+ /* Sort the array in ascending order. This is a true inplace
+ algorithm with N log N operations. Worst case (an already sorted
+ array) is something like 20% slower */
+
+ size_t N;
+ size_t k;
+
+ if (count == 0)
+ {
+ return; /* No data to sort */
+ }
+
+ /* We have n_data elements, last element is at 'n_data-1', first at
+ '0' Set N to the last element number. */
+
+ N = count - 1;
+
+ k = N / 2;
+ k++; /* Compensate the first use of 'k--' */
+ do
+ {
+ k--;
+ downheap (data, size, N, k, compare);
+ }
+ while (k > 0);
+
+ while (N > 0)
+ {
+ /* first swap the elements */
+ swap (data, size, 0, N);
+
+ /* then process the heap */
+ N--;
+
+ downheap (data, size, N, 0, compare);
+ }
+}
diff --git a/gsl-1.9/sort/sortind.c b/gsl-1.9/sort/sortind.c
new file mode 100644
index 0000000..52cdc47
--- /dev/null
+++ b/gsl-1.9/sort/sortind.c
@@ -0,0 +1,101 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <gsl/gsl_heapsort.h>
+
+static inline void downheap (size_t * p, const void *data, const size_t size, const size_t N, size_t k, gsl_comparison_fn_t compare);
+
+#define CMP(data,size,j,k) (compare((const char *)(data) + (size) * (j), (const char *)(data) + (size) * (k)))
+
+static inline void
+downheap (size_t * p, const void *data, const size_t size, const size_t N, size_t k, gsl_comparison_fn_t compare)
+{
+ const size_t pki = p[k];
+
+ while (k <= N / 2)
+ {
+ size_t j = 2 * k;
+
+ if (j < N && CMP (data, size, p[j], p[j + 1]) < 0)
+ {
+ j++;
+ }
+
+ if (CMP (data, size, pki, p[j]) >= 0)
+ {
+ break;
+ }
+
+ p[k] = p[j];
+
+ k = j;
+ }
+
+ p[k] = pki;
+}
+
+int
+gsl_heapsort_index (size_t * p, const void *data, size_t count, size_t size, gsl_comparison_fn_t compare)
+{
+ /* Sort the array in ascending order. This is a true inplace
+ algorithm with N log N operations. Worst case (an already sorted
+ array) is something like 20% slower */
+
+ size_t i, k, N;
+
+ if (count == 0)
+ {
+ return GSL_SUCCESS; /* No data to sort */
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ p[i] = i ; /* set permutation to identity */
+ }
+
+ /* We have n_data elements, last element is at 'n_data-1', first at
+ '0' Set N to the last element number. */
+
+ N = count - 1;
+
+ k = N / 2;
+ k++; /* Compensate the first use of 'k--' */
+ do
+ {
+ k--;
+ downheap (p, data, size, N, k, compare);
+ }
+ while (k > 0);
+
+ while (N > 0)
+ {
+ /* first swap the elements */
+ size_t tmp = p[0];
+ p[0] = p[N];
+ p[N] = tmp;
+
+ /* then process the heap */
+ N--;
+
+ downheap (p, data, size, N, 0, compare);
+ }
+
+ return GSL_SUCCESS;
+}
diff --git a/gsl-1.9/sort/sortvec.c b/gsl-1.9/sort/sortvec.c
new file mode 100644
index 0000000..e949c71
--- /dev/null
+++ b/gsl-1.9/sort/sortvec.c
@@ -0,0 +1,90 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ *
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_sort.h>
+#include <gsl/gsl_sort_vector.h>
+
+#define BASE_LONG_DOUBLE
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_LONG_DOUBLE
+
+#define BASE_DOUBLE
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_DOUBLE
+
+#define BASE_FLOAT
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_FLOAT
+
+#define BASE_ULONG
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_ULONG
+
+#define BASE_LONG
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_LONG
+
+#define BASE_UINT
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_UINT
+
+#define BASE_INT
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_INT
+
+#define BASE_USHORT
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_USHORT
+
+#define BASE_SHORT
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_SHORT
+
+#define BASE_UCHAR
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_UCHAR
+
+#define BASE_CHAR
+#include "templates_on.h"
+#include "sortvec_source.c"
+#include "templates_off.h"
+#undef BASE_CHAR
diff --git a/gsl-1.9/sort/sortvec_source.c b/gsl-1.9/sort/sortvec_source.c
new file mode 100644
index 0000000..59dfa63
--- /dev/null
+++ b/gsl-1.9/sort/sortvec_source.c
@@ -0,0 +1,93 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ *
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+static inline void FUNCTION (my, downheap) (BASE * data, const size_t stride, const size_t N, size_t k);
+
+static inline void
+FUNCTION (my, downheap) (BASE * data, const size_t stride, const size_t N, size_t k)
+{
+ BASE v = data[k * stride];
+
+ while (k <= N / 2)
+ {
+ size_t j = 2 * k;
+
+ if (j < N && data[j * stride] < data[(j + 1) * stride])
+ {
+ j++;
+ }
+
+ if (!(v < data[j * stride])) /* avoid infinite loop if nan */
+ {
+ break;
+ }
+
+ data[k * stride] = data[j * stride];
+
+ k = j;
+ }
+
+ data[k * stride] = v;
+}
+
+void
+TYPE (gsl_sort) (BASE * data, const size_t stride, const size_t n)
+{
+ size_t N;
+ size_t k;
+
+ if (n == 0)
+ {
+ return; /* No data to sort */
+ }
+
+ /* We have n_data elements, last element is at 'n_data-1', first at
+ '0' Set N to the last element number. */
+
+ N = n - 1;
+
+ k = N / 2;
+ k++; /* Compensate the first use of 'k--' */
+ do
+ {
+ k--;
+ FUNCTION (my, downheap) (data, stride, N, k);
+ }
+ while (k > 0);
+
+ while (N > 0)
+ {
+ /* first swap the elements */
+ BASE tmp = data[0 * stride];
+ data[0 * stride] = data[N * stride];
+ data[N * stride] = tmp;
+
+ /* then process the heap */
+ N--;
+
+ FUNCTION (my, downheap) (data, stride, N, 0);
+ }
+}
+
+void
+TYPE (gsl_sort_vector) (TYPE (gsl_vector) * v)
+{
+ TYPE (gsl_sort) (v->data, v->stride, v->size) ;
+}
+
diff --git a/gsl-1.9/sort/sortvecind.c b/gsl-1.9/sort/sortvecind.c
new file mode 100644
index 0000000..a79f906
--- /dev/null
+++ b/gsl-1.9/sort/sortvecind.c
@@ -0,0 +1,90 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ *
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_sort.h>
+#include <gsl/gsl_sort_vector.h>
+
+#define BASE_LONG_DOUBLE
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_LONG_DOUBLE
+
+#define BASE_DOUBLE
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_DOUBLE
+
+#define BASE_FLOAT
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_FLOAT
+
+#define BASE_ULONG
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_ULONG
+
+#define BASE_LONG
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_LONG
+
+#define BASE_UINT
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_UINT
+
+#define BASE_INT
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_INT
+
+#define BASE_USHORT
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_USHORT
+
+#define BASE_SHORT
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_SHORT
+
+#define BASE_UCHAR
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_UCHAR
+
+#define BASE_CHAR
+#include "templates_on.h"
+#include "sortvecind_source.c"
+#include "templates_off.h"
+#undef BASE_CHAR
diff --git a/gsl-1.9/sort/sortvecind_source.c b/gsl-1.9/sort/sortvecind_source.c
new file mode 100644
index 0000000..04769ee
--- /dev/null
+++ b/gsl-1.9/sort/sortvecind_source.c
@@ -0,0 +1,106 @@
+/*
+ * Implement Heap sort -- direct and indirect sorting
+ * Based on descriptions in Sedgewick "Algorithms in C"
+ *
+ * Copyright (C) 1999 Thomas Walter
+ *
+ * 18 February 2000: Modified for GSL by Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+static inline void FUNCTION (index, downheap) (size_t * p, const BASE * data, const size_t stride, const size_t N, size_t k);
+
+static inline void
+FUNCTION (index, downheap) (size_t * p, const BASE * data, const size_t stride, const size_t N, size_t k)
+{
+ const size_t pki = p[k];
+
+ while (k <= N / 2)
+ {
+ size_t j = 2 * k;
+
+ if (j < N && data[p[j] * stride] < data[p[j + 1] * stride])
+ {
+ j++;
+ }
+
+ if (!(data[pki * stride] < data[p[j] * stride])) /* avoid infinite loop if nan */
+ {
+ break;
+ }
+
+ p[k] = p[j];
+
+ k = j;
+ }
+
+ p[k] = pki;
+}
+
+void
+FUNCTION (gsl_sort, index) (size_t * p, const BASE * data, const size_t stride, const size_t n)
+{
+ size_t N;
+ size_t i, k;
+
+ if (n == 0)
+ {
+ return; /* No data to sort */
+ }
+
+ /* set permutation to identity */
+
+ for (i = 0 ; i < n ; i++)
+ {
+ p[i] = i ;
+ }
+
+ /* We have n_data elements, last element is at 'n_data-1', first at
+ '0' Set N to the last element number. */
+
+ N = n - 1;
+
+ k = N / 2;
+ k++; /* Compensate the first use of 'k--' */
+ do
+ {
+ k--;
+ FUNCTION (index, downheap) (p, data, stride, N, k);
+ }
+ while (k > 0);
+
+ while (N > 0)
+ {
+ /* first swap the elements */
+ size_t tmp = p[0];
+ p[0] = p[N];
+ p[N] = tmp;
+
+ /* then process the heap */
+ N--;
+
+ FUNCTION (index, downheap) (p, data, stride, N, 0);
+ }
+}
+
+int
+FUNCTION (gsl_sort_vector, index) (gsl_permutation * permutation, const TYPE (gsl_vector) * v)
+{
+ if (permutation->size != v->size)
+ {
+ GSL_ERROR ("permutation and vector lengths are not equal", GSL_EBADLEN);
+ }
+
+ FUNCTION (gsl_sort, index) (permutation->data, v->data, v->stride, v->size) ;
+
+ return GSL_SUCCESS ;
+}
diff --git a/gsl-1.9/sort/subset.c b/gsl-1.9/sort/subset.c
new file mode 100644
index 0000000..436dc7d
--- /dev/null
+++ b/gsl-1.9/sort/subset.c
@@ -0,0 +1,86 @@
+/* sort/subset.c
+ *
+ * Copyright (C) 2001 Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_sort.h>
+#include <gsl/gsl_sort_vector.h>
+
+#define BASE_LONG_DOUBLE
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_LONG_DOUBLE
+
+#define BASE_DOUBLE
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_DOUBLE
+
+#define BASE_FLOAT
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_FLOAT
+
+#define BASE_ULONG
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_ULONG
+
+#define BASE_LONG
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_LONG
+
+#define BASE_UINT
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_UINT
+
+#define BASE_INT
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_INT
+
+#define BASE_USHORT
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_USHORT
+
+#define BASE_SHORT
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_SHORT
+
+#define BASE_UCHAR
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_UCHAR
+
+#define BASE_CHAR
+#include "templates_on.h"
+#include "subset_source.c"
+#include "templates_off.h"
+#undef BASE_CHAR
diff --git a/gsl-1.9/sort/subset_source.c b/gsl-1.9/sort/subset_source.c
new file mode 100644
index 0000000..8d02426
--- /dev/null
+++ b/gsl-1.9/sort/subset_source.c
@@ -0,0 +1,146 @@
+/* sort/subset_source.c
+ *
+ * Copyright (C) 1999,2000,2001 Thomas Walter, Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+/* find the k-th smallest elements of the vector data, in ascending order */
+
+int
+FUNCTION (gsl_sort, smallest) (BASE * dest, const size_t k,
+ const BASE * src, const size_t stride,
+ const size_t n)
+{
+ size_t i, j;
+ BASE xbound;
+
+ if (k > n)
+ {
+ GSL_ERROR ("subset length k exceeds vector length n", GSL_EINVAL);
+ }
+
+ if (k == 0 || n == 0)
+ {
+ return GSL_SUCCESS;
+ }
+
+ /* take the first element */
+
+ j = 1;
+ xbound = src[0 * stride];
+ dest[0] = xbound;
+
+ /* examine the remaining elements */
+
+ for (i = 1; i < n; i++)
+ {
+ size_t i1;
+
+ BASE xi = src[i * stride];
+
+ if (j < k)
+ {
+ j++;
+ }
+ else if (xi >= xbound)
+ {
+ continue;
+ }
+
+ for (i1 = j - 1; i1 > 0 ; i1--)
+ {
+ if (xi > dest[i1 - 1])
+ break;
+
+ dest[i1] = dest[i1 - 1];
+ }
+
+ dest[i1] = xi;
+
+ xbound = dest[j-1];
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+int
+FUNCTION (gsl_sort_vector,smallest) (BASE * dest, const size_t k,
+ const TYPE (gsl_vector) * v)
+{
+ return FUNCTION (gsl_sort, smallest) (dest, k, v->data, v->stride, v->size);
+}
+
+int
+FUNCTION (gsl_sort, largest) (BASE * dest, const size_t k,
+ const BASE * src, const size_t stride,
+ const size_t n)
+{
+ size_t i, j;
+ BASE xbound;
+
+ if (k > n)
+ {
+ GSL_ERROR ("subset length k exceeds vector length n", GSL_EINVAL);
+ }
+
+ if (k == 0 || n == 0)
+ {
+ return GSL_SUCCESS;
+ }
+
+ /* take the first element */
+
+ j = 1;
+ xbound = src[0 * stride];
+ dest[0] = xbound;
+
+ /* examine the remaining elements */
+
+ for (i = 1; i < n; i++)
+ {
+ size_t i1;
+
+ BASE xi = src[i * stride];
+
+ if (j < k)
+ {
+ j++;
+ }
+ else if (xi <= xbound)
+ {
+ continue;
+ }
+
+ for (i1 = j - 1; i1 > 0 ; i1--)
+ {
+ if (xi < dest[i1 - 1])
+ break;
+
+ dest[i1] = dest[i1 - 1];
+ }
+
+ dest[i1] = xi;
+
+ xbound = dest[j-1];
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+int
+FUNCTION (gsl_sort_vector,largest) (BASE * dest, const size_t k,
+ const TYPE (gsl_vector) * v)
+{
+ return FUNCTION (gsl_sort, largest) (dest, k, v->data, v->stride, v->size);
+}
diff --git a/gsl-1.9/sort/subsetind.c b/gsl-1.9/sort/subsetind.c
new file mode 100644
index 0000000..cc01e99
--- /dev/null
+++ b/gsl-1.9/sort/subsetind.c
@@ -0,0 +1,86 @@
+/* sort/subsetind.c
+ *
+ * Copyright (C) 2001 Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+#include <config.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_sort.h>
+#include <gsl/gsl_sort_vector.h>
+
+#define BASE_LONG_DOUBLE
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_LONG_DOUBLE
+
+#define BASE_DOUBLE
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_DOUBLE
+
+#define BASE_FLOAT
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_FLOAT
+
+#define BASE_ULONG
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_ULONG
+
+#define BASE_LONG
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_LONG
+
+#define BASE_UINT
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_UINT
+
+#define BASE_INT
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_INT
+
+#define BASE_USHORT
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_USHORT
+
+#define BASE_SHORT
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_SHORT
+
+#define BASE_UCHAR
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_UCHAR
+
+#define BASE_CHAR
+#include "templates_on.h"
+#include "subsetind_source.c"
+#include "templates_off.h"
+#undef BASE_CHAR
diff --git a/gsl-1.9/sort/subsetind_source.c b/gsl-1.9/sort/subsetind_source.c
new file mode 100644
index 0000000..5505fdf
--- /dev/null
+++ b/gsl-1.9/sort/subsetind_source.c
@@ -0,0 +1,146 @@
+/* sort/subsetind_source.c
+ *
+ * Copyright (C) 1999,2000,2001 Thomas Walter, Brian Gough
+ *
+ * This 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, or (at your option) any
+ * later version.
+ *
+ * This source 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.
+ */
+
+/* find the k-th smallest elements of the vector data, in ascending order */
+
+int
+FUNCTION (gsl_sort, smallest_index) (size_t * p, const size_t k,
+ const BASE * src, const size_t stride,
+ const size_t n)
+{
+ size_t i, j;
+ BASE xbound;
+
+ if (k > n)
+ {
+ GSL_ERROR ("subset length k exceeds vector length n", GSL_EINVAL);
+ }
+
+ if (k == 0 || n == 0)
+ {
+ return GSL_SUCCESS;
+ }
+
+ /* take the first element */
+
+ j = 1;
+ xbound = src[0 * stride];
+ p[0] = 0;
+
+ /* examine the remaining elements */
+
+ for (i = 1; i < n; i++)
+ {
+ size_t i1;
+
+ BASE xi = src[i * stride];
+
+ if (j < k)
+ {
+ j++;
+ }
+ else if (xi >= xbound)
+ {
+ continue;
+ }
+
+ for (i1 = j - 1; i1 > 0 ; i1--)
+ {
+ if (xi > src[p[i1 - 1] * stride])
+ break;
+
+ p[i1] = p[i1 - 1];
+ }
+
+ p[i1] = i;
+
+ xbound = src[p[j-1] * stride];
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+int
+FUNCTION (gsl_sort_vector,smallest_index) (size_t * p, const size_t k,
+ const TYPE (gsl_vector) * v)
+{
+ return FUNCTION (gsl_sort, smallest_index) (p, k, v->data, v->stride, v->size);
+}
+
+int
+FUNCTION (gsl_sort, largest_index) (size_t * p, const size_t k,
+ const BASE * src, const size_t stride,
+ const size_t n)
+{
+ size_t i, j;
+ BASE xbound;
+
+ if (k > n)
+ {
+ GSL_ERROR ("subset length k exceeds vector length n", GSL_EINVAL);
+ }
+
+ if (k == 0 || n == 0)
+ {
+ return GSL_SUCCESS;
+ }
+
+ /* take the first element */
+
+ j = 1;
+ xbound = src[0 * stride];
+ p[0] = 0;
+
+ /* examine the remaining elements */
+
+ for (i = 1; i < n; i++)
+ {
+ size_t i1;
+
+ BASE xi = src[i * stride];
+
+ if (j < k)
+ {
+ j++;
+ }
+ else if (xi <= xbound)
+ {
+ continue;
+ }
+
+ for (i1 = j - 1; i1 > 0 ; i1--)
+ {
+ if (xi < src[stride * p[i1 - 1]])
+ break;
+
+ p[i1] = p[i1 - 1];
+ }
+
+ p[i1] = i;
+
+ xbound = src[stride * p[j-1]];
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+int
+FUNCTION (gsl_sort_vector,largest_index) (size_t * p, const size_t k,
+ const TYPE (gsl_vector) * v)
+{
+ return FUNCTION (gsl_sort, largest_index) (p, k, v->data, v->stride, v->size);
+}
diff --git a/gsl-1.9/sort/test.c b/gsl-1.9/sort/test.c
new file mode 100644
index 0000000..24d3bc3
--- /dev/null
+++ b/gsl-1.9/sort/test.c
@@ -0,0 +1,140 @@
+/* sort/test.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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 <stdio.h>
+#include <stdlib.h>
+#include <gsl/gsl_math.h>
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_test.h>
+#include <gsl/gsl_heapsort.h>
+#include <gsl/gsl_sort.h>
+#include <gsl/gsl_sort_vector.h>
+#include <gsl/gsl_ieee_utils.h>
+
+size_t urand (size_t);
+
+#include "test_heapsort.c"
+
+#define BASE_LONG_DOUBLE
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_LONG_DOUBLE
+
+#define BASE_DOUBLE
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_DOUBLE
+
+#define BASE_FLOAT
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_FLOAT
+
+#define BASE_ULONG
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_ULONG
+
+#define BASE_LONG
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_LONG
+
+#define BASE_UINT
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_UINT
+
+#define BASE_INT
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_INT
+
+#define BASE_USHORT
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_USHORT
+
+#define BASE_SHORT
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_SHORT
+
+#define BASE_UCHAR
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_UCHAR
+
+#define BASE_CHAR
+#include "templates_on.h"
+#include "test_source.c"
+#include "templates_off.h"
+#undef BASE_CHAR
+
+int
+main (void)
+{
+ size_t i, s;
+
+ gsl_ieee_env_setup ();
+
+ /* Test for lengths of 1 ... 31, then 32, 64, 128, 256, ... */
+
+ for (i = 1; i < 1024; i = (i < 32) ? i + 1 : 2 * i)
+ test_heapsort (i);
+
+ for (i = 1; i < 1024; i = (i < 32) ? i + 1 : 2 * i)
+ {
+ for (s = 1; s < 4; s++)
+ {
+ test_sort_vector (i, s);
+ test_sort_vector_float (i, s);
+ test_sort_vector_long_double (i, s);
+ test_sort_vector_ulong (i, s);
+ test_sort_vector_long (i, s);
+ test_sort_vector_uint (i, s);
+ test_sort_vector_int (i, s);
+ test_sort_vector_ushort (i, s);
+ test_sort_vector_short (i, s);
+ test_sort_vector_uchar (i, s);
+ test_sort_vector_char (i, s);
+ }
+ }
+
+ exit (gsl_test_summary ());
+}
+
+size_t
+urand (size_t N)
+{
+ static unsigned long int x = 1;
+ x = (1103515245 * x + 12345) & 0x7fffffffUL;
+ return (size_t) ((x / 2147483648.0) * N);
+}
diff --git a/gsl-1.9/sort/test_heapsort.c b/gsl-1.9/sort/test_heapsort.c
new file mode 100644
index 0000000..a93a7dd
--- /dev/null
+++ b/gsl-1.9/sort/test_heapsort.c
@@ -0,0 +1,183 @@
+/* sort/test_heapsort.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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.
+ */
+
+int cmp_dbl (const void *a, const void *b);
+void test_heapsort (size_t N);
+void initialize (double *data, size_t N);
+void cpy (double *dest, double *src, size_t N);
+void randomize (double *data, size_t n);
+void reverse (double *data, size_t N);
+int check (double *data, double *orig, size_t N);
+int pcheck (size_t * p, double *data, double *orig, size_t N);
+
+void
+test_heapsort (size_t N)
+{
+ int status;
+
+ double *orig = (double *) malloc (N * sizeof (double));
+ double *data = (double *) malloc (N * sizeof (double));
+ size_t *p = (size_t *) malloc (N * sizeof(size_t));
+
+ initialize (orig, N);
+
+ /* Already sorted */
+ cpy (data, orig, N);
+
+ status = gsl_heapsort_index (p, data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status |= pcheck (p, data, orig, N);
+ gsl_test (status, "indexing array, n = %u, ordered", N);
+
+ gsl_heapsort (data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status = check (data, orig, N);
+
+ gsl_test (status, "sorting, array, n = %u, ordered", N);
+
+ /* Reverse the data */
+
+ cpy (data, orig, N);
+ reverse (data, N);
+
+ status = gsl_heapsort_index (p, data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status |= pcheck (p, data, orig, N);
+ gsl_test (status, "indexing array, n = %u, reversed", N);
+
+ gsl_heapsort (data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status = check (data, orig, N);
+
+ gsl_test (status, "sorting, array, n = %u, reversed", N);
+
+ /* Perform some shuffling */
+
+ cpy (data, orig, N);
+ randomize (data, N);
+
+ status = gsl_heapsort_index (p, data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status |= pcheck (p, data, orig, N);
+ gsl_test (status, "indexing array, n = %u, randomized", N);
+
+ gsl_heapsort (data, N, sizeof (double), (gsl_comparison_fn_t) & cmp_dbl);
+ status = check (data, orig, N);
+
+ gsl_test (status, "sorting, array, n = %u, randomized", N);
+
+ free (orig);
+ free (data);
+ free (p);
+}
+
+void
+initialize (double *data, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N; i++)
+ {
+ data[i] = i;
+ }
+}
+
+void
+cpy (double *dest, double *src, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N; i++)
+ {
+ dest[i] = src[i];
+ }
+}
+
+void
+randomize (double *data, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N; i++)
+ {
+ size_t j = urand (N);
+ double tmp = data[i];
+ data[i] = data[j];
+ data[j] = tmp;
+ }
+}
+
+void
+reverse (double *data, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N / 2; i++)
+ {
+ size_t j = N - i - 1;
+
+ {
+ double tmp = data[i];
+ data[i] = data[j];
+ data[j] = tmp;
+ }
+ }
+}
+
+int
+check (double *data, double *orig, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N; i++)
+ {
+ if (data[i] != orig[i])
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+int
+pcheck (size_t * p, double *data, double *orig, size_t N)
+{
+ size_t i;
+
+ for (i = 0; i < N; i++)
+ {
+ if (data[p[i]] != orig[i])
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+
+int
+cmp_dbl (const void *a, const void *b)
+{
+ const double x = *(const double *) a;
+ const double y = *(const double *) b;
+ if (x > y)
+ return 1;
+ if (x == y)
+ return 0;
+ else
+ return -1;
+}
diff --git a/gsl-1.9/sort/test_source.c b/gsl-1.9/sort/test_source.c
new file mode 100644
index 0000000..bf2f598
--- /dev/null
+++ b/gsl-1.9/sort/test_source.c
@@ -0,0 +1,292 @@
+/* sort/test_source.c
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000 Thomas Walter, 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.
+ */
+
+void TYPE (test_sort_vector) (size_t N, size_t stride);
+void FUNCTION (my, initialize) (TYPE (gsl_vector) * v);
+void FUNCTION (my, randomize) (TYPE (gsl_vector) * v);
+int FUNCTION (my, check) (TYPE (gsl_vector) * data, TYPE (gsl_vector) * orig);
+int FUNCTION (my, pcheck) (gsl_permutation * p, TYPE (gsl_vector) * data, TYPE (gsl_vector) * orig);
+int FUNCTION (my, scheck) (BASE * x, size_t k, TYPE (gsl_vector) * data);
+int FUNCTION (my, lcheck) (BASE * x, size_t k, TYPE (gsl_vector) * data);
+int FUNCTION (my, sicheck) (size_t * p, size_t k, gsl_permutation * perm,
+ TYPE (gsl_vector) * data);
+int FUNCTION (my, licheck) (size_t * p, size_t k, gsl_permutation * perm,
+ TYPE (gsl_vector) * data);
+
+void
+TYPE (test_sort_vector) (size_t N, size_t stride)
+{
+ int status;
+ size_t k = N/2;
+
+ TYPE (gsl_block) * b1 = FUNCTION (gsl_block, calloc) (N * stride);
+ TYPE (gsl_block) * b2 = FUNCTION (gsl_block, calloc) (N * stride);
+ TYPE (gsl_block) * b3 = FUNCTION (gsl_block, calloc) (N * stride);
+
+ TYPE (gsl_vector) * orig = FUNCTION (gsl_vector, alloc_from_block) (b1, 0, N, stride);
+ TYPE (gsl_vector) * data = FUNCTION (gsl_vector, alloc_from_block) (b2, 0, N, stride);
+ TYPE (gsl_vector) * data2 = FUNCTION (gsl_vector, alloc_from_block) (b3, 0, N, stride);
+
+ BASE * small = malloc(k * sizeof(BASE));
+ BASE * large = malloc(k * sizeof(BASE));
+ size_t * index = malloc(k * sizeof(size_t));
+
+ gsl_permutation *p = gsl_permutation_alloc (N);
+
+ FUNCTION (my, initialize) (orig);
+
+ /* Already sorted */
+ FUNCTION (gsl_vector, memcpy) (data, orig);
+
+ status = FUNCTION (gsl_sort_vector, index) (p, data);
+ status |= FUNCTION (my, pcheck) (p, data, orig);
+ gsl_test (status, "indexing " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ TYPE (gsl_sort_vector) (data);
+ status = FUNCTION (my, check) (data, orig);
+ gsl_test (status, "sorting, " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ FUNCTION (gsl_sort_vector, smallest) (small, k, data);
+ status = FUNCTION (my, scheck) (small, k, orig);
+ gsl_test (status, "smallest, " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest) (large, k, data);
+ status = FUNCTION (my, lcheck) (large, k, orig);
+ gsl_test (status, "largest, " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ FUNCTION (gsl_sort_vector, smallest_index) (index, k, data);
+ status = FUNCTION (my, sicheck) (index, k, p, data);
+ gsl_test (status, "smallest index, " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest_index) (index, k, data);
+ status = FUNCTION (my, licheck) (index, k, p, data);
+ gsl_test (status, "largest index, " NAME (gsl_vector) ", n = %u, stride = %u, ordered", N, stride);
+
+ /* Reverse the data */
+
+ FUNCTION (gsl_vector, memcpy) (data, orig);
+ FUNCTION (gsl_vector, reverse) (data);
+
+ status = FUNCTION (gsl_sort_vector, index) (p, data);
+ status |= FUNCTION (my, pcheck) (p, data, orig);
+ gsl_test (status, "indexing " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ TYPE (gsl_sort_vector) (data);
+ status = FUNCTION (my, check) (data, orig);
+ gsl_test (status, "sorting, " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ FUNCTION (gsl_vector, memcpy) (data, orig);
+ FUNCTION (gsl_vector, reverse) (data);
+
+ FUNCTION (gsl_sort_vector, smallest) (small, k, data);
+ status = FUNCTION (my, scheck) (small, k, orig);
+ gsl_test (status, "smallest, " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest) (large, k, data);
+ status = FUNCTION (my, lcheck) (large, k, orig);
+ gsl_test (status, "largest, " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ FUNCTION (gsl_sort_vector, smallest_index) (index, k, data);
+ status = FUNCTION (my, sicheck) (index, k, p, data);
+ gsl_test (status, "smallest index, " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest_index) (index, k, data);
+ status = FUNCTION (my, licheck) (index, k, p, data);
+ gsl_test (status, "largest index, " NAME (gsl_vector) ", n = %u, stride = %u, reversed", N, stride);
+
+ /* Perform some shuffling */
+
+ FUNCTION (gsl_vector, memcpy) (data, orig);
+ FUNCTION (my, randomize) (data);
+ FUNCTION (gsl_vector, memcpy) (data2, data);
+
+ status = FUNCTION (gsl_sort_vector, index) (p, data);
+ status |= FUNCTION (my, pcheck) (p, data, orig);
+ gsl_test (status, "indexing " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ TYPE (gsl_sort_vector) (data);
+ status = FUNCTION (my, check) (data, orig);
+ gsl_test (status, "sorting, " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ FUNCTION (gsl_vector, memcpy) (data, data2);
+
+ FUNCTION (gsl_sort_vector, smallest) (small, k, data);
+ status = FUNCTION (my, scheck) (small, k, orig);
+ gsl_test (status, "smallest, " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest) (large, k, data);
+ status = FUNCTION (my, lcheck) (large, k, orig);
+ gsl_test (status, "largest, " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ FUNCTION (gsl_sort_vector, smallest_index) (index, k, data);
+ status = FUNCTION (my, sicheck) (index, k, p, data);
+ gsl_test (status, "smallest index, " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ FUNCTION (gsl_sort_vector, largest_index) (index, k, data);
+ status = FUNCTION (my, licheck) (index, k, p, data);
+ gsl_test (status, "largest index, " NAME (gsl_vector) ", n = %u, stride = %u, randomized", N, stride);
+
+ FUNCTION (gsl_vector, free) (orig);
+ FUNCTION (gsl_vector, free) (data);
+ FUNCTION (gsl_vector, free) (data2);
+ FUNCTION (gsl_block, free) (b1);
+ FUNCTION (gsl_block, free) (b2);
+ FUNCTION (gsl_block, free) (b3);
+ gsl_permutation_free (p);
+ free (small);
+ free (large);
+ free (index);
+}
+
+
+void
+FUNCTION (my, initialize) (TYPE (gsl_vector) * v)
+{
+ size_t i;
+ ATOMIC k = 0, kk;
+
+ /* Must be sorted initially */
+
+ for (i = 0; i < v->size; i++)
+ {
+ kk = k;
+ k++;
+ if (k < kk) /* prevent overflow */
+ k = kk;
+ FUNCTION (gsl_vector, set) (v, i, k);
+ }
+}
+
+void
+FUNCTION (my, randomize) (TYPE (gsl_vector) * v)
+{
+ size_t i;
+
+ for (i = 0; i < v->size; i++)
+ {
+ size_t j = urand (v->size);
+ FUNCTION (gsl_vector, swap_elements) (v, i, j);
+ }
+}
+
+int
+FUNCTION (my, check) (TYPE (gsl_vector) * data, TYPE (gsl_vector) * orig)
+{
+ size_t i;
+
+ for (i = 0; i < data->size; i++)
+ {
+ if (FUNCTION (gsl_vector, get) (data, i) != FUNCTION (gsl_vector, get) (orig, i))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+int
+FUNCTION (my, pcheck) (gsl_permutation * p, TYPE (gsl_vector) * data, TYPE (gsl_vector) * orig)
+{
+ size_t i;
+
+ for (i = 0; i < p->size; i++)
+ {
+ if (FUNCTION (gsl_vector, get) (data, p->data[i]) != FUNCTION (gsl_vector, get) (orig, i))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+int
+FUNCTION (my, scheck) (BASE * x, size_t k, TYPE (gsl_vector) * data)
+{
+ size_t i;
+
+ for (i = 0; i < k; i++)
+ {
+ if (x[i] != FUNCTION (gsl_vector, get) (data, i))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+
+int
+FUNCTION (my, lcheck) (BASE * x, size_t k, TYPE (gsl_vector) * data)
+{
+ size_t i;
+
+ for (i = 0; i < k; i++)
+ {
+ if (x[i] != FUNCTION (gsl_vector, get) (data, data->size - i - 1))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+int
+FUNCTION (my, sicheck) (size_t * p1, size_t k, gsl_permutation * p,
+ TYPE (gsl_vector) * data)
+{
+ size_t i;
+
+ for (i = 0; i < k; i++)
+ {
+ if (FUNCTION(gsl_vector,get)(data,p1[i])
+ != FUNCTION(gsl_vector,get)(data, p->data[i]))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+int
+FUNCTION (my, licheck) (size_t * p1, size_t k, gsl_permutation * p,
+ TYPE (gsl_vector) * data)
+{
+ size_t i;
+
+ for (i = 0; i < k; i++)
+ {
+ if (FUNCTION(gsl_vector,get)(data,p1[i])
+ != FUNCTION(gsl_vector,get)(data, p->data[p->size - i - 1]))
+ {
+ return GSL_FAILURE;
+ }
+ }
+
+ return GSL_SUCCESS;
+}
+
+
+