From 5233c01a26329306c9f1d08c1a39733aee2cc518 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 21 Dec 2004 09:22:10 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r2423, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/tb/; revision=2424 --- chaos/src/standard_map.hpp | 130 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 chaos/src/standard_map.hpp (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp new file mode 100644 index 0000000..5f77af9 --- /dev/null +++ b/chaos/src/standard_map.hpp @@ -0,0 +1,130 @@ +// +// +// 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 "map_base.hpp" +#include + +// standard map: I[n+1] = I[n] + k * sin(theta[n]) +// theta[n+1] = theta[n] + I[n] + k * sin(theta[n]) +// 0 <= theta <= 2*pi +// taken from Willi-Hans Steeb: Chaos and Fractals + +class standard: + protected map_base +{ +public: + standard() + : m_k(0.8) + { + m_num_eq = 2; + m_data = new data_t[2]; + set_I(0.1); + set_theta(0.2); + } + + ~standard() + { + delete m_data; + } + + virtual void m_step() + { + data_t I = m_data[0]; + data_t theta = m_data[1]; + + m_data[0] = I + m_k * sin(theta); + theta = theta + I + k * sin(theta); + + if (y > 2 * M_PI) + { + do + { + y -= 2*M_PI; + } + while (y > 2 * M_PI); + goto put_data; + } + + if (y < 0) + { + do + { + y += 2*M_PI; + } + while (y < 0); + } + + put_data: + m_data[1] = theta; + } + + + void set_I(t_float f) + { + m_data[0] = (data_t) f; + } + + t_float get_I() + { + return (t_float)m_data[0]; + } + + + void set_theta(t_float f) + { + if ( (f >= 0) && (f < 2*M_PI)) + m_data[1] = (data_t) f; + else + post("value for theta %f out of range", f); + } + + t_float get_theta() + { + return (t_float)m_data[1]; + } + + + void set_k(t_float f) + { + m_k = (data_t) f; + } + + t_float get_k() + { + return (t_float)m_k; + } + +private: + data_t m_k; +}; + + +#define STANDARD_CALLBACKS \ +MAP_CALLBACKS; \ +FLEXT_CALLVAR_F(m_system->get_I, m_system->set_I); \ +FLEXT_CALLVAR_F(m_system->get_theta, m_system->set_theta); \ +FLEXT_CALLVAR_F(m_system->get_k, m_system->set_k); + + +#define STANDARD_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +FLEXT_ADDATTR_VAR("I",m_system->get_I, m_system->set_I); \ +FLEXT_ADDATTR_VAR("theta",m_system->get_theta, m_system->set_theta); \ +FLEXT_ADDATTR_VAR("k",m_system->get_k, m_system->set_k); -- cgit v1.2.1 From 404bfef9e23dfc3166cb2005367e7e8a41863914 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 23 Dec 2004 10:07:17 +0000 Subject: base class macros svn path=/trunk/externals/tb/; revision=2426 --- chaos/src/standard_map.hpp | 68 ++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index 5f77af9..9515efe 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -31,12 +31,13 @@ class standard: { public: standard() - : m_k(0.8) { m_num_eq = 2; m_data = new data_t[2]; - set_I(0.1); - set_theta(0.2); + + CHAOS_SYS_INIT(I,0.1); + CHAOS_SYS_INIT(theta,0.2); + CHAOS_SYS_INIT(k, 0.8); } ~standard() @@ -48,8 +49,9 @@ public: { data_t I = m_data[0]; data_t theta = m_data[1]; + data_t k = CHAOS_PARAMETER(k); - m_data[0] = I + m_k * sin(theta); + m_data[0] = I + k * sin(theta); theta = theta + I + k * sin(theta); if (y > 2 * M_PI) @@ -76,55 +78,27 @@ public: } - void set_I(t_float f) - { - m_data[0] = (data_t) f; - } - - t_float get_I() - { - return (t_float)m_data[0]; - } - - - void set_theta(t_float f) - { - if ( (f >= 0) && (f < 2*M_PI)) - m_data[1] = (data_t) f; - else - post("value for theta %f out of range", f); - } - - t_float get_theta() - { - return (t_float)m_data[1]; - } - - - void set_k(t_float f) - { - m_k = (data_t) f; - } + CHAOS_SYSVAR_FUNCS(I, 0); - t_float get_k() + CHAOS_SYSVAR_FUNCS_PRED(theta, 1, m_pred_theta); + bool m_pred_theta(t_float f) { - return (t_float)m_k; + return (f >= 0) && (f < 2*M_PI); } -private: - data_t m_k; + CHAOS_SYSPAR_FUNCS(I, 1); }; -#define STANDARD_CALLBACKS \ -MAP_CALLBACKS; \ -FLEXT_CALLVAR_F(m_system->get_I, m_system->set_I); \ -FLEXT_CALLVAR_F(m_system->get_theta, m_system->set_theta); \ -FLEXT_CALLVAR_F(m_system->get_k, m_system->set_k); +#define STANDARD_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(I); \ +CHAOS_SYS_CALLBACKS(theta); \ +CHAOS_SYS_CALLBACKS(k); -#define STANDARD_ATTRIBUTES \ -MAP_ATTRIBUTES; \ -FLEXT_ADDATTR_VAR("I",m_system->get_I, m_system->set_I); \ -FLEXT_ADDATTR_VAR("theta",m_system->get_theta, m_system->set_theta); \ -FLEXT_ADDATTR_VAR("k",m_system->get_k, m_system->set_k); +#define STANDARD_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(I); \ +CHAOS_SYS_ATTRIBUTE(theta); \ +CHAOS_SYS_ATTRIBUTE(k); -- cgit v1.2.1 From b2f2fd990f9059db784a7849726c6fc5006c70f9 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 27 Dec 2004 14:44:11 +0000 Subject: a lot of new objects ... svn path=/trunk/externals/tb/; revision=2431 --- chaos/src/standard_map.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index 9515efe..c0f0b8d 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -26,11 +26,11 @@ // 0 <= theta <= 2*pi // taken from Willi-Hans Steeb: Chaos and Fractals -class standard: - protected map_base +class standard_map: + public map_base { public: - standard() + standard_map() { m_num_eq = 2; m_data = new data_t[2]; @@ -40,7 +40,7 @@ public: CHAOS_SYS_INIT(k, 0.8); } - ~standard() + ~standard_map() { delete m_data; } @@ -54,23 +54,23 @@ public: m_data[0] = I + k * sin(theta); theta = theta + I + k * sin(theta); - if (y > 2 * M_PI) + if (theta > 2 * M_PI) { do { - y -= 2*M_PI; + theta -= 2*M_PI; } - while (y > 2 * M_PI); + while (theta > 2 * M_PI); goto put_data; } - if (y < 0) + if (theta < 0) { do { - y += 2*M_PI; + theta += 2*M_PI; } - while (y < 0); + while (theta < 0); } put_data: @@ -86,18 +86,18 @@ public: return (f >= 0) && (f < 2*M_PI); } - CHAOS_SYSPAR_FUNCS(I, 1); + CHAOS_SYSPAR_FUNCS(k); }; -#define STANDARD_CALLBACKS \ +#define STANDARD_MAP_CALLBACKS \ MAP_CALLBACKS; \ CHAOS_SYS_CALLBACKS(I); \ CHAOS_SYS_CALLBACKS(theta); \ CHAOS_SYS_CALLBACKS(k); -#define STANDARD_ATTRIBUTES \ +#define STANDARD_MAP_ATTRIBUTES \ MAP_ATTRIBUTES; \ CHAOS_SYS_ATTRIBUTE(I); \ CHAOS_SYS_ATTRIBUTE(theta); \ -- 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/standard_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index c0f0b8d..cadcf1e 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -33,7 +33,7 @@ public: standard_map() { m_num_eq = 2; - m_data = new data_t[2]; + m_data = new data_t[m_num_eq]; CHAOS_SYS_INIT(I,0.1); CHAOS_SYS_INIT(theta,0.2); -- 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/standard_map.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index cadcf1e..663280a 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -32,17 +32,19 @@ class standard_map: public: standard_map() { - m_num_eq = 2; - m_data = new data_t[m_num_eq]; + CHAOS_PRECONSTRUCTOR; + + CHAOS_SYS_INIT(I,0.1,0); + CHAOS_SYS_INIT(theta,0.2,1); + + CHAOS_PAR_INIT(k, 0.8); - CHAOS_SYS_INIT(I,0.1); - CHAOS_SYS_INIT(theta,0.2); - CHAOS_SYS_INIT(k, 0.8); + CHAOS_POSTCONSTRUCTOR; } ~standard_map() { - delete m_data; + } virtual void m_step() -- 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/standard_map.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index 663280a..4df1eb9 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -30,16 +30,13 @@ class standard_map: public map_base { public: - standard_map() + standard_map(): + map_base(2) { - CHAOS_PRECONSTRUCTOR; - CHAOS_SYS_INIT(I,0.1,0); CHAOS_SYS_INIT(theta,0.2,1); CHAOS_PAR_INIT(k, 0.8); - - CHAOS_POSTCONSTRUCTOR; } ~standard_map() -- 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/standard_map.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index 4df1eb9..8798edc 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -27,11 +27,10 @@ // taken from Willi-Hans Steeb: Chaos and Fractals class standard_map: - public map_base + public map_base<2> { public: - standard_map(): - map_base(2) + standard_map() { CHAOS_SYS_INIT(I,0.1,0); CHAOS_SYS_INIT(theta,0.2,1); -- cgit v1.2.1 From 2c157bd8aa1f5387169cc0c0910d36c8068c4068 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 21 May 2006 19:17:04 +0000 Subject: improved inlining for maps svn path=/trunk/externals/tb/; revision=5106 --- chaos/src/standard_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/standard_map.hpp') diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp index 8798edc..399484b 100644 --- a/chaos/src/standard_map.hpp +++ b/chaos/src/standard_map.hpp @@ -43,7 +43,7 @@ public: } - virtual void m_step() + void m_step() { data_t I = m_data[0]; data_t theta = m_data[1]; -- cgit v1.2.1