aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chaos/src/chaos.hpp13
-rw-r--r--chaos/src/chua.hpp262
-rw-r--r--chaos/src/driven_van_der_pol.hpp108
-rw-r--r--chaos/src/duffing.hpp124
-rw-r--r--chaos/src/latoomutgamma.hpp94
-rw-r--r--chaos/src/linear_congruental.hpp66
-rw-r--r--chaos/src/ode_base.hpp79
-rw-r--r--chaos/src/tent_map.hpp58
8 files changed, 395 insertions, 409 deletions
diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp
index 971d503..259f56e 100644
--- a/chaos/src/chaos.hpp
+++ b/chaos/src/chaos.hpp
@@ -38,27 +38,14 @@
/* internal we can work with a higher precision than pd */
#ifdef DOUBLE_PRECISION
typedef double data_t;
-#define CHAOS_ABS(x) fabs(x)
#else
typedef float data_t;
-#define CHAOS_ABS(x) fabsf(x)
#endif
-inline data_t chaos_mod(data_t x, data_t y)
-{
-#ifdef DOUBLE_PRECISION
- return fmod(x,y);
-#else
- return fmodf(x,y);
-#endif
-}
-
inline data_t rand_range(data_t low, data_t high)
{
return low + ( (rand() * (high - low)) / RAND_MAX);
}
-
-
#define __chaos_hpp
#endif /* __chaos_hpp */
diff --git a/chaos/src/chua.hpp b/chaos/src/chua.hpp
index f8c6e31..7669a24 100644
--- a/chaos/src/chua.hpp
+++ b/chaos/src/chua.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// 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,
@@ -23,143 +23,143 @@
// chua system: dx1/dt = alpha * (x2 - x1 - h(x1))
// dx2/dt = x1 - x2 + x3
// dx3/dt = - beta * x2
-//
+//
// with h(x) = b*x + a - b (for x > 1)
// a*x (for -1 <= x <= 1
// b*x - a + b (for x < -1)
-//
+//
// taken from Viktor Avrutin: lecture notes
class chua:
- public ode_base<3>
+ public ode_base<3>
{
public:
- chua()
- {
- CHAOS_PAR_INIT(method,2);
- CHAOS_PAR_INIT(dt,0.05);
-
- CHAOS_SYS_INIT(x1,1,1);
- CHAOS_SYS_INIT(x2,1,1);
- CHAOS_SYS_INIT(x3,1,1);
-
- CHAOS_PAR_INIT(a,140);
- CHAOS_PAR_INIT(b,30);
- CHAOS_PAR_INIT(alpha,30);
- CHAOS_PAR_INIT(beta,30);
- }
-
- virtual void m_system(data_t* deriv, data_t* data)
- {
- data_t x1 = data[0];
- data_t x2 = data[1];
- data_t x3 = data[2];
-
- data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b);
-
- data_t h;
-
- if (x1 > 1)
- h = b*x1 + a - b;
- else if (x1 < -1)
- h = b*x1 - a + b;
- else
- h = a*x1;
-
- deriv[0] = CHAOS_PARAMETER(alpha) * (x2 - x1 - h);
- deriv[1] = x1 - x2 + x3;
- deriv[2] = - CHAOS_PARAMETER(beta) * x2;
- }
-
- virtual void m_verify()
- {
- data_t x1 = m_data[0];
- data_t x2 = m_data[1];
- data_t x3 = m_data[2];
-
- if ( CHAOS_ABS(x3) < 1e-10)
- x3 = 0;
-
- if (x1 == 0 && x2 == 0 && x3 == 0) /* fixpoint at (0,0,0) */
- {
- reset();
- return;
- }
- else
- {
- data_t c = m_c;
- if (m_c)
- {
- data_t mc = - c;
- if (x1 == c && x3 == mc) /* fixpoint at (c,0,-c) */
- {
- reset();
- return;
- }
- if (x1 == mc && x3 == c) /* fixpoint at (-c,0,c) */
- {
- reset();
- return;
- }
- }
- }
- }
-
- inline void reset()
- {
- m_data[0] = rand_range(-1,1);
- m_data[1] = rand_range(-1,1);
- m_data[2] = rand_range(-1,1);
- }
-
- CHAOS_SYSVAR_FUNCS(x1, 0);
- CHAOS_SYSVAR_FUNCS(x2, 1);
- CHAOS_SYSVAR_FUNCS(x3, 2);
-
- /* due to stability issues, we hook into the predicates */
- data_t m_c;
- bool m_pred_a(data_t a)
- {
- data_t b = CHAOS_PARAMETER(b);
- m_c = (b - a) / (b + 1);
- return true;
- }
-
- bool m_pred_b(data_t b)
- {
- if (b == -1)
- m_c = 0;
- else
- {
- data_t a = CHAOS_PARAMETER(a);
- m_c = (b - a) / (b + 1);
- }
- return true;
- }
-
- CHAOS_SYSPAR_FUNCS_PRED(a, m_pred_a);
- CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b);
- CHAOS_SYSPAR_FUNCS(alpha);
- CHAOS_SYSPAR_FUNCS(beta);
+ chua()
+ {
+ CHAOS_PAR_INIT(method,2);
+ CHAOS_PAR_INIT(dt,0.05);
+
+ CHAOS_SYS_INIT(x1,1,1);
+ CHAOS_SYS_INIT(x2,1,1);
+ CHAOS_SYS_INIT(x3,1,1);
+
+ CHAOS_PAR_INIT(a,140);
+ CHAOS_PAR_INIT(b,30);
+ CHAOS_PAR_INIT(alpha,30);
+ CHAOS_PAR_INIT(beta,30);
+ }
+
+ virtual void m_system(data_t* deriv, data_t* data)
+ {
+ data_t x1 = data[0];
+ data_t x2 = data[1];
+ data_t x3 = data[2];
+
+ data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b);
+
+ data_t h;
+
+ if (x1 > 1)
+ h = b*x1 + a - b;
+ else if (x1 < -1)
+ h = b*x1 - a + b;
+ else
+ h = a*x1;
+
+ deriv[0] = CHAOS_PARAMETER(alpha) * (x2 - x1 - h);
+ deriv[1] = x1 - x2 + x3;
+ deriv[2] = - CHAOS_PARAMETER(beta) * x2;
+ }
+
+ virtual void m_verify()
+ {
+ data_t x1 = m_data[0];
+ data_t x2 = m_data[1];
+ data_t x3 = m_data[2];
+
+ if ( std::abs(x3) < 1e-10)
+ x3 = 0;
+
+ if (x1 == 0 && x2 == 0 && x3 == 0) /* fixpoint at (0,0,0) */
+ {
+ reset();
+ return;
+ }
+ else
+ {
+ data_t c = m_c;
+ if (m_c)
+ {
+ data_t mc = - c;
+ if (x1 == c && x3 == mc) /* fixpoint at (c,0,-c) */
+ {
+ reset();
+ return;
+ }
+ if (x1 == mc && x3 == c) /* fixpoint at (-c,0,c) */
+ {
+ reset();
+ return;
+ }
+ }
+ }
+ }
+
+ inline void reset()
+ {
+ m_data[0] = rand_range(-1,1);
+ m_data[1] = rand_range(-1,1);
+ m_data[2] = rand_range(-1,1);
+ }
+
+ CHAOS_SYSVAR_FUNCS(x1, 0);
+ CHAOS_SYSVAR_FUNCS(x2, 1);
+ CHAOS_SYSVAR_FUNCS(x3, 2);
+
+ /* due to stability issues, we hook into the predicates */
+ data_t m_c;
+ bool m_pred_a(data_t a)
+ {
+ data_t b = CHAOS_PARAMETER(b);
+ m_c = (b - a) / (b + 1);
+ return true;
+ }
+
+ bool m_pred_b(data_t b)
+ {
+ if (b == -1)
+ m_c = 0;
+ else
+ {
+ data_t a = CHAOS_PARAMETER(a);
+ m_c = (b - a) / (b + 1);
+ }
+ return true;
+ }
+
+ CHAOS_SYSPAR_FUNCS_PRED(a, m_pred_a);
+ CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b);
+ CHAOS_SYSPAR_FUNCS(alpha);
+ CHAOS_SYSPAR_FUNCS(beta);
};
-#define CHUA_CALLBACKS \
-ODE_CALLBACKS; \
-CHAOS_SYS_CALLBACKS(alpha); \
-CHAOS_SYS_CALLBACKS(beta); \
-CHAOS_SYS_CALLBACKS(a); \
-CHAOS_SYS_CALLBACKS(b); \
-CHAOS_SYS_CALLBACKS(x1); \
-CHAOS_SYS_CALLBACKS(x2); \
+#define CHUA_CALLBACKS \
+ODE_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(alpha); \
+CHAOS_SYS_CALLBACKS(beta); \
+CHAOS_SYS_CALLBACKS(a); \
+CHAOS_SYS_CALLBACKS(b); \
+CHAOS_SYS_CALLBACKS(x1); \
+CHAOS_SYS_CALLBACKS(x2); \
CHAOS_SYS_CALLBACKS(x3);
-#define CHUA_ATTRIBUTES \
-ODE_ATTRIBUTES; \
-CHAOS_SYS_ATTRIBUTE(a); \
-CHAOS_SYS_ATTRIBUTE(b); \
-CHAOS_SYS_ATTRIBUTE(alpha); \
-CHAOS_SYS_ATTRIBUTE(beta); \
-CHAOS_SYS_ATTRIBUTE(x1); \
-CHAOS_SYS_ATTRIBUTE(x2); \
+#define CHUA_ATTRIBUTES \
+ODE_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(a); \
+CHAOS_SYS_ATTRIBUTE(b); \
+CHAOS_SYS_ATTRIBUTE(alpha); \
+CHAOS_SYS_ATTRIBUTE(beta); \
+CHAOS_SYS_ATTRIBUTE(x1); \
+CHAOS_SYS_ATTRIBUTE(x2); \
CHAOS_SYS_ATTRIBUTE(x3);
diff --git a/chaos/src/driven_van_der_pol.hpp b/chaos/src/driven_van_der_pol.hpp
index 3c034d2..31c2e2d 100644
--- a/chaos/src/driven_van_der_pol.hpp
+++ b/chaos/src/driven_van_der_pol.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// 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,
@@ -30,66 +30,66 @@
// taken from Willi-Hans Steeb: Chaos and Fractals
class driven_van_der_pol
- : public ode_base<3>
+ : public ode_base<3>
{
public:
- driven_van_der_pol()
- {
- CHAOS_PAR_INIT(method,2);
- CHAOS_PAR_INIT(dt,0.01);
+ driven_van_der_pol()
+ {
+ CHAOS_PAR_INIT(method,2);
+ CHAOS_PAR_INIT(dt,0.01);
- CHAOS_SYS_INIT(u1,0.8, 0);
- CHAOS_SYS_INIT(u2,0.6, 1);
- CHAOS_SYS_INIT(u3,0.4, 2);
+ CHAOS_SYS_INIT(u1,0.8, 0);
+ CHAOS_SYS_INIT(u2,0.6, 1);
+ CHAOS_SYS_INIT(u3,0.4, 2);
- CHAOS_PAR_INIT(a,5);
- CHAOS_PAR_INIT(Omega,2.466);
- CHAOS_PAR_INIT(k,5);
- }
-
+ CHAOS_PAR_INIT(a,5);
+ CHAOS_PAR_INIT(Omega,2.466);
+ CHAOS_PAR_INIT(k,5);
+ }
- virtual void m_system(data_t* deriv, data_t* data)
- {
- data_t u1 = data[0], u2 = data[1], u3 = data[2];
-
- deriv[0] = u2;
- deriv[1] = - CHAOS_PARAMETER(a) * (u1*u1 -1) * u2 - u1 +
- CHAOS_PARAMETER(k)*cos(u3);
- deriv[2] = CHAOS_PARAMETER(Omega);
- }
-
- virtual void m_verify()
- {
- /* make sure to stay in the range of 2 pi */
- if (m_data[2] > 2*M_PI)
- m_data[2] = chaos_mod(m_data[2], 2*M_PI);
- }
- CHAOS_SYSVAR_FUNCS(u1, 0);
- CHAOS_SYSVAR_FUNCS(u2, 1);
- CHAOS_SYSVAR_FUNCS(u3, 2);
+ void m_system(data_t* deriv, data_t* data)
+ {
+ data_t u1 = data[0], u2 = data[1], u3 = data[2];
- CHAOS_SYSPAR_FUNCS(a);
- CHAOS_SYSPAR_FUNCS(k);
- CHAOS_SYSPAR_FUNCS(Omega);
+ deriv[0] = u2;
+ deriv[1] = - CHAOS_PARAMETER(a) * (u1*u1 -1) * u2 - u1 +
+ CHAOS_PARAMETER(k)*cos(u3);
+ deriv[2] = CHAOS_PARAMETER(Omega);
+ }
+
+ void m_verify()
+ {
+ /* make sure to stay in the range of 2 pi */
+ if (m_data[2] > 2*M_PI)
+ m_data[2] = std::fmod(m_data[2], data_t(2*M_PI));
+ }
+
+ CHAOS_SYSVAR_FUNCS(u1, 0);
+ CHAOS_SYSVAR_FUNCS(u2, 1);
+ CHAOS_SYSVAR_FUNCS(u3, 2);
+
+ CHAOS_SYSPAR_FUNCS(a);
+ CHAOS_SYSPAR_FUNCS(k);
+ CHAOS_SYSPAR_FUNCS(Omega);
};
-#define DRIVEN_VAN_DER_POL_CALLBACKS \
-ODE_CALLBACKS; \
-CHAOS_SYS_CALLBACKS(u1); \
-CHAOS_SYS_CALLBACKS(u2); \
-CHAOS_SYS_CALLBACKS(u3); \
-CHAOS_SYS_CALLBACKS(a); \
-CHAOS_SYS_CALLBACKS(k); \
+#define DRIVEN_VAN_DER_POL_CALLBACKS \
+ODE_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(u1); \
+CHAOS_SYS_CALLBACKS(u2); \
+CHAOS_SYS_CALLBACKS(u3); \
+CHAOS_SYS_CALLBACKS(a); \
+CHAOS_SYS_CALLBACKS(k); \
CHAOS_SYS_CALLBACKS(Omega);
-#define DRIVEN_VAN_DER_POL_ATTRIBUTES \
-ODE_ATTRIBUTES; \
-CHAOS_SYS_ATTRIBUTE(u1); \
-CHAOS_SYS_ATTRIBUTE(u2); \
-CHAOS_SYS_ATTRIBUTE(u3); \
-CHAOS_SYS_ATTRIBUTE(a); \
-CHAOS_SYS_ATTRIBUTE(k); \
+#define DRIVEN_VAN_DER_POL_ATTRIBUTES \
+ODE_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(u1); \
+CHAOS_SYS_ATTRIBUTE(u2); \
+CHAOS_SYS_ATTRIBUTE(u3); \
+CHAOS_SYS_ATTRIBUTE(a); \
+CHAOS_SYS_ATTRIBUTE(k); \
CHAOS_SYS_ATTRIBUTE(Omega);
diff --git a/chaos/src/duffing.hpp b/chaos/src/duffing.hpp
index ee7f7fb..b5d931c 100644
--- a/chaos/src/duffing.hpp
+++ b/chaos/src/duffing.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// chaos~
// Copyright (C) 2005 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,
@@ -22,73 +22,73 @@
// duffing equation: dx/dt = y
// dy/dt = x * (1 - x^2) + R*cos(omega * t) - gamma * y
-//
+//
class duffing:
- public ode_base<2>
+ public ode_base<2>
{
public:
- duffing()
- {
- CHAOS_PAR_INIT(method,0);
- CHAOS_PAR_INIT(dt,0.01);
-
- CHAOS_SYS_INIT(x, 0.5, 0);
- CHAOS_SYS_INIT(y, 0.5, 1);
-
- CHAOS_PAR_INIT(R, 0.4);
- CHAOS_PAR_INIT(omega, 1);
- CHAOS_PAR_INIT(gamma, 0.25);
-
- t = 0;
- }
-
-
- virtual void m_system(data_t* deriv, data_t* data)
- {
- data_t x = data[0], y = data[1];
-
- deriv[0] = y;
- deriv[1] = x * (1 - x*x) +
- CHAOS_PARAMETER(R) * cos( CHAOS_PARAMETER(omega) * t) -
- CHAOS_PARAMETER(gamma) * y;
- t += CHAOS_PARAMETER(dt);
- t = chaos_mod(t, M_PI);
- }
-
- virtual void m_verify()
- {
- if (m_data[0] == 0 && m_data[1] == 0 && m_data[2] == 0)
- for (int i = 0; i != 3; ++i)
- m_data[i] = rand_range(0,3);
- }
-
-
- CHAOS_SYSVAR_FUNCS(x,0);
- CHAOS_SYSVAR_FUNCS(y,1);
-
- CHAOS_SYSPAR_FUNCS(R);
- CHAOS_SYSPAR_FUNCS(omega);
- CHAOS_SYSPAR_FUNCS(gamma);
+ duffing()
+ {
+ CHAOS_PAR_INIT(method,0);
+ CHAOS_PAR_INIT(dt,0.01);
+
+ CHAOS_SYS_INIT(x, 0.5, 0);
+ CHAOS_SYS_INIT(y, 0.5, 1);
+
+ CHAOS_PAR_INIT(R, 0.4);
+ CHAOS_PAR_INIT(omega, 1);
+ CHAOS_PAR_INIT(gamma, 0.25);
+
+ t = 0;
+ }
+
+
+ virtual void m_system(data_t* deriv, data_t* data)
+ {
+ data_t x = data[0], y = data[1];
+
+ deriv[0] = y;
+ deriv[1] = x * (1 - x*x) +
+ CHAOS_PARAMETER(R) * cos( CHAOS_PARAMETER(omega) * t) -
+ CHAOS_PARAMETER(gamma) * y;
+ t += CHAOS_PARAMETER(dt);
+ t = std::fmod(t, data_t(M_PI));
+ }
+
+ virtual void m_verify()
+ {
+ if (m_data[0] == 0 && m_data[1] == 0 && m_data[2] == 0)
+ for (int i = 0; i != 3; ++i)
+ m_data[i] = rand_range(0,3);
+ }
+
+
+ CHAOS_SYSVAR_FUNCS(x,0);
+ CHAOS_SYSVAR_FUNCS(y,1);
+
+ CHAOS_SYSPAR_FUNCS(R);
+ CHAOS_SYSPAR_FUNCS(omega);
+ CHAOS_SYSPAR_FUNCS(gamma);
private:
- data_t t;
+ data_t t;
};
-#define DUFFING_CALLBACKS \
-ODE_CALLBACKS; \
-CHAOS_SYS_CALLBACKS(x); \
-CHAOS_SYS_CALLBACKS(y); \
-CHAOS_SYS_CALLBACKS(R); \
-CHAOS_SYS_CALLBACKS(gamma); \
+#define DUFFING_CALLBACKS \
+ODE_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x); \
+CHAOS_SYS_CALLBACKS(y); \
+CHAOS_SYS_CALLBACKS(R); \
+CHAOS_SYS_CALLBACKS(gamma); \
CHAOS_SYS_CALLBACKS(omega);
-#define DUFFING_ATTRIBUTES \
-ODE_ATTRIBUTES; \
-CHAOS_SYS_ATTRIBUTE(x); \
-CHAOS_SYS_ATTRIBUTE(y); \
-CHAOS_SYS_ATTRIBUTE(R); \
-CHAOS_SYS_ATTRIBUTE(gamma); \
+#define DUFFING_ATTRIBUTES \
+ODE_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x); \
+CHAOS_SYS_ATTRIBUTE(y); \
+CHAOS_SYS_ATTRIBUTE(R); \
+CHAOS_SYS_ATTRIBUTE(gamma); \
CHAOS_SYS_ATTRIBUTE(omega);
diff --git a/chaos/src/latoomutgamma.hpp b/chaos/src/latoomutgamma.hpp
index 0120745..040a071 100644
--- a/chaos/src/latoomutgamma.hpp
+++ b/chaos/src/latoomutgamma.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// 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,
@@ -27,59 +27,59 @@
// taken from Pickover: Chaos In Wonderland
class latoomutgamma
- : public map_base<2>
+ : public map_base<2>
{
public:
- latoomutgamma()
- {
- CHAOS_SYS_INIT(x1,0.5,0);
- CHAOS_SYS_INIT(x2,0.5,1);
-
- CHAOS_PAR_INIT(a,-0.966918);
- CHAOS_PAR_INIT(b,2.879879);
- }
+ latoomutgamma()
+ {
+ CHAOS_SYS_INIT(x1,0.5,0);
+ CHAOS_SYS_INIT(x2,0.5,1);
- void m_step()
- {
- data_t x1 = m_data[0], x2 = m_data[1];
- data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b);
- data_t tmp;
-
- tmp = sin(x1*b);
- m_data[0] = CHAOS_ABS(sin(x2*b)) + tmp*tmp;
- tmp = sin(x2*a);
- m_data[1] = CHAOS_ABS(sin(x1*a)) + tmp*tmp;
- }
+ CHAOS_PAR_INIT(a,-0.966918);
+ CHAOS_PAR_INIT(b,2.879879);
+ }
+ void m_step()
+ {
+ data_t x1 = m_data[0], x2 = m_data[1];
+ data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b);
+ data_t tmp;
- /* function has a fix point for x1 == x2 == 0 */
- void m_verify()
- {
- if (m_data[0] == 0 && m_data[1] == 0)
- for (int i = 0; i != 2; ++i)
- m_data[i] = rand_range(-1,1);
- }
-
- CHAOS_SYSVAR_FUNCS(x1, 0);
- CHAOS_SYSVAR_FUNCS(x2, 1);
+ tmp = sin(x1*b);
+ m_data[0] = std::abs(sin(x2*b)) + tmp*tmp;
+ tmp = sin(x2*a);
+ m_data[1] = std::abs(sin(x1*a)) + tmp*tmp;
+ }
- CHAOS_SYSPAR_FUNCS(a);
- CHAOS_SYSPAR_FUNCS(b);
+
+ /* function has a fix point for x1 == x2 == 0 */
+ void m_verify()
+ {
+ if (m_data[0] == 0 && m_data[1] == 0)
+ for (int i = 0; i != 2; ++i)
+ m_data[i] = rand_range(-1,1);
+ }
+
+ CHAOS_SYSVAR_FUNCS(x1, 0);
+ CHAOS_SYSVAR_FUNCS(x2, 1);
+
+ CHAOS_SYSPAR_FUNCS(a);
+ CHAOS_SYSPAR_FUNCS(b);
};
-#define LATOOMUTGAMMA_CALLBACKS \
-MAP_CALLBACKS; \
-CHAOS_SYS_CALLBACKS(x1); \
-CHAOS_SYS_CALLBACKS(x2); \
-CHAOS_SYS_CALLBACKS(a); \
+#define LATOOMUTGAMMA_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(x1); \
+CHAOS_SYS_CALLBACKS(x2); \
+CHAOS_SYS_CALLBACKS(a); \
CHAOS_SYS_CALLBACKS(b);
-#define LATOOMUTGAMMA_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-CHAOS_SYS_ATTRIBUTE(x1); \
-CHAOS_SYS_ATTRIBUTE(x2); \
-CHAOS_SYS_ATTRIBUTE(a); \
+#define LATOOMUTGAMMA_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(x1); \
+CHAOS_SYS_ATTRIBUTE(x2); \
+CHAOS_SYS_ATTRIBUTE(a); \
CHAOS_SYS_ATTRIBUTE(b);
diff --git a/chaos/src/linear_congruental.hpp b/chaos/src/linear_congruental.hpp
index 25bc837..9c6310f 100644
--- a/chaos/src/linear_congruental.hpp
+++ b/chaos/src/linear_congruental.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// 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,
@@ -25,43 +25,43 @@
// taken from Julien C. Sprott, Chaos and Time-Series Analysis
class linear_congruental:
- public map_base<2>
+ public map_base<2>
{
public:
- linear_congruental()
- {
- CHAOS_SYS_INIT(x, 0, 0);
-
- CHAOS_PAR_INIT(A, 1741);
- CHAOS_PAR_INIT(B, 54773);
- CHAOS_PAR_INIT(C, 259200);
- }
+ linear_congruental()
+ {
+ CHAOS_SYS_INIT(x, 0, 0);
+
+ CHAOS_PAR_INIT(A, 1741);
+ CHAOS_PAR_INIT(B, 54773);
+ CHAOS_PAR_INIT(C, 259200);
+ }
- void m_step()
- {
- data_t x = m_data[0];
+ void m_step()
+ {
+ data_t x = m_data[0];
- m_data[0] = chaos_mod( CHAOS_PARAMETER(A) * x + CHAOS_PARAMETER(B), CHAOS_PARAMETER(C));
- }
+ m_data[0] = std::fmod( CHAOS_PARAMETER(A) * x + CHAOS_PARAMETER(B), CHAOS_PARAMETER(C));
+ }
- CHAOS_SYSVAR_FUNCS(x,0);
+ CHAOS_SYSVAR_FUNCS(x,0);
- CHAOS_SYSPAR_FUNCS(A);
- CHAOS_SYSPAR_FUNCS(B);
- CHAOS_SYSPAR_FUNCS(C);
+ CHAOS_SYSPAR_FUNCS(A);
+ CHAOS_SYSPAR_FUNCS(B);
+ CHAOS_SYSPAR_FUNCS(C);
};
-#define LINEAR_CONGRUENTAL_CALLBACKS \
-MAP_CALLBACKS; \
-CHAOS_SYS_CALLBACKS(A); \
-CHAOS_SYS_CALLBACKS(B); \
-CHAOS_SYS_CALLBACKS(C); \
+#define LINEAR_CONGRUENTAL_CALLBACKS \
+MAP_CALLBACKS; \
+CHAOS_SYS_CALLBACKS(A); \
+CHAOS_SYS_CALLBACKS(B); \
+CHAOS_SYS_CALLBACKS(C); \
CHAOS_SYS_CALLBACKS(x);
-#define LINEAR_CONGRUENTAL_ATTRIBUTES \
-MAP_ATTRIBUTES; \
-CHAOS_SYS_ATTRIBUTE(A); \
-CHAOS_SYS_ATTRIBUTE(B); \
-CHAOS_SYS_ATTRIBUTE(C); \
+#define LINEAR_CONGRUENTAL_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+CHAOS_SYS_ATTRIBUTE(A); \
+CHAOS_SYS_ATTRIBUTE(B); \
+CHAOS_SYS_ATTRIBUTE(C); \
CHAOS_SYS_ATTRIBUTE(x);
diff --git a/chaos/src/ode_base.hpp b/chaos/src/ode_base.hpp
index f46332c..42478bc 100644
--- a/chaos/src/ode_base.hpp
+++ b/chaos/src/ode_base.hpp
@@ -76,59 +76,58 @@ protected:
data_t m_k1[dimensions];
data_t m_k2[dimensions];
data_t m_k3[dimensions];
- data_t m_tmp[dimensions];
-// data_t m_tmp[dimensions];
+ data_t m_tmp[dimensions];
virtual void m_system (data_t* deriv, data_t* data) = 0;
void rk1()
{
-// m_system (m_k0, m_data);
-// for (int i = 0; i != dimensions; ++i)
-// m_data[i] += m_dt * m_k0[i];
+ m_system (m_k0, chaos_base<dimensions>::m_data);
+ for (int i = 0; i != dimensions; ++i)
+ chaos_base<dimensions>::m_data[i] += m_dt * m_k0[i];
}
void rk2()
{
-// m_system (m_k0, m_data);
-// for (int i = 0; i != dimensions; ++i)
-// m_k0[i] = m_k0[i] * 0.5 * m_dt + m_data[i];
-//
-// m_system (m_k1, m_k0);
-// for (int i = 0; i != dimensions; ++i)
-// m_data[i] += m_dt * m_k1[i];
+ for (int i = 0; i != dimensions; ++i)
+ m_k0[i] = m_k0[i] * 0.5 * m_dt + chaos_base<dimensions>::m_data[i];
+
+ m_system (m_k0, chaos_base<dimensions>::m_data);
+ m_system (m_k1, m_k0);
+ for (int i = 0; i != dimensions; ++i)
+ chaos_base<dimensions>::m_data[i] += m_dt * m_k1[i];
}
void rk4()
{
-// m_system (m_k0, m_data);
-// for (int i = 0; i != dimensions; ++i)
-// {
-// m_k0[i] *= m_dt;
-// m_tmp[i] = m_data[i] + 0.5 * m_k0[i];
-// }
-//
-// m_system (m_k1, m_tmp);
-// for (int i = 0; i != dimensions; ++i)
-// {
-// m_k1[i] *= m_dt;
-// m_tmp[i] = m_data[i] + 0.5 * m_k1[i];
-// }
-//
-// m_system (m_k2, m_tmp);
-// for (int i = 0; i != dimensions; ++i)
-// {
-// m_k2[i] *= m_dt;
-// m_tmp[i] = m_data[i] + m_k2[i];
-// }
-//
-// m_system (m_k3, m_tmp);
-// for (int i = 0; i != dimensions; ++i)
-// m_k3[i] *= m_dt;
-//
-// for (int i = 0; i != dimensions; ++i)
-// m_data[i] += (m_k0[i] + 2. * (m_k1[i] + m_k2[i]) + m_k3[i])
-// / 6.;
+ m_system (m_k0, chaos_base<dimensions>::m_data);
+ for (int i = 0; i != dimensions; ++i)
+ {
+ m_k0[i] *= m_dt;
+ m_tmp[i] = chaos_base<dimensions>::m_data[i] + 0.5 * m_k0[i];
+ }
+
+ m_system (m_k1, m_tmp);
+ for (int i = 0; i != dimensions; ++i)
+ {
+ m_k1[i] *= m_dt;
+ m_tmp[i] = chaos_base<dimensions>::m_data[i] + 0.5 * m_k1[i];
+ }
+
+ m_system (m_k2, m_tmp);
+ for (int i = 0; i != dimensions; ++i)
+ {
+ m_k2[i] *= m_dt;
+ m_tmp[i] = chaos_base<dimensions>::m_data[i] + m_k2[i];
+ }
+
+ m_system (m_k3, m_tmp);
+ for (int i = 0; i != dimensions; ++i)
+ m_k3[i] *= m_dt;
+
+ for (int i = 0; i != dimensions; ++i)
+ chaos_base<dimensions>::m_data[i] += (m_k0[i] + 2. * (m_k1[i] + m_k2[i]) + m_k3[i])
+ / 6.;
}
};
diff --git a/chaos/src/tent_map.hpp b/chaos/src/tent_map.hpp
index f8f2c29..b0961ee 100644
--- a/chaos/src/tent_map.hpp
+++ b/chaos/src/tent_map.hpp
@@ -1,18 +1,18 @@
-//
-//
+//
+//
// 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,
@@ -26,36 +26,36 @@
class tent_map:
- public map_base<1>
+ public map_base<1>
{
public:
- tent_map()
- {
- CHAOS_SYS_INIT(x, 0.6,0);
- }
-
-
- void m_step()
- {
- data_t data = m_data[0];
-
- m_data[0] = 1 - 2*CHAOS_ABS(data);
- }
-
- CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x);
- bool m_pred_x(t_float f)
- {
- return (f > -1) && (f < 1);
- }
+ tent_map()
+ {
+ CHAOS_SYS_INIT(x, 0.6,0);
+ }
+
+
+ void m_step()
+ {
+ data_t data = m_data[0];
+
+ m_data[0] = 1 - 2*std::abs(data);
+ }
+
+ CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x);
+ bool m_pred_x(t_float f)
+ {
+ return (f > -1) && (f < 1);
+ }
};
-#define TENT_MAP_CALLBACKS \
-MAP_CALLBACKS \
+#define TENT_MAP_CALLBACKS \
+MAP_CALLBACKS \
CHAOS_SYS_CALLBACKS(x);
-#define TENT_MAP_ATTRIBUTES \
-MAP_ATTRIBUTES \
+#define TENT_MAP_ATTRIBUTES \
+MAP_ATTRIBUTES \
CHAOS_SYS_ATTRIBUTE(x);
-
+