diff options
Diffstat (limited to 'gsl-1.9/vector')
47 files changed, 8009 insertions, 0 deletions
diff --git a/gsl-1.9/vector/ChangeLog b/gsl-1.9/vector/ChangeLog new file mode 100644 index 0000000..f445ece --- /dev/null +++ b/gsl-1.9/vector/ChangeLog @@ -0,0 +1,204 @@ +2007-02-17 Brian Gough <bjg@network-theory.co.uk> + + * test_source.c (FUNCTION): avoid running tests on char, because + it can be unsigned + +2007-01-26 Brian Gough <bjg@network-theory.co.uk> + + * minmax_source.c: added support for NaNs + +2006-10-31 Brian Gough <bjg@network-theory.co.uk> + + * prop_source.c: added functions gsl_vector_ispos, + gsl_vector_isneg + +2004-09-13 Brian Gough <bjg@network-theory.co.uk> + + * swap_source.c (gsl_vector_swap): fixed bug where stride of + first argument v was used for second argument w + + * test.c: improved test coverage + +2003-01-01 Brian Gough <brian.gough@network-theory.co.uk> + + * gsl_vector_complex_float.h (gsl_vector_complex_float_get): + removed const from zero + + * vector_source.c (FUNCTION): removed const from zero + +Sun Jan 27 22:29:54 2002 Brian Gough <bjg@network-theory.co.uk> + + * test.c: ensure that range check is working when running the + tests + +Fri Sep 14 19:13:20 2001 Brian Gough <bjg@network-theory.co.uk> + + * view.c (USE_QUALIFIER): added missing qualified types + +Thu Aug 23 13:22:29 2001 Brian Gough <bjg@network-theory.co.uk> + + * gsl_vector_complex_float.h: added const to second argument of + _ptr functions + + * gsl_vector.h: changed definition of gsl_vector_const_view to + compile with Sun's cc + +Fri Aug 3 14:11:51 2001 Brian Gough <bjg@network-theory.co.uk> + + * added gsl_vector_ptr and gsl_vector_const_ptr functions + +Mon Jul 16 21:28:37 2001 Brian Gough <bjg@network-theory.co.uk> + + * reim_source.c: initialized views to null + +Fri Jul 13 21:29:06 2001 Brian Gough <bjg@network-theory.co.uk> + + * changed views to be structs and used casts to initialize them + +Mon Jul 2 12:34:43 2001 Brian Gough <bjg@network-theory.co.uk> + + * view.h: provide macros for initializing null vectors and views + +Sun Jul 1 22:38:30 2001 Brian Gough <bjg@network-theory.co.uk> + + * introduction of new-style vector views + + * view_source.c: changed order of arguments to be consistent with + rest of library for _with_stride functions + +Mon May 14 22:43:18 2001 Brian Gough <bjg@network-theory.co.uk> + + * vector_source.c (FUNCTION): removed unnecessary inline from + static function definition + +Tue Mar 27 15:12:07 2001 Brian Gough <bjg@network-theory.co.uk> + + * view_source.c: split view functions into a separate file + +Sat Sep 9 16:45:15 2000 Brian Gough <bjg@network-theory.co.uk> + + * added an owner field for indicating whether the underlying + memory is owned by the vector. Changed the meaning of the block + field to always be the address of the underlying block, even for + subviews (previously the block field was set to NULL in this + case). + +Sun Jul 16 10:39:39 2000 Brian Gough <bjg@network-theory.co.uk> + + * init_source.c (FUNCTION): added gsl_vector_view function for + creating a vector view of an ordinary C array + +Sat Jul 15 21:44:49 2000 Brian Gough <bjg@network-theory.co.uk> + + * changed GSL_EDOM to GSL_EINVAL for invalid vector size arguments + +Sat Jun 17 15:37:57 2000 Brian Gough <bjg@network-theory.co.uk> + + * fixed up missing MULTIPLICITY factors in various functions + +Sun May 28 12:25:31 2000 Brian Gough <bjg@network-theory.co.uk> + + * test_complex_source.c (FUNCTION): use binary mode "b" when + reading and writing binary files + + * test_source.c (FUNCTION): use binary mode "b" when reading and + writing binary files + +Fri May 5 10:57:16 2000 Brian Gough <bjg@network-theory.co.uk> + + * oper_source.c (FUNCTION): changed functions + gsl_vector_mul_elements and gsl_vector_div_elements to + gsl_vector_mul and gsl_vector_div since the _elements suffix is + redundant for vectors (unlike matrices). + + * oper.c: added simple arithmetic operations (+,-,*,/,scale,+const) + +Wed Apr 26 14:17:14 2000 Brian Gough <bjg@network-theory.co.uk> + + * prop_source.c (FUNCTION): added const to argument of + gsl_vector_isnull + + * init_source.c (FUNCTION): added gsl_vector_set_basis(v,i) to set + v to basis vector v = e_i (0,0,...,1,...,0) + +Tue Apr 25 11:31:38 2000 Brian Gough <bjg@network-theory.co.uk> + + * test_source.c (FUNCTION): modified the tests so that they work + more cleanly with checkergcc when using long doubles. The trick + seems to be to avoid having any long doubles on the stack. + +Sat Apr 22 15:09:44 2000 Brian Gough <bjg@network-theory.co.uk> + + * init_source.c (FUNCTION): separated subvector functions into + gsl_vector_subvector and gsl_vector_subvector_with_stride + +Sat Mar 25 20:23:58 2000 Brian Gough <bjg@network-theory.co.uk> + + * swap_source.c (FUNCTION): renames gsl_vector_swap to + gsl_vector_swap_elements + +Tue Mar 21 21:15:10 2000 Brian Gough <bjg@network-theory.co.uk> + + * vector_source.c (FUNCTION): added set_zero function + +Thu Feb 24 16:19:55 2000 Brian Gough <bjg@network-theory.co.uk> + + * added missing prototypes for gsl_vector_complex_..._reverse + +Fri Feb 18 20:48:32 2000 Brian Gough <bjg@network-theory.co.uk> + + * swap_source.c (FUNCTION): added gsl_vector_reverse function for + flipping the order of a vector + + * copy_source.c: renamed gsl_vector_copy to gsl_vector_cpy + since it acts like memcpy (dest, src) not 'cp(copy) from to' + +Thu Dec 2 20:39:02 1999 Brian Gough <bjg@network-theory.co.uk> + + * init_source.c: fixed bug, block element needs to be null in + gsl_vector_alloc_from_vector to maintain correct ownership, + added gsl_vector_view_from_vector (Thanks to Fabrice Rossi) + +Tue Oct 19 14:13:14 1999 Brian Gough <bjg@network-theory.co.uk> + + * added gsl_vector_swap function to exchange elements + +Fri Oct 1 15:47:45 1999 Brian Gough <bjg@network-theory.co.uk> + + * removed support for gsl_vector_ptr. Use set/get instead. + + * now uses separate block directory for memory management + +Mon Mar 1 19:38:16 1999 Brian Gough <bjg@netsci.freeserve.co.uk> + + * test_source.c: added tests for gsl_vector_ptr with and without + stride + + * gsl_vector_char.h: added missing code to gsl_vector_char_ptr for + stride in char case. + + +Sun Nov 8 18:39:40 1998 Brian Gough <bjg@vvv.lanl.gov> + + * test_io.c, test_complex_io.c: split out the printf/scanf + routines since these aren't supported on all platforms + for long double + +Fri Jul 24 19:44:52 1998 Brian Gough <bjg@vvv.lanl.gov> + + * added parent pointer in structs, to determine whether or not + we're allowed to free the memory pointed to by * data. + +Wed Jun 10 19:13:35 1998 Brian Gough <bjg@vvv.lanl.gov> + + * init_source.c: added a cast for each malloc + +Sun Apr 26 14:10:06 1998 Brian Gough <bjg@vvv.lanl.gov> + + * added support for complex vectors + +Mon Apr 6 15:06:38 1998 Brian Gough <bjg@vvv.lanl.gov> + + * make range checking the default, you have to define + GSL_RANGE_CHECK_OFF to turn it off + diff --git a/gsl-1.9/vector/Makefile.am b/gsl-1.9/vector/Makefile.am new file mode 100644 index 0000000..3531001 --- /dev/null +++ b/gsl-1.9/vector/Makefile.am @@ -0,0 +1,21 @@ +noinst_LTLIBRARIES = libgslvector.la + +check_PROGRAMS = test test_static + +pkginclude_HEADERS = gsl_vector.h gsl_vector_char.h gsl_vector_complex.h gsl_vector_complex_double.h gsl_vector_complex_float.h gsl_vector_complex_long_double.h gsl_vector_double.h gsl_vector_float.h gsl_vector_int.h gsl_vector_long.h gsl_vector_long_double.h gsl_vector_short.h gsl_vector_uchar.h gsl_vector_uint.h gsl_vector_ulong.h gsl_vector_ushort.h + +INCLUDES= -I$(top_builddir) -I$(top_srcdir) + +TESTS = $(check_PROGRAMS) + +test_LDADD = libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +test_static_LDADD = libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la + +test_SOURCES = test.c +test_static_SOURCES = test_static.c + +CLEANFILES = test.txt test.dat + +noinst_HEADERS = vector_source.c init_source.c file_source.c copy_source.c swap_source.c prop_source.c test_complex_source.c test_source.c minmax_source.c oper_source.c reim_source.c subvector_source.c view_source.c + +libgslvector_la_SOURCES = init.c file.c vector.c copy.c swap.c prop.c minmax.c oper.c reim.c subvector.c view.c view.h diff --git a/gsl-1.9/vector/Makefile.in b/gsl-1.9/vector/Makefile.in new file mode 100644 index 0000000..d1837a4 --- /dev/null +++ b/gsl-1.9/vector/Makefile.in @@ -0,0 +1,559 @@ +# 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) test_static$(EXEEXT) +subdir = vector +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) +libgslvector_la_LIBADD = +am_libgslvector_la_OBJECTS = init.lo file.lo vector.lo copy.lo swap.lo \ + prop.lo minmax.lo oper.lo reim.lo subvector.lo view.lo +libgslvector_la_OBJECTS = $(am_libgslvector_la_OBJECTS) +am_test_OBJECTS = test.$(OBJEXT) +test_OBJECTS = $(am_test_OBJECTS) +test_DEPENDENCIES = libgslvector.la ../block/libgslblock.la \ + ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la \ + ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +am_test_static_OBJECTS = test_static.$(OBJEXT) +test_static_OBJECTS = $(am_test_static_OBJECTS) +test_static_DEPENDENCIES = libgslvector.la ../block/libgslblock.la \ + ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la \ + ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libgslvector_la_SOURCES) $(test_SOURCES) \ + $(test_static_SOURCES) +DIST_SOURCES = $(libgslvector_la_SOURCES) $(test_SOURCES) \ + $(test_static_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 = libgslvector.la +pkginclude_HEADERS = gsl_vector.h gsl_vector_char.h gsl_vector_complex.h gsl_vector_complex_double.h gsl_vector_complex_float.h gsl_vector_complex_long_double.h gsl_vector_double.h gsl_vector_float.h gsl_vector_int.h gsl_vector_long.h gsl_vector_long_double.h gsl_vector_short.h gsl_vector_uchar.h gsl_vector_uint.h gsl_vector_ulong.h gsl_vector_ushort.h +INCLUDES = -I$(top_builddir) -I$(top_srcdir) +TESTS = $(check_PROGRAMS) +test_LDADD = libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +test_static_LDADD = libgslvector.la ../block/libgslblock.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +test_SOURCES = test.c +test_static_SOURCES = test_static.c +CLEANFILES = test.txt test.dat +noinst_HEADERS = vector_source.c init_source.c file_source.c copy_source.c swap_source.c prop_source.c test_complex_source.c test_source.c minmax_source.c oper_source.c reim_source.c subvector_source.c view_source.c +libgslvector_la_SOURCES = init.c file.c vector.c copy.c swap.c prop.c minmax.c oper.c reim.c subvector.c view.c view.h +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 vector/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps vector/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 +libgslvector.la: $(libgslvector_la_OBJECTS) $(libgslvector_la_DEPENDENCIES) + $(LINK) $(libgslvector_la_LDFLAGS) $(libgslvector_la_OBJECTS) $(libgslvector_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) +test_static$(EXEEXT): $(test_static_OBJECTS) $(test_static_DEPENDENCIES) + @rm -f test_static$(EXEEXT) + $(LINK) $(test_static_LDFLAGS) $(test_static_OBJECTS) $(test_static_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: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +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/vector/TODO b/gsl-1.9/vector/TODO new file mode 100644 index 0000000..94cb054 --- /dev/null +++ b/gsl-1.9/vector/TODO @@ -0,0 +1,3 @@ +* Pretty print function + +* Vector p-norms diff --git a/gsl-1.9/vector/copy.c b/gsl-1.9/vector/copy.c new file mode 100644 index 0000000..1b42916 --- /dev/null +++ b/gsl-1.9/vector/copy.c @@ -0,0 +1,87 @@ +#include <config.h> +#include <gsl/gsl_vector.h> +#include <gsl/gsl_errno.h> + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "copy_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/copy_source.c b/gsl-1.9/vector/copy_source.c new file mode 100644 index 0000000..2bfd425 --- /dev/null +++ b/gsl-1.9/vector/copy_source.c @@ -0,0 +1,51 @@ +/* vector/copy_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 +FUNCTION (gsl_vector, memcpy) (TYPE (gsl_vector) * dest, + const TYPE (gsl_vector) * src) +{ + const size_t src_size = src->size; + const size_t dest_size = dest->size; + + if (src_size != dest_size) + { + GSL_ERROR ("vector lengths are not equal", GSL_EBADLEN); + } + + { + const size_t src_stride = src->stride ; + const size_t dest_stride = dest->stride ; + size_t j; + + for (j = 0; j < src_size; j++) + { + size_t k; + + for (k = 0; k < MULTIPLICITY; k++) + { + dest->data[MULTIPLICITY * dest_stride * j + k] + = src->data[MULTIPLICITY * src_stride * j + k]; + } + } + } + + return GSL_SUCCESS; +} + diff --git a/gsl-1.9/vector/file.c b/gsl-1.9/vector/file.c new file mode 100644 index 0000000..d7b8872 --- /dev/null +++ b/gsl-1.9/vector/file.c @@ -0,0 +1,89 @@ +#include <config.h> +#include <stdio.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_block.h> +#include <gsl/gsl_vector.h> + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "file_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/file_source.c b/gsl-1.9/vector/file_source.c new file mode 100644 index 0000000..c845b7d --- /dev/null +++ b/gsl-1.9/vector/file_source.c @@ -0,0 +1,63 @@ +/* vector/file_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 +FUNCTION (gsl_vector, fread) (FILE * stream, TYPE (gsl_vector) * v) +{ + int status = FUNCTION (gsl_block, raw_fread) (stream, + v->data, + v->size, + v->stride); + return status; +} + +int +FUNCTION (gsl_vector, fwrite) (FILE * stream, const TYPE (gsl_vector) * v) +{ + int status = FUNCTION (gsl_block, raw_fwrite) (stream, + v->data, + v->size, + v->stride); + return status; +} + +#if !(USES_LONGDOUBLE && !HAVE_PRINTF_LONGDOUBLE) +int +FUNCTION (gsl_vector, fprintf) (FILE * stream, const TYPE (gsl_vector) * v, + const char *format) +{ + int status = FUNCTION (gsl_block, raw_fprintf) (stream, + v->data, + v->size, + v->stride, + format); + return status; +} + +int +FUNCTION (gsl_vector, fscanf) (FILE * stream, TYPE (gsl_vector) * v) +{ + int status = FUNCTION (gsl_block, raw_fscanf) (stream, + v->data, + v->size, + v->stride); + return status; +} +#endif + diff --git a/gsl-1.9/vector/gsl_vector.h b/gsl-1.9/vector/gsl_vector.h new file mode 100644 index 0000000..cf762e4 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector.h @@ -0,0 +1,25 @@ +#ifndef __GSL_VECTOR_H__ +#define __GSL_VECTOR_H__ + +#include <gsl/gsl_vector_complex_long_double.h> +#include <gsl/gsl_vector_complex_double.h> +#include <gsl/gsl_vector_complex_float.h> + +#include <gsl/gsl_vector_long_double.h> +#include <gsl/gsl_vector_double.h> +#include <gsl/gsl_vector_float.h> + +#include <gsl/gsl_vector_ulong.h> +#include <gsl/gsl_vector_long.h> + +#include <gsl/gsl_vector_uint.h> +#include <gsl/gsl_vector_int.h> + +#include <gsl/gsl_vector_ushort.h> +#include <gsl/gsl_vector_short.h> + +#include <gsl/gsl_vector_uchar.h> +#include <gsl/gsl_vector_char.h> + + +#endif /* __GSL_VECTOR_H__ */ diff --git a/gsl-1.9/vector/gsl_vector_char.h b/gsl-1.9/vector/gsl_vector_char.h new file mode 100644 index 0000000..22debdd --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_char.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_char.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_CHAR_H__ +#define __GSL_VECTOR_CHAR_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + char *data; + gsl_block_char *block; + int owner; +} +gsl_vector_char; + +typedef struct +{ + gsl_vector_char vector; +} _gsl_vector_char_view; + +typedef _gsl_vector_char_view gsl_vector_char_view; + +typedef struct +{ + gsl_vector_char vector; +} _gsl_vector_char_const_view; + +typedef const _gsl_vector_char_const_view gsl_vector_char_const_view; + + +/* Allocation */ + +gsl_vector_char *gsl_vector_char_alloc (const size_t n); +gsl_vector_char *gsl_vector_char_calloc (const size_t n); + +gsl_vector_char *gsl_vector_char_alloc_from_block (gsl_block_char * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_char *gsl_vector_char_alloc_from_vector (gsl_vector_char * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_char_free (gsl_vector_char * v); + +/* Views */ + +_gsl_vector_char_view +gsl_vector_char_view_array (char *v, size_t n); + +_gsl_vector_char_view +gsl_vector_char_view_array_with_stride (char *base, + size_t stride, + size_t n); + +_gsl_vector_char_const_view +gsl_vector_char_const_view_array (const char *v, size_t n); + +_gsl_vector_char_const_view +gsl_vector_char_const_view_array_with_stride (const char *base, + size_t stride, + size_t n); + +_gsl_vector_char_view +gsl_vector_char_subvector (gsl_vector_char *v, + size_t i, + size_t n); + +_gsl_vector_char_view +gsl_vector_char_subvector_with_stride (gsl_vector_char *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_char_const_view +gsl_vector_char_const_subvector (const gsl_vector_char *v, + size_t i, + size_t n); + +_gsl_vector_char_const_view +gsl_vector_char_const_subvector_with_stride (const gsl_vector_char *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +char gsl_vector_char_get (const gsl_vector_char * v, const size_t i); +void gsl_vector_char_set (gsl_vector_char * v, const size_t i, char x); + +char *gsl_vector_char_ptr (gsl_vector_char * v, const size_t i); +const char *gsl_vector_char_const_ptr (const gsl_vector_char * v, const size_t i); + +void gsl_vector_char_set_zero (gsl_vector_char * v); +void gsl_vector_char_set_all (gsl_vector_char * v, char x); +int gsl_vector_char_set_basis (gsl_vector_char * v, size_t i); + +int gsl_vector_char_fread (FILE * stream, gsl_vector_char * v); +int gsl_vector_char_fwrite (FILE * stream, const gsl_vector_char * v); +int gsl_vector_char_fscanf (FILE * stream, gsl_vector_char * v); +int gsl_vector_char_fprintf (FILE * stream, const gsl_vector_char * v, + const char *format); + +int gsl_vector_char_memcpy (gsl_vector_char * dest, const gsl_vector_char * src); + +int gsl_vector_char_reverse (gsl_vector_char * v); + +int gsl_vector_char_swap (gsl_vector_char * v, gsl_vector_char * w); +int gsl_vector_char_swap_elements (gsl_vector_char * v, const size_t i, const size_t j); + +char gsl_vector_char_max (const gsl_vector_char * v); +char gsl_vector_char_min (const gsl_vector_char * v); +void gsl_vector_char_minmax (const gsl_vector_char * v, char * min_out, char * max_out); + +size_t gsl_vector_char_max_index (const gsl_vector_char * v); +size_t gsl_vector_char_min_index (const gsl_vector_char * v); +void gsl_vector_char_minmax_index (const gsl_vector_char * v, size_t * imin, size_t * imax); + +int gsl_vector_char_add (gsl_vector_char * a, const gsl_vector_char * b); +int gsl_vector_char_sub (gsl_vector_char * a, const gsl_vector_char * b); +int gsl_vector_char_mul (gsl_vector_char * a, const gsl_vector_char * b); +int gsl_vector_char_div (gsl_vector_char * a, const gsl_vector_char * b); +int gsl_vector_char_scale (gsl_vector_char * a, const double x); +int gsl_vector_char_add_constant (gsl_vector_char * a, const double x); + +int gsl_vector_char_isnull (const gsl_vector_char * v); +int gsl_vector_char_ispos (const gsl_vector_char * v); +int gsl_vector_char_isneg (const gsl_vector_char * v); + +#ifdef HAVE_INLINE + +extern inline +char +gsl_vector_char_get (const gsl_vector_char * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_char_set (gsl_vector_char * v, const size_t i, char x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +char * +gsl_vector_char_ptr (gsl_vector_char * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (char *) (v->data + i * v->stride); +} + +extern inline +const char * +gsl_vector_char_const_ptr (const gsl_vector_char * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const char *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_CHAR_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_complex.h b/gsl-1.9/vector/gsl_vector_complex.h new file mode 100644 index 0000000..2767615 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_complex.h @@ -0,0 +1,17 @@ +#ifndef __GSL_VECTOR_COMPLEX_H__ +#define __GSL_VECTOR_COMPLEX_H__ + +#define GSL_VECTOR_REAL(z, i) ((z)->data[2*(i)*(z)->stride]) +#define GSL_VECTOR_IMAG(z, i) ((z)->data[2*(i)*(z)->stride + 1]) + +#if GSL_RANGE_CHECK +#define GSL_VECTOR_COMPLEX(zv, i) (((i) >= (zv)->size ? (gsl_error ("index out of range", __FILE__, __LINE__, GSL_EINVAL), 0):0 , *GSL_COMPLEX_AT((zv),(i)))) +#else +#define GSL_VECTOR_COMPLEX(zv, i) (GSL_COMPLEX_AT((zv),(i))) +#endif + +#define GSL_COMPLEX_AT(zv,i) ((gsl_complex*)&((zv)->data[2*(i)*(zv)->stride])) +#define GSL_COMPLEX_FLOAT_AT(zv,i) ((gsl_complex_float*)&((zv)->data[2*(i)*(zv)->stride])) +#define GSL_COMPLEX_LONG_DOUBLE_AT(zv,i) ((gsl_complex_long_double*)&((zv)->data[2*(i)*(zv)->stride])) + +#endif /* __GSL_VECTOR_COMPLEX_H__ */ diff --git a/gsl-1.9/vector/gsl_vector_complex_double.h b/gsl-1.9/vector/gsl_vector_complex_double.h new file mode 100644 index 0000000..ec7cf73 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_complex_double.h @@ -0,0 +1,247 @@ +/* vector/gsl_vector_complex_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_COMPLEX_DOUBLE_H__ +#define __GSL_VECTOR_COMPLEX_DOUBLE_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_complex.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_vector_double.h> +#include <gsl/gsl_vector_complex.h> +#include <gsl/gsl_block_complex_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 + +typedef struct +{ + size_t size; + size_t stride; + double *data; + gsl_block_complex *block; + int owner; +} gsl_vector_complex; + +typedef struct +{ + gsl_vector_complex vector; +} _gsl_vector_complex_view; + +typedef _gsl_vector_complex_view gsl_vector_complex_view; + +typedef struct +{ + gsl_vector_complex vector; +} _gsl_vector_complex_const_view; + +typedef const _gsl_vector_complex_const_view gsl_vector_complex_const_view; + +/* Allocation */ + +gsl_vector_complex *gsl_vector_complex_alloc (const size_t n); +gsl_vector_complex *gsl_vector_complex_calloc (const size_t n); + +gsl_vector_complex * +gsl_vector_complex_alloc_from_block (gsl_block_complex * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_complex * +gsl_vector_complex_alloc_from_vector (gsl_vector_complex * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_complex_free (gsl_vector_complex * v); + +/* Views */ + +_gsl_vector_complex_view +gsl_vector_complex_view_array (double *base, + size_t n); + +_gsl_vector_complex_view +gsl_vector_complex_view_array_with_stride (double *base, + size_t stride, + size_t n); + +_gsl_vector_complex_const_view +gsl_vector_complex_const_view_array (const double *base, + size_t n); + +_gsl_vector_complex_const_view +gsl_vector_complex_const_view_array_with_stride (const double *base, + size_t stride, + size_t n); + +_gsl_vector_complex_view +gsl_vector_complex_subvector (gsl_vector_complex *base, + size_t i, + size_t n); + + +_gsl_vector_complex_view +gsl_vector_complex_subvector_with_stride (gsl_vector_complex *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_complex_const_view +gsl_vector_complex_const_subvector (const gsl_vector_complex *base, + size_t i, + size_t n); + + +_gsl_vector_complex_const_view +gsl_vector_complex_const_subvector_with_stride (const gsl_vector_complex *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_view +gsl_vector_complex_real (gsl_vector_complex *v); + +_gsl_vector_view +gsl_vector_complex_imag (gsl_vector_complex *v); + +_gsl_vector_const_view +gsl_vector_complex_const_real (const gsl_vector_complex *v); + +_gsl_vector_const_view +gsl_vector_complex_const_imag (const gsl_vector_complex *v); + + +/* Operations */ + +gsl_complex +gsl_vector_complex_get (const gsl_vector_complex * v, const size_t i); + +void gsl_vector_complex_set (gsl_vector_complex * v, const size_t i, + gsl_complex z); + +gsl_complex +*gsl_vector_complex_ptr (gsl_vector_complex * v, const size_t i); + +const gsl_complex +*gsl_vector_complex_const_ptr (const gsl_vector_complex * v, const size_t i); + +void gsl_vector_complex_set_zero (gsl_vector_complex * v); +void gsl_vector_complex_set_all (gsl_vector_complex * v, + gsl_complex z); +int gsl_vector_complex_set_basis (gsl_vector_complex * v, size_t i); + +int gsl_vector_complex_fread (FILE * stream, + gsl_vector_complex * v); +int gsl_vector_complex_fwrite (FILE * stream, + const gsl_vector_complex * v); +int gsl_vector_complex_fscanf (FILE * stream, + gsl_vector_complex * v); +int gsl_vector_complex_fprintf (FILE * stream, + const gsl_vector_complex * v, + const char *format); + +int gsl_vector_complex_memcpy (gsl_vector_complex * dest, const gsl_vector_complex * src); + +int gsl_vector_complex_reverse (gsl_vector_complex * v); + +int gsl_vector_complex_swap (gsl_vector_complex * v, gsl_vector_complex * w); +int gsl_vector_complex_swap_elements (gsl_vector_complex * v, const size_t i, const size_t j); + +int gsl_vector_complex_isnull (const gsl_vector_complex * v); +int gsl_vector_complex_ispos (const gsl_vector_complex * v); +int gsl_vector_complex_isneg (const gsl_vector_complex * v); + +#ifdef HAVE_INLINE + +extern inline +gsl_complex +gsl_vector_complex_get (const gsl_vector_complex * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + gsl_complex zero = {{0, 0}}; + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero); + } +#endif + return *GSL_COMPLEX_AT (v, i); +} + +extern inline +void +gsl_vector_complex_set (gsl_vector_complex * v, + const size_t i, gsl_complex z) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + *GSL_COMPLEX_AT (v, i) = z; +} + +extern inline +gsl_complex * +gsl_vector_complex_ptr (gsl_vector_complex * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_AT (v, i); +} + +extern inline +const gsl_complex * +gsl_vector_complex_const_ptr (const gsl_vector_complex * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_AT (v, i); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_COMPLEX_DOUBLE_H__ */ diff --git a/gsl-1.9/vector/gsl_vector_complex_float.h b/gsl-1.9/vector/gsl_vector_complex_float.h new file mode 100644 index 0000000..0823a23 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_complex_float.h @@ -0,0 +1,247 @@ +/* vector/gsl_vector_complex_float.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_COMPLEX_FLOAT_H__ +#define __GSL_VECTOR_COMPLEX_FLOAT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_complex.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_vector_float.h> +#include <gsl/gsl_vector_complex.h> +#include <gsl/gsl_block_complex_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 + +typedef struct +{ + size_t size; + size_t stride; + float *data; + gsl_block_complex_float *block; + int owner; +} gsl_vector_complex_float; + +typedef struct +{ + gsl_vector_complex_float vector; +} _gsl_vector_complex_float_view; + +typedef _gsl_vector_complex_float_view gsl_vector_complex_float_view; + +typedef struct +{ + gsl_vector_complex_float vector; +} _gsl_vector_complex_float_const_view; + +typedef const _gsl_vector_complex_float_const_view gsl_vector_complex_float_const_view; + +/* Allocation */ + +gsl_vector_complex_float *gsl_vector_complex_float_alloc (const size_t n); +gsl_vector_complex_float *gsl_vector_complex_float_calloc (const size_t n); + +gsl_vector_complex_float * +gsl_vector_complex_float_alloc_from_block (gsl_block_complex_float * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_complex_float * +gsl_vector_complex_float_alloc_from_vector (gsl_vector_complex_float * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_complex_float_free (gsl_vector_complex_float * v); + +/* Views */ + +_gsl_vector_complex_float_view +gsl_vector_complex_float_view_array (float *base, + size_t n); + +_gsl_vector_complex_float_view +gsl_vector_complex_float_view_array_with_stride (float *base, + size_t stride, + size_t n); + +_gsl_vector_complex_float_const_view +gsl_vector_complex_float_const_view_array (const float *base, + size_t n); + +_gsl_vector_complex_float_const_view +gsl_vector_complex_float_const_view_array_with_stride (const float *base, + size_t stride, + size_t n); + +_gsl_vector_complex_float_view +gsl_vector_complex_float_subvector (gsl_vector_complex_float *base, + size_t i, + size_t n); + + +_gsl_vector_complex_float_view +gsl_vector_complex_float_subvector_with_stride (gsl_vector_complex_float *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_complex_float_const_view +gsl_vector_complex_float_const_subvector (const gsl_vector_complex_float *base, + size_t i, + size_t n); + + +_gsl_vector_complex_float_const_view +gsl_vector_complex_float_const_subvector_with_stride (const gsl_vector_complex_float *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_float_view +gsl_vector_complex_float_real (gsl_vector_complex_float *v); + +_gsl_vector_float_view +gsl_vector_complex_float_imag (gsl_vector_complex_float *v); + +_gsl_vector_float_const_view +gsl_vector_complex_float_const_real (const gsl_vector_complex_float *v); + +_gsl_vector_float_const_view +gsl_vector_complex_float_const_imag (const gsl_vector_complex_float *v); + + +/* Operations */ + +gsl_complex_float +gsl_vector_complex_float_get (const gsl_vector_complex_float * v, const size_t i); + +void gsl_vector_complex_float_set (gsl_vector_complex_float * v, const size_t i, + gsl_complex_float z); + +gsl_complex_float +*gsl_vector_complex_float_ptr (gsl_vector_complex_float * v, const size_t i); + +const gsl_complex_float +*gsl_vector_complex_float_const_ptr (const gsl_vector_complex_float * v, const size_t i); + +void gsl_vector_complex_float_set_zero (gsl_vector_complex_float * v); +void gsl_vector_complex_float_set_all (gsl_vector_complex_float * v, + gsl_complex_float z); +int gsl_vector_complex_float_set_basis (gsl_vector_complex_float * v, size_t i); + +int gsl_vector_complex_float_fread (FILE * stream, + gsl_vector_complex_float * v); +int gsl_vector_complex_float_fwrite (FILE * stream, + const gsl_vector_complex_float * v); +int gsl_vector_complex_float_fscanf (FILE * stream, + gsl_vector_complex_float * v); +int gsl_vector_complex_float_fprintf (FILE * stream, + const gsl_vector_complex_float * v, + const char *format); + +int gsl_vector_complex_float_memcpy (gsl_vector_complex_float * dest, const gsl_vector_complex_float * src); + +int gsl_vector_complex_float_reverse (gsl_vector_complex_float * v); + +int gsl_vector_complex_float_swap (gsl_vector_complex_float * v, gsl_vector_complex_float * w); +int gsl_vector_complex_float_swap_elements (gsl_vector_complex_float * v, const size_t i, const size_t j); + +int gsl_vector_complex_float_isnull (const gsl_vector_complex_float * v); +int gsl_vector_complex_float_ispos (const gsl_vector_complex_float * v); +int gsl_vector_complex_float_isneg (const gsl_vector_complex_float * v); + +#ifdef HAVE_INLINE + +extern inline +gsl_complex_float +gsl_vector_complex_float_get (const gsl_vector_complex_float * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + gsl_complex_float zero = {{0, 0}}; + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero); + } +#endif + return *GSL_COMPLEX_FLOAT_AT (v, i); +} + +extern inline +void +gsl_vector_complex_float_set (gsl_vector_complex_float * v, + const size_t i, gsl_complex_float z) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + *GSL_COMPLEX_FLOAT_AT (v, i) = z; +} + +extern inline +gsl_complex_float * +gsl_vector_complex_float_ptr (gsl_vector_complex_float * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_FLOAT_AT (v, i); +} + +extern inline +const gsl_complex_float * +gsl_vector_complex_float_const_ptr (const gsl_vector_complex_float * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_FLOAT_AT (v, i); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_COMPLEX_FLOAT_H__ */ diff --git a/gsl-1.9/vector/gsl_vector_complex_long_double.h b/gsl-1.9/vector/gsl_vector_complex_long_double.h new file mode 100644 index 0000000..77ee9a8 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_complex_long_double.h @@ -0,0 +1,247 @@ +/* vector/gsl_vector_complex_long_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_COMPLEX_LONG_DOUBLE_H__ +#define __GSL_VECTOR_COMPLEX_LONG_DOUBLE_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_complex.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_vector_long_double.h> +#include <gsl/gsl_vector_complex.h> +#include <gsl/gsl_block_complex_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 + +typedef struct +{ + size_t size; + size_t stride; + long double *data; + gsl_block_complex_long_double *block; + int owner; +} gsl_vector_complex_long_double; + +typedef struct +{ + gsl_vector_complex_long_double vector; +} _gsl_vector_complex_long_double_view; + +typedef _gsl_vector_complex_long_double_view gsl_vector_complex_long_double_view; + +typedef struct +{ + gsl_vector_complex_long_double vector; +} _gsl_vector_complex_long_double_const_view; + +typedef const _gsl_vector_complex_long_double_const_view gsl_vector_complex_long_double_const_view; + +/* Allocation */ + +gsl_vector_complex_long_double *gsl_vector_complex_long_double_alloc (const size_t n); +gsl_vector_complex_long_double *gsl_vector_complex_long_double_calloc (const size_t n); + +gsl_vector_complex_long_double * +gsl_vector_complex_long_double_alloc_from_block (gsl_block_complex_long_double * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_complex_long_double * +gsl_vector_complex_long_double_alloc_from_vector (gsl_vector_complex_long_double * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_complex_long_double_free (gsl_vector_complex_long_double * v); + +/* Views */ + +_gsl_vector_complex_long_double_view +gsl_vector_complex_long_double_view_array (long double *base, + size_t n); + +_gsl_vector_complex_long_double_view +gsl_vector_complex_long_double_view_array_with_stride (long double *base, + size_t stride, + size_t n); + +_gsl_vector_complex_long_double_const_view +gsl_vector_complex_long_double_const_view_array (const long double *base, + size_t n); + +_gsl_vector_complex_long_double_const_view +gsl_vector_complex_long_double_const_view_array_with_stride (const long double *base, + size_t stride, + size_t n); + +_gsl_vector_complex_long_double_view +gsl_vector_complex_long_double_subvector (gsl_vector_complex_long_double *base, + size_t i, + size_t n); + + +_gsl_vector_complex_long_double_view +gsl_vector_complex_long_double_subvector_with_stride (gsl_vector_complex_long_double *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_complex_long_double_const_view +gsl_vector_complex_long_double_const_subvector (const gsl_vector_complex_long_double *base, + size_t i, + size_t n); + + +_gsl_vector_complex_long_double_const_view +gsl_vector_complex_long_double_const_subvector_with_stride (const gsl_vector_complex_long_double *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_long_double_view +gsl_vector_complex_long_double_real (gsl_vector_complex_long_double *v); + +_gsl_vector_long_double_view +gsl_vector_complex_long_double_imag (gsl_vector_complex_long_double *v); + +_gsl_vector_long_double_const_view +gsl_vector_complex_long_double_const_real (const gsl_vector_complex_long_double *v); + +_gsl_vector_long_double_const_view +gsl_vector_complex_long_double_const_imag (const gsl_vector_complex_long_double *v); + + +/* Operations */ + +gsl_complex_long_double +gsl_vector_complex_long_double_get (const gsl_vector_complex_long_double * v, const size_t i); + +void gsl_vector_complex_long_double_set (gsl_vector_complex_long_double * v, const size_t i, + gsl_complex_long_double z); + +gsl_complex_long_double +*gsl_vector_complex_long_double_ptr (gsl_vector_complex_long_double * v, const size_t i); + +const gsl_complex_long_double +*gsl_vector_complex_long_double_const_ptr (const gsl_vector_complex_long_double * v, const size_t i); + +void gsl_vector_complex_long_double_set_zero (gsl_vector_complex_long_double * v); +void gsl_vector_complex_long_double_set_all (gsl_vector_complex_long_double * v, + gsl_complex_long_double z); +int gsl_vector_complex_long_double_set_basis (gsl_vector_complex_long_double * v, size_t i); + +int gsl_vector_complex_long_double_fread (FILE * stream, + gsl_vector_complex_long_double * v); +int gsl_vector_complex_long_double_fwrite (FILE * stream, + const gsl_vector_complex_long_double * v); +int gsl_vector_complex_long_double_fscanf (FILE * stream, + gsl_vector_complex_long_double * v); +int gsl_vector_complex_long_double_fprintf (FILE * stream, + const gsl_vector_complex_long_double * v, + const char *format); + +int gsl_vector_complex_long_double_memcpy (gsl_vector_complex_long_double * dest, const gsl_vector_complex_long_double * src); + +int gsl_vector_complex_long_double_reverse (gsl_vector_complex_long_double * v); + +int gsl_vector_complex_long_double_swap (gsl_vector_complex_long_double * v, gsl_vector_complex_long_double * w); +int gsl_vector_complex_long_double_swap_elements (gsl_vector_complex_long_double * v, const size_t i, const size_t j); + +int gsl_vector_complex_long_double_isnull (const gsl_vector_complex_long_double * v); +int gsl_vector_complex_long_double_ispos (const gsl_vector_complex_long_double * v); +int gsl_vector_complex_long_double_isneg (const gsl_vector_complex_long_double * v); + +#ifdef HAVE_INLINE + +extern inline +gsl_complex_long_double +gsl_vector_complex_long_double_get (const gsl_vector_complex_long_double * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + gsl_complex_long_double zero = {{0, 0}}; + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero); + } +#endif + return *GSL_COMPLEX_LONG_DOUBLE_AT (v, i); +} + +extern inline +void +gsl_vector_complex_long_double_set (gsl_vector_complex_long_double * v, + const size_t i, gsl_complex_long_double z) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + *GSL_COMPLEX_LONG_DOUBLE_AT (v, i) = z; +} + +extern inline +gsl_complex_long_double * +gsl_vector_complex_long_double_ptr (gsl_vector_complex_long_double * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_LONG_DOUBLE_AT (v, i); +} + +extern inline +const gsl_complex_long_double * +gsl_vector_complex_long_double_const_ptr (const gsl_vector_complex_long_double * v, + const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return GSL_COMPLEX_LONG_DOUBLE_AT (v, i); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_COMPLEX_LONG_DOUBLE_H__ */ diff --git a/gsl-1.9/vector/gsl_vector_double.h b/gsl-1.9/vector/gsl_vector_double.h new file mode 100644 index 0000000..189c4ab --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_double.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_DOUBLE_H__ +#define __GSL_VECTOR_DOUBLE_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + double *data; + gsl_block *block; + int owner; +} +gsl_vector; + +typedef struct +{ + gsl_vector vector; +} _gsl_vector_view; + +typedef _gsl_vector_view gsl_vector_view; + +typedef struct +{ + gsl_vector vector; +} _gsl_vector_const_view; + +typedef const _gsl_vector_const_view gsl_vector_const_view; + + +/* Allocation */ + +gsl_vector *gsl_vector_alloc (const size_t n); +gsl_vector *gsl_vector_calloc (const size_t n); + +gsl_vector *gsl_vector_alloc_from_block (gsl_block * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector *gsl_vector_alloc_from_vector (gsl_vector * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_free (gsl_vector * v); + +/* Views */ + +_gsl_vector_view +gsl_vector_view_array (double *v, size_t n); + +_gsl_vector_view +gsl_vector_view_array_with_stride (double *base, + size_t stride, + size_t n); + +_gsl_vector_const_view +gsl_vector_const_view_array (const double *v, size_t n); + +_gsl_vector_const_view +gsl_vector_const_view_array_with_stride (const double *base, + size_t stride, + size_t n); + +_gsl_vector_view +gsl_vector_subvector (gsl_vector *v, + size_t i, + size_t n); + +_gsl_vector_view +gsl_vector_subvector_with_stride (gsl_vector *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_const_view +gsl_vector_const_subvector (const gsl_vector *v, + size_t i, + size_t n); + +_gsl_vector_const_view +gsl_vector_const_subvector_with_stride (const gsl_vector *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +double gsl_vector_get (const gsl_vector * v, const size_t i); +void gsl_vector_set (gsl_vector * v, const size_t i, double x); + +double *gsl_vector_ptr (gsl_vector * v, const size_t i); +const double *gsl_vector_const_ptr (const gsl_vector * v, const size_t i); + +void gsl_vector_set_zero (gsl_vector * v); +void gsl_vector_set_all (gsl_vector * v, double x); +int gsl_vector_set_basis (gsl_vector * v, size_t i); + +int gsl_vector_fread (FILE * stream, gsl_vector * v); +int gsl_vector_fwrite (FILE * stream, const gsl_vector * v); +int gsl_vector_fscanf (FILE * stream, gsl_vector * v); +int gsl_vector_fprintf (FILE * stream, const gsl_vector * v, + const char *format); + +int gsl_vector_memcpy (gsl_vector * dest, const gsl_vector * src); + +int gsl_vector_reverse (gsl_vector * v); + +int gsl_vector_swap (gsl_vector * v, gsl_vector * w); +int gsl_vector_swap_elements (gsl_vector * v, const size_t i, const size_t j); + +double gsl_vector_max (const gsl_vector * v); +double gsl_vector_min (const gsl_vector * v); +void gsl_vector_minmax (const gsl_vector * v, double * min_out, double * max_out); + +size_t gsl_vector_max_index (const gsl_vector * v); +size_t gsl_vector_min_index (const gsl_vector * v); +void gsl_vector_minmax_index (const gsl_vector * v, size_t * imin, size_t * imax); + +int gsl_vector_add (gsl_vector * a, const gsl_vector * b); +int gsl_vector_sub (gsl_vector * a, const gsl_vector * b); +int gsl_vector_mul (gsl_vector * a, const gsl_vector * b); +int gsl_vector_div (gsl_vector * a, const gsl_vector * b); +int gsl_vector_scale (gsl_vector * a, const double x); +int gsl_vector_add_constant (gsl_vector * a, const double x); + +int gsl_vector_isnull (const gsl_vector * v); +int gsl_vector_ispos (const gsl_vector * v); +int gsl_vector_isneg (const gsl_vector * v); + +#ifdef HAVE_INLINE + +extern inline +double +gsl_vector_get (const gsl_vector * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_set (gsl_vector * v, const size_t i, double x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +double * +gsl_vector_ptr (gsl_vector * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (double *) (v->data + i * v->stride); +} + +extern inline +const double * +gsl_vector_const_ptr (const gsl_vector * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const double *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_DOUBLE_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_float.h b/gsl-1.9/vector/gsl_vector_float.h new file mode 100644 index 0000000..4fb280b --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_float.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_float.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_FLOAT_H__ +#define __GSL_VECTOR_FLOAT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + float *data; + gsl_block_float *block; + int owner; +} +gsl_vector_float; + +typedef struct +{ + gsl_vector_float vector; +} _gsl_vector_float_view; + +typedef _gsl_vector_float_view gsl_vector_float_view; + +typedef struct +{ + gsl_vector_float vector; +} _gsl_vector_float_const_view; + +typedef const _gsl_vector_float_const_view gsl_vector_float_const_view; + + +/* Allocation */ + +gsl_vector_float *gsl_vector_float_alloc (const size_t n); +gsl_vector_float *gsl_vector_float_calloc (const size_t n); + +gsl_vector_float *gsl_vector_float_alloc_from_block (gsl_block_float * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_float *gsl_vector_float_alloc_from_vector (gsl_vector_float * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_float_free (gsl_vector_float * v); + +/* Views */ + +_gsl_vector_float_view +gsl_vector_float_view_array (float *v, size_t n); + +_gsl_vector_float_view +gsl_vector_float_view_array_with_stride (float *base, + size_t stride, + size_t n); + +_gsl_vector_float_const_view +gsl_vector_float_const_view_array (const float *v, size_t n); + +_gsl_vector_float_const_view +gsl_vector_float_const_view_array_with_stride (const float *base, + size_t stride, + size_t n); + +_gsl_vector_float_view +gsl_vector_float_subvector (gsl_vector_float *v, + size_t i, + size_t n); + +_gsl_vector_float_view +gsl_vector_float_subvector_with_stride (gsl_vector_float *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_float_const_view +gsl_vector_float_const_subvector (const gsl_vector_float *v, + size_t i, + size_t n); + +_gsl_vector_float_const_view +gsl_vector_float_const_subvector_with_stride (const gsl_vector_float *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +float gsl_vector_float_get (const gsl_vector_float * v, const size_t i); +void gsl_vector_float_set (gsl_vector_float * v, const size_t i, float x); + +float *gsl_vector_float_ptr (gsl_vector_float * v, const size_t i); +const float *gsl_vector_float_const_ptr (const gsl_vector_float * v, const size_t i); + +void gsl_vector_float_set_zero (gsl_vector_float * v); +void gsl_vector_float_set_all (gsl_vector_float * v, float x); +int gsl_vector_float_set_basis (gsl_vector_float * v, size_t i); + +int gsl_vector_float_fread (FILE * stream, gsl_vector_float * v); +int gsl_vector_float_fwrite (FILE * stream, const gsl_vector_float * v); +int gsl_vector_float_fscanf (FILE * stream, gsl_vector_float * v); +int gsl_vector_float_fprintf (FILE * stream, const gsl_vector_float * v, + const char *format); + +int gsl_vector_float_memcpy (gsl_vector_float * dest, const gsl_vector_float * src); + +int gsl_vector_float_reverse (gsl_vector_float * v); + +int gsl_vector_float_swap (gsl_vector_float * v, gsl_vector_float * w); +int gsl_vector_float_swap_elements (gsl_vector_float * v, const size_t i, const size_t j); + +float gsl_vector_float_max (const gsl_vector_float * v); +float gsl_vector_float_min (const gsl_vector_float * v); +void gsl_vector_float_minmax (const gsl_vector_float * v, float * min_out, float * max_out); + +size_t gsl_vector_float_max_index (const gsl_vector_float * v); +size_t gsl_vector_float_min_index (const gsl_vector_float * v); +void gsl_vector_float_minmax_index (const gsl_vector_float * v, size_t * imin, size_t * imax); + +int gsl_vector_float_add (gsl_vector_float * a, const gsl_vector_float * b); +int gsl_vector_float_sub (gsl_vector_float * a, const gsl_vector_float * b); +int gsl_vector_float_mul (gsl_vector_float * a, const gsl_vector_float * b); +int gsl_vector_float_div (gsl_vector_float * a, const gsl_vector_float * b); +int gsl_vector_float_scale (gsl_vector_float * a, const double x); +int gsl_vector_float_add_constant (gsl_vector_float * a, const double x); + +int gsl_vector_float_isnull (const gsl_vector_float * v); +int gsl_vector_float_ispos (const gsl_vector_float * v); +int gsl_vector_float_isneg (const gsl_vector_float * v); + +#ifdef HAVE_INLINE + +extern inline +float +gsl_vector_float_get (const gsl_vector_float * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_float_set (gsl_vector_float * v, const size_t i, float x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +float * +gsl_vector_float_ptr (gsl_vector_float * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (float *) (v->data + i * v->stride); +} + +extern inline +const float * +gsl_vector_float_const_ptr (const gsl_vector_float * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const float *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_FLOAT_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_int.h b/gsl-1.9/vector/gsl_vector_int.h new file mode 100644 index 0000000..02b50a4 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_int.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_int.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_INT_H__ +#define __GSL_VECTOR_INT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + int *data; + gsl_block_int *block; + int owner; +} +gsl_vector_int; + +typedef struct +{ + gsl_vector_int vector; +} _gsl_vector_int_view; + +typedef _gsl_vector_int_view gsl_vector_int_view; + +typedef struct +{ + gsl_vector_int vector; +} _gsl_vector_int_const_view; + +typedef const _gsl_vector_int_const_view gsl_vector_int_const_view; + + +/* Allocation */ + +gsl_vector_int *gsl_vector_int_alloc (const size_t n); +gsl_vector_int *gsl_vector_int_calloc (const size_t n); + +gsl_vector_int *gsl_vector_int_alloc_from_block (gsl_block_int * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_int *gsl_vector_int_alloc_from_vector (gsl_vector_int * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_int_free (gsl_vector_int * v); + +/* Views */ + +_gsl_vector_int_view +gsl_vector_int_view_array (int *v, size_t n); + +_gsl_vector_int_view +gsl_vector_int_view_array_with_stride (int *base, + size_t stride, + size_t n); + +_gsl_vector_int_const_view +gsl_vector_int_const_view_array (const int *v, size_t n); + +_gsl_vector_int_const_view +gsl_vector_int_const_view_array_with_stride (const int *base, + size_t stride, + size_t n); + +_gsl_vector_int_view +gsl_vector_int_subvector (gsl_vector_int *v, + size_t i, + size_t n); + +_gsl_vector_int_view +gsl_vector_int_subvector_with_stride (gsl_vector_int *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_int_const_view +gsl_vector_int_const_subvector (const gsl_vector_int *v, + size_t i, + size_t n); + +_gsl_vector_int_const_view +gsl_vector_int_const_subvector_with_stride (const gsl_vector_int *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +int gsl_vector_int_get (const gsl_vector_int * v, const size_t i); +void gsl_vector_int_set (gsl_vector_int * v, const size_t i, int x); + +int *gsl_vector_int_ptr (gsl_vector_int * v, const size_t i); +const int *gsl_vector_int_const_ptr (const gsl_vector_int * v, const size_t i); + +void gsl_vector_int_set_zero (gsl_vector_int * v); +void gsl_vector_int_set_all (gsl_vector_int * v, int x); +int gsl_vector_int_set_basis (gsl_vector_int * v, size_t i); + +int gsl_vector_int_fread (FILE * stream, gsl_vector_int * v); +int gsl_vector_int_fwrite (FILE * stream, const gsl_vector_int * v); +int gsl_vector_int_fscanf (FILE * stream, gsl_vector_int * v); +int gsl_vector_int_fprintf (FILE * stream, const gsl_vector_int * v, + const char *format); + +int gsl_vector_int_memcpy (gsl_vector_int * dest, const gsl_vector_int * src); + +int gsl_vector_int_reverse (gsl_vector_int * v); + +int gsl_vector_int_swap (gsl_vector_int * v, gsl_vector_int * w); +int gsl_vector_int_swap_elements (gsl_vector_int * v, const size_t i, const size_t j); + +int gsl_vector_int_max (const gsl_vector_int * v); +int gsl_vector_int_min (const gsl_vector_int * v); +void gsl_vector_int_minmax (const gsl_vector_int * v, int * min_out, int * max_out); + +size_t gsl_vector_int_max_index (const gsl_vector_int * v); +size_t gsl_vector_int_min_index (const gsl_vector_int * v); +void gsl_vector_int_minmax_index (const gsl_vector_int * v, size_t * imin, size_t * imax); + +int gsl_vector_int_add (gsl_vector_int * a, const gsl_vector_int * b); +int gsl_vector_int_sub (gsl_vector_int * a, const gsl_vector_int * b); +int gsl_vector_int_mul (gsl_vector_int * a, const gsl_vector_int * b); +int gsl_vector_int_div (gsl_vector_int * a, const gsl_vector_int * b); +int gsl_vector_int_scale (gsl_vector_int * a, const double x); +int gsl_vector_int_add_constant (gsl_vector_int * a, const double x); + +int gsl_vector_int_isnull (const gsl_vector_int * v); +int gsl_vector_int_ispos (const gsl_vector_int * v); +int gsl_vector_int_isneg (const gsl_vector_int * v); + +#ifdef HAVE_INLINE + +extern inline +int +gsl_vector_int_get (const gsl_vector_int * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_int_set (gsl_vector_int * v, const size_t i, int x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +int * +gsl_vector_int_ptr (gsl_vector_int * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (int *) (v->data + i * v->stride); +} + +extern inline +const int * +gsl_vector_int_const_ptr (const gsl_vector_int * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const int *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_INT_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_long.h b/gsl-1.9/vector/gsl_vector_long.h new file mode 100644 index 0000000..fcbfa15 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_long.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_long.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_LONG_H__ +#define __GSL_VECTOR_LONG_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + long *data; + gsl_block_long *block; + int owner; +} +gsl_vector_long; + +typedef struct +{ + gsl_vector_long vector; +} _gsl_vector_long_view; + +typedef _gsl_vector_long_view gsl_vector_long_view; + +typedef struct +{ + gsl_vector_long vector; +} _gsl_vector_long_const_view; + +typedef const _gsl_vector_long_const_view gsl_vector_long_const_view; + + +/* Allocation */ + +gsl_vector_long *gsl_vector_long_alloc (const size_t n); +gsl_vector_long *gsl_vector_long_calloc (const size_t n); + +gsl_vector_long *gsl_vector_long_alloc_from_block (gsl_block_long * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_long *gsl_vector_long_alloc_from_vector (gsl_vector_long * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_long_free (gsl_vector_long * v); + +/* Views */ + +_gsl_vector_long_view +gsl_vector_long_view_array (long *v, size_t n); + +_gsl_vector_long_view +gsl_vector_long_view_array_with_stride (long *base, + size_t stride, + size_t n); + +_gsl_vector_long_const_view +gsl_vector_long_const_view_array (const long *v, size_t n); + +_gsl_vector_long_const_view +gsl_vector_long_const_view_array_with_stride (const long *base, + size_t stride, + size_t n); + +_gsl_vector_long_view +gsl_vector_long_subvector (gsl_vector_long *v, + size_t i, + size_t n); + +_gsl_vector_long_view +gsl_vector_long_subvector_with_stride (gsl_vector_long *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_long_const_view +gsl_vector_long_const_subvector (const gsl_vector_long *v, + size_t i, + size_t n); + +_gsl_vector_long_const_view +gsl_vector_long_const_subvector_with_stride (const gsl_vector_long *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +long gsl_vector_long_get (const gsl_vector_long * v, const size_t i); +void gsl_vector_long_set (gsl_vector_long * v, const size_t i, long x); + +long *gsl_vector_long_ptr (gsl_vector_long * v, const size_t i); +const long *gsl_vector_long_const_ptr (const gsl_vector_long * v, const size_t i); + +void gsl_vector_long_set_zero (gsl_vector_long * v); +void gsl_vector_long_set_all (gsl_vector_long * v, long x); +int gsl_vector_long_set_basis (gsl_vector_long * v, size_t i); + +int gsl_vector_long_fread (FILE * stream, gsl_vector_long * v); +int gsl_vector_long_fwrite (FILE * stream, const gsl_vector_long * v); +int gsl_vector_long_fscanf (FILE * stream, gsl_vector_long * v); +int gsl_vector_long_fprintf (FILE * stream, const gsl_vector_long * v, + const char *format); + +int gsl_vector_long_memcpy (gsl_vector_long * dest, const gsl_vector_long * src); + +int gsl_vector_long_reverse (gsl_vector_long * v); + +int gsl_vector_long_swap (gsl_vector_long * v, gsl_vector_long * w); +int gsl_vector_long_swap_elements (gsl_vector_long * v, const size_t i, const size_t j); + +long gsl_vector_long_max (const gsl_vector_long * v); +long gsl_vector_long_min (const gsl_vector_long * v); +void gsl_vector_long_minmax (const gsl_vector_long * v, long * min_out, long * max_out); + +size_t gsl_vector_long_max_index (const gsl_vector_long * v); +size_t gsl_vector_long_min_index (const gsl_vector_long * v); +void gsl_vector_long_minmax_index (const gsl_vector_long * v, size_t * imin, size_t * imax); + +int gsl_vector_long_add (gsl_vector_long * a, const gsl_vector_long * b); +int gsl_vector_long_sub (gsl_vector_long * a, const gsl_vector_long * b); +int gsl_vector_long_mul (gsl_vector_long * a, const gsl_vector_long * b); +int gsl_vector_long_div (gsl_vector_long * a, const gsl_vector_long * b); +int gsl_vector_long_scale (gsl_vector_long * a, const double x); +int gsl_vector_long_add_constant (gsl_vector_long * a, const double x); + +int gsl_vector_long_isnull (const gsl_vector_long * v); +int gsl_vector_long_ispos (const gsl_vector_long * v); +int gsl_vector_long_isneg (const gsl_vector_long * v); + +#ifdef HAVE_INLINE + +extern inline +long +gsl_vector_long_get (const gsl_vector_long * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_long_set (gsl_vector_long * v, const size_t i, long x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +long * +gsl_vector_long_ptr (gsl_vector_long * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (long *) (v->data + i * v->stride); +} + +extern inline +const long * +gsl_vector_long_const_ptr (const gsl_vector_long * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const long *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_LONG_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_long_double.h b/gsl-1.9/vector/gsl_vector_long_double.h new file mode 100644 index 0000000..15ff57a --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_long_double.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_long_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_LONG_DOUBLE_H__ +#define __GSL_VECTOR_LONG_DOUBLE_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + long double *data; + gsl_block_long_double *block; + int owner; +} +gsl_vector_long_double; + +typedef struct +{ + gsl_vector_long_double vector; +} _gsl_vector_long_double_view; + +typedef _gsl_vector_long_double_view gsl_vector_long_double_view; + +typedef struct +{ + gsl_vector_long_double vector; +} _gsl_vector_long_double_const_view; + +typedef const _gsl_vector_long_double_const_view gsl_vector_long_double_const_view; + + +/* Allocation */ + +gsl_vector_long_double *gsl_vector_long_double_alloc (const size_t n); +gsl_vector_long_double *gsl_vector_long_double_calloc (const size_t n); + +gsl_vector_long_double *gsl_vector_long_double_alloc_from_block (gsl_block_long_double * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_long_double *gsl_vector_long_double_alloc_from_vector (gsl_vector_long_double * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_long_double_free (gsl_vector_long_double * v); + +/* Views */ + +_gsl_vector_long_double_view +gsl_vector_long_double_view_array (long double *v, size_t n); + +_gsl_vector_long_double_view +gsl_vector_long_double_view_array_with_stride (long double *base, + size_t stride, + size_t n); + +_gsl_vector_long_double_const_view +gsl_vector_long_double_const_view_array (const long double *v, size_t n); + +_gsl_vector_long_double_const_view +gsl_vector_long_double_const_view_array_with_stride (const long double *base, + size_t stride, + size_t n); + +_gsl_vector_long_double_view +gsl_vector_long_double_subvector (gsl_vector_long_double *v, + size_t i, + size_t n); + +_gsl_vector_long_double_view +gsl_vector_long_double_subvector_with_stride (gsl_vector_long_double *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_long_double_const_view +gsl_vector_long_double_const_subvector (const gsl_vector_long_double *v, + size_t i, + size_t n); + +_gsl_vector_long_double_const_view +gsl_vector_long_double_const_subvector_with_stride (const gsl_vector_long_double *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +long double gsl_vector_long_double_get (const gsl_vector_long_double * v, const size_t i); +void gsl_vector_long_double_set (gsl_vector_long_double * v, const size_t i, long double x); + +long double *gsl_vector_long_double_ptr (gsl_vector_long_double * v, const size_t i); +const long double *gsl_vector_long_double_const_ptr (const gsl_vector_long_double * v, const size_t i); + +void gsl_vector_long_double_set_zero (gsl_vector_long_double * v); +void gsl_vector_long_double_set_all (gsl_vector_long_double * v, long double x); +int gsl_vector_long_double_set_basis (gsl_vector_long_double * v, size_t i); + +int gsl_vector_long_double_fread (FILE * stream, gsl_vector_long_double * v); +int gsl_vector_long_double_fwrite (FILE * stream, const gsl_vector_long_double * v); +int gsl_vector_long_double_fscanf (FILE * stream, gsl_vector_long_double * v); +int gsl_vector_long_double_fprintf (FILE * stream, const gsl_vector_long_double * v, + const char *format); + +int gsl_vector_long_double_memcpy (gsl_vector_long_double * dest, const gsl_vector_long_double * src); + +int gsl_vector_long_double_reverse (gsl_vector_long_double * v); + +int gsl_vector_long_double_swap (gsl_vector_long_double * v, gsl_vector_long_double * w); +int gsl_vector_long_double_swap_elements (gsl_vector_long_double * v, const size_t i, const size_t j); + +long double gsl_vector_long_double_max (const gsl_vector_long_double * v); +long double gsl_vector_long_double_min (const gsl_vector_long_double * v); +void gsl_vector_long_double_minmax (const gsl_vector_long_double * v, long double * min_out, long double * max_out); + +size_t gsl_vector_long_double_max_index (const gsl_vector_long_double * v); +size_t gsl_vector_long_double_min_index (const gsl_vector_long_double * v); +void gsl_vector_long_double_minmax_index (const gsl_vector_long_double * v, size_t * imin, size_t * imax); + +int gsl_vector_long_double_add (gsl_vector_long_double * a, const gsl_vector_long_double * b); +int gsl_vector_long_double_sub (gsl_vector_long_double * a, const gsl_vector_long_double * b); +int gsl_vector_long_double_mul (gsl_vector_long_double * a, const gsl_vector_long_double * b); +int gsl_vector_long_double_div (gsl_vector_long_double * a, const gsl_vector_long_double * b); +int gsl_vector_long_double_scale (gsl_vector_long_double * a, const double x); +int gsl_vector_long_double_add_constant (gsl_vector_long_double * a, const double x); + +int gsl_vector_long_double_isnull (const gsl_vector_long_double * v); +int gsl_vector_long_double_ispos (const gsl_vector_long_double * v); +int gsl_vector_long_double_isneg (const gsl_vector_long_double * v); + +#ifdef HAVE_INLINE + +extern inline +long double +gsl_vector_long_double_get (const gsl_vector_long_double * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_long_double_set (gsl_vector_long_double * v, const size_t i, long double x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +long double * +gsl_vector_long_double_ptr (gsl_vector_long_double * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (long double *) (v->data + i * v->stride); +} + +extern inline +const long double * +gsl_vector_long_double_const_ptr (const gsl_vector_long_double * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const long double *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_LONG_DOUBLE_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_short.h b/gsl-1.9/vector/gsl_vector_short.h new file mode 100644 index 0000000..45218cf --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_short.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_short.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_SHORT_H__ +#define __GSL_VECTOR_SHORT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + short *data; + gsl_block_short *block; + int owner; +} +gsl_vector_short; + +typedef struct +{ + gsl_vector_short vector; +} _gsl_vector_short_view; + +typedef _gsl_vector_short_view gsl_vector_short_view; + +typedef struct +{ + gsl_vector_short vector; +} _gsl_vector_short_const_view; + +typedef const _gsl_vector_short_const_view gsl_vector_short_const_view; + + +/* Allocation */ + +gsl_vector_short *gsl_vector_short_alloc (const size_t n); +gsl_vector_short *gsl_vector_short_calloc (const size_t n); + +gsl_vector_short *gsl_vector_short_alloc_from_block (gsl_block_short * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_short *gsl_vector_short_alloc_from_vector (gsl_vector_short * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_short_free (gsl_vector_short * v); + +/* Views */ + +_gsl_vector_short_view +gsl_vector_short_view_array (short *v, size_t n); + +_gsl_vector_short_view +gsl_vector_short_view_array_with_stride (short *base, + size_t stride, + size_t n); + +_gsl_vector_short_const_view +gsl_vector_short_const_view_array (const short *v, size_t n); + +_gsl_vector_short_const_view +gsl_vector_short_const_view_array_with_stride (const short *base, + size_t stride, + size_t n); + +_gsl_vector_short_view +gsl_vector_short_subvector (gsl_vector_short *v, + size_t i, + size_t n); + +_gsl_vector_short_view +gsl_vector_short_subvector_with_stride (gsl_vector_short *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_short_const_view +gsl_vector_short_const_subvector (const gsl_vector_short *v, + size_t i, + size_t n); + +_gsl_vector_short_const_view +gsl_vector_short_const_subvector_with_stride (const gsl_vector_short *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +short gsl_vector_short_get (const gsl_vector_short * v, const size_t i); +void gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x); + +short *gsl_vector_short_ptr (gsl_vector_short * v, const size_t i); +const short *gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i); + +void gsl_vector_short_set_zero (gsl_vector_short * v); +void gsl_vector_short_set_all (gsl_vector_short * v, short x); +int gsl_vector_short_set_basis (gsl_vector_short * v, size_t i); + +int gsl_vector_short_fread (FILE * stream, gsl_vector_short * v); +int gsl_vector_short_fwrite (FILE * stream, const gsl_vector_short * v); +int gsl_vector_short_fscanf (FILE * stream, gsl_vector_short * v); +int gsl_vector_short_fprintf (FILE * stream, const gsl_vector_short * v, + const char *format); + +int gsl_vector_short_memcpy (gsl_vector_short * dest, const gsl_vector_short * src); + +int gsl_vector_short_reverse (gsl_vector_short * v); + +int gsl_vector_short_swap (gsl_vector_short * v, gsl_vector_short * w); +int gsl_vector_short_swap_elements (gsl_vector_short * v, const size_t i, const size_t j); + +short gsl_vector_short_max (const gsl_vector_short * v); +short gsl_vector_short_min (const gsl_vector_short * v); +void gsl_vector_short_minmax (const gsl_vector_short * v, short * min_out, short * max_out); + +size_t gsl_vector_short_max_index (const gsl_vector_short * v); +size_t gsl_vector_short_min_index (const gsl_vector_short * v); +void gsl_vector_short_minmax_index (const gsl_vector_short * v, size_t * imin, size_t * imax); + +int gsl_vector_short_add (gsl_vector_short * a, const gsl_vector_short * b); +int gsl_vector_short_sub (gsl_vector_short * a, const gsl_vector_short * b); +int gsl_vector_short_mul (gsl_vector_short * a, const gsl_vector_short * b); +int gsl_vector_short_div (gsl_vector_short * a, const gsl_vector_short * b); +int gsl_vector_short_scale (gsl_vector_short * a, const double x); +int gsl_vector_short_add_constant (gsl_vector_short * a, const double x); + +int gsl_vector_short_isnull (const gsl_vector_short * v); +int gsl_vector_short_ispos (const gsl_vector_short * v); +int gsl_vector_short_isneg (const gsl_vector_short * v); + +#ifdef HAVE_INLINE + +extern inline +short +gsl_vector_short_get (const gsl_vector_short * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +short * +gsl_vector_short_ptr (gsl_vector_short * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (short *) (v->data + i * v->stride); +} + +extern inline +const short * +gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const short *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_SHORT_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_uchar.h b/gsl-1.9/vector/gsl_vector_uchar.h new file mode 100644 index 0000000..895d187 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_uchar.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_uchar.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_UCHAR_H__ +#define __GSL_VECTOR_UCHAR_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + unsigned char *data; + gsl_block_uchar *block; + int owner; +} +gsl_vector_uchar; + +typedef struct +{ + gsl_vector_uchar vector; +} _gsl_vector_uchar_view; + +typedef _gsl_vector_uchar_view gsl_vector_uchar_view; + +typedef struct +{ + gsl_vector_uchar vector; +} _gsl_vector_uchar_const_view; + +typedef const _gsl_vector_uchar_const_view gsl_vector_uchar_const_view; + + +/* Allocation */ + +gsl_vector_uchar *gsl_vector_uchar_alloc (const size_t n); +gsl_vector_uchar *gsl_vector_uchar_calloc (const size_t n); + +gsl_vector_uchar *gsl_vector_uchar_alloc_from_block (gsl_block_uchar * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_uchar *gsl_vector_uchar_alloc_from_vector (gsl_vector_uchar * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_uchar_free (gsl_vector_uchar * v); + +/* Views */ + +_gsl_vector_uchar_view +gsl_vector_uchar_view_array (unsigned char *v, size_t n); + +_gsl_vector_uchar_view +gsl_vector_uchar_view_array_with_stride (unsigned char *base, + size_t stride, + size_t n); + +_gsl_vector_uchar_const_view +gsl_vector_uchar_const_view_array (const unsigned char *v, size_t n); + +_gsl_vector_uchar_const_view +gsl_vector_uchar_const_view_array_with_stride (const unsigned char *base, + size_t stride, + size_t n); + +_gsl_vector_uchar_view +gsl_vector_uchar_subvector (gsl_vector_uchar *v, + size_t i, + size_t n); + +_gsl_vector_uchar_view +gsl_vector_uchar_subvector_with_stride (gsl_vector_uchar *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_uchar_const_view +gsl_vector_uchar_const_subvector (const gsl_vector_uchar *v, + size_t i, + size_t n); + +_gsl_vector_uchar_const_view +gsl_vector_uchar_const_subvector_with_stride (const gsl_vector_uchar *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +unsigned char gsl_vector_uchar_get (const gsl_vector_uchar * v, const size_t i); +void gsl_vector_uchar_set (gsl_vector_uchar * v, const size_t i, unsigned char x); + +unsigned char *gsl_vector_uchar_ptr (gsl_vector_uchar * v, const size_t i); +const unsigned char *gsl_vector_uchar_const_ptr (const gsl_vector_uchar * v, const size_t i); + +void gsl_vector_uchar_set_zero (gsl_vector_uchar * v); +void gsl_vector_uchar_set_all (gsl_vector_uchar * v, unsigned char x); +int gsl_vector_uchar_set_basis (gsl_vector_uchar * v, size_t i); + +int gsl_vector_uchar_fread (FILE * stream, gsl_vector_uchar * v); +int gsl_vector_uchar_fwrite (FILE * stream, const gsl_vector_uchar * v); +int gsl_vector_uchar_fscanf (FILE * stream, gsl_vector_uchar * v); +int gsl_vector_uchar_fprintf (FILE * stream, const gsl_vector_uchar * v, + const char *format); + +int gsl_vector_uchar_memcpy (gsl_vector_uchar * dest, const gsl_vector_uchar * src); + +int gsl_vector_uchar_reverse (gsl_vector_uchar * v); + +int gsl_vector_uchar_swap (gsl_vector_uchar * v, gsl_vector_uchar * w); +int gsl_vector_uchar_swap_elements (gsl_vector_uchar * v, const size_t i, const size_t j); + +unsigned char gsl_vector_uchar_max (const gsl_vector_uchar * v); +unsigned char gsl_vector_uchar_min (const gsl_vector_uchar * v); +void gsl_vector_uchar_minmax (const gsl_vector_uchar * v, unsigned char * min_out, unsigned char * max_out); + +size_t gsl_vector_uchar_max_index (const gsl_vector_uchar * v); +size_t gsl_vector_uchar_min_index (const gsl_vector_uchar * v); +void gsl_vector_uchar_minmax_index (const gsl_vector_uchar * v, size_t * imin, size_t * imax); + +int gsl_vector_uchar_add (gsl_vector_uchar * a, const gsl_vector_uchar * b); +int gsl_vector_uchar_sub (gsl_vector_uchar * a, const gsl_vector_uchar * b); +int gsl_vector_uchar_mul (gsl_vector_uchar * a, const gsl_vector_uchar * b); +int gsl_vector_uchar_div (gsl_vector_uchar * a, const gsl_vector_uchar * b); +int gsl_vector_uchar_scale (gsl_vector_uchar * a, const double x); +int gsl_vector_uchar_add_constant (gsl_vector_uchar * a, const double x); + +int gsl_vector_uchar_isnull (const gsl_vector_uchar * v); +int gsl_vector_uchar_ispos (const gsl_vector_uchar * v); +int gsl_vector_uchar_isneg (const gsl_vector_uchar * v); + +#ifdef HAVE_INLINE + +extern inline +unsigned char +gsl_vector_uchar_get (const gsl_vector_uchar * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_uchar_set (gsl_vector_uchar * v, const size_t i, unsigned char x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +unsigned char * +gsl_vector_uchar_ptr (gsl_vector_uchar * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (unsigned char *) (v->data + i * v->stride); +} + +extern inline +const unsigned char * +gsl_vector_uchar_const_ptr (const gsl_vector_uchar * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const unsigned char *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_UCHAR_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_uint.h b/gsl-1.9/vector/gsl_vector_uint.h new file mode 100644 index 0000000..2394ff2 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_uint.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_uint.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_UINT_H__ +#define __GSL_VECTOR_UINT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + unsigned int *data; + gsl_block_uint *block; + int owner; +} +gsl_vector_uint; + +typedef struct +{ + gsl_vector_uint vector; +} _gsl_vector_uint_view; + +typedef _gsl_vector_uint_view gsl_vector_uint_view; + +typedef struct +{ + gsl_vector_uint vector; +} _gsl_vector_uint_const_view; + +typedef const _gsl_vector_uint_const_view gsl_vector_uint_const_view; + + +/* Allocation */ + +gsl_vector_uint *gsl_vector_uint_alloc (const size_t n); +gsl_vector_uint *gsl_vector_uint_calloc (const size_t n); + +gsl_vector_uint *gsl_vector_uint_alloc_from_block (gsl_block_uint * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_uint *gsl_vector_uint_alloc_from_vector (gsl_vector_uint * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_uint_free (gsl_vector_uint * v); + +/* Views */ + +_gsl_vector_uint_view +gsl_vector_uint_view_array (unsigned int *v, size_t n); + +_gsl_vector_uint_view +gsl_vector_uint_view_array_with_stride (unsigned int *base, + size_t stride, + size_t n); + +_gsl_vector_uint_const_view +gsl_vector_uint_const_view_array (const unsigned int *v, size_t n); + +_gsl_vector_uint_const_view +gsl_vector_uint_const_view_array_with_stride (const unsigned int *base, + size_t stride, + size_t n); + +_gsl_vector_uint_view +gsl_vector_uint_subvector (gsl_vector_uint *v, + size_t i, + size_t n); + +_gsl_vector_uint_view +gsl_vector_uint_subvector_with_stride (gsl_vector_uint *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_uint_const_view +gsl_vector_uint_const_subvector (const gsl_vector_uint *v, + size_t i, + size_t n); + +_gsl_vector_uint_const_view +gsl_vector_uint_const_subvector_with_stride (const gsl_vector_uint *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +unsigned int gsl_vector_uint_get (const gsl_vector_uint * v, const size_t i); +void gsl_vector_uint_set (gsl_vector_uint * v, const size_t i, unsigned int x); + +unsigned int *gsl_vector_uint_ptr (gsl_vector_uint * v, const size_t i); +const unsigned int *gsl_vector_uint_const_ptr (const gsl_vector_uint * v, const size_t i); + +void gsl_vector_uint_set_zero (gsl_vector_uint * v); +void gsl_vector_uint_set_all (gsl_vector_uint * v, unsigned int x); +int gsl_vector_uint_set_basis (gsl_vector_uint * v, size_t i); + +int gsl_vector_uint_fread (FILE * stream, gsl_vector_uint * v); +int gsl_vector_uint_fwrite (FILE * stream, const gsl_vector_uint * v); +int gsl_vector_uint_fscanf (FILE * stream, gsl_vector_uint * v); +int gsl_vector_uint_fprintf (FILE * stream, const gsl_vector_uint * v, + const char *format); + +int gsl_vector_uint_memcpy (gsl_vector_uint * dest, const gsl_vector_uint * src); + +int gsl_vector_uint_reverse (gsl_vector_uint * v); + +int gsl_vector_uint_swap (gsl_vector_uint * v, gsl_vector_uint * w); +int gsl_vector_uint_swap_elements (gsl_vector_uint * v, const size_t i, const size_t j); + +unsigned int gsl_vector_uint_max (const gsl_vector_uint * v); +unsigned int gsl_vector_uint_min (const gsl_vector_uint * v); +void gsl_vector_uint_minmax (const gsl_vector_uint * v, unsigned int * min_out, unsigned int * max_out); + +size_t gsl_vector_uint_max_index (const gsl_vector_uint * v); +size_t gsl_vector_uint_min_index (const gsl_vector_uint * v); +void gsl_vector_uint_minmax_index (const gsl_vector_uint * v, size_t * imin, size_t * imax); + +int gsl_vector_uint_add (gsl_vector_uint * a, const gsl_vector_uint * b); +int gsl_vector_uint_sub (gsl_vector_uint * a, const gsl_vector_uint * b); +int gsl_vector_uint_mul (gsl_vector_uint * a, const gsl_vector_uint * b); +int gsl_vector_uint_div (gsl_vector_uint * a, const gsl_vector_uint * b); +int gsl_vector_uint_scale (gsl_vector_uint * a, const double x); +int gsl_vector_uint_add_constant (gsl_vector_uint * a, const double x); + +int gsl_vector_uint_isnull (const gsl_vector_uint * v); +int gsl_vector_uint_ispos (const gsl_vector_uint * v); +int gsl_vector_uint_isneg (const gsl_vector_uint * v); + +#ifdef HAVE_INLINE + +extern inline +unsigned int +gsl_vector_uint_get (const gsl_vector_uint * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_uint_set (gsl_vector_uint * v, const size_t i, unsigned int x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +unsigned int * +gsl_vector_uint_ptr (gsl_vector_uint * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (unsigned int *) (v->data + i * v->stride); +} + +extern inline +const unsigned int * +gsl_vector_uint_const_ptr (const gsl_vector_uint * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const unsigned int *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_UINT_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_ulong.h b/gsl-1.9/vector/gsl_vector_ulong.h new file mode 100644 index 0000000..db0ae76 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_ulong.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_ulong.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_ULONG_H__ +#define __GSL_VECTOR_ULONG_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + unsigned long *data; + gsl_block_ulong *block; + int owner; +} +gsl_vector_ulong; + +typedef struct +{ + gsl_vector_ulong vector; +} _gsl_vector_ulong_view; + +typedef _gsl_vector_ulong_view gsl_vector_ulong_view; + +typedef struct +{ + gsl_vector_ulong vector; +} _gsl_vector_ulong_const_view; + +typedef const _gsl_vector_ulong_const_view gsl_vector_ulong_const_view; + + +/* Allocation */ + +gsl_vector_ulong *gsl_vector_ulong_alloc (const size_t n); +gsl_vector_ulong *gsl_vector_ulong_calloc (const size_t n); + +gsl_vector_ulong *gsl_vector_ulong_alloc_from_block (gsl_block_ulong * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_ulong *gsl_vector_ulong_alloc_from_vector (gsl_vector_ulong * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_ulong_free (gsl_vector_ulong * v); + +/* Views */ + +_gsl_vector_ulong_view +gsl_vector_ulong_view_array (unsigned long *v, size_t n); + +_gsl_vector_ulong_view +gsl_vector_ulong_view_array_with_stride (unsigned long *base, + size_t stride, + size_t n); + +_gsl_vector_ulong_const_view +gsl_vector_ulong_const_view_array (const unsigned long *v, size_t n); + +_gsl_vector_ulong_const_view +gsl_vector_ulong_const_view_array_with_stride (const unsigned long *base, + size_t stride, + size_t n); + +_gsl_vector_ulong_view +gsl_vector_ulong_subvector (gsl_vector_ulong *v, + size_t i, + size_t n); + +_gsl_vector_ulong_view +gsl_vector_ulong_subvector_with_stride (gsl_vector_ulong *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_ulong_const_view +gsl_vector_ulong_const_subvector (const gsl_vector_ulong *v, + size_t i, + size_t n); + +_gsl_vector_ulong_const_view +gsl_vector_ulong_const_subvector_with_stride (const gsl_vector_ulong *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +unsigned long gsl_vector_ulong_get (const gsl_vector_ulong * v, const size_t i); +void gsl_vector_ulong_set (gsl_vector_ulong * v, const size_t i, unsigned long x); + +unsigned long *gsl_vector_ulong_ptr (gsl_vector_ulong * v, const size_t i); +const unsigned long *gsl_vector_ulong_const_ptr (const gsl_vector_ulong * v, const size_t i); + +void gsl_vector_ulong_set_zero (gsl_vector_ulong * v); +void gsl_vector_ulong_set_all (gsl_vector_ulong * v, unsigned long x); +int gsl_vector_ulong_set_basis (gsl_vector_ulong * v, size_t i); + +int gsl_vector_ulong_fread (FILE * stream, gsl_vector_ulong * v); +int gsl_vector_ulong_fwrite (FILE * stream, const gsl_vector_ulong * v); +int gsl_vector_ulong_fscanf (FILE * stream, gsl_vector_ulong * v); +int gsl_vector_ulong_fprintf (FILE * stream, const gsl_vector_ulong * v, + const char *format); + +int gsl_vector_ulong_memcpy (gsl_vector_ulong * dest, const gsl_vector_ulong * src); + +int gsl_vector_ulong_reverse (gsl_vector_ulong * v); + +int gsl_vector_ulong_swap (gsl_vector_ulong * v, gsl_vector_ulong * w); +int gsl_vector_ulong_swap_elements (gsl_vector_ulong * v, const size_t i, const size_t j); + +unsigned long gsl_vector_ulong_max (const gsl_vector_ulong * v); +unsigned long gsl_vector_ulong_min (const gsl_vector_ulong * v); +void gsl_vector_ulong_minmax (const gsl_vector_ulong * v, unsigned long * min_out, unsigned long * max_out); + +size_t gsl_vector_ulong_max_index (const gsl_vector_ulong * v); +size_t gsl_vector_ulong_min_index (const gsl_vector_ulong * v); +void gsl_vector_ulong_minmax_index (const gsl_vector_ulong * v, size_t * imin, size_t * imax); + +int gsl_vector_ulong_add (gsl_vector_ulong * a, const gsl_vector_ulong * b); +int gsl_vector_ulong_sub (gsl_vector_ulong * a, const gsl_vector_ulong * b); +int gsl_vector_ulong_mul (gsl_vector_ulong * a, const gsl_vector_ulong * b); +int gsl_vector_ulong_div (gsl_vector_ulong * a, const gsl_vector_ulong * b); +int gsl_vector_ulong_scale (gsl_vector_ulong * a, const double x); +int gsl_vector_ulong_add_constant (gsl_vector_ulong * a, const double x); + +int gsl_vector_ulong_isnull (const gsl_vector_ulong * v); +int gsl_vector_ulong_ispos (const gsl_vector_ulong * v); +int gsl_vector_ulong_isneg (const gsl_vector_ulong * v); + +#ifdef HAVE_INLINE + +extern inline +unsigned long +gsl_vector_ulong_get (const gsl_vector_ulong * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_ulong_set (gsl_vector_ulong * v, const size_t i, unsigned long x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +unsigned long * +gsl_vector_ulong_ptr (gsl_vector_ulong * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (unsigned long *) (v->data + i * v->stride); +} + +extern inline +const unsigned long * +gsl_vector_ulong_const_ptr (const gsl_vector_ulong * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const unsigned long *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_ULONG_H__ */ + + diff --git a/gsl-1.9/vector/gsl_vector_ushort.h b/gsl-1.9/vector/gsl_vector_ushort.h new file mode 100644 index 0000000..5e04748 --- /dev/null +++ b/gsl-1.9/vector/gsl_vector_ushort.h @@ -0,0 +1,228 @@ +/* vector/gsl_vector_ushort.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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_VECTOR_USHORT_H__ +#define __GSL_VECTOR_USHORT_H__ + +#include <stdlib.h> +#include <gsl/gsl_types.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_check_range.h> +#include <gsl/gsl_block_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 + +typedef struct +{ + size_t size; + size_t stride; + unsigned short *data; + gsl_block_ushort *block; + int owner; +} +gsl_vector_ushort; + +typedef struct +{ + gsl_vector_ushort vector; +} _gsl_vector_ushort_view; + +typedef _gsl_vector_ushort_view gsl_vector_ushort_view; + +typedef struct +{ + gsl_vector_ushort vector; +} _gsl_vector_ushort_const_view; + +typedef const _gsl_vector_ushort_const_view gsl_vector_ushort_const_view; + + +/* Allocation */ + +gsl_vector_ushort *gsl_vector_ushort_alloc (const size_t n); +gsl_vector_ushort *gsl_vector_ushort_calloc (const size_t n); + +gsl_vector_ushort *gsl_vector_ushort_alloc_from_block (gsl_block_ushort * b, + const size_t offset, + const size_t n, + const size_t stride); + +gsl_vector_ushort *gsl_vector_ushort_alloc_from_vector (gsl_vector_ushort * v, + const size_t offset, + const size_t n, + const size_t stride); + +void gsl_vector_ushort_free (gsl_vector_ushort * v); + +/* Views */ + +_gsl_vector_ushort_view +gsl_vector_ushort_view_array (unsigned short *v, size_t n); + +_gsl_vector_ushort_view +gsl_vector_ushort_view_array_with_stride (unsigned short *base, + size_t stride, + size_t n); + +_gsl_vector_ushort_const_view +gsl_vector_ushort_const_view_array (const unsigned short *v, size_t n); + +_gsl_vector_ushort_const_view +gsl_vector_ushort_const_view_array_with_stride (const unsigned short *base, + size_t stride, + size_t n); + +_gsl_vector_ushort_view +gsl_vector_ushort_subvector (gsl_vector_ushort *v, + size_t i, + size_t n); + +_gsl_vector_ushort_view +gsl_vector_ushort_subvector_with_stride (gsl_vector_ushort *v, + size_t i, + size_t stride, + size_t n); + +_gsl_vector_ushort_const_view +gsl_vector_ushort_const_subvector (const gsl_vector_ushort *v, + size_t i, + size_t n); + +_gsl_vector_ushort_const_view +gsl_vector_ushort_const_subvector_with_stride (const gsl_vector_ushort *v, + size_t i, + size_t stride, + size_t n); + +/* Operations */ + +unsigned short gsl_vector_ushort_get (const gsl_vector_ushort * v, const size_t i); +void gsl_vector_ushort_set (gsl_vector_ushort * v, const size_t i, unsigned short x); + +unsigned short *gsl_vector_ushort_ptr (gsl_vector_ushort * v, const size_t i); +const unsigned short *gsl_vector_ushort_const_ptr (const gsl_vector_ushort * v, const size_t i); + +void gsl_vector_ushort_set_zero (gsl_vector_ushort * v); +void gsl_vector_ushort_set_all (gsl_vector_ushort * v, unsigned short x); +int gsl_vector_ushort_set_basis (gsl_vector_ushort * v, size_t i); + +int gsl_vector_ushort_fread (FILE * stream, gsl_vector_ushort * v); +int gsl_vector_ushort_fwrite (FILE * stream, const gsl_vector_ushort * v); +int gsl_vector_ushort_fscanf (FILE * stream, gsl_vector_ushort * v); +int gsl_vector_ushort_fprintf (FILE * stream, const gsl_vector_ushort * v, + const char *format); + +int gsl_vector_ushort_memcpy (gsl_vector_ushort * dest, const gsl_vector_ushort * src); + +int gsl_vector_ushort_reverse (gsl_vector_ushort * v); + +int gsl_vector_ushort_swap (gsl_vector_ushort * v, gsl_vector_ushort * w); +int gsl_vector_ushort_swap_elements (gsl_vector_ushort * v, const size_t i, const size_t j); + +unsigned short gsl_vector_ushort_max (const gsl_vector_ushort * v); +unsigned short gsl_vector_ushort_min (const gsl_vector_ushort * v); +void gsl_vector_ushort_minmax (const gsl_vector_ushort * v, unsigned short * min_out, unsigned short * max_out); + +size_t gsl_vector_ushort_max_index (const gsl_vector_ushort * v); +size_t gsl_vector_ushort_min_index (const gsl_vector_ushort * v); +void gsl_vector_ushort_minmax_index (const gsl_vector_ushort * v, size_t * imin, size_t * imax); + +int gsl_vector_ushort_add (gsl_vector_ushort * a, const gsl_vector_ushort * b); +int gsl_vector_ushort_sub (gsl_vector_ushort * a, const gsl_vector_ushort * b); +int gsl_vector_ushort_mul (gsl_vector_ushort * a, const gsl_vector_ushort * b); +int gsl_vector_ushort_div (gsl_vector_ushort * a, const gsl_vector_ushort * b); +int gsl_vector_ushort_scale (gsl_vector_ushort * a, const double x); +int gsl_vector_ushort_add_constant (gsl_vector_ushort * a, const double x); + +int gsl_vector_ushort_isnull (const gsl_vector_ushort * v); +int gsl_vector_ushort_ispos (const gsl_vector_ushort * v); +int gsl_vector_ushort_isneg (const gsl_vector_ushort * v); + +#ifdef HAVE_INLINE + +extern inline +unsigned short +gsl_vector_ushort_get (const gsl_vector_ushort * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); + } +#endif + return v->data[i * v->stride]; +} + +extern inline +void +gsl_vector_ushort_set (gsl_vector_ushort * v, const size_t i, unsigned short x) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } +#endif + v->data[i * v->stride] = x; +} + +extern inline +unsigned short * +gsl_vector_ushort_ptr (gsl_vector_ushort * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (unsigned short *) (v->data + i * v->stride); +} + +extern inline +const unsigned short * +gsl_vector_ushort_const_ptr (const gsl_vector_ushort * v, const size_t i) +{ +#if GSL_RANGE_CHECK + if (i >= v->size) + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } +#endif + return (const unsigned short *) (v->data + i * v->stride); +} + + +#endif /* HAVE_INLINE */ + +__END_DECLS + +#endif /* __GSL_VECTOR_USHORT_H__ */ + + diff --git a/gsl-1.9/vector/init.c b/gsl-1.9/vector/init.c new file mode 100644 index 0000000..5f3b000 --- /dev/null +++ b/gsl-1.9/vector/init.c @@ -0,0 +1,87 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_vector.h> + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "init_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/init_source.c b/gsl-1.9/vector/init_source.c new file mode 100644 index 0000000..b3dca82 --- /dev/null +++ b/gsl-1.9/vector/init_source.c @@ -0,0 +1,228 @@ +/* vector/init_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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. + */ + +TYPE (gsl_vector) * +FUNCTION (gsl_vector, alloc) (const size_t n) +{ + TYPE (gsl_block) * block; + TYPE (gsl_vector) * v; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, 0); + } + + v = (TYPE (gsl_vector) *) malloc (sizeof (TYPE (gsl_vector))); + + if (v == 0) + { + GSL_ERROR_VAL ("failed to allocate space for vector struct", + GSL_ENOMEM, 0); + } + + block = FUNCTION (gsl_block,alloc) (n); + + if (block == 0) + { + free (v) ; + + GSL_ERROR_VAL ("failed to allocate space for block", + GSL_ENOMEM, 0); + } + + v->data = block->data ; + v->size = n; + v->stride = 1; + v->block = block; + v->owner = 1; + + return v; +} + +TYPE (gsl_vector) * +FUNCTION (gsl_vector, calloc) (const size_t n) +{ + size_t i; + + TYPE (gsl_vector) * v = FUNCTION (gsl_vector, alloc) (n); + + if (v == 0) + return 0; + + /* initialize vector to zero */ + + for (i = 0; i < MULTIPLICITY * n; i++) + { + v->data[i] = 0; + } + + return v; +} + +TYPE (gsl_vector) * +FUNCTION (gsl_vector, alloc_from_block) (TYPE(gsl_block) * block, + const size_t offset, + const size_t n, + const size_t stride) +{ + TYPE (gsl_vector) * v; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, 0); + } + + if (stride == 0) + { + GSL_ERROR_VAL ("stride must be positive integer", GSL_EINVAL, 0); + } + + if (block->size <= offset + (n - 1) * stride) + { + GSL_ERROR_VAL ("vector would extend past end of block", GSL_EINVAL, 0); + } + + v = (TYPE (gsl_vector) *) malloc (sizeof (TYPE (gsl_vector))); + + if (v == 0) + { + GSL_ERROR_VAL ("failed to allocate space for vector struct", + GSL_ENOMEM, 0); + } + + v->data = block->data + MULTIPLICITY * offset ; + v->size = n; + v->stride = stride; + v->block = block; + v->owner = 0; + + return v; +} + +TYPE (gsl_vector) * +FUNCTION (gsl_vector, alloc_from_vector) (TYPE(gsl_vector) * w, + const size_t offset, + const size_t n, + const size_t stride) +{ + TYPE (gsl_vector) * v; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, 0); + } + + if (stride == 0) + { + GSL_ERROR_VAL ("stride must be positive integer", GSL_EINVAL, 0); + } + + if (offset + (n - 1) * stride >= w->size) + { + GSL_ERROR_VAL ("vector would extend past end of block", GSL_EINVAL, 0); + } + + v = (TYPE (gsl_vector) *) malloc (sizeof (TYPE (gsl_vector))); + + if (v == 0) + { + GSL_ERROR_VAL ("failed to allocate space for vector struct", + GSL_ENOMEM, 0); + } + + v->data = w->data + MULTIPLICITY * w->stride * offset ; + v->size = n; + v->stride = stride * w->stride; + v->block = w->block; + v->owner = 0; + + return v; +} + + +void +FUNCTION (gsl_vector, free) (TYPE (gsl_vector) * v) +{ + if (v->owner) + { + FUNCTION(gsl_block, free) (v->block) ; + } + free (v); +} + + +void +FUNCTION (gsl_vector, set_all) (TYPE (gsl_vector) * v, BASE x) +{ + ATOMIC * const data = v->data; + const size_t n = v->size; + const size_t stride = v->stride; + + size_t i; + + for (i = 0; i < n; i++) + { + *(BASE *) (data + MULTIPLICITY * i * stride) = x; + } +} + +void +FUNCTION (gsl_vector, set_zero) (TYPE (gsl_vector) * v) +{ + ATOMIC * const data = v->data; + const size_t n = v->size; + const size_t stride = v->stride; + const BASE zero = ZERO ; + + size_t i; + + for (i = 0; i < n; i++) + { + *(BASE *) (data + MULTIPLICITY * i * stride) = zero; + } +} + +int +FUNCTION (gsl_vector, set_basis) (TYPE (gsl_vector) * v, size_t i) +{ + ATOMIC * const data = v->data; + const size_t n = v->size; + const size_t stride = v->stride; + const BASE zero = ZERO ; + const BASE one = ONE; + + size_t k; + + if (i >= n) + { + GSL_ERROR ("index out of range", GSL_EINVAL); + } + + for (k = 0; k < n; k++) + { + *(BASE *) (data + MULTIPLICITY * k * stride) = zero; + } + + *(BASE *) (data + MULTIPLICITY * i * stride) = one; + + return GSL_SUCCESS; +} diff --git a/gsl-1.9/vector/minmax.c b/gsl-1.9/vector/minmax.c new file mode 100644 index 0000000..27ee8db --- /dev/null +++ b/gsl-1.9/vector/minmax.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_math.h> +#include <gsl/gsl_vector.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/vector/minmax_source.c b/gsl-1.9/vector/minmax_source.c new file mode 100644 index 0000000..4fbd86e --- /dev/null +++ b/gsl-1.9/vector/minmax_source.c @@ -0,0 +1,217 @@ +/* vector/minmax_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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. + */ + +BASE +FUNCTION(gsl_vector,max) (const TYPE(gsl_vector) * v) +{ + /* finds the largest element of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + BASE max = v->data[0 * stride]; + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x > max) + max = x; +#ifdef FP + if (isnan (x)) + return x; +#endif + } + + return max; +} + +BASE +FUNCTION(gsl_vector,min) (const TYPE(gsl_vector) * v) +{ + /* finds the smallest element of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + BASE min = v->data[0 * stride]; + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x < min) + min = x; +#ifdef FP + if (isnan (x)) + return x; +#endif + } + + return min; +} + +void +FUNCTION(gsl_vector,minmax) (const TYPE(gsl_vector) * v, + BASE * min_out, + BASE * max_out) +{ + /* finds the smallest and largest elements of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + BASE max = v->data[0 * stride]; + BASE min = v->data[0 * stride]; + + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x < min) + { + min = x; + } + if (x > max) + { + max = x; + } +#ifdef FP + if (isnan (x)) + { + min = x; + max = x; + break; + } +#endif + } + + *min_out = min; + *max_out = max; +} + + +size_t +FUNCTION(gsl_vector,max_index) (const TYPE(gsl_vector) * v) +{ + /* finds the largest element of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + BASE max = v->data[0 * stride]; + size_t imax = 0; + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x > max) + { + max = x; + imax = i; + } +#ifdef FP + if (isnan (x)) + { + return i; + } +#endif + } + + return imax; +} + +size_t +FUNCTION(gsl_vector,min_index) (const TYPE(gsl_vector) * v) +{ + /* finds the smallest element of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + BASE min = v->data[0 * stride]; + size_t imin = 0; + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x < min) + { + min = x; + imin = i; + } +#ifdef FP + if (isnan (x)) + { + return i; + } +#endif + } + + return imin; +} + + +void +FUNCTION(gsl_vector,minmax_index) (const TYPE(gsl_vector) * v, + size_t * imin_out, + size_t * imax_out) +{ + /* finds the smallest and largest elements of a vector */ + + const size_t N = v->size ; + const size_t stride = v->stride ; + + size_t imin = 0, imax = 0; + BASE max = v->data[0 * stride]; + BASE min = v->data[0 * stride]; + + size_t i; + + for (i = 0; i < N; i++) + { + BASE x = v->data[i*stride]; + if (x < min) + { + min = x; + imin = i; + } + if (x > max) + { + max = x; + imax = i; + } +#ifdef FP + if (isnan (x)) + { + imin = i; + imax = i; + break; + } +#endif + } + + *imin_out = imin; + *imax_out = imax; +} + + diff --git a/gsl-1.9/vector/oper.c b/gsl-1.9/vector/oper.c new file mode 100644 index 0000000..ded3922 --- /dev/null +++ b/gsl-1.9/vector/oper.c @@ -0,0 +1,71 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_vector.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "oper_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/vector/oper_source.c b/gsl-1.9/vector/oper_source.c new file mode 100644 index 0000000..e60bae3 --- /dev/null +++ b/gsl-1.9/vector/oper_source.c @@ -0,0 +1,150 @@ +/* vector/oper_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 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 +FUNCTION(gsl_vector, add) (TYPE(gsl_vector) * a, const TYPE(gsl_vector) * b) +{ + const size_t N = a->size; + + if (b->size != N) + { + GSL_ERROR ("vectors must have same length", GSL_EBADLEN); + } + else + { + const size_t stride_a = a->stride; + const size_t stride_b = b->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride_a] += b->data[i * stride_b]; + } + + return GSL_SUCCESS; + } +} + +int +FUNCTION(gsl_vector, sub) (TYPE(gsl_vector) * a, const TYPE(gsl_vector) * b) +{ + const size_t N = a->size; + + if (b->size != N) + { + GSL_ERROR ("vectors must have same length", GSL_EBADLEN); + } + else + { + const size_t stride_a = a->stride; + const size_t stride_b = b->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride_a] -= b->data[i * stride_b]; + } + + return GSL_SUCCESS; + } +} + +int +FUNCTION(gsl_vector, mul) (TYPE(gsl_vector) * a, const TYPE(gsl_vector) * b) +{ + const size_t N = a->size; + + if (b->size != N) + { + GSL_ERROR ("vectors must have same length", GSL_EBADLEN); + } + else + { + const size_t stride_a = a->stride; + const size_t stride_b = b->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride_a] *= b->data[i * stride_b]; + } + + return GSL_SUCCESS; + } +} + +int +FUNCTION(gsl_vector, div) (TYPE(gsl_vector) * a, const TYPE(gsl_vector) * b) +{ + const size_t N = a->size; + + if (b->size != N) + { + GSL_ERROR ("vectors must have same length", GSL_EBADLEN); + } + else + { + const size_t stride_a = a->stride; + const size_t stride_b = b->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride_a] /= b->data[i * stride_b]; + } + + return GSL_SUCCESS; + } +} + +int +FUNCTION(gsl_vector, scale) (TYPE(gsl_vector) * a, const double x) +{ + const size_t N = a->size; + const size_t stride = a->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride] *= x; + } + + return GSL_SUCCESS; +} + +int +FUNCTION(gsl_vector, add_constant) (TYPE(gsl_vector) * a, const double x) +{ + const size_t N = a->size; + const size_t stride = a->stride; + + size_t i; + + for (i = 0; i < N; i++) + { + a->data[i * stride] += x; + } + + return GSL_SUCCESS; +} diff --git a/gsl-1.9/vector/prop.c b/gsl-1.9/vector/prop.c new file mode 100644 index 0000000..eeb18d6 --- /dev/null +++ b/gsl-1.9/vector/prop.c @@ -0,0 +1,87 @@ +#include <config.h> +#include <gsl/gsl_vector.h> +#include <gsl/gsl_errno.h> + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "prop_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/prop_source.c b/gsl-1.9/vector/prop_source.c new file mode 100644 index 0000000..9f1cf2f --- /dev/null +++ b/gsl-1.9/vector/prop_source.c @@ -0,0 +1,91 @@ +/* vector/prop_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 +FUNCTION (gsl_vector, isnull) (const TYPE (gsl_vector) * v) +{ + const size_t n = v->size; + const size_t stride = v->stride ; + + size_t j; + + for (j = 0; j < n; j++) + { + size_t k; + + for (k = 0; k < MULTIPLICITY; k++) + { + if (v->data[MULTIPLICITY * stride * j + k] != 0.0) + { + return 0; + } + } + } + + return 1; +} + +int +FUNCTION (gsl_vector, ispos) (const TYPE (gsl_vector) * v) +{ + const size_t n = v->size; + const size_t stride = v->stride ; + + size_t j; + + for (j = 0; j < n; j++) + { + size_t k; + + for (k = 0; k < MULTIPLICITY; k++) + { + if (v->data[MULTIPLICITY * stride * j + k] <= 0.0) + { + return 0; + } + } + } + + return 1; +} + +int +FUNCTION (gsl_vector, isneg) (const TYPE (gsl_vector) * v) +{ + const size_t n = v->size; + const size_t stride = v->stride ; + + size_t j; + + for (j = 0; j < n; j++) + { + size_t k; + + for (k = 0; k < MULTIPLICITY; k++) + { + if (v->data[MULTIPLICITY * stride * j + k] >= 0.0) + { + return 0; + } + } + } + + return 1; +} + diff --git a/gsl-1.9/vector/reim.c b/gsl-1.9/vector/reim.c new file mode 100644 index 0000000..9271a1a --- /dev/null +++ b/gsl-1.9/vector/reim.c @@ -0,0 +1,44 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_vector.h> + +#include "view.h" + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define USE_QUALIFIER +#define QUALIFIER const + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "reim_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT diff --git a/gsl-1.9/vector/reim_source.c b/gsl-1.9/vector/reim_source.c new file mode 100644 index 0000000..452129e --- /dev/null +++ b/gsl-1.9/vector/reim_source.c @@ -0,0 +1,56 @@ +/* vector/reim_source.c + * + * Copyright (C) 2001 Brian Gough + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +QUALIFIED_REAL_VIEW(_gsl_vector, view) +FUNCTION(gsl_vector, real) (QUALIFIED_TYPE(gsl_vector) * v) +{ + REAL_TYPE(gsl_vector) s = NULL_VECTOR; + + s.data = v->data; + s.size = v->size; + s.stride = MULTIPLICITY * v->stride; + s.block = 0; /* FIXME: should be v->block, but cannot point to + block of different type */ + s.owner = 0; + + { + QUALIFIED_REAL_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + view.vector = s; + return view; + } +} + +QUALIFIED_REAL_VIEW(_gsl_vector, view) +FUNCTION(gsl_vector, imag) (QUALIFIED_TYPE(gsl_vector) * v) +{ + REAL_TYPE(gsl_vector) s = NULL_VECTOR; + + s.data = v->data + 1; + s.size = v->size; + s.stride = MULTIPLICITY * v->stride; + s.block = 0; /* FIXME: cannot point to block of different type */ + s.owner = 0; + + { + QUALIFIED_REAL_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + view.vector = s; + return view; + } +} + diff --git a/gsl-1.9/vector/subvector.c b/gsl-1.9/vector/subvector.c new file mode 100644 index 0000000..5f6b83e --- /dev/null +++ b/gsl-1.9/vector/subvector.c @@ -0,0 +1,176 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_vector.h> + +#include "view.h" + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_CHAR + +#define USE_QUALIFIER +#define QUALIFIER const + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "subvector_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/subvector_source.c b/gsl-1.9/vector/subvector_source.c new file mode 100644 index 0000000..c7137ac --- /dev/null +++ b/gsl-1.9/vector/subvector_source.c @@ -0,0 +1,86 @@ +/* vector/subvector_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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. + */ + +QUALIFIED_VIEW(_gsl_vector, view) +FUNCTION(gsl_vector, subvector) (QUALIFIED_TYPE(gsl_vector) * v, size_t offset, size_t n) +{ + QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, view); + } + + if (offset + (n - 1) >= v->size) + { + GSL_ERROR_VAL ("view would extend past end of vector", + GSL_EINVAL, view); + } + + { + TYPE(gsl_vector) s = NULL_VECTOR; + + s.data = v->data + MULTIPLICITY * v->stride * offset ; + s.size = n; + s.stride = v->stride; + s.block = v->block; + s.owner = 0; + + view.vector = s; + return view; + } +} + +QUALIFIED_VIEW(_gsl_vector, view) +FUNCTION(gsl_vector, subvector_with_stride) (QUALIFIED_TYPE(gsl_vector) * v, size_t offset, size_t stride, size_t n) +{ + QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, view); + } + + if (stride == 0) + { + GSL_ERROR_VAL ("stride must be positive integer", + GSL_EINVAL, view); + } + + if (offset + (n - 1) * stride >= v->size) + { + GSL_ERROR_VAL ("view would extend past end of vector", + GSL_EINVAL, view); + } + + { + TYPE(gsl_vector) s = NULL_VECTOR; + + s.data = v->data + MULTIPLICITY * v->stride * offset ; + s.size = n; + s.stride = v->stride * stride; + s.block = v->block; + s.owner = 0; + + view.vector = s; + return view; + } +} diff --git a/gsl-1.9/vector/swap.c b/gsl-1.9/vector/swap.c new file mode 100644 index 0000000..226e983 --- /dev/null +++ b/gsl-1.9/vector/swap.c @@ -0,0 +1,87 @@ +#include <config.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_vector.h> + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "swap_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/swap_source.c b/gsl-1.9/vector/swap_source.c new file mode 100644 index 0000000..816cb6e --- /dev/null +++ b/gsl-1.9/vector/swap_source.c @@ -0,0 +1,107 @@ +/* vector/swap_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 +FUNCTION (gsl_vector, swap) (TYPE (gsl_vector) * v, TYPE (gsl_vector) * w) +{ + ATOMIC * d1 = v->data ; + ATOMIC * d2 = w->data ; + const size_t size = v->size ; + const size_t s1 = MULTIPLICITY * v->stride ; + const size_t s2 = MULTIPLICITY * w->stride ; + size_t i, k ; + + if (v->size != w->size) + { + GSL_ERROR("vector lengths must be equal", GSL_EINVAL); + } + + for (i = 0; i < size; i++) + { + for (k = 0; k < MULTIPLICITY; k++) + { + ATOMIC tmp = d1[i*s1 + k]; + d1[i*s1+k] = d2[i*s2 + k]; + d2[i*s2+k] = tmp; + } + } + + return GSL_SUCCESS; +} + +int +FUNCTION (gsl_vector, swap_elements) (TYPE (gsl_vector) * v, const size_t i, const size_t j) +{ + ATOMIC * data = v->data ; + const size_t size = v->size ; + const size_t stride = v->stride ; + + if (i >= size) + { + GSL_ERROR("first index is out of range", GSL_EINVAL); + } + + if (j >= size) + { + GSL_ERROR("second index is out of range", GSL_EINVAL); + } + + if (i != j) + { + const size_t s = MULTIPLICITY * stride ; + size_t k ; + + for (k = 0; k < MULTIPLICITY; k++) + { + ATOMIC tmp = data[j*s + k]; + data[j*s+k] = data[i*s + k]; + data[i*s+k] = tmp; + } + } + + return GSL_SUCCESS; +} + +int +FUNCTION (gsl_vector, reverse) (TYPE (gsl_vector) * v) +{ + ATOMIC * data = v->data ; + const size_t size = v->size ; + const size_t stride = v->stride ; + + const size_t s = MULTIPLICITY * stride ; + + size_t i ; + + for (i = 0 ; i < (size / 2) ; i++) + { + size_t j = size - i - 1 ; + size_t k; + + for (k = 0; k < MULTIPLICITY; k++) + { + ATOMIC tmp = data[j*s + k]; + data[j*s+k] = data[i*s + k]; + data[i*s+k] = tmp; + } + } + + return GSL_SUCCESS; +} + diff --git a/gsl-1.9/vector/test.c b/gsl-1.9/vector/test.c new file mode 100644 index 0000000..453116a --- /dev/null +++ b/gsl-1.9/vector/test.c @@ -0,0 +1,243 @@ +/* vector/test.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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> + +#if (!GSL_RANGE_CHECK) && HAVE_INLINE +#undef GSL_RANGE_CHECK +#define GSL_RANGE_CHECK 1 +#endif + +#include <stdlib.h> +#include <fcntl.h> +#include <stdio.h> +#include <gsl/gsl_math.h> +#include <gsl/gsl_vector.h> +#include <gsl/gsl_test.h> +#include <gsl/gsl_ieee_utils.h> + +int status = 0; + +#ifndef DESC +#define DESC "" +#endif + + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "test_complex_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "test_complex_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "test_complex_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#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 + +void my_error_handler (const char *reason, const char *file, + int line, int err); + +int +main (void) +{ + size_t stride, ostride, N; + + gsl_ieee_env_setup (); + + for (N = 10; N < 1024; N = 2*N + 1) + { + for (stride = 1; stride < 5 ; stride++) + { + test_func (stride, N); + test_float_func (stride, N); + test_long_double_func (stride, N); + test_ulong_func (stride, N); + test_long_func (stride, N); + test_uint_func (stride, N); + test_int_func (stride, N); + test_ushort_func (stride, N); + test_short_func (stride, N); + test_uchar_func (stride, N); + test_char_func (stride, N); + + test_complex_func (stride, N); + test_complex_float_func (stride, N); + test_complex_long_double_func (stride, N); + + for (ostride = 1; ostride < 5 ; ostride++) + { + test_ops (stride, ostride, N); + test_float_ops (stride, ostride, N); + test_long_double_ops (stride, ostride, N); + test_ulong_ops (stride, ostride, N); + test_long_ops (stride, ostride, N); + test_uint_ops (stride, ostride, N); + test_int_ops (stride, ostride, N); + test_ushort_ops (stride, ostride, N); + test_short_ops (stride, ostride, N); + test_uchar_ops (stride, ostride, N); + test_char_ops (stride, ostride, N); + } + + test_text (stride, N); + test_float_text (stride, N); +#if HAVE_PRINTF_LONGDOUBLE + test_long_double_text (stride, N); +#endif + test_ulong_text (stride, N); + test_long_text (stride, N); + test_uint_text (stride, N); + test_int_text (stride, N); + test_ushort_text (stride, N); + test_short_text (stride, N); + test_uchar_text (stride, N); + test_char_text (stride, N); + + test_complex_text (stride, N); + test_complex_float_text (stride, N); +#if HAVE_PRINTF_LONGDOUBLE + test_complex_long_double_text (stride, N); +#endif + + test_file (stride, N); + test_float_file (stride, N); + test_long_double_file (stride, N); + test_ulong_file (stride, N); + test_long_file (stride, N); + test_uint_file (stride, N); + test_int_file (stride, N); + test_ushort_file (stride, N); + test_short_file (stride, N); + test_uchar_file (stride, N); + test_char_file (stride, N); + test_complex_file (stride, N); + test_complex_float_file (stride, N); + test_complex_long_double_file (stride, N); + } + } + +#if GSL_RANGE_CHECK + gsl_set_error_handler (&my_error_handler); + + for (N = 1; N < 1024; N *=2) + { + for (stride = 1; stride < 5 ; stride++) + { + test_trap (stride, N); + test_float_trap (stride, N); + test_long_double_trap (stride, N); + test_ulong_trap (stride, N); + test_long_trap (stride, N); + test_uint_trap (stride, N); + test_int_trap (stride, N); + test_ushort_trap (stride, N); + test_short_trap (stride, N); + test_uchar_trap (stride, N); + test_char_trap (stride, N); + test_complex_trap (stride, N); + test_complex_float_trap (stride, N); + test_complex_long_double_trap (stride, N); + } + } +#endif + + exit (gsl_test_summary ()); +} + +void +my_error_handler (const char *reason, const char *file, int line, int err) +{ + if (0) + printf ("(caught [%s:%d: %s (%d)])\n", file, line, reason, err); + status = 1; +} diff --git a/gsl-1.9/vector/test_complex_source.c b/gsl-1.9/vector/test_complex_source.c new file mode 100644 index 0000000..d2b6398 --- /dev/null +++ b/gsl-1.9/vector/test_complex_source.c @@ -0,0 +1,579 @@ +/* vector/test_complex_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 FUNCTION (test, func) (size_t stride, size_t N); +void FUNCTION (test, ops) (size_t stride1, size_t stride2, size_t N); +void FUNCTION (test, file) (size_t stride, size_t N); +void FUNCTION (test, text) (size_t stride, size_t N); +void FUNCTION (test, trap) (size_t stride, size_t N); +TYPE (gsl_vector) * FUNCTION(create, vector) (size_t stride, size_t N); + +#define TEST(expr,desc) gsl_test((expr), NAME(gsl_vector) desc " stride=%d, N=%d", stride, N) +#define TEST2(expr,desc) gsl_test((expr), NAME(gsl_vector) desc " stride1=%d, stride2=%d, N=%d", stride1, stride2, N) + +TYPE (gsl_vector) * +FUNCTION(create, vector) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (gsl_vector, calloc) (N*stride); + v->stride = stride; + v->size = N; + return v; +} + +void +FUNCTION (test, func) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v0; + TYPE (gsl_vector) * v; + QUALIFIED_VIEW(gsl_vector,view) view; + + size_t i, j; + + if (stride == 1) + { + v = FUNCTION (gsl_vector, calloc) (N); + + TEST(v->data == 0, "_calloc pointer"); + TEST(v->size != N, "_calloc size"); + TEST(v->stride != 1, "_calloc stride"); + + { + int status = (FUNCTION(gsl_vector,isnull)(v) != 1); + TEST (status, "_isnull" DESC " on calloc vector"); + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on calloc vector"); + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on calloc vector"); + } + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ + } + + if (stride == 1) + { + v = FUNCTION (gsl_vector, alloc) (N); + + TEST(v->data == 0, "_alloc pointer"); + TEST(v->size != N, "_alloc size"); + TEST(v->stride != 1, "_alloc stride"); + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ + } + + if (stride == 1) + { + v0 = FUNCTION (gsl_vector, alloc) (N); + view = FUNCTION (gsl_vector, subvector) (v0, 0, N); + v = &view.vector; + } + else + { + v0 = FUNCTION (gsl_vector, alloc) (N * stride); + + for (i = 0; i < N*stride; i++) + { + BASE x = ZERO; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1234); + FUNCTION (gsl_vector, set) (v0, i, x); + } + + view = FUNCTION (gsl_vector, subvector_with_stride) (v0, 0, stride, N); + v = &view.vector; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE x = ZERO; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1234); + FUNCTION (gsl_vector, set) (v, i, x); + } + + for (i = 0; i < N; i++) + { + if (v->data[2*i*stride] != (ATOMIC) (i) || v->data[2 * i * stride + 1] != (ATOMIC) (i + 1234)) + status = 1; + }; + + TEST(status,"_set" DESC " writes into array"); + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE x, y; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1234); + y = FUNCTION (gsl_vector, get) (v, i); + if (!GSL_COMPLEX_EQ (x, y)) + status = 1; + }; + + TEST (status, "_get" DESC " reads from array"); + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, ptr) (v, i) != (BASE *)v->data + i*stride) + status = 1; + }; + + TEST (status, "_ptr" DESC " access to array"); + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, const_ptr) (v, i) != (BASE *)v->data + i*stride) + status = 1; + }; + + TEST (status, "_const_ptr" DESC " access to array"); + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE x = ZERO; + FUNCTION (gsl_vector, set) (v, i, x); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 1); + TEST (status, "_isnull" DESC " on null vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on null vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on null vector") ; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE x = ZERO; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1234); + FUNCTION (gsl_vector, set) (v, i, x); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on non-null vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on non-null vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_isneg" DESC " on non-null vector") ; + } + + { + int status = 0; + + FUNCTION (gsl_vector, set_zero) (v); + + for (i = 0; i < N; i++) + { + BASE x, y = ZERO; + x = FUNCTION (gsl_vector, get) (v, i); + if (!GSL_COMPLEX_EQ (x, y)) + status = 1; + }; + + TEST (status, "_setzero" DESC " on non-null vector") ; + } + + { + int status = 0; + + BASE x; + GSL_REAL (x) = (ATOMIC)27; + GSL_IMAG (x) = (ATOMIC)(27 + 1234); + + FUNCTION (gsl_vector, set_all) (v, x); + + for (i = 0; i < N; i++) + { + BASE y = FUNCTION (gsl_vector, get) (v, i); + if (!GSL_COMPLEX_EQ (x, y)) + status = 1; + }; + + TEST (status, "_setall" DESC " to non-zero value") ; + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set_basis) (v, i); + + for (j = 0; j < N; j++) + { + BASE x = FUNCTION (gsl_vector, get) (v, j); + BASE one = ONE; + BASE zero = ZERO; + + if (i == j) + { + if (!GSL_COMPLEX_EQ (x, one)) + status = 1 ; + } + else + { + if (!GSL_COMPLEX_EQ (x, zero)) + status = 1; + } + }; + } + + TEST (status, "_setbasis" DESC " over range") ; + } + + for (i = 0; i < N; i++) + { + BASE x = ZERO; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1234); + FUNCTION (gsl_vector, set) (v, i, x); + } + + { + int status; + BASE x, y, r, s ; + GSL_REAL(x) = 2 ; + GSL_IMAG(x) = 2 + 1234; + GSL_REAL(y) = 5 ; + GSL_IMAG(y) = 5 + 1234; + + FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ; + + r = FUNCTION(gsl_vector,get)(v,2); + s = FUNCTION(gsl_vector,get)(v,5); + + status = ! GSL_COMPLEX_EQ(r,y) ; + status |= ! GSL_COMPLEX_EQ(s,x) ; + + FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ; + + r = FUNCTION(gsl_vector,get)(v,2); + s = FUNCTION(gsl_vector,get)(v,5); + + status |= ! GSL_COMPLEX_EQ(r,x) ; + status |= ! GSL_COMPLEX_EQ(s,y) ; + + TEST (status, "_swap_elements" DESC " exchanges elements") ; + } + + { + int status = 0; + + FUNCTION (gsl_vector,reverse) (v) ; + + for (i = 0; i < N; i++) + { + BASE x,r ; + GSL_REAL(x) = (ATOMIC)(N - i - 1) ; + GSL_IMAG(x) = (ATOMIC)(N - i - 1 + 1234); + + r = FUNCTION (gsl_vector, get) (v, i); + + status |= !GSL_COMPLEX_EQ(r,x); + } + + gsl_test (status, NAME(gsl_vector) "_reverse" DESC " reverses elements") ; + } + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array) (v->data, N*stride); + + for (i = 0; i < N; i++) + { + BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i*stride) ; + BASE y = FUNCTION (gsl_vector, get) (v, i); + if (!GSL_COMPLEX_EQ(x,y)) + status = 1; + }; + + TEST (status, "_view_array" DESC); + } + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array_with_stride) (v->data, stride, N*stride); + + for (i = 0; i < N; i++) + { + BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ; + BASE y = FUNCTION (gsl_vector, get) (v, i); + if (!GSL_COMPLEX_EQ(x,y)) + status = 1; + }; + + TEST (status, "_view_array_with_stride" DESC); + } + + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector) (v, N/3, N/2); + + for (i = 0; i < N/2; i++) + { + BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ; + BASE y = FUNCTION (gsl_vector, get) (v, (N/3)+i); + if (!GSL_COMPLEX_EQ(x,y)) + status = 1; + }; + + TEST (status, "_view_subvector" DESC); + } + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector_with_stride) (v, N/5, 3, N/4); + + for (i = 0; i < N/4; i++) + { + BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ; + BASE y = FUNCTION (gsl_vector, get) (v, (N/5)+3*i); + if (!GSL_COMPLEX_EQ(x,y)) + status = 1; + }; + + TEST (status, "_view_subvector_with_stride" DESC); + } + + + { + int status = 0; + + QUALIFIED_REAL_VIEW(gsl_vector,view) vv = FUNCTION(gsl_vector, real) (v); + + for (i = 0; i < N; i++) + { + ATOMIC xr = REAL_VIEW (gsl_vector, get) (&vv.vector, i) ; + BASE y = FUNCTION (gsl_vector, get) (v, i); + ATOMIC yr = GSL_REAL(y); + + if (xr != yr) + status = 1; + }; + + TEST (status, "_real" DESC); + } + + { + int status = 0; + + QUALIFIED_REAL_VIEW(gsl_vector,view) vv = FUNCTION(gsl_vector, imag) (v); + + for (i = 0; i < N; i++) + { + ATOMIC xr = REAL_VIEW (gsl_vector, get) (&vv.vector, i) ; + BASE y = FUNCTION (gsl_vector, get) (v, i); + ATOMIC yr = GSL_IMAG(y); + + if (xr != yr) + status = 1; + }; + + TEST (status, "_imag" DESC); + } + + + FUNCTION (gsl_vector, free) (v0); /* free whatever is in v */ +} + +void +FUNCTION (test, file) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride, N); + TYPE (gsl_vector) * w = FUNCTION (create, vector) (stride, N); + + size_t i; + + { + FILE *f = fopen ("test.dat", "wb"); + + for (i = 0; i < N; i++) + { + BASE x = ZERO; + GSL_REAL (x) = (ATOMIC)(N - i); + GSL_IMAG (x) = (ATOMIC)(N - i + 1); + FUNCTION (gsl_vector, set) (v, i, x); + }; + + FUNCTION (gsl_vector, fwrite) (f, v); + + fclose (f); + } + + { + FILE *f = fopen ("test.dat", "rb"); + + FUNCTION (gsl_vector, fread) (f, w); + + status = 0; + for (i = 0; i < N; i++) + { + if (w->data[2 * i * stride] != (ATOMIC) (N - i) || w->data[2 * i * stride + 1] != (ATOMIC) (N - i + 1)) + status = 1; + }; + fclose (f); + } + + FUNCTION (gsl_vector, free) (v); + FUNCTION (gsl_vector, free) (w); + + gsl_test (status, NAME (gsl_vector) "_write and read work"); + +} + +#if USES_LONGDOUBLE && ! HAVE_PRINTF_LONGDOUBLE +/* skip this test */ +#else +void +FUNCTION (test, text) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride, N); + TYPE (gsl_vector) * w = FUNCTION (create, vector) (stride, N); + + size_t i; + + { + FILE *f = fopen ("test.txt", "w"); + + for (i = 0; i < N; i++) + { + BASE x; + GSL_REAL (x) = (ATOMIC)i; + GSL_IMAG (x) = (ATOMIC)(i + 1); + FUNCTION (gsl_vector, set) (v, i, x); + }; + + FUNCTION (gsl_vector, fprintf) (f, v, OUT_FORMAT); + + fclose (f); + } + + { + FILE *f = fopen ("test.txt", "r"); + + FUNCTION (gsl_vector, fscanf) (f, w); + + status = 0; + for (i = 0; i < N; i++) + { + if (w->data[2 * i * stride] != (ATOMIC) i || w->data[2 * i * stride + 1] != (ATOMIC) (i + 1)) + status = 1; + }; + fclose (f); + } + + FUNCTION (gsl_vector, free) (v); + FUNCTION (gsl_vector, free) (w); + + gsl_test (status, NAME (gsl_vector) "_fprintf and fscanf"); +} +#endif + +void +FUNCTION (test, trap) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * vc = FUNCTION (create, vector) (stride, N); + + BASE z = {{(ATOMIC)1.2, (ATOMIC)3.4}}; + BASE z1 = {{(ATOMIC)4.5, (ATOMIC)6.7}}; + + size_t j = 0; + + status = 0; + FUNCTION (gsl_vector, set) (vc, j - 1, z); + gsl_test (!status, + NAME (gsl_vector) "_set traps index below lower bound"); + + status = 0; + FUNCTION (gsl_vector, set) (vc, N + 1, z); + gsl_test (!status, + NAME (gsl_vector) "_set traps index above upper bound"); + + status = 0; + FUNCTION (gsl_vector, set) (vc, N, z); + gsl_test (!status, NAME (gsl_vector) "_set traps index at upper bound"); + + status = 0; + z1 = FUNCTION (gsl_vector, get) (vc, j - 1); + gsl_test (!status, + NAME (gsl_vector) "_get traps index below lower bound"); + + gsl_test (GSL_REAL (z1) != 0, + NAME (gsl_vector) "_get returns zero real below lower bound"); + gsl_test (GSL_IMAG (z1) != 0, + NAME (gsl_vector) "_get returns zero imag below lower bound"); + + status = 0; + z1 = FUNCTION (gsl_vector, get) (vc, N + 1); + gsl_test (!status, + NAME (gsl_vector) "_get traps index above upper bound"); + gsl_test (GSL_REAL (z1) != 0, + NAME (gsl_vector) "_get returns zero real above upper bound"); + gsl_test (GSL_IMAG (z1) != 0, + NAME (gsl_vector) "_get returns zero imag above upper bound"); + + status = 0; + z1 = FUNCTION (gsl_vector, get) (vc, N); + gsl_test (!status, NAME (gsl_vector) "_get traps index at upper bound"); + gsl_test (GSL_REAL (z1) != 0, + NAME (gsl_vector) "_get returns zero real at upper bound"); + gsl_test (GSL_IMAG (z1) != 0, + NAME (gsl_vector) "_get returns zero imag at upper bound"); + + FUNCTION (gsl_vector, free) (vc); +} + + + + diff --git a/gsl-1.9/vector/test_source.c b/gsl-1.9/vector/test_source.c new file mode 100644 index 0000000..03fac79 --- /dev/null +++ b/gsl-1.9/vector/test_source.c @@ -0,0 +1,808 @@ +/* vector/test_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 FUNCTION (test, func) (size_t stride, size_t N); +void FUNCTION (test, ops) (size_t stride1, size_t stride2, size_t N); +void FUNCTION (test, file) (size_t stride, size_t N); +void FUNCTION (test, text) (size_t stride, size_t N); +void FUNCTION (test, trap) (size_t stride, size_t N); +TYPE (gsl_vector) * FUNCTION(create, vector) (size_t stride, size_t N); + +#define TEST(expr,desc) gsl_test((expr), NAME(gsl_vector) desc " stride=%d, N=%d", stride, N) +#define TEST2(expr,desc) gsl_test((expr), NAME(gsl_vector) desc " stride1=%d, stride2=%d, N=%d", stride1, stride2, N) + +TYPE (gsl_vector) * +FUNCTION(create, vector) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (gsl_vector, calloc) (N*stride); + v->stride = stride; + v->size = N; + return v; +} + +void +FUNCTION (test, func) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v0; + TYPE (gsl_vector) * v; + QUALIFIED_VIEW(gsl_vector,view) view; + + size_t i, j; + + if (stride == 1) + { + v = FUNCTION (gsl_vector, calloc) (N); + + TEST(v->data == 0, "_calloc pointer"); + TEST(v->size != N, "_calloc size"); + TEST(v->stride != 1, "_calloc stride"); + + { + int status = (FUNCTION(gsl_vector,isnull)(v) != 1); + TEST (status, "_isnull" DESC " on calloc vector"); + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on calloc vector"); + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on calloc vector"); + } + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ + } + + if (stride == 1) + { + v = FUNCTION (gsl_vector, alloc) (N); + + TEST(v->data == 0, "_alloc pointer"); + TEST(v->size != N, "_alloc size"); + TEST(v->stride != 1, "_alloc stride"); + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ + } + + if (stride == 1) + { + v0 = FUNCTION (gsl_vector, alloc) (N); + view = FUNCTION (gsl_vector, subvector) (v0, 0, N); + v = &view.vector; + } + else + { + v0 = FUNCTION (gsl_vector, alloc) (N * stride); + + for (i = 0; i < N*stride; i++) + { + v0->data[i] = i; + } + + view = FUNCTION (gsl_vector, subvector_with_stride) (v0, 0, stride, N); + v = &view.vector; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) i); + } + + for (i = 0; i < N; i++) + { + if (v->data[i*stride] != (ATOMIC) (i)) + status = 1; + }; + + TEST(status,"_set" DESC " writes into array"); + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC) (i)) + status = 1; + }; + + TEST (status, "_get" DESC " reads from array"); + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, ptr) (v, i) != v->data + i*stride) + status = 1; + }; + + TEST (status, "_ptr" DESC " access to array"); + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, const_ptr) (v, i) != v->data + i*stride) + status = 1; + }; + + TEST (status, "_const_ptr" DESC " access to array"); + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) 0); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 1); + TEST (status, "_isnull" DESC " on null vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on null vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on null vector") ; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) (i % 10)); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on non-negative vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on non-negative vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on non-negative vector") ; + } + + +#ifndef UNSIGNED + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) ((i % 10) - 5)); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on mixed vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on mixed vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on mixed vector") ; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, -(ATOMIC) (i % 10)); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on non-positive vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on non-positive vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on non-positive non-null vector") ; + } +#endif + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) (i % 10 + 1)); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on positive vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 1); + TEST (status, "_ispos" DESC " on positive vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 0); + TEST (status, "_isneg" DESC " on positive vector") ; + } + + +#if (!defined(UNSIGNED) && !defined(BASE_CHAR)) + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, -(ATOMIC) (i % 10 + 1)); + } + + status = (FUNCTION(gsl_vector,isnull)(v) != 0); + TEST (status, "_isnull" DESC " on negative vector") ; + + status = (FUNCTION(gsl_vector,ispos)(v) != 0); + TEST (status, "_ispos" DESC " on negative vector") ; + + status = (FUNCTION(gsl_vector,isneg)(v) != 1); + TEST (status, "_isneg" DESC " on negative vector") ; + } +#endif + + { + int status = 0; + + FUNCTION (gsl_vector, set_zero) (v); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC)0) + status = 1; + }; + + TEST (status, "_setzero" DESC " on non-null vector") ; + } + + { + int status = 0; + + FUNCTION (gsl_vector, set_all) (v, (ATOMIC)27); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC) (27)) + status = 1; + }; + + TEST (status, "_setall" DESC " to non-zero value") ; + } + + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set_basis) (v, i); + + for (j = 0; j < N; j++) + { + if (i == j) + { + if (FUNCTION (gsl_vector, get) (v, j) != (ATOMIC)1) + status = 1 ; + } + else + { + if (FUNCTION (gsl_vector, get) (v, j) != (ATOMIC)(0)) + status = 1; + } + }; + } + + TEST (status, "_setbasis" DESC " over range") ; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) i); + } + + FUNCTION (gsl_vector, scale) (v, 2.0); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC) (i*2.0)) + status = 1; + }; + + TEST (status, "_scale" DESC " by 2") ; + } + + { + int status = 0; + + FUNCTION (gsl_vector, add_constant) (v, (ATOMIC)7); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC) (i*2.0 + 7)) + status = 1; + }; + + TEST (status, "_add_constant" DESC) ; + } + + { + int status = 0; + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) i); + } + + FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ; + + status = (FUNCTION(gsl_vector,get)(v,2) != 5) ; + status |= (FUNCTION(gsl_vector,get)(v,5) != 2) ; + + FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ; + + status |= (FUNCTION(gsl_vector,get)(v,2) != 2) ; + status |= (FUNCTION(gsl_vector,get)(v,5) != 5) ; + + TEST (status, "_swap_elements" DESC " (2,5)") ; + } + + { + int status = 0; + + FUNCTION (gsl_vector,reverse) (v) ; + + for (i = 0; i < N; i++) + { + status |= (FUNCTION (gsl_vector, get) (v, i) != (ATOMIC) (N - i - 1)); + } + + TEST (status, "_reverse" DESC " reverses elements") ; + } + + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array) (v->data, N*stride); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (&v1.vector, i*stride) != FUNCTION (gsl_vector, get) (v, i)) + status = 1; + }; + + TEST (status, "_view_array" DESC); + } + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array_with_stride) (v->data, stride, N*stride); + + for (i = 0; i < N; i++) + { + if (FUNCTION (gsl_vector, get) (&v1.vector, i) != FUNCTION (gsl_vector, get) (v, i)) + status = 1; + }; + + TEST (status, "_view_array_with_stride" DESC); + } + + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector) (v, N/3, N/2); + + for (i = 0; i < N/2; i++) + { + if (FUNCTION (gsl_vector, get) (&v1.vector, i) != FUNCTION (gsl_vector, get) (v, (N/3) + i)) + status = 1; + }; + + TEST (status, "_view_subvector" DESC); + } + + { + int status = 0; + + QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector_with_stride) (v, N/5, 3, N/4); + + for (i = 0; i < N/4; i++) + { + if (FUNCTION (gsl_vector, get) (&v1.vector, i) != FUNCTION (gsl_vector, get) (v, (N/5) + 3*i)) + status = 1; + }; + + TEST (status, "_view_subvector_with_stride" DESC); + } + + + { + BASE exp_max = FUNCTION(gsl_vector,get)(v, 0); + BASE exp_min = FUNCTION(gsl_vector,get)(v, 0); + size_t exp_imax = 0, exp_imin = 0; + + for (i = 0; i < N; i++) + { + BASE k = FUNCTION(gsl_vector, get) (v, i) ; + if (k < exp_min) { + exp_min = FUNCTION(gsl_vector, get) (v, i); + exp_imin = i; + } + } + + for (i = 0; i < N; i++) + { + BASE k = FUNCTION(gsl_vector, get) (v, i) ; + if (k > exp_max) { + exp_max = FUNCTION(gsl_vector, get) (v, i) ; + exp_imax = i; + } + } + + { + BASE max = FUNCTION(gsl_vector, max) (v) ; + TEST (max != exp_max, "_max returns correct maximum value"); + } + + { + BASE min = FUNCTION(gsl_vector, min) (v) ; + TEST (min != exp_min, "_min returns correct minimum value"); + } + + { + BASE min, max; + FUNCTION(gsl_vector, minmax) (v, &min, &max); + + TEST (max != exp_max, "_minmax returns correct maximum value"); + TEST (min != exp_min, "_minmax returns correct minimum value"); + } + + + { + size_t imax = FUNCTION(gsl_vector, max_index) (v) ; + TEST (imax != exp_imax, "_max_index returns correct maximum i"); + } + + { + size_t imin = FUNCTION(gsl_vector, min_index) (v) ; + TEST (imin != exp_imin, "_min_index returns correct minimum i"); + } + + { + size_t imin, imax; + + FUNCTION(gsl_vector, minmax_index) (v, &imin, &imax); + + TEST (imax != exp_imax, "_minmax_index returns correct maximum i"); + TEST (imin != exp_imin, "_minmax_index returns correct minimum i"); + } + +#if FP + i = N/2; + FUNCTION(gsl_vector, set) (v, i, GSL_NAN); + exp_max = GSL_NAN; exp_min = GSL_NAN; + exp_imax = i; exp_imin = i; + + { + BASE max = FUNCTION(gsl_vector, max) (v) ; + gsl_test_abs (max, exp_max, 0, "_max returns correct maximum value for NaN"); + } + + { + BASE min = FUNCTION(gsl_vector, min) (v) ; + gsl_test_abs (min, exp_min, 0, "_min returns correct minimum value for NaN"); + } + + { + BASE min, max; + FUNCTION(gsl_vector, minmax) (v, &min, &max); + + gsl_test_abs (max, exp_max, 0, "_minmax returns correct maximum value for NaN"); + gsl_test_abs (min, exp_min, 0, "_minmax returns correct minimum value for NaN"); + } + + + { + size_t imax = FUNCTION(gsl_vector, max_index) (v) ; + TEST (imax != exp_imax, "_max_index returns correct maximum i for NaN"); + } + + { + size_t imin = FUNCTION(gsl_vector, min_index) (v) ; + TEST (imin != exp_imin, "_min_index returns correct minimum i for NaN"); + } + + { + size_t imin, imax; + + FUNCTION(gsl_vector, minmax_index) (v, &imin, &imax); + + TEST (imax != exp_imax, "_minmax_index returns correct maximum i for NaN"); + TEST (imin != exp_imin, "_minmax_index returns correct minimum i for NaN"); + } +#endif + + } + + + FUNCTION (gsl_vector, free) (v0); /* free whatever is in v */ +} + +void +FUNCTION (test, ops) (size_t stride1, size_t stride2, size_t N) +{ + size_t i; + TYPE (gsl_vector) * a = FUNCTION (create, vector) (stride1, N); + TYPE (gsl_vector) * b = FUNCTION (create, vector) (stride2, N); + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride1, N); + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (a, i, (BASE)(3 + i)); + FUNCTION (gsl_vector, set) (b, i, (BASE)(3 + 2 * i)); + } + + FUNCTION(gsl_vector, memcpy) (v, a); + FUNCTION(gsl_vector, add) (v, b); + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE r = FUNCTION(gsl_vector,get) (v,i); + BASE x = FUNCTION(gsl_vector,get) (a,i); + BASE y = FUNCTION(gsl_vector,get) (b,i); + BASE z = x + y; + if (r != z) + status = 1; + } + TEST2 (status, "_add vector addition"); + } + + { + int status = 0; + + FUNCTION(gsl_vector, swap) (a, b); + + for (i = 0; i < N; i++) + { + status |= (FUNCTION (gsl_vector, get) (a, i) != (BASE)(3 + 2 * i)); + status |= (FUNCTION (gsl_vector, get) (b, i) != (BASE)(3 + i)); + } + + FUNCTION(gsl_vector, swap) (a, b); + + for (i = 0; i < N; i++) + { + status |= (FUNCTION (gsl_vector, get) (a, i) != (BASE)(3 + i)); + status |= (FUNCTION (gsl_vector, get) (b, i) != (BASE)(3 + 2 * i)); + } + + TEST2 (status, "_swap exchange vectors"); + } + + FUNCTION(gsl_vector, memcpy) (v, a); + FUNCTION(gsl_vector, sub) (v, b); + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE r = FUNCTION(gsl_vector,get) (v,i); + BASE x = FUNCTION(gsl_vector,get) (a,i); + BASE y = FUNCTION(gsl_vector,get) (b,i); + BASE z = x - y; + if (r != z) + status = 1; + } + + TEST2 (status, "_sub vector subtraction"); + } + + FUNCTION(gsl_vector, memcpy) (v, a); + FUNCTION(gsl_vector, mul) (v, b); + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE r = FUNCTION(gsl_vector,get) (v,i); + BASE x = FUNCTION(gsl_vector,get) (a,i); + BASE y = FUNCTION(gsl_vector,get) (b,i); + BASE z = x * y; + if (r != z) + status = 1; + } + + TEST2 (status, "_mul multiplication"); + } + + FUNCTION(gsl_vector, memcpy) (v, a); + FUNCTION(gsl_vector, div) (v, b); + + { + int status = 0; + + for (i = 0; i < N; i++) + { + BASE r = FUNCTION(gsl_vector,get) (v,i); + BASE x = FUNCTION(gsl_vector,get) (a,i); + BASE y = FUNCTION(gsl_vector,get) (b,i); + BASE z = x / y; + if (fabs(r - z) > 2 * GSL_FLT_EPSILON * fabs(z)) + status = 1; + } + TEST2 (status, "_div division"); + } + + FUNCTION(gsl_vector, free) (a); + FUNCTION(gsl_vector, free) (b); + FUNCTION(gsl_vector, free) (v); +} + + +void +FUNCTION (test, file) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride, N); + TYPE (gsl_vector) * w = FUNCTION (create, vector) (stride, N); + + size_t i; + + { + FILE *f = fopen ("test.dat", "wb"); + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) (N - i)); + }; + + FUNCTION (gsl_vector, fwrite) (f, v); + + fclose (f); + } + + { + FILE *f = fopen ("test.dat", "rb"); + + FUNCTION (gsl_vector, fread) (f, w); + + status = 0; + for (i = 0; i < N; i++) + { + if (w->data[i*stride] != (ATOMIC) (N - i)) + status = 1; + }; + + TEST (status, "_write and read"); + + fclose (f); + } + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ + FUNCTION (gsl_vector, free) (w); /* free whatever is in w */ +} + +#if USES_LONGDOUBLE && ! HAVE_PRINTF_LONGDOUBLE +/* skip this test */ +#else +void +FUNCTION (test, text) (size_t stride, size_t N) +{ + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride, N); + TYPE (gsl_vector) * w = FUNCTION (create, vector) (stride, N); + + size_t i; + + { + FILE *f = fopen ("test.txt", "w"); + + for (i = 0; i < N; i++) + { + FUNCTION (gsl_vector, set) (v, i, (ATOMIC) i); + }; + + FUNCTION (gsl_vector, fprintf) (f, v, OUT_FORMAT); + + fclose (f); + } + + { + FILE *f = fopen ("test.txt", "r"); + + FUNCTION (gsl_vector, fscanf) (f, w); + + status = 0; + for (i = 0; i < N; i++) + { + if (w->data[i*stride] != (ATOMIC) i) + status = 1; + }; + + gsl_test (status, NAME (gsl_vector) "_fprintf and fscanf"); + + fclose (f); + } + + FUNCTION (gsl_vector, free) (v); + FUNCTION (gsl_vector, free) (w); +} +#endif + +void +FUNCTION (test, trap) (size_t stride, size_t N) +{ + double x; + size_t j = 0; + TYPE (gsl_vector) * v = FUNCTION (create, vector) (stride, N); + v->size = N; + v->stride = stride; + + status = 0; + FUNCTION (gsl_vector, set) (v, j - 1, (ATOMIC)0); + TEST (!status, "_set traps index below lower bound"); + + status = 0; + FUNCTION (gsl_vector, set) (v, N + 1, (ATOMIC)0); + TEST (!status, "_set traps index above upper bound"); + + status = 0; + FUNCTION (gsl_vector, set) (v, N, (ATOMIC)0); + TEST (!status, "_set traps index at upper bound"); + + status = 0; + x = FUNCTION (gsl_vector, get) (v, j - 1); + TEST (!status, "_get traps index below lower bound"); + TEST (x != 0, "_get returns zero for index below lower bound"); + + status = 0; + x = FUNCTION (gsl_vector, get) (v, N + 1); + TEST (!status, "_get traps index above upper bound"); + TEST (x != 0, "_get returns zero for index above upper bound"); + + status = 0; + x = FUNCTION (gsl_vector, get) (v, N); + TEST (!status, "_get traps index at upper bound"); + TEST (x != 0, "_get returns zero for index at upper bound"); + + FUNCTION (gsl_vector, free) (v); /* free whatever is in v */ +} + + + + + diff --git a/gsl-1.9/vector/test_static.c b/gsl-1.9/vector/test_static.c new file mode 100644 index 0000000..bd11f00 --- /dev/null +++ b/gsl-1.9/vector/test_static.c @@ -0,0 +1,6 @@ +#undef HAVE_INLINE +#ifndef NO_INLINE +#define NO_INLINE +#endif +#define DESC " (static)" +#include "test.c" diff --git a/gsl-1.9/vector/vector.c b/gsl-1.9/vector/vector.c new file mode 100644 index 0000000..4dc2a82 --- /dev/null +++ b/gsl-1.9/vector/vector.c @@ -0,0 +1,109 @@ +/* vector/vector.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 <gsl/gsl_errno.h> +#include <gsl/gsl_vector.h> + +/* turn off range checking at runtime if zero */ +int gsl_check_range = 1; + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "vector_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/vector_source.c b/gsl-1.9/vector/vector_source.c new file mode 100644 index 0000000..f0f6332 --- /dev/null +++ b/gsl-1.9/vector/vector_source.c @@ -0,0 +1,83 @@ +/* vector/vector_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, 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 HIDE_INLINE_STATIC +BASE +FUNCTION (gsl_vector, get) (const TYPE (gsl_vector) * v, const size_t i) +{ + if (gsl_check_range) + { + if (i >= v->size) /* size_t is unsigned, can't be negative */ + { + BASE zero = ZERO; + GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero); + } + } + + /* The following line is a generalization of return v->data[i] */ + + return *(BASE *) (v->data + MULTIPLICITY * i * v->stride); +} + +void +FUNCTION (gsl_vector, set) (TYPE (gsl_vector) * v, const size_t i, BASE x) +{ + if (gsl_check_range) + { + if (i >= v->size) /* size_t is unsigned, can't be negative */ + { + GSL_ERROR_VOID ("index out of range", GSL_EINVAL); + } + } + + /* The following line is a generalization of v->data[i] = x */ + + *(BASE *) (v->data + MULTIPLICITY * i * v->stride) = x; +} + +BASE * +FUNCTION (gsl_vector, ptr) (TYPE (gsl_vector) * v, const size_t i) +{ + if (gsl_check_range) + { + if (i >= v->size) /* size_t is unsigned, can't be negative */ + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } + } + + return (BASE *) (v->data + MULTIPLICITY * i * v->stride); +} + +const BASE * +FUNCTION (gsl_vector, const_ptr) (const TYPE (gsl_vector) * v, const size_t i) +{ + if (gsl_check_range) + { + if (i >= v->size) /* size_t is unsigned, can't be negative */ + { + GSL_ERROR_NULL ("index out of range", GSL_EINVAL); + } + } + + /* The following line is a generalization of return v->data[i] */ + + return (const BASE *) (v->data + MULTIPLICITY * i * v->stride); +} +#endif diff --git a/gsl-1.9/vector/view.c b/gsl-1.9/vector/view.c new file mode 100644 index 0000000..da7b5e9 --- /dev/null +++ b/gsl-1.9/vector/view.c @@ -0,0 +1,176 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_vector.h> + +#include "view.h" + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_CHAR + +#define USE_QUALIFIER +#define QUALIFIER const + +#define BASE_GSL_COMPLEX_LONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_LONG + +#define BASE_GSL_COMPLEX +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX + +#define BASE_GSL_COMPLEX_FLOAT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_GSL_COMPLEX_FLOAT + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "view_source.c" +#include "templates_off.h" +#undef BASE_CHAR diff --git a/gsl-1.9/vector/view.h b/gsl-1.9/vector/view.h new file mode 100644 index 0000000..37e324a --- /dev/null +++ b/gsl-1.9/vector/view.h @@ -0,0 +1,2 @@ +#define NULL_VECTOR {0, 0, 0, 0, 0} +#define NULL_VECTOR_VIEW {{0, 0, 0, 0, 0}} diff --git a/gsl-1.9/vector/view_source.c b/gsl-1.9/vector/view_source.c new file mode 100644 index 0000000..421bbc3 --- /dev/null +++ b/gsl-1.9/vector/view_source.c @@ -0,0 +1,76 @@ +/* vector/view_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Gerard Jungman, 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. + */ + +QUALIFIED_VIEW(_gsl_vector,view) +FUNCTION(gsl_vector, view_array) (QUALIFIER ATOMIC * base, size_t n) +{ + QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, view); + } + + { + TYPE(gsl_vector) v = NULL_VECTOR; + + v.data = (ATOMIC *)base ; + v.size = n; + v.stride = 1; + v.block = 0; + v.owner = 0; + + view.vector = v; + return view; + } +} + +QUALIFIED_VIEW(_gsl_vector,view) +FUNCTION(gsl_vector, view_array_with_stride) (QUALIFIER ATOMIC * base, + size_t stride, + size_t n) +{ + QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW; + + if (n == 0) + { + GSL_ERROR_VAL ("vector length n must be positive integer", + GSL_EINVAL, view); + } + + if (stride == 0) + { + GSL_ERROR_VAL ("stride must be positive integer", + GSL_EINVAL, view); + } + + { + TYPE(gsl_vector) v = NULL_VECTOR; + + v.data = (ATOMIC *)base ; + v.size = n; + v.stride = stride; + v.block = 0; + v.owner = 0; + + view.vector = v; + return view; + } +} |