summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile.am14
-rw-r--r--configure.ac18
-rw-r--r--src/Makefile.am22
-rw-r--r--src/vZ.hpp29
-rw-r--r--src/vZ/integrator.hpp83
-rw-r--r--src/vZ/simple.hpp56
-rw-r--r--tests/Makefile.am25
-rw-r--r--tests/compile.cpp8
9 files changed, 245 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 4683a61..291d1aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,10 @@
Makefile
Makefile.in
+# Files created by `make check'
+/tests/*-test
+/tests/*.log
+
# pkg-config files
*.pc
diff --git a/Makefile.am b/Makefile.am
index a6bedb1..ef36208 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,16 +1,16 @@
###########################################################################
## Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> ##
## ##
-## This file is part of The Dimension Build Suite. ##
+## This file is part of The vZ Build Suite. ##
## ##
-## The Dimension Build Suite is free software; you can redistribute it ##
-## and/or modify it under the terms of the GNU General Public License as ##
+## The vZ Build Suite 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 3 of the ##
## License, or (at your option) any later version. ##
## ##
-## The Dimension Build Suite 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 ##
+## The vZ Build Suite 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 ##
@@ -18,5 +18,7 @@
###########################################################################
ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = src \
+ tests
EXTRA_DIST = autogen.sh
diff --git a/configure.ac b/configure.ac
index b25ea62..0a53d5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,22 +1,22 @@
dnl Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com>
dnl
-dnl This file is part of The Dimension Build Suite.
+dnl This file is part of The vZ Build Suite.
dnl
-dnl The Dimension Build Suite is free software; you can redistribute it
-dnl and/or modify it under the terms of the GNU General Public License as
+dnl The vZ Build Suite is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 3 of the
dnl License, or (at your option) any later version.
dnl
-dnl The Dimension Build Suite is distributed in the hope that it will be
-dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-dnl of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl The vZ Build Suite is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl Initialization
-AC_PREREQ(2.65)
+AC_PREREQ(2.68)
AC_INIT(vZ, 0.0.0, tavianator@gmail.com, vz,
[http://www.gitorious.org/vz])
AM_INIT_AUTOMAKE([parallel-tests color-tests])
@@ -28,5 +28,7 @@ AC_PROG_LIBTOOL
dnl Generate Makefiles
AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile
+ src/Makefile
+ tests/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..25f6803
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,22 @@
+###########################################################################
+## Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> ##
+## ##
+## This file is part of The Dimension Build Suite. ##
+## ##
+## The Dimension Build Suite 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 3 of the ##
+## License, or (at your option) any later version. ##
+## ##
+## The Dimension Build Suite 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, see <http://www.gnu.org/licenses/>. ##
+###########################################################################
+
+nobase_include_HEADERS = vZ.hpp \
+ vZ/integrator.hpp \
+ vZ/simple.hpp
diff --git a/src/vZ.hpp b/src/vZ.hpp
new file mode 100644
index 0000000..1d7327b
--- /dev/null
+++ b/src/vZ.hpp
@@ -0,0 +1,29 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The Dimension Library. *
+ * *
+ * The Dimension Library is free software; you can redistribute it and/ *
+ * or modify it under the terms of the GNU Lesser General Public License *
+ * as published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// vZ -- A Runge-Kutta type numerical integration library
+
+#ifndef VZ_HPP
+#define VZ_HPP
+
+#include <vZ/integrator.hpp>
+#include <vZ/simple.hpp>
+
+#endif // VZ_HPP
diff --git a/src/vZ/integrator.hpp b/src/vZ/integrator.hpp
new file mode 100644
index 0000000..394f40f
--- /dev/null
+++ b/src/vZ/integrator.hpp
@@ -0,0 +1,83 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The vZ Library. *
+ * *
+ * The vZ Library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The vZ Library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#ifndef VZ_INTEGRATOR_HPP
+#define VZ_INTEGRATOR_HPP
+
+#include <tr1/functional>
+#include <algorithm>
+
+namespace vZ
+{
+ // Base Integrator class
+ //
+ // All integration methods derrive from this class
+ // If the initial value problem is specified as
+ // y' = f(t, y); y(t0) = y0
+ // then an Integrator could be constructed as Integrator(f, dt).y(y0).t(t0)
+ template <typename Real>
+ class GenericIntegrator
+ {
+ public:
+ typedef std::tr1::function<Real (Real, Real)> Function;
+
+ // By default, y and t start at zero
+ GenericIntegrator(Function f, Real dt)
+ : m_f(f), m_y(0), m_t(0), m_dt(dt) { }
+ virtual ~GenericIntegrator() { }
+
+ GenericIntegrator& y(Real y) { m_y = y; return *this; }
+ GenericIntegrator& t(Real t) { m_t = t; return *this; }
+ GenericIntegrator& dt(Real dt) { m_dt = dt; return *this; }
+
+ Real y() const { return m_y; }
+ Real t() const { return m_t; }
+ Real dt() const { return m_dt; }
+
+ // Integrate until time t
+ void integrate(Real t_final);
+
+ protected:
+ virtual void step(Real& t, Real& dt) = 0;
+ Function m_f;
+
+ private:
+ Real m_y;
+ Real m_t, m_dt;
+ };
+
+ // Type alias
+ typedef GenericIntegrator<double> Integrator;
+
+ // Definitions
+
+ template <typename Real>
+ void
+ GenericIntegrator<Real>::integrate(Real t_final)
+ {
+ while (m_t < t_final) {
+ m_dt = std::min(m_dt, t_final - m_t);
+ step(m_t, m_dt);
+ }
+ }
+}
+
+
+#endif // VZ_INTEGRATOR_HPP
diff --git a/src/vZ/simple.hpp b/src/vZ/simple.hpp
new file mode 100644
index 0000000..65b7560
--- /dev/null
+++ b/src/vZ/simple.hpp
@@ -0,0 +1,56 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The vZ Library. *
+ * *
+ * The vZ Library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The vZ Library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#ifndef VZ_SIMPLE_HPP
+#define VZ_SIMPLE_HPP
+
+#include <vector>
+
+namespace vZ
+{
+ // Base class for non-adaptive RK-style algorithms
+ template <typename Real>
+ class GenericSimpleIntegrator : public GenericIntegrator<Real>
+ {
+ public:
+ typedef typename GenericIntegrator<Real>::Function Function;
+
+ // Coefficients in the tableau representation of the RK algorithm
+ typedef std::vector<std::vector<Real> > ACoefficients;
+ typedef std::vector<Real> BCoefficients;
+
+ GenericSimpleIntegrator(Function f, Real dt,
+ ACoefficients a, BCoefficients b)
+ : GenericIntegrator<Real>(f, dt), m_a(a), m_b(b) { }
+ virtual ~GenericSimpleIntegrator() { }
+
+ protected:
+ virtual void step(Real& t, Real& dt);
+
+ private:
+ ACoefficients m_a;
+ BCoefficients m_b;
+ };
+
+ // Type alias
+ typedef GenericSimpleIntegrator<double> SimpleIntegrator;
+}
+
+#endif // VZ_SIMPLE_HPP
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..156bc06
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,25 @@
+###########################################################################
+## Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> ##
+## ##
+## This file is part of The Dimension Build Suite. ##
+## ##
+## The Dimension Build Suite 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 3 of the ##
+## License, or (at your option) any later version. ##
+## ##
+## The Dimension Build Suite 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, see <http://www.gnu.org/licenses/>. ##
+###########################################################################
+
+INCLUDES = -I$(top_srcdir)/src
+
+check_PROGRAMS = compile-test
+TESTS = $(check_PROGRAMS)
+
+compile_test_SOURCES = compile.cpp
diff --git a/tests/compile.cpp b/tests/compile.cpp
new file mode 100644
index 0000000..17381b4
--- /dev/null
+++ b/tests/compile.cpp
@@ -0,0 +1,8 @@
+#include "vZ.hpp"
+#include <cstdlib>
+
+int
+main()
+{
+ return EXIT_SUCCESS;
+}