aboutsummaryrefslogtreecommitdiff
path: root/chaos/src
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2004-12-23 10:07:17 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:57 +0200
commit404bfef9e23dfc3166cb2005367e7e8a41863914 (patch)
tree3995ab20cf7ec984560c44e4fdeef1106ce8ff1c /chaos/src
parent5233c01a26329306c9f1d08c1a39733aee2cc518 (diff)
base class macros
svn path=/trunk/externals/tb/; revision=2426
Diffstat (limited to 'chaos/src')
-rw-r--r--chaos/src/bernoulli_map.hpp29
-rw-r--r--chaos/src/bungalow_tent_map.hpp54
-rw-r--r--chaos/src/chaos.hpp2
-rw-r--r--chaos/src/chaos_base.hpp92
-rw-r--r--chaos/src/circle_map.hpp73
-rw-r--r--chaos/src/gauss_map.hpp29
-rw-r--r--chaos/src/henon_map.hpp90
-rw-r--r--chaos/src/ikeda_laser_map.hpp126
-rw-r--r--chaos/src/logistic_map.hpp53
-rw-r--r--chaos/src/lorenz.hpp129
-rw-r--r--chaos/src/lozi_map.hpp90
-rw-r--r--chaos/src/sine_map.hpp28
-rw-r--r--chaos/src/standard_map.hpp68
-rw-r--r--chaos/src/tent_map.hpp21
14 files changed, 335 insertions, 549 deletions
diff --git a/chaos/src/bernoulli_map.hpp b/chaos/src/bernoulli_map.hpp
index b006c92..50bca13 100644
--- a/chaos/src/bernoulli_map.hpp
+++ b/chaos/src/bernoulli_map.hpp
@@ -32,10 +32,10 @@ public:
{
m_num_eq = 1:
m_data = new data_t[1];
- set_x(0.5f);
+ CHAOS_SYS_INIT(x,0.5)
}
- ~bernoulli()
+ ~Bernoulli()
{
delete m_data;
}
@@ -50,26 +50,19 @@ public:
m_data[0] = 2.f * x - 1.f;
}
- void set_x(t_float f)
+ CHAOS_SYSVAR_FUNCS_PRED(x,0,m_pred_x);
+ bool m_pred_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];
+ return (f >= 0) && (f < 1);
}
};
-#define BERNOULLI_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+#define BERNOULLI_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x);
-#define BERNOULLI_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+#define BERNOULLI_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x);
diff --git a/chaos/src/bungalow_tent_map.hpp b/chaos/src/bungalow_tent_map.hpp
index 6708eae..dfb6e25 100644
--- a/chaos/src/bungalow_tent_map.hpp
+++ b/chaos/src/bungalow_tent_map.hpp
@@ -37,11 +37,11 @@ class bungalow_tent:
{
public:
bungalow_tent()
- : m_r(0.5)
{
m_num_eq = 1;
m_data = new data_t[1];
- set_x(0.5f);
+ CHAOS_SYS_INIT(x, 0.5);
+ CHAOS_SYS_INIT(r, 0.5);
}
~bungalow_tent()
@@ -52,7 +52,7 @@ public:
virtual void m_step()
{
data_t x = m_data[0];
- data_t r = m_r;
+ data_t r = CHAOS_PARAMETER(r);
if ( x < - 0.5)
{
@@ -77,45 +77,25 @@ public:
}
- void set_x(t_float f)
+ CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x);
+ bool m_pred_x(t_float f)
{
- if ( (f > -1) && (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];
- }
-
- void set_r(t_float f)
- {
- if ( (f > -.5) && (f < 1))
- m_data[0] = (data_t) f;
- else
- post("value for r %f out of range", f);
+ return (f >= -1) && (f < 1);
}
- t_float get_r()
+ CHAOS_SYSVAR_FUNCS_PRED(r, 0, m_pred_r);
+ bool m_pred_r(t_float f)
{
- return (t_float)m_data[0];
+ return (f >= -0.5) && (f < 1);
}
-
-private:
- data_t m_r;
-
};
+#define BUNGALOW_TENT_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x); \
+CHAOS_SYS_CALLBACKS(r);
-#define BUNGALOW_TENT_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
-
-
-#define BUNGALOW_TENT_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+#define BUNGALOW_TENT_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x) \
+CHAOS_SYS_ATTRIBUTE(r)
diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp
index d65ba5c..4f51902 100644
--- a/chaos/src/chaos.hpp
+++ b/chaos/src/chaos.hpp
@@ -22,7 +22,7 @@
#define FLEXT_ATTRIBUTES 1
-#include "flext.h"
+//#include "flext.h"
/* internal we can work with a higher precision than pd */
#ifdef DOUBLE_PRECISION
diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp
index 231580b..a42e275 100644
--- a/chaos/src/chaos_base.hpp
+++ b/chaos/src/chaos_base.hpp
@@ -1,4 +1,4 @@
-//
+a//
//
// chaos~
// Copyright (C) 2004 Tim Blechmann
@@ -36,7 +36,6 @@ public:
return m_num_eq;
}
- /* prototype for system function */
virtual void m_step();
data_t * m_data; // state of the system
@@ -51,5 +50,94 @@ FLEXT_CALLGET_F(m_system->get_num_eq);
#define CHAOS_ATTRIBUTES \
FLEXT_ADDATTR_GET("dimension",m_system->get_num_eq);
+
+
+// macros for simplified system state functions
+#define CHAOS_SYS_SETFUNC(NAME, NR) \
+ void set_##NAME(t_float f) \
+ { \
+ m_data[NR] = (data_t) f; \
+ }
+
+#define CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \
+ void set_##NAME(t_float f) \
+ { \
+ if ( PRED(f) ) \
+ m_data[NR] = (data_t) f; \
+ else \
+ post("value for dimension " #NAME " %f out of range", f); \
+ }
+
+#define CHAOS_SYS_GETFUNC(NAME, NR) \
+ t_float get_##NAME() \
+ { \
+ return (t_float)m_data[NR]; \
+ }
+
+/* to be called in the public part */
+#define CHAOS_SYSVAR_FUNCS_PRED(NAME, NR, PRED) \
+public: \
+CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \
+CHAOS_SYS_GETFUNC(NAME, NR)
+
+#define CHAOS_SYSVAR_FUNCS(NAME, NR) \
+public: \
+CHAOS_SYS_SETFUNC(NAME, NR) \
+CHAOS_SYS_GETFUNC(NAME, NR)
+
+
+
+// macros for simplified system parameter functions
+#define CHAOS_PAR_SETFUNC(NAME) \
+ void set_##NAME(t_float f) \
+ { \
+ m_##NAME = (data_t) f; \
+ }
+
+#define CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \
+ void set_##NAME(t_float f) \
+ { \
+ if ( PRED(f) ) \
+ m_##NAME = (data_t) f; \
+ else \
+ post("value for parameter " #NAME " %f out of range", f); \
+ }
+
+#define CHAOS_PAR_GETFUNC(NAME) \
+ t_float get_##NAME() \
+ { \
+ return (t_float)m_##NAME; \
+ }
+
+
+#define CHAOS_SYSPAR_FUNCS_PRED(NAME, PRED) \
+public: \
+CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \
+CHAOS_PAR_GETFUNC(NAME) \
+private: \
+data_t m_##NAME; \
+public:
+
+#define CHAOS_SYSPAR_FUNCS(NAME) \
+public: \
+CHAOS_PAR_SETFUNC(NAME) \
+CHAOS_PAR_GETFUNC(NAME) \
+private: \
+data_t m_##NAME; \
+public:
+
+
+#define CHAOS_SYS_CALLBACKS(NAME) \
+FLEXT_CALLVAR_F(m_system->get_##NAME, m_system->set_##NAME);
+
+#define CHAOS_SYS_ATTRIBUTE(NAME) \
+FLEXT_ADDATTR_VAR(#NAME,m_system->get_##NAME, m_system->set_##NAME);
+
+#define CHAOS_SYS_INIT(NAME, VALUE) \
+set_##NAME(VALUE);
+
+#define CHAOS_PARAMETER(NAME) m_##NAME
+
+
#define __chaos_base_hpp
#endif /* __chaos_base_hpp */
diff --git a/chaos/src/circle_map.hpp b/chaos/src/circle_map.hpp
index f1ef406..02817de 100644
--- a/chaos/src/circle_map.hpp
+++ b/chaos/src/circle_map.hpp
@@ -29,11 +29,12 @@ class circle_map:
{
public:
circle_map()
- : m_omega(0.4), m_r(1)
{
m_num_eq = 1;
m_data = new data_t[1];
- set_x(0.5);
+ CHAOS_SYS_INIT(omega, 0.4);
+ CHAOS_SYS_INIT(r, 1);
+ CHAOS_SYS_INIT(x, 0.5);
}
~circle_map()
@@ -44,63 +45,27 @@ public:
virtual void m_step()
{
data_t x = m_data[0];
- data_t omega = m_omega;
- data_t r = m_r;
+ data_t omega = CHAOS_PARAMETER(omega);
+ data_t r = CHAOS_PARAMETER(r);
m_data[0] = x + omega - r / (2.f * M_PI) * sin (2.f * M_PI * x);
}
- void set_x(t_float f)
- {
- m_data[0] = (data_t) f;
- }
-
- t_float get_x()
- {
- return (t_float)m_data[0];
- }
-
- void set_r(t_float f)
- {
- m_r = (data_t) f;
- }
-
-
- t_float get_r()
- {
- return (t_float)m_r;
- }
-
-
- void set_omega (t_float f)
- {
- m_omega = (data_t) f;
- }
-
- t_float get_omega()
- {
- return (t_float)m_omega;
- }
-
-
-private:
- data_t m_omega;
- data_t m_r;
+ CHAOS_SYSVAR_FUNCS(x,0);
+ CHAOS_SYSPAR_FUNCS(r);
+ CHAOS_SYSPAR_FUNCS(omega);
};
-#define CIRCLE_MAP_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_ATTRVAR_F(m_system->m_omega); \
-FLEXT_ATTRVAR_F(m_system->m_r); \
-FLEXT_CALLVAR_F(m_system->get_omega, m_system->set_omega); \
-FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+#define CIRCLE_MAP_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(omega); \
+CHAOS_SYS_CALLBACKS(r); \
+CHAOS_SYS_CALLBACKS(x);
+
-#define CIRCLE_MAP_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR1("omega",m_system->m_omega); \
-FLEXT_ADDATTR_VAR1("r",m_system->m_r); \
-FLEXT_ADDATTR_VAR("omega",m_system->get_omega, m_system->set_omega); \
-FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+#define CIRCLE_MAP_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(omega); \
+CHAOS_SYS_ATTRIBUTE(r); \
+CHAOS_SYS_ATTRIBUTE(x);
diff --git a/chaos/src/gauss_map.hpp b/chaos/src/gauss_map.hpp
index e2316ec..537dcfb 100644
--- a/chaos/src/gauss_map.hpp
+++ b/chaos/src/gauss_map.hpp
@@ -33,7 +33,7 @@ public:
{
m_num_eq = 1;
m_data = new data_t[1];
- set_x(0.5);
+ CHAOS_SYS_INIT(x,0.5);
}
~gauss()
@@ -51,27 +51,20 @@ public:
m_data[0] = fmod(1.f / data);
}
- void set_x(t_float f)
+ CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x);
+ bool m_pred_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];
+ return (f >= 0) && (f < 1);
}
-
};
-#define GAUSS_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+#define GAUSS_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x);
+
+#define GAUSS_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x);
-#define GAUSS_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
diff --git a/chaos/src/henon_map.hpp b/chaos/src/henon_map.hpp
index d29e8a7..0aecbee 100644
--- a/chaos/src/henon_map.hpp
+++ b/chaos/src/henon_map.hpp
@@ -30,12 +30,14 @@ class henon:
{
public:
henon()
- : m_a(1.4), m_b(0.3)
{
m_num_eq = 2;
m_data = new data_t[1];
- set_x(0.f);
- set_y(0.f);
+
+ CHAOS_SYS_INIT(x,0);
+ CHAOS_SYS_INIT(y,0);
+ CHAOS_SYS_INIT(a,1.4);
+ CHAOS_SYS_INIT(b,0.3);
}
~henon()
@@ -48,74 +50,34 @@ public:
data_t x = m_data[0];
data_t y = m_data[1];
- m_data[0] = 1 + y - m_a * x * x;
- m_data[1] = m_b * x;
-
+ m_data[0] = 1 + y - CHAOS_PARAMETER(a) * x * x;
+ m_data[1] = CHAOS_PARAMETER(b) * x;
}
+ CHAOS_SYSVAR_FUNCS(x, 0);
+ CHAOS_SYSVAR_FUNCS(y, 1);
- void set_x(t_float f)
- {
- m_data[0] = (data_t) f;
- }
-
- t_float get_x()
- {
- return (t_float)m_data[0];
- }
-
-
- void set_y(t_float f)
- {
- m_data[1] = (data_t) f;
- }
+ CHAOS_SYSPAR_FUNCS(a);
- t_float get_y()
+ CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b);
+ bool m_pred_b(t_float f)
{
- return (t_float)m_data[1];
+ return (f != 0);
}
-
-
- void set_a(t_float f)
- {
- m_a = (data_t) f;
- }
-
- t_float get_a()
- {
- return (t_float)m_a;
- }
-
-
- void set_b(t_float f)
- {
- if (f != 0)
- m_b = (data_t) f;
- else
- post("value for b %f out of range", f);
- }
-
- t_float get_b()
- {
- return (t_float)m_b;
- }
-
-private:
- data_t m_a;
- data_t m_b;
};
-#define HENON_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \
-FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
-FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
+#define HENON_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(a); \
+CHAOS_SYS_CALLBACKS(b); \
+CHAOS_SYS_CALLBACKS(x); \
+CHAOS_SYS_CALLBACKS(y);
+
+#define HENON_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(a); \
+CHAOS_SYS_ATTRIBUTE(b); \
+CHAOS_SYS_ATTRIBUTE(x); \
+CHAOS_SYS_ATTRIBUTE(y);
-#define HENON_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \
-FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
-FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
diff --git a/chaos/src/ikeda_laser_map.hpp b/chaos/src/ikeda_laser_map.hpp
index 39d75c4..ccc14cc 100644
--- a/chaos/src/ikeda_laser_map.hpp
+++ b/chaos/src/ikeda_laser_map.hpp
@@ -36,12 +36,15 @@ class ikeda:
{
public:
ikeda()
- : m_c1(0.4), m_c2(0.9), m_c3(9), m_roh(0.85)
{
m_num_eq = 2;
m_data = new data_t[2];
- set_x(0.5);
- set_y(0.5);
+ CHAOS_SYS_INIT(c1,0.4);
+ CHAOS_SYS_INIT(c2,0.9);
+ CHAOS_SYS_INIT(c3,9);
+ CHAOS_SYS_INIT(roh,0.85);
+ CHAOS_SYS_INIT(x,0.5);
+ CHAOS_SYS_INIT(y,0.5);
}
~ikeda()
@@ -54,100 +57,41 @@ public:
data_t x = m_data[0];
data_t y = m_data[1];
- data_t tau = m_c1 - m_c3 / (1 + x*x + y*y);
+ data_t tau = CHAOS_PARAMETER(c1) -
+ CHAOS_PARAMETER(c3) / (1 + x*x + y*y);
data_t cos_tau = cos(tau);
data_t sin_tau = sin(tau);
- m_data[0] = m_roh + m_c2 * (x * cos_tau - y * sin_tau);
- m_data[1] = m_c2 * (x * sin_tau + y * cos_tau);
+ m_data[0] = CHAOS_PARAMETER(roh) + CHAOS_PARAMETER(c2)
+ * (x * cos_tau - y * sin_tau);
+ m_data[1] = CHAOS_PARAMETER(c2) * (x * sin_tau + y * cos_tau);
}
-
- void set_x(t_float f)
- {
- m_data[0] = (data_t) f;
- }
-
- t_float get_x()
- {
- return (t_float)m_data[0];
- }
-
- void set_y(t_float f)
- {
- m_data[1] = (data_t) f;
- }
-
- t_float get_y()
- {
- return (t_float)m_data[1];
- }
-
-
- void set_c1(t_float f)
- {
- m_c1 = (data_t) f;
- }
-
- t_float get_c1()
- {
- return (t_float)m_c1;
- }
-
-
- void set_c2(t_float f)
- {
- m_c2[1] = (data_t) f;
- }
-
- t_float get_c2()
- {
- return (t_float)m_c2;
- }
-
-
- void set_c3(t_float f)
- {
- m_c3 = (data_t) f;
- }
-
- t_float get_c3()
- {
- return (t_float)m_c3;
- }
-
-
- void set_roh(t_float f)
- {
- m_roh = (data_t) f;
- }
-
- t_float get_roh()
- {
- return (t_float)m_roh;
- }
-
+ CHAOS_SYSVAR_FUNCS(x, 0);
+ CHAOS_SYSVAR_FUNCS(y, 1);
-private:
- data_t m_c1, m_c2, m_c3, m_roh;
-};
+ CHAOS_PAR_FUNCS(c1);
+ CHAOS_PAR_FUNCS(c2);
+ CHAOS_PAR_FUNCS(c3);
+ CHAOS_PAR_FUNCS(roh);
-
-#define IKEDA_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_c1, m_system->set_c1); \
-FLEXT_CALLVAR_F(m_system->get_c2, m_system->set_c2); \
-FLEXT_CALLVAR_F(m_system->get_c3, m_system->set_c3); \
-FLEXT_CALLVAR_F(m_system->get_roh, m_system->set_roh); \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
-FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y); \
+};
-#define IKEDA_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("c1",m_system->get_c1, m_system->set_c1); \
-FLEXT_ADDATTR_VAR("c2",m_system->get_c2, m_system->set_c2); \
-FLEXT_ADDATTR_VAR("c3",m_system->get_c3, m_system->set_c3); \
-FLEXT_ADDATTR_VAR("roh",m_system->get_roh, m_system->set_roh); \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
-FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
+#define IKEDA_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(c1); \
+CHAOS_SYS_CALLBACKS(c2); \
+CHAOS_SYS_CALLBACKS(c3); \
+CHAOS_SYS_CALLBACKS(roh); \
+CHAOS_SYS_CALLBACKS(x); \
+CHAOS_SYS_CALLBACKS(y);
+
+#define IKEDA_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(c1); \
+CHAOS_SYS_ATTRIBUTE(c2); \
+CHAOS_SYS_ATTRIBUTE(c3); \
+CHAOS_SYS_ATTRIBUTE(roh); \
+CHAOS_SYS_ATTRIBUTE(x); \
+CHAOS_SYS_ATTRIBUTE(y);
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);
diff --git a/chaos/src/lorenz.hpp b/chaos/src/lorenz.hpp
index 70dad4d..e3e5ccd 100644
--- a/chaos/src/lorenz.hpp
+++ b/chaos/src/lorenz.hpp
@@ -30,13 +30,17 @@ class lorenz
{
public:
logistic()
- : m_sigma(16), m_b(4), m_r(40)
{
m_num_eq = 3;
m_data = new data_t[3];
- set_x1(0.8f);
- set_x2(0.8f);
- set_x3(0.8f);
+
+ CHAOS_SYS_INIT(x1,0.8);
+ CHAOS_SYS_INIT(x2,0.8);
+ CHAOS_SYS_INIT(x3,0.8);
+ CHAOS_SYS_INIT(sigma,16);
+ CHAOS_SYS_INIT(b,4);
+ CHAOS_SYS_INIT(r,40);
+
set_method(0);
}
@@ -49,102 +53,41 @@ public:
{
data_t x1 = data[0], x2 = data[1], x3 = data[2];
- deriv[0] = m_sigma * (x2 - x1);
- deriv[1] = - x1 * x3 + m_r * x1 - x2;
- deriv[3] = x1 * x2 - m_b * x3;
- }
-
- void set_x1(t_float f)
- {
- m_data[0] = (data_t) f;
+ deriv[0] = CHAOS_PARAMETER(sigma) * (x2 - x1);
+ deriv[1] = - x1 * x3 + CHAOS_PARAMETER(r) * x1 - x2;
+ deriv[3] = x1 * x2 - CHAOS_PARAMETER(b) * x3;
}
- t_float get_x1()
- {
- return (t_float)m_data[0];
- }
-
- void set_x2(t_float f)
- {
- m_data[1] = (data_t) f;
- }
-
- t_float get_x2()
- {
- return (t_float)m_data[1];
- }
-
- void set_x3(t_float f)
- {
- m_data[2] = (data_t) f;
- }
-
- t_float get_x3()
- {
- return (t_float)m_data[2];
- }
+ CHAOS_SYSVAR_FUNCS(x1, 0);
+ CHAOS_SYSVAR_FUNCS(x2, 1);
+ CHAOS_SYSVAR_FUNCS(x3, 2);
+ CHAOS_SYSPAR_FUNCS_PRED(sigma, m_pred);
+ CHAOS_SYSPAR_FUNCS_PRED(b, m_pred);
+ CHAOS_SYSPAR_FUNCS_PRED(r, m_pred);
- void set_sigma(t_float f)
+ bool m_pred (t_float f)
{
- if (f > 0)
- m_sigma = (data_t) f;
- else
- post("value for sigma %f out of range", f);
+ return (f > 0);
}
- t_float get_sigma()
- {
- return (t_float)m_sigma;
- }
-
-
- void set_r(t_float f)
- {
- if (f > 0)
- m_r = (data_t) f;
- else
- post("value for r %f out of range", f);
- }
-
- t_float get_r()
- {
- return (t_float)m_r;
- }
-
- void set_b(t_float f)
- {
- if (f > 0)
- m_b = (data_t) f;
- else
- post("value for b %f out of range", f);
- }
-
- t_float get_b()
- {
- return (t_float)m_b;
- }
-
-
-private:
- data_t m_sigma, m_r, m_b;
};
-#define LORENZ_CALLBACKS \
-ODE_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_sigma, m_system->set_sigma); \
-FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
-FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
-FLEXT_CALLVAR_F(m_system->get_x1, m_system->set_x1); \
-FLEXT_CALLVAR_F(m_system->get_x2, m_system->set_x2); \
-FLEXT_CALLVAR_F(m_system->get_x3, m_system->set_x3);
-
-#define LORENZ_ATTRIBUTES \
-ODE_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("sigma",m_system->get_sigma, m_system->set_sigma); \
-FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
-FLEXT_ADDATTR_VAR("b",m_system->get_g, m_system->set_g); \
-FLEXT_ADDATTR_VAR("x1",m_system->get_x1, m_system->set_x1); \
-FLEXT_ADDATTR_VAR("x2",m_system->get_x2, m_system->set_x2); \
-FLEXT_ADDATTR_VAR("x3",m_system->get_x3, m_system->set_x3);
+#define LORENZ_CALLBACKS \
+ODE_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x1); \
+CHAOS_SYS_CALLBACKS(x2); \
+CHAOS_SYS_CALLBACKS(x3); \
+CHAOS_SYS_CALLBACKS(sigma); \
+CHAOS_SYS_CALLBACKS(r); \
+CHAOS_SYS_CALLBACKS(b);
+
+#define LORENZ_ATTRIBUTES \
+ODE_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x1); \
+CHAOS_SYS_ATTRIBUTE(x2); \
+CHAOS_SYS_ATTRIBUTE(x3); \
+CHAOS_SYS_ATTRIBUTE(sigma); \
+CHAOS_SYS_ATTRIBUTE(r); \
+CHAOS_SYS_ATTRIBUTE(b);
diff --git a/chaos/src/lozi_map.hpp b/chaos/src/lozi_map.hpp
index 50192c4..8bee655 100644
--- a/chaos/src/lozi_map.hpp
+++ b/chaos/src/lozi_map.hpp
@@ -30,12 +30,13 @@ class lozi:
{
public:
lozi()
- : m_a(1.4), m_b(0.3)
{
m_num_eq = 2;
m_data = new data_t[1];
- set_x(0.5);
- set_y(0.5);
+ CHAOS_SYS_INIT(x,0);
+ CHAOS_SYS_INIT(y,0);
+ CHAOS_SYS_INIT(a,1.4);
+ CHAOS_SYS_INIT(b,0.3);
}
~lozi()
@@ -49,78 +50,37 @@ public:
data_t y = m_data[1];
if (x > 0)
- m_data[0] = 1 + y - m_a * x;
+ m_data[0] = 1 + y - CHAOS_PARAMETER(a) * x;
else
- m_data[0] = 1 + y + m_a * x;
+ m_data[0] = 1 + y + CHAOS_PARAMETER(a) * x;
- m_data[1] = m_b * x;
+ m_data[1] = CHAOS_PARAMETER(b) * x;
}
+ CHAOS_SYSVAR_FUNCS(x, 0);
+ CHAOS_SYSVAR_FUNCS(y, 1);
- void set_x(t_float f)
- {
- m_data[0] = (data_t) f;
- }
-
- t_float get_x()
- {
- return (t_float)m_data[0];
- }
-
-
- void set_y(t_float f)
- {
- m_data[1] = (data_t) f;
- }
-
- t_float get_y()
- {
- return (t_float)m_data[1];
- }
-
+ CHAOS_SYSPAR_FUNCS(a);
- void set_a(t_float f)
+ CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b);
+ bool m_pred_b(t_float f)
{
- m_a = (data_t) f;
+ return (f != 0);
}
-
- t_float get_a()
- {
- return (t_float)m_a;
- }
-
-
- void set_b(t_float f)
- {
- if (f != 0)
- m_b = (data_t) f;
- else
- post("value for b %f out of range", f);
- }
-
- t_float get_b()
- {
- return (t_float)m_b;
- }
-
-
-private:
- data_t m_a;
- data_t m_b;
};
-#define LOZI_CALLBACKS \
-MAP_CALLBACKS; \
-FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \
-FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
-FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
+#define LOZI_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(a); \
+CHAOS_SYS_CALLBACKS(b); \
+CHAOS_SYS_CALLBACKS(x); \
+CHAOS_SYS_CALLBACKS(y);
-#define LOZI_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \
-FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
-FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
+#define LOZI_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(a); \
+CHAOS_SYS_ATTRIBUTE(b); \
+CHAOS_SYS_ATTRIBUTE(x); \
+CHAOS_SYS_ATTRIBUTE(y);
diff --git a/chaos/src/sine_map.hpp b/chaos/src/sine_map.hpp
index dd62458..d083270 100644
--- a/chaos/src/sine_map.hpp
+++ b/chaos/src/sine_map.hpp
@@ -34,7 +34,7 @@ public:
{
m_num_eq = 1;
m_data = new data_t[1];
- set_x(0.5);
+ CHAOS_SYS_INIT(x,0);
}
~sine()
@@ -47,26 +47,20 @@ public:
m_data[0] = sin (M_PI * m_data[0]);
}
- 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);
- }
+ CHAOS_SYSVAR_FUNCS_PRED(x, m_pred);
- t_float get_x()
+ bool m_pred(t_float f)
{
- return (t_float)m_data[0];
+ return (f >= 0) && (f <= 1);
}
-
};
-#define SINE_CALLBACKS \
-MAP_CALLBACKS \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+#define SINE_CALLBACKS \
+MAP_CALLBACKS \
+CHAOS_SYS_CALLBACKS(x);
+
+#define SINE_ATTRIBUTES \
+MAP_ATTRIBUTES \
+CHAOS_SYS_ATTRIBUTE(x);
-#define SINE_ATTRIBUTES \
-MAP_ATTRIBUTES \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
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);
diff --git a/chaos/src/tent_map.hpp b/chaos/src/tent_map.hpp
index 16de333..137599a 100644
--- a/chaos/src/tent_map.hpp
+++ b/chaos/src/tent_map.hpp
@@ -33,7 +33,7 @@ public:
{
m_num_eq = 1;
m_data = new data_t[1];
- set_x(0.5);
+ CHAOS_SYS_INIT(x, 0.5);
}
~tent()
@@ -50,14 +50,21 @@ public:
else
m_data[0] = 2.f * (1.f - data);
}
+
+ CHAOS_SYSPAR_FUNCS_PRED(x, m_pred_x);
+ bool m_pred_x(t_float f)
+ {
+ return (f >= 0) && (f < 1);
+ }
};
-#define LOGISTIC_CALLBACKS \
-MAP_CALLBACKS \
-FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+#define LOGISTIC_CALLBACKS \
+MAP_CALLBACKS \
+CHAOS_SYS_CALLBACKS(x);
+
+#define LOGISTIC_ATTRIBUTES \
+MAP_ATTRIBUTES \
+CHAOS_SYS_ATTRIBUTE(x);
-#define LOGISTIC_ATTRIBUTES \
-MAP_ATTRIBUTES \
-FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);