From 6963657b3f3ee4321394953a2cc67cd7386cce2d Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 27 Dec 2004 22:55:41 +0000 Subject: additions and better code reuse svn path=/trunk/externals/tb/; revision=2433 --- chaos/src/roessler.hpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 chaos/src/roessler.hpp (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp new file mode 100644 index 0000000..85272ee --- /dev/null +++ b/chaos/src/roessler.hpp @@ -0,0 +1,89 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// 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; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" + +// roessler model: dx1/dt = - (x2 + x3) +// dx2/dt = x1 + a * x2 +// dx3/dt = b + (x1 - c) * x3 +// taken from Peitgen / Jürgens / Saupe: Chaos and Fractals + +class roessler + : public ode_base +{ +public: + roessler() + { + m_num_eq = 3; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(method,0); + CHAOS_SYS_INIT(x1,0); + CHAOS_SYS_INIT(x2,0); + CHAOS_SYS_INIT(x3,0); + CHAOS_SYS_INIT(a,4); + CHAOS_SYS_INIT(b,4); + CHAOS_SYS_INIT(c,4); + + ode_base_alloc(); + } + + ~roessler() + { + ode_base_free(); + delete m_data; + } + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t x1 = data[0], x2 = data[1], x3 = data[2]; + + deriv[0] = - (x2 - x1); + deriv[1] = x1 + CHAOS_PARAMETER(a) * x2; + deriv[2] = CHAOS_PARAMETER(b) + (x1 - CHAOS_PARAMETER(c)) * x3; + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + CHAOS_SYSVAR_FUNCS(x3, 2); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); +}; + + +#define ROESSLER_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(x3); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); + +#define ROESSLER_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(x3); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); -- cgit v1.2.1 From 2a0d532e5965402f19f74f70dfdcc7efd1055b15 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 1 Jan 2005 11:06:58 +0000 Subject: speedup using function pointers svn path=/trunk/externals/tb/; revision=2439 --- chaos/src/roessler.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index 85272ee..4b36666 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -41,6 +41,7 @@ public: CHAOS_SYS_INIT(a,4); CHAOS_SYS_INIT(b,4); CHAOS_SYS_INIT(c,4); + CHAOS_SYS_INIT(dt,0.01); ode_base_alloc(); } -- cgit v1.2.1 From 2434290915cda6ed855e4dc2249312153b995817 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 9 Jun 2005 12:52:17 +0000 Subject: changed initialisation svn path=/trunk/externals/tb/; revision=3145 --- chaos/src/roessler.hpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index 4b36666..3603a58 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -31,25 +31,27 @@ class roessler public: roessler() { - m_num_eq = 3; - m_data = new data_t[m_num_eq]; + CHAOS_PRECONSTRUCTOR; - CHAOS_SYS_INIT(method,0); - CHAOS_SYS_INIT(x1,0); - CHAOS_SYS_INIT(x2,0); - CHAOS_SYS_INIT(x3,0); - CHAOS_SYS_INIT(a,4); - CHAOS_SYS_INIT(b,4); - CHAOS_SYS_INIT(c,4); - CHAOS_SYS_INIT(dt,0.01); + CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(dt,0.01); + CHAOS_SYS_INIT(x1,0,0); + CHAOS_SYS_INIT(x2,0,1); + CHAOS_SYS_INIT(x3,0,2); + + CHAOS_PAR_INIT(a,4); + CHAOS_PAR_INIT(b,4); + CHAOS_PAR_INIT(c,4); + + CHAOS_POSTCONSTRUCTOR; ode_base_alloc(); } ~roessler() { ode_base_free(); - delete m_data; + } virtual void m_system(data_t* deriv, data_t* data) -- cgit v1.2.1 From d1ed55f96f9cecc818844006fb36cd58ca70da5e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 16 Jun 2005 13:02:02 +0000 Subject: - parameter searching (broken) - misc. updates svn path=/trunk/externals/tb/; revision=3192 --- chaos/src/roessler.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index 3603a58..e2c55e0 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -34,11 +34,11 @@ public: CHAOS_PRECONSTRUCTOR; CHAOS_PAR_INIT(method,0); - CHAOS_PAR_INIT(dt,0.01); + CHAOS_PAR_INIT(dt,0.001); - CHAOS_SYS_INIT(x1,0,0); - CHAOS_SYS_INIT(x2,0,1); - CHAOS_SYS_INIT(x3,0,2); + CHAOS_SYS_INIT(x1,0.2,0); + CHAOS_SYS_INIT(x2,0.1,1); + CHAOS_SYS_INIT(x3,0.3,2); CHAOS_PAR_INIT(a,4); CHAOS_PAR_INIT(b,4); @@ -58,7 +58,7 @@ public: { data_t x1 = data[0], x2 = data[1], x3 = data[2]; - deriv[0] = - (x2 - x1); + deriv[0] = - (x2 + x3); deriv[1] = x1 + CHAOS_PARAMETER(a) * x2; deriv[2] = CHAOS_PARAMETER(b) + (x1 - CHAOS_PARAMETER(c)) * x3; } -- cgit v1.2.1 From ef53e19b3d9019b1b1f3345390f55ae9229ce390 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 22 Oct 2005 15:11:45 +0000 Subject: cleanups and new system svn path=/trunk/externals/tb/; revision=3750 --- chaos/src/roessler.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index e2c55e0..fd65d4e 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -29,10 +29,9 @@ class roessler : public ode_base { public: - roessler() + roessler(): + ode_base(3) { - CHAOS_PRECONSTRUCTOR; - CHAOS_PAR_INIT(method,0); CHAOS_PAR_INIT(dt,0.001); @@ -43,15 +42,10 @@ public: CHAOS_PAR_INIT(a,4); CHAOS_PAR_INIT(b,4); CHAOS_PAR_INIT(c,4); - - CHAOS_POSTCONSTRUCTOR; - ode_base_alloc(); } ~roessler() { - ode_base_free(); - } virtual void m_system(data_t* deriv, data_t* data) -- cgit v1.2.1 From 13cba7a7997e318fbba01a36912219355e387d52 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 21 May 2006 18:34:34 +0000 Subject: rewrote most stuff using templates svn path=/trunk/externals/tb/; revision=5105 --- chaos/src/roessler.hpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'chaos/src/roessler.hpp') diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index fd65d4e..aa03a47 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -23,14 +23,13 @@ // roessler model: dx1/dt = - (x2 + x3) // dx2/dt = x1 + a * x2 // dx3/dt = b + (x1 - c) * x3 -// taken from Peitgen / Jürgens / Saupe: Chaos and Fractals +// taken from Peitgen / J�rgens / Saupe: Chaos and Fractals class roessler - : public ode_base + : public ode_base<3> { public: - roessler(): - ode_base(3) + roessler() { CHAOS_PAR_INIT(method,0); CHAOS_PAR_INIT(dt,0.001); @@ -44,9 +43,6 @@ public: CHAOS_PAR_INIT(c,4); } - ~roessler() - { - } virtual void m_system(data_t* deriv, data_t* data) { -- cgit v1.2.1