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/logistic_map.hpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 chaos/src/logistic_map.hpp (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp new file mode 100644 index 0000000..c443f45 --- /dev/null +++ b/chaos/src/logistic_map.hpp @@ -0,0 +1,91 @@ +// +// +// 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" + +// logistic map: x[n+1] = alpha * x[n] * (1 - x[n]) +// 0 <= x[n] < 1 +// 0 <= alpha <= 4 + +class logistic: + protected map_base +{ +public: + logistic() + : m_alpha(3.8) + { + m_num_eq = 1; + m_data = new data_t[1]; + set_x(0.5f); + } + + ~logistic() + { + delete m_data; + } + + virtual void m_step() + { + data_t data = m_data[0]; + data_t alpha = m_alpha; + m_data[0] = alpha * data * (1.f - data); + } + + void set_alpha(t_float f) + { + if ( (f > 0) && (f < 4)) + m_alpha = (data_t) f; + else + post("value for alpha %f out of range", f); + } + + t_float get_alpha() + { + return (t_float)m_alpha; + } + + void set_x(t_float f) + { + if ( (f > 0) && (f < 1)) + m_data[0] = (data_t) f; + else + post("value for x %f out of range", f); + } + + t_float get_x() + { + return (t_float)m_data[0]; + } + +private: + data_t m_alpha; +}; + +#define LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +FLEXT_CALLVAR_F(m_system->get_alpha, m_system->set_alpha); \ +FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); + +#define LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +FLEXT_ADDATTR_VAR("alpha",m_system->get_alpha, m_system->set_alpha); \ +FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); + + -- 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/logistic_map.hpp | 53 ++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 35 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index c443f45..e0111f7 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -29,11 +29,11 @@ class logistic: { public: logistic() - : m_alpha(3.8) { m_num_eq = 1; m_data = new data_t[1]; - set_x(0.5f); + CHAOS_SYS_INIT(alpha, 3.8); + CHAOS_SYS_INIT(x, 0.5); } ~logistic() @@ -44,48 +44,31 @@ public: virtual void m_step() { data_t data = m_data[0]; - data_t alpha = m_alpha; + data_t alpha = CHAOS_PARAMETER(alpha); m_data[0] = alpha * data * (1.f - data); } - void set_alpha(t_float f) + CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); + bool m_pred_alpha(t_float f) { - if ( (f > 0) && (f < 4)) - m_alpha = (data_t) f; - else - post("value for alpha %f out of range", f); + return (f > 0) && (f < 4); } - t_float get_alpha() + CHAOS_SYSVAR_FUNCS_PRED(x, m_pred_x); + + bool m_pred_x(t_float f) { - return (t_float)m_alpha; + return (f > 0) && (f < 1); } - - void set_x(t_float f) - { - if ( (f > 0) && (f < 1)) - m_data[0] = (data_t) f; - else - post("value for x %f out of range", f); - } - - t_float get_x() - { - return (t_float)m_data[0]; - } - -private: - data_t m_alpha; }; -#define LOGISTIC_CALLBACKS \ -MAP_CALLBACKS; \ -FLEXT_CALLVAR_F(m_system->get_alpha, m_system->set_alpha); \ -FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); - -#define LOGISTIC_ATTRIBUTES \ -MAP_ATTRIBUTES; \ -FLEXT_ADDATTR_VAR("alpha",m_system->get_alpha, m_system->set_alpha); \ -FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); +#define LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(alpha); \ +CHAOS_SYS_CALLBACKS(x); +#define LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(alpha); \ +CHAOS_SYS_ATTRIBUTE(x); -- cgit v1.2.1 From 45932d6b4b33ecd4f4dc2e7eab9f210dfa46cc34 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 24 Dec 2004 15:31:14 +0000 Subject: xmas's changes svn path=/trunk/externals/tb/; revision=2427 --- chaos/src/logistic_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index e0111f7..94b38d0 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -54,7 +54,7 @@ public: return (f > 0) && (f < 4); } - CHAOS_SYSVAR_FUNCS_PRED(x, m_pred_x); + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); bool m_pred_x(t_float f) { -- cgit v1.2.1 From 5c3670b6322b60b8bc5f60e22d891fe39b854e3e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 24 Dec 2004 23:20:22 +0000 Subject: more changes ... getting stable ... svn path=/trunk/externals/tb/; revision=2428 --- chaos/src/logistic_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 94b38d0..e72a3a7 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -25,7 +25,7 @@ // 0 <= alpha <= 4 class logistic: - protected map_base + public map_base { public: logistic() -- cgit v1.2.1 From 43dd4efedf1ecfe721cde5830bdcee67ffa48907 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 28 Dec 2004 12:38:45 +0000 Subject: a few new attractors ... svn path=/trunk/externals/tb/; revision=2434 --- chaos/src/logistic_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index e72a3a7..1808baa 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -31,7 +31,7 @@ public: logistic() { m_num_eq = 1; - m_data = new data_t[1]; + m_data = new data_t[m_num_eq]; CHAOS_SYS_INIT(alpha, 3.8); CHAOS_SYS_INIT(x, 0.5); } -- 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/logistic_map.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 1808baa..ef2f603 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -21,7 +21,7 @@ #include "map_base.hpp" // logistic map: x[n+1] = alpha * x[n] * (1 - x[n]) -// 0 <= x[n] < 1 +// 0 < x[n] < 1 // 0 <= alpha <= 4 class logistic: @@ -43,9 +43,9 @@ public: virtual void m_step() { - data_t data = m_data[0]; + data_t x = m_data[0]; data_t alpha = CHAOS_PARAMETER(alpha); - m_data[0] = alpha * data * (1.f - data); + m_data[0] = alpha * x * (1.f - x); } CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); @@ -60,6 +60,14 @@ public: { return (f > 0) && (f < 1); } + + virtual void m_verify() + { + data_t x = m_data[0]; + if (m_pred_x(x)) + return; + m_data[0] = 0.5; + } }; #define LOGISTIC_CALLBACKS \ -- 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/logistic_map.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index ef2f603..16e824e 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -30,10 +30,12 @@ class logistic: public: logistic() { - m_num_eq = 1; - m_data = new data_t[m_num_eq]; - CHAOS_SYS_INIT(alpha, 3.8); - CHAOS_SYS_INIT(x, 0.5); + CHAOS_PRECONSTRUCTOR; + + CHAOS_PAR_INIT(alpha, 3.8); + CHAOS_SYS_INIT(x, 0.5,0); + + CHAOS_POSTCONSTRUCTOR; } ~logistic() -- 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/logistic_map.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 16e824e..c01abcc 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -51,14 +51,14 @@ public: } CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); - bool m_pred_alpha(t_float f) + bool m_pred_alpha(data_t f) { return (f > 0) && (f < 4); } CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); - bool m_pred_x(t_float f) + bool m_pred_x(data_t f) { return (f > 0) && (f < 1); } -- 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/logistic_map.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index c01abcc..3e0ef24 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -28,19 +28,15 @@ class logistic: public map_base { public: - logistic() + logistic(): + map_base(1) { - CHAOS_PRECONSTRUCTOR; - CHAOS_PAR_INIT(alpha, 3.8); CHAOS_SYS_INIT(x, 0.5,0); - - CHAOS_POSTCONSTRUCTOR; } ~logistic() { - delete m_data; } virtual void m_step() -- 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/logistic_map.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 3e0ef24..7880d21 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -25,11 +25,10 @@ // 0 <= alpha <= 4 class logistic: - public map_base + public map_base<1> { public: - logistic(): - map_base(1) + logistic() { CHAOS_PAR_INIT(alpha, 3.8); CHAOS_SYS_INIT(x, 0.5,0); -- 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/logistic_map.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/logistic_map.hpp') diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 7880d21..2d19855 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -38,7 +38,7 @@ public: { } - virtual void m_step() + void m_step() { data_t x = m_data[0]; data_t alpha = CHAOS_PARAMETER(alpha); -- cgit v1.2.1