diff options
41 files changed, 670 insertions, 286 deletions
diff --git a/chaos/src/Makefile.am b/chaos/src/Makefile.am index a524de5..6812701 100644 --- a/chaos/src/Makefile.am +++ b/chaos/src/Makefile.am @@ -4,12 +4,16 @@ BUILT_SOURCES = main.cpp ode_base.cpp chaos_base.cpp chaos_dsp.cpp \ bernoulli_dsp.cpp bernoulli_msg.cpp \ bungalow_tent_dsp.cpp bungalow_tent_msg.cpp \ circle_map_dsp.cpp circle_map_msg.cpp \ + coupled_logistic_dsp.cpp coupled_logistic_msg.cpp \ + driven_anharmonic_dsp.cpp driven_anharmonic_msg.cpp \ + driven_van_der_pol_dsp.cpp driven_van_der_pol_msg.cpp \ gauss_map_dsp.cpp gauss_map_msg.cpp \ henon_map_dsp.cpp henon_map_msg.cpp \ ikeda_laser_map_dsp.cpp ikeda_laser_map_msg.cpp \ logistic_dsp.cpp logistic_msg.cpp \ lorenz_dsp.cpp lorenz_msg.cpp \ lozi_map_dsp.cpp lozi_map_msg.cpp \ + roessler_dsp.cpp roessler_msg.cpp \ sine_map_dsp.cpp sine_map_msg.cpp \ standard_map_dsp.cpp standard_map_msg.cpp \ tent_map_dsp.cpp tent_map_msg.cpp diff --git a/chaos/src/bernoulli_dsp.cpp b/chaos/src/bernoulli_dsp.cpp index 8e8d0da..3cf9480 100644 --- a/chaos/src/bernoulli_dsp.cpp +++ b/chaos/src/bernoulli_dsp.cpp @@ -21,14 +21,4 @@ #include "bernoulli_map.hpp" #include "chaos_dsp.hpp" -class bernoulli_dsp: - public chaos_dsp<bernoulli> -{ - CHAOS_DSP_INIT(bernoulli, BERNOULLI_ATTRIBUTES); - - BERNOULLI_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("bernoulli~", bernoulli_dsp); +CHAOS_DSP_CLASS(bernoulli, BERNOULLI); diff --git a/chaos/src/bungalow_tent_dsp.cpp b/chaos/src/bungalow_tent_dsp.cpp index 33bef1c..111a96a 100644 --- a/chaos/src/bungalow_tent_dsp.cpp +++ b/chaos/src/bungalow_tent_dsp.cpp @@ -21,14 +21,4 @@ #include "bungalow_tent_map.hpp" #include "chaos_dsp.hpp" -class bungalow_tent_dsp: - public chaos_dsp<bungalow_tent> -{ - CHAOS_DSP_INIT(bungalow_tent, BUNGALOW_TENT_ATTRIBUTES); - - BUNGALOW_TENT_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("bungalow_tent~", bungalow_tent_dsp); +CHAOS_DSP_CLASS(bungalow_tent,BUNGALOW_TENT); diff --git a/chaos/src/bungalow_tent_msg.cpp b/chaos/src/bungalow_tent_msg.cpp index 8c6b1be..6c3ae7e 100644 --- a/chaos/src/bungalow_tent_msg.cpp +++ b/chaos/src/bungalow_tent_msg.cpp @@ -21,14 +21,4 @@ #include "bungalow_tent_map.hpp" #include "chaos_msg.hpp" -class bungalow_tent_msg: - public chaos_msg<bungalow_tent> -{ - CHAOS_MSG_INIT(bungalow_tent, BUNGALOW_TENT_ATTRIBUTES); - - BUNGALOW_TENT_CALLBACKS; -}; - - - -FLEXT_LIB_V("bungalow_tent", bungalow_tent_msg); +CHAOS_MSG_CLASS(bungalow_tent, BUNGALOW_TENT); diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp index 65a9c46..4bf3ea3 100644 --- a/chaos/src/chaos.hpp +++ b/chaos/src/chaos.hpp @@ -23,6 +23,7 @@ #define FLEXT_ATTRIBUTES 1 #include "flext.h" +#include "chaos_defs.hpp" /* 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 795383e..ce6fc11 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -21,7 +21,6 @@ #ifndef __chaos_base_hpp #include "chaos.hpp" -#include "chaos_defs.hpp" class chaos_base { diff --git a/chaos/src/chaos_defs.hpp b/chaos/src/chaos_defs.hpp index ae86223..b4c2b46 100644 --- a/chaos/src/chaos_defs.hpp +++ b/chaos/src/chaos_defs.hpp @@ -131,7 +131,47 @@ set_##NAME(VALUE); - +/* macros for class generation */ +#define CHAOS_DSP_CLASS(CLASSNAME,CLASSNAME_UC) \ +class CLASSNAME##_dsp: \ + public chaos_dsp<CLASSNAME> \ +{ \ + CHAOS_DSP_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_DSP_V(#CLASSNAME"~", CLASSNAME##_dsp); + +#define CHAOS_DSP_CLASS_NAME(CLASSNAME,CLASSNAME_UC, NAME) \ +class CLASSNAME##_dsp: \ + public chaos_dsp<CLASSNAME> \ +{ \ + CHAOS_DSP_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_DSP_V(#NAME, CLASSNAME##_dsp); + + +#define CHAOS_MSG_CLASS(CLASSNAME,CLASSNAME_UC) \ +class CLASSNAME##_msg: \ + public chaos_msg<CLASSNAME> \ +{ \ + CHAOS_MSG_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#CLASSNAME, CLASSNAME##_msg); + +#define CHAOS_MSG_CLASS_NAME(CLASSNAME,CLASSNAME_UC, NAME) \ +class CLASSNAME##_msg: \ + public chaos_msg<CLASSNAME> \ +{ \ + CHAOS_MSG_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#NAME, CLASSNAME##_msg); + +#define CHAOS_ADD(NAME) \ +FLEXT_DSP_SETUP(NAME##_dsp); \ +FLEXT_SETUP(NAME##_msg); #define __chaos_defs_hpp #endif /* __chaos_defs_hpp */ diff --git a/chaos/src/circle_map_dsp.cpp b/chaos/src/circle_map_dsp.cpp index fbd7c9d..e5ddef4 100644 --- a/chaos/src/circle_map_dsp.cpp +++ b/chaos/src/circle_map_dsp.cpp @@ -21,14 +21,4 @@ #include "circle_map.hpp" #include "chaos_dsp.hpp" -class circle_map_dsp: - public chaos_dsp<circle_map> -{ - CHAOS_DSP_INIT(circle_map, CIRCLE_MAP_ATTRIBUTES); - - CIRCLE_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("circle_map~", circle_map_dsp); +CHAOS_DSP_CLASS(circle_map, CIRCLE_MAP) diff --git a/chaos/src/circle_map_msg.cpp b/chaos/src/circle_map_msg.cpp index 3e771b3..7fa6c9b 100644 --- a/chaos/src/circle_map_msg.cpp +++ b/chaos/src/circle_map_msg.cpp @@ -21,14 +21,4 @@ #include "circle_map.hpp" #include "chaos_msg.hpp" -class circle_map_msg: - public chaos_msg<circle_map> -{ - CHAOS_MSG_INIT(circle_map, CIRCLE_MAP_ATTRIBUTES); - - CIRCLE_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("circle_map", circle_map_msg); +CHAOS_MSG_CLASS(circle_map, CIRCLE_MAP); diff --git a/chaos/src/coupled_logistic.hpp b/chaos/src/coupled_logistic.hpp new file mode 100644 index 0000000..eb5b326 --- /dev/null +++ b/chaos/src/coupled_logistic.hpp @@ -0,0 +1,82 @@ +// +// +// 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" + +// coupled_logistic map: x[n+1] = r * x[n] * (1 - x[n]) + e * (y[n] - x[n]) +// y[n+1] = r * y[n] * (1 - y[n]) + e * (x[t] - y[t]) +// 1 <= r <= 4 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class coupled_logistic: + public map_base +{ +public: + coupled_logistic() + { + m_num_eq = 2; + m_data = new data_t[2]; + CHAOS_SYS_INIT(e, 0.06); + CHAOS_SYS_INIT(r, 3.7); + CHAOS_SYS_INIT(x, 0.1); + CHAOS_SYS_INIT(x, 0.2); + } + + ~coupled_logistic() + { + delete m_data; + } + + virtual void m_step() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + data_t e = CHAOS_PARAMETER(e); + data_t r = CHAOS_PARAMETER(r); + m_data[0] = r * x * (1.f - x) + e * (y - x); + m_data[1] = r * y * (1.f - y) + e * (x - y); + } + + CHAOS_SYSPAR_FUNCS(e); + CHAOS_SYSPAR_FUNCS_PRED(r, m_pred_r); + bool m_pred_r(t_float f) + { + return (f > 0) && (f < 4); + } + + CHAOS_SYSVAR_FUNCS(x, 0); + CHAOS_SYSVAR_FUNCS(y, 0); + +}; + +#define COUPLED_LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(e); \ +CHAOS_SYS_CALLBACKS(r); \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); + +#define COUPLED_LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(e); \ +CHAOS_SYS_ATTRIBUTE(r); \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); + diff --git a/chaos/src/coupled_logistic_dsp.cpp b/chaos/src/coupled_logistic_dsp.cpp new file mode 100644 index 0000000..166ca79 --- /dev/null +++ b/chaos/src/coupled_logistic_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// 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 "coupled_logistic.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(coupled_logistic, COUPLED_LOGISTIC) + diff --git a/chaos/src/coupled_logistic_msg.cpp b/chaos/src/coupled_logistic_msg.cpp new file mode 100644 index 0000000..994a79d --- /dev/null +++ b/chaos/src/coupled_logistic_msg.cpp @@ -0,0 +1,34 @@ +// +// +// 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 "coupled_logistic.hpp" +#include "chaos_msg.hpp" + +class coupled_logistic_msg: + public chaos_msg<coupled_logistic> +{ + CHAOS_MSG_INIT(coupled_logistic, COUPLED_LOGISTIC_ATTRIBUTES); + + COUPLED_LOGISTIC_CALLBACKS; +}; + + + +FLEXT_LIB_V("coupled_logistic", coupled_logistic_msg); diff --git a/chaos/src/driven_anharmonic.hpp b/chaos/src/driven_anharmonic.hpp new file mode 100644 index 0000000..8c319e9 --- /dev/null +++ b/chaos/src/driven_anharmonic.hpp @@ -0,0 +1,111 @@ +// +// +// 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" +#include <cmath> + +// driven anharmonic: +// d2u/dt2 + a * du/dt + b*u + c * u*u*u = k1 + k2*cos(Omega*t) +// equivalent: +// du1/dt = u2 +// du2/dt = -a*u2 - b*u1 -c*u*u*u + k1 + k2*cos(Omega*t) +// taken from Willi-Hans Steeb: Chaos and Fractals + +class driven_anharmonic + : public ode_base +{ +public: + driven_anharmonic() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(method,0); + CHAOS_SYS_INIT(dt,0.01); + + CHAOS_SYS_INIT(u1,0); + CHAOS_SYS_INIT(u2,1); + + CHAOS_SYS_INIT(a,1); + CHAOS_SYS_INIT(b,-10); + CHAOS_SYS_INIT(c,100); + CHAOS_SYS_INIT(Omega,3.5); + CHAOS_SYS_INIT(k1,0.01); + CHAOS_SYS_INIT(k2,1); + + ode_base_alloc(); + m_t = 0; + } + + ~driven_anharmonic() + { + ode_base_free(); + delete m_data; + } + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t u1 = data[0], u2 = data[1]; + + deriv[0] = u2; + deriv[1] = - CHAOS_PARAMETER(a) * u2 - CHAOS_PARAMETER(b) * u1 - + CHAOS_PARAMETER(c) * u1*u1*u1 + CHAOS_PARAMETER(k1) + + CHAOS_PARAMETER(k2) * cos (CHAOS_PARAMETER(Omega) * m_t); + m_t += m_dt; + + if (m_t > 2 * M_PI) + m_t = fmod(m_t, 2*M_PI); + } + + data_t m_t; + + CHAOS_SYSVAR_FUNCS(u1, 0); + CHAOS_SYSVAR_FUNCS(u2, 1); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); + CHAOS_SYSPAR_FUNCS(k1); + CHAOS_SYSPAR_FUNCS(k2); + CHAOS_SYSPAR_FUNCS(Omega); +}; + + +#define DRIVEN_ANHARMONIC_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(u1); \ +CHAOS_SYS_CALLBACKS(u2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); \ +CHAOS_SYS_CALLBACKS(k1); \ +CHAOS_SYS_CALLBACKS(k2); \ +CHAOS_SYS_CALLBACKS(Omega); + +#define DRIVEN_ANHARMONIC_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(u1); \ +CHAOS_SYS_ATTRIBUTE(u2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); \ +CHAOS_SYS_ATTRIBUTE(k1); \ +CHAOS_SYS_ATTRIBUTE(k2); \ +CHAOS_SYS_ATTRIBUTE(Omega); diff --git a/chaos/src/driven_anharmonic_dsp.cpp b/chaos/src/driven_anharmonic_dsp.cpp new file mode 100644 index 0000000..c26deaf --- /dev/null +++ b/chaos/src/driven_anharmonic_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// 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 "driven_anharmonic.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(driven_anharmonic, DRIVEN_ANHARMONIC); + diff --git a/chaos/src/driven_anharmonic_msg.cpp b/chaos/src/driven_anharmonic_msg.cpp new file mode 100644 index 0000000..934b0f0 --- /dev/null +++ b/chaos/src/driven_anharmonic_msg.cpp @@ -0,0 +1,25 @@ +// +// +// 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 "driven_anharmonic.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(driven_anharmonic, DRIVEN_ANHARMONIC); + diff --git a/chaos/src/driven_van_der_pol.hpp b/chaos/src/driven_van_der_pol.hpp new file mode 100644 index 0000000..23386b3 --- /dev/null +++ b/chaos/src/driven_van_der_pol.hpp @@ -0,0 +1,95 @@ +// +// +// 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" +#include <cmath> + +// driven van_der_pol: +// d2u/dt2 + a*(u*u -1)*du/dt + u = k * cos(Omega*t) +// equivalent: +// du1/dt = u2 +// du2/dt = -a*(u1*u1 - 1)*u2 - u1 + k*cos(u3) +// du3/dt = Omega +// taken from Willi-Hans Steeb: Chaos and Fractals + +class driven_van_der_pol + : public ode_base +{ +public: + driven_van_der_pol() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(method,0); + CHAOS_SYS_INIT(dt,0.01); + + CHAOS_SYS_INIT(u1,0.8); + CHAOS_SYS_INIT(u2,0.6); + CHAOS_SYS_INIT(u3,0.4); + + CHAOS_SYS_INIT(a,5); + CHAOS_SYS_INIT(Omega,2.466); + CHAOS_SYS_INIT(k,5); + + ode_base_alloc(); + } + + ~driven_van_der_pol() + { + ode_base_free(); + delete m_data; + } + + 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); + } + + 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(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(a); \ +CHAOS_SYS_ATTRIBUTE(k); \ +CHAOS_SYS_ATTRIBUTE(Omega); diff --git a/chaos/src/driven_van_der_pol_dsp.cpp b/chaos/src/driven_van_der_pol_dsp.cpp new file mode 100644 index 0000000..e0787ae --- /dev/null +++ b/chaos/src/driven_van_der_pol_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// 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 "driven_van_der_pol.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(driven_van_der_pol, DRIVEN_VAN_DER_POL); + diff --git a/chaos/src/driven_van_der_pol_msg.cpp b/chaos/src/driven_van_der_pol_msg.cpp new file mode 100644 index 0000000..488d96e --- /dev/null +++ b/chaos/src/driven_van_der_pol_msg.cpp @@ -0,0 +1,25 @@ +// +// +// 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 "driven_van_der_pol.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(driven_van_der_pol, DRIVEN_VAN_DER_POL); + diff --git a/chaos/src/gauss_map_dsp.cpp b/chaos/src/gauss_map_dsp.cpp index 70e659d..f9d849e 100644 --- a/chaos/src/gauss_map_dsp.cpp +++ b/chaos/src/gauss_map_dsp.cpp @@ -21,14 +21,4 @@ #include "gauss_map.hpp" #include "chaos_dsp.hpp" -class gauss_map_dsp: - public chaos_dsp<gauss_map> -{ - CHAOS_DSP_INIT(gauss_map, GAUSS_MAP_ATTRIBUTES); - - GAUSS_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("gauss_map~", gauss_map_dsp); +CHAOS_DSP_CLASS(gauss_map, GAUSS_MAP); diff --git a/chaos/src/gauss_map_msg.cpp b/chaos/src/gauss_map_msg.cpp index 61e0379..6d00da6 100644 --- a/chaos/src/gauss_map_msg.cpp +++ b/chaos/src/gauss_map_msg.cpp @@ -21,14 +21,4 @@ #include "gauss_map.hpp" #include "chaos_msg.hpp" -class gauss_map_msg: - public chaos_msg<gauss_map> -{ - CHAOS_MSG_INIT(gauss_map, GAUSS_MAP_ATTRIBUTES); - - GAUSS_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("gauss_map", gauss_map_msg); +CHAOS_MSG_CLASS(gauss_map, GAUSS_MAP); diff --git a/chaos/src/henon_map_dsp.cpp b/chaos/src/henon_map_dsp.cpp index f28e83f..f7e6103 100644 --- a/chaos/src/henon_map_dsp.cpp +++ b/chaos/src/henon_map_dsp.cpp @@ -21,14 +21,4 @@ #include "henon_map.hpp" #include "chaos_dsp.hpp" -class henon_dsp: - public chaos_dsp<henon> -{ - CHAOS_DSP_INIT(henon, HENON_ATTRIBUTES); - - HENON_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("henon~", henon_dsp); +CHAOS_DSP_CLASS_NAME(henon, HENON, "henon~"); diff --git a/chaos/src/henon_map_msg.cpp b/chaos/src/henon_map_msg.cpp index 10849fd..22cddde 100644 --- a/chaos/src/henon_map_msg.cpp +++ b/chaos/src/henon_map_msg.cpp @@ -21,14 +21,4 @@ #include "henon_map.hpp" #include "chaos_msg.hpp" -class henon_msg: - public chaos_msg<henon> -{ - CHAOS_MSG_INIT(henon, HENON_ATTRIBUTES); - - HENON_CALLBACKS; -}; - - - -FLEXT_LIB_V("henon", henon_msg); +CHAOS_MSG_CLASS_NAME(henon, HENON, "henon"); diff --git a/chaos/src/ikeda_laser_map_dsp.cpp b/chaos/src/ikeda_laser_map_dsp.cpp index cf7c9cf..ea18e21 100644 --- a/chaos/src/ikeda_laser_map_dsp.cpp +++ b/chaos/src/ikeda_laser_map_dsp.cpp @@ -21,14 +21,6 @@ #include "ikeda_laser_map.hpp" #include "chaos_dsp.hpp" -class ikeda_laser_map_dsp: - public chaos_dsp<ikeda_laser_map> -{ - CHAOS_DSP_INIT(ikeda_laser_map, IKEDA_LASER_MAP_ATTRIBUTES); - IKEDA_LASER_MAP_CALLBACKS; -}; +CHAOS_DSP_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, "ikeda"); - - -FLEXT_LIB_DSP_V("ikeda~", ikeda_laser_map_dsp); diff --git a/chaos/src/ikeda_laser_map_msg.cpp b/chaos/src/ikeda_laser_map_msg.cpp index d5f775a..1659159 100644 --- a/chaos/src/ikeda_laser_map_msg.cpp +++ b/chaos/src/ikeda_laser_map_msg.cpp @@ -21,14 +21,4 @@ #include "ikeda_laser_map.hpp" #include "chaos_msg.hpp" -class ikeda_laser_map_msg: - public chaos_msg<ikeda_laser_map> -{ - CHAOS_MSG_INIT(ikeda_laser_map, IKEDA_LASER_MAP_ATTRIBUTES); - - IKEDA_LASER_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("ikeda_laser_map", ikeda_laser_map_msg); +CHAOS_MSG_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, "ikeda~"); diff --git a/chaos/src/logistic_dsp.cpp b/chaos/src/logistic_dsp.cpp index 1c20a05..6a88748 100644 --- a/chaos/src/logistic_dsp.cpp +++ b/chaos/src/logistic_dsp.cpp @@ -21,14 +21,4 @@ #include "logistic_map.hpp" #include "chaos_dsp.hpp" -class logistic_dsp: - public chaos_dsp<logistic> -{ - CHAOS_DSP_INIT(logistic, LOGISTIC_ATTRIBUTES); - - LOGISTIC_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("logistic~", logistic_dsp); +CHAOS_DSP_CLASS(logistic, LOGISTIC); diff --git a/chaos/src/logistic_msg.cpp b/chaos/src/logistic_msg.cpp index db7bcbf..60fef89 100644 --- a/chaos/src/logistic_msg.cpp +++ b/chaos/src/logistic_msg.cpp @@ -21,14 +21,4 @@ #include "logistic_map.hpp" #include "chaos_msg.hpp" -class logistic_msg: - public chaos_msg<logistic> -{ - CHAOS_MSG_INIT(logistic, LOGISTIC_ATTRIBUTES); - - LOGISTIC_CALLBACKS; -}; - - - -FLEXT_LIB_V("logistic", logistic_msg); +CHAOS_MSG_CLASS(logistic, LOGISTIC); diff --git a/chaos/src/lorenz.hpp b/chaos/src/lorenz.hpp index a31c151..c876b4a 100644 --- a/chaos/src/lorenz.hpp +++ b/chaos/src/lorenz.hpp @@ -44,8 +44,6 @@ public: CHAOS_SYS_INIT(r,40); ode_base_alloc(); - - set_method(0); } ~lorenz() diff --git a/chaos/src/lorenz_dsp.cpp b/chaos/src/lorenz_dsp.cpp index 8dc3763..e1b8ad1 100644 --- a/chaos/src/lorenz_dsp.cpp +++ b/chaos/src/lorenz_dsp.cpp @@ -21,14 +21,4 @@ #include "lorenz.hpp" #include "chaos_dsp.hpp" -class lorenz_dsp: - public chaos_dsp<lorenz> -{ - CHAOS_DSP_INIT(lorenz, LORENZ_ATTRIBUTES); - - LORENZ_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("lorenz~", lorenz_dsp); +CHAOS_DSP_CLASS(lorenz, LORENZ); diff --git a/chaos/src/lorenz_msg.cpp b/chaos/src/lorenz_msg.cpp index 6ad3ed9..09b02e8 100644 --- a/chaos/src/lorenz_msg.cpp +++ b/chaos/src/lorenz_msg.cpp @@ -21,14 +21,4 @@ #include "lorenz.hpp" #include "chaos_msg.hpp" -class lorenz_msg: - public chaos_msg<lorenz> -{ - CHAOS_MSG_INIT(lorenz, LORENZ_ATTRIBUTES); - - LORENZ_CALLBACKS; -}; - - - -FLEXT_LIB_V("lorenz", lorenz_msg); +CHAOS_MSG_CLASS(lorenz, LORENZ); diff --git a/chaos/src/lozi_map_dsp.cpp b/chaos/src/lozi_map_dsp.cpp index f8c4695..0448412 100644 --- a/chaos/src/lozi_map_dsp.cpp +++ b/chaos/src/lozi_map_dsp.cpp @@ -21,14 +21,4 @@ #include "lozi_map.hpp" #include "chaos_dsp.hpp" -class lozi_map_dsp: - public chaos_dsp<lozi_map> -{ - CHAOS_DSP_INIT(lozi_map, LOZI_MAP_ATTRIBUTES); - - LOZI_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("lozi~", lozi_map_dsp); +CHAOS_DSP_CLASS_NAME(lozi_map, LOZI_MAP, "lozi"); diff --git a/chaos/src/lozi_map_msg.cpp b/chaos/src/lozi_map_msg.cpp index 947e772..099cbec 100644 --- a/chaos/src/lozi_map_msg.cpp +++ b/chaos/src/lozi_map_msg.cpp @@ -21,14 +21,4 @@ #include "lozi_map.hpp" #include "chaos_msg.hpp" -class lozi_map_msg: - public chaos_msg<lozi_map> -{ - CHAOS_MSG_INIT(lozi_map, LOZI_MAP_ATTRIBUTES); - - LOZI_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("lozi", lozi_map_msg); +CHAOS_MSG_CLASS_NAME(lozi_map, LOZI_MAP, "lozi"); diff --git a/chaos/src/main.cpp b/chaos/src/main.cpp index 16f2908..84589f8 100644 --- a/chaos/src/main.cpp +++ b/chaos/src/main.cpp @@ -19,46 +19,28 @@ // Boston, MA 02111-1307, USA. #include "chaos.hpp" +#include "chaos_defs.hpp" void chaos_library_setup() { post("chaos~ version "PACKAGE_VERSION"\n"); - FLEXT_DSP_SETUP(bernoulli_dsp); - FLEXT_SETUP(bernoulli_msg); - - FLEXT_DSP_SETUP(bungalow_tent_dsp); - FLEXT_SETUP(bungalow_tent_msg); - - FLEXT_DSP_SETUP(circle_map_dsp); - FLEXT_SETUP(circle_map_msg); - - FLEXT_DSP_SETUP(gauss_map_dsp); - FLEXT_SETUP(gauss_map_msg); - - FLEXT_DSP_SETUP(henon_dsp); - FLEXT_SETUP(henon_msg); - - FLEXT_DSP_SETUP(ikeda_laser_map_dsp); - FLEXT_SETUP(ikeda_laser_map_msg); - - FLEXT_DSP_SETUP(logistic_dsp); - FLEXT_SETUP(logistic_msg); - - FLEXT_DSP_SETUP(lorenz_dsp); - FLEXT_SETUP(lorenz_msg); - - FLEXT_DSP_SETUP(lozi_map_dsp); - FLEXT_SETUP(lozi_map_msg); - - FLEXT_DSP_SETUP(sine_map_dsp); - FLEXT_SETUP(sine_map_msg); - - FLEXT_DSP_SETUP(standard_map_dsp); - FLEXT_SETUP(standard_map_msg); - - FLEXT_DSP_SETUP(tent_map_dsp); - FLEXT_SETUP(tent_map_msg); + CHAOS_ADD(bernoulli); + CHAOS_ADD(bungalow_tent); + CHAOS_ADD(circle_map); + CHAOS_ADD(coupled_logistic); + CHAOS_ADD(driven_anharmonic); + CHAOS_ADD(driven_van_der_pol); + CHAOS_ADD(gauss_map); + CHAOS_ADD(henon); + CHAOS_ADD(ikeda_laser_map); + CHAOS_ADD(logistic); + CHAOS_ADD(lorenz); + CHAOS_ADD(lozi_map); + CHAOS_ADD(roesser); + CHAOS_ADD(sine_map); + CHAOS_ADD(standard_map); + CHAOS_ADD(tent_map); } FLEXT_LIB_SETUP(chaos, chaos_library_setup); 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); diff --git a/chaos/src/roessler_dsp.cpp b/chaos/src/roessler_dsp.cpp new file mode 100644 index 0000000..e5ee834 --- /dev/null +++ b/chaos/src/roessler_dsp.cpp @@ -0,0 +1,24 @@ +// +// +// 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 "roessler.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(roessler,ROESSLER); diff --git a/chaos/src/roessler_msg.cpp b/chaos/src/roessler_msg.cpp new file mode 100644 index 0000000..aad1bf6 --- /dev/null +++ b/chaos/src/roessler_msg.cpp @@ -0,0 +1,24 @@ +// +// +// 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 "roessler.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(roessler,ROESSLER); diff --git a/chaos/src/sine_map_dsp.cpp b/chaos/src/sine_map_dsp.cpp index a2d2929..b1ca11e 100644 --- a/chaos/src/sine_map_dsp.cpp +++ b/chaos/src/sine_map_dsp.cpp @@ -21,14 +21,5 @@ #include "sine_map.hpp" #include "chaos_dsp.hpp" -class sine_map_dsp: - public chaos_dsp<sine_map> -{ - CHAOS_DSP_INIT(sine_map, SINE_MAP_ATTRIBUTES); - SINE_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("sine_map~", sine_map_dsp); +CHAOS_DSP_CLASS(sine_map, SINE_MAP); diff --git a/chaos/src/sine_map_msg.cpp b/chaos/src/sine_map_msg.cpp index 1d9a90e..aacc51c 100644 --- a/chaos/src/sine_map_msg.cpp +++ b/chaos/src/sine_map_msg.cpp @@ -21,14 +21,4 @@ #include "sine_map.hpp" #include "chaos_msg.hpp" -class sine_map_msg: - public chaos_msg<sine_map> -{ - CHAOS_MSG_INIT(sine_map, SINE_MAP_ATTRIBUTES); - - SINE_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("sine_map", sine_map_msg); +CHAOS_MSG_CLASS(sine_map, SINE_MAP); diff --git a/chaos/src/standard_map_dsp.cpp b/chaos/src/standard_map_dsp.cpp index fa7d3be..c16276c 100644 --- a/chaos/src/standard_map_dsp.cpp +++ b/chaos/src/standard_map_dsp.cpp @@ -21,14 +21,5 @@ #include "standard_map.hpp" #include "chaos_dsp.hpp" -class standard_map_dsp: - public chaos_dsp<standard_map> -{ - CHAOS_DSP_INIT(standard_map, STANDARD_MAP_ATTRIBUTES); - STANDARD_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_DSP_V("standard_map~", standard_map_dsp); +CHAOS_DSP_CLASS(standard_map, STANDARD_MAP); diff --git a/chaos/src/standard_map_msg.cpp b/chaos/src/standard_map_msg.cpp index fdd3bda..92c1084 100644 --- a/chaos/src/standard_map_msg.cpp +++ b/chaos/src/standard_map_msg.cpp @@ -21,14 +21,4 @@ #include "standard_map.hpp" #include "chaos_msg.hpp" -class standard_map_msg: - public chaos_msg<standard_map> -{ - CHAOS_MSG_INIT(standard_map, STANDARD_MAP_ATTRIBUTES); - - STANDARD_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("standard_map", standard_map_msg); +CHAOS_MSG_CLASS(standard_map, STANDARD_MAP); diff --git a/chaos/src/tent_map_dsp.cpp b/chaos/src/tent_map_dsp.cpp index 10fe609..44c909d 100644 --- a/chaos/src/tent_map_dsp.cpp +++ b/chaos/src/tent_map_dsp.cpp @@ -21,14 +21,6 @@ #include "tent_map.hpp" #include "chaos_dsp.hpp" -class tent_map_dsp: - public chaos_dsp<tent_map> -{ - CHAOS_DSP_INIT(tent_map, TENT_MAP_ATTRIBUTES); - TENT_MAP_CALLBACKS; -}; - - -FLEXT_LIB_DSP_V("tent~", tent_map_dsp); +CHAOS_DSP_CLASS_NAME(tent_map, TENT_MAP, "tent~"); diff --git a/chaos/src/tent_map_msg.cpp b/chaos/src/tent_map_msg.cpp index 60c3c63..3da82ab 100644 --- a/chaos/src/tent_map_msg.cpp +++ b/chaos/src/tent_map_msg.cpp @@ -21,14 +21,4 @@ #include "tent_map.hpp" #include "chaos_msg.hpp" -class tent_map_msg: - public chaos_msg<tent_map> -{ - CHAOS_MSG_INIT(tent_map, TENT_MAP_ATTRIBUTES); - - TENT_MAP_CALLBACKS; -}; - - - -FLEXT_LIB_V("tent", tent_map_msg); +CHAOS_MSG_CLASS_NAME(tent_map, TENT_MAP, "tent"); |