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/Makefile.am | 5 ++ chaos/src/chaos.hpp | 4 +- chaos/src/chaos_defs.hpp | 1 + chaos/src/chaos_dsp.hpp | 160 +++++++++++++++++++++++++++------------- chaos/src/duffing_map.hpp | 76 +++++++++++++++++++ chaos/src/duffing_map_dsp.cpp | 24 ++++++ chaos/src/duffing_map_msg.cpp | 24 ++++++ chaos/src/latoocarfian.hpp | 98 ++++++++++++++++++++++++ chaos/src/latoocarfian_dsp.cpp | 24 ++++++ chaos/src/latoocarfian_msg.cpp | 24 ++++++ chaos/src/latoomutalpha.hpp | 88 ++++++++++++++++++++++ chaos/src/latoomutalpha_dsp.cpp | 24 ++++++ chaos/src/latoomutalpha_msg.cpp | 24 ++++++ chaos/src/latoomutbeta.hpp | 83 +++++++++++++++++++++ chaos/src/latoomutbeta_dsp.cpp | 24 ++++++ chaos/src/latoomutbeta_msg.cpp | 24 ++++++ chaos/src/latoomutgamma.hpp | 83 +++++++++++++++++++++ chaos/src/latoomutgamma_dsp.cpp | 24 ++++++ chaos/src/latoomutgamma_msg.cpp | 24 ++++++ chaos/src/logistic_map.hpp | 2 +- chaos/src/main.cpp | 7 +- 21 files changed, 792 insertions(+), 55 deletions(-) create mode 100644 chaos/src/duffing_map.hpp create mode 100644 chaos/src/duffing_map_dsp.cpp create mode 100644 chaos/src/duffing_map_msg.cpp create mode 100644 chaos/src/latoocarfian.hpp create mode 100644 chaos/src/latoocarfian_dsp.cpp create mode 100644 chaos/src/latoocarfian_msg.cpp create mode 100644 chaos/src/latoomutalpha.hpp create mode 100644 chaos/src/latoomutalpha_dsp.cpp create mode 100644 chaos/src/latoomutalpha_msg.cpp create mode 100644 chaos/src/latoomutbeta.hpp create mode 100644 chaos/src/latoomutbeta_dsp.cpp create mode 100644 chaos/src/latoomutbeta_msg.cpp create mode 100644 chaos/src/latoomutgamma.hpp create mode 100644 chaos/src/latoomutgamma_dsp.cpp create mode 100644 chaos/src/latoomutgamma_msg.cpp diff --git a/chaos/src/Makefile.am b/chaos/src/Makefile.am index 6812701..cbaa287 100644 --- a/chaos/src/Makefile.am +++ b/chaos/src/Makefile.am @@ -7,9 +7,14 @@ BUILT_SOURCES = main.cpp ode_base.cpp chaos_base.cpp chaos_dsp.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 \ + duffing_map_dsp.cpp duffing_map_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 \ + latoocarfian_dsp.cpp latoocarfian_msg.cpp \ + latoomutalpha_dsp.cpp latoomutalpha_msg.cpp \ + latoomutbeta_dsp.cpp latoomutbeta_msg.cpp \ + latoomutgamma_dsp.cpp latoomutgamma_msg.cpp \ logistic_dsp.cpp logistic_msg.cpp \ lorenz_dsp.cpp lorenz_msg.cpp \ lozi_map_dsp.cpp lozi_map_msg.cpp \ diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp index 4bf3ea3..231ecdc 100644 --- a/chaos/src/chaos.hpp +++ b/chaos/src/chaos.hpp @@ -28,8 +28,10 @@ /* 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 t_float data_t; +typedef float data_t; +#define CHAOS_ABS(x) fabsf(x) #endif diff --git a/chaos/src/chaos_defs.hpp b/chaos/src/chaos_defs.hpp index b4c2b46..08c47d4 100644 --- a/chaos/src/chaos_defs.hpp +++ b/chaos/src/chaos_defs.hpp @@ -106,6 +106,7 @@ void set_##NAME(t_float &f) \ m_system->set_##NAME(f); \ } \ FLEXT_CALLVAR_F(get_##NAME, set_##NAME); + #define CHAOS_SYS_CALLBACKS_I(NAME) \ public: \ diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp index 1eff6fc..c2f78b3 100644 --- a/chaos/src/chaos_dsp.hpp +++ b/chaos/src/chaos_dsp.hpp @@ -60,62 +60,118 @@ public: int m_phase; /* phase counter */ float m_sr; /* sample rate */ - int m_method; /* interpolation method */ + int m_imethod; /* interpolation method */ + + int get_imethod(int &i) + { + i = m_imethod; + } + + void set_imethod(int i) + { + if( (i >= 0) && (i <= 2) ) + m_imethod = i; + else + { + post("interpolation method out of range"); + return; + } + if( i != 2) + { + for (int j = 0; j != m_system->get_num_eq(); ++j) + { + m_nextvalues[i] = 0; + m_nextmidpts[i] = 0; + m_curves[i] = 0; + } + } + + } + + int get_freq(float &f) + { + f = m_freq; + } + + void set_freq(float f) + { + if( (f >= 0) && (f <= m_sr*0.5) ) + m_freq = f; + else + post("frequency out of range"); + } + FLEXT_CALLVAR_F(get_freq, set_freq); + FLEXT_CALLVAR_I(get_imethod, set_imethod); }; /* create constructor / destructor */ -#define CHAOS_DSP_INIT(SYSTEM, ATTRIBUTES) \ -FLEXT_HEADER(SYSTEM##_dsp, chaos_dsp) \ - \ -SYSTEM##_dsp(int argc, t_atom* argv ) \ -{ \ - m_system = new SYSTEM; \ - \ - int size = m_system->get_num_eq(); \ - \ - m_values = new t_float[size]; \ - m_slopes = new t_float[size]; \ - m_nextvalues = new t_float[size]; \ - m_nextmidpts = new t_float[size]; \ - m_curves = new t_float[size]; \ - \ - /* create inlets and zero arrays*/ \ - for (int i = 0; i != size; ++i) \ - { \ - AddOutSignal(); \ - m_values[i] = 0; \ - m_slopes[i] = 0; \ - m_nextvalues[i] = 0; \ - m_nextmidpts[i] = 0; \ - m_curves[i] = 0; \ - } \ - \ - \ - \ - m_freq = GetAFloat(argv[0]); \ - m_method = (char)GetAFloat(argv[1]); \ - m_phase = 0; \ - \ - FLEXT_ADDATTR_VAR1("frequency",m_freq); \ - FLEXT_ADDATTR_VAR1("method",m_method); \ - \ - ATTRIBUTES; \ -} \ - \ -~SYSTEM##_dsp() \ -{ \ - delete m_system; \ - delete m_values; \ - delete m_slopes; \ - delete m_nextvalues; \ - delete m_nextmidpts; \ - delete m_curves; \ -} \ - \ -FLEXT_ATTRVAR_F(m_freq); \ -FLEXT_ATTRVAR_I(m_method); +#define CHAOS_DSP_INIT(SYSTEM, ATTRIBUTES) \ +FLEXT_HEADER(SYSTEM##_dsp, chaos_dsp) \ + \ +SYSTEM##_dsp(int argc, t_atom* argv ) \ +{ \ + m_sr = 44100; /* assume default sampling rate (for max frequency) */ \ + m_system = new SYSTEM; \ + \ + int size = m_system->get_num_eq(); \ + \ + m_values = new t_float[size]; \ + m_slopes = new t_float[size]; \ + m_nextvalues = new t_float[size]; \ + m_nextmidpts = new t_float[size]; \ + m_curves = new t_float[size]; \ + \ + /* create inlets and zero arrays*/ \ + for (int i = 0; i != size; ++i) \ + { \ + AddOutSignal(); \ + m_values[i] = 0; \ + m_slopes[i] = 0; \ + m_nextvalues[i] = 0; \ + m_nextmidpts[i] = 0; \ + m_curves[i] = 0; \ + } \ + \ + FLEXT_ADDATTR_VAR("frequency", get_freq, set_freq); \ + FLEXT_ADDATTR_VAR("interpolation_method",get_imethod, set_imethod); \ + \ + if (argc > 0) \ + { \ + CHAOS_SYS_INIT(freq, GetAInt(argv[0])); \ + } \ + else \ + { \ + CHAOS_SYS_INIT(freq, 440); \ + } \ + \ + if (argc > 1) \ + { \ + CHAOS_SYS_INIT(imethod, GetAInt(argv[1])); \ + } \ + else \ + { \ + CHAOS_SYS_INIT(imethod, 0); \ + } \ + \ + m_phase = 0; \ + \ + ATTRIBUTES; \ +} \ + \ +~SYSTEM##_dsp() \ +{ \ + delete m_system; \ + delete m_values; \ + delete m_slopes; \ + delete m_nextvalues; \ + delete m_nextmidpts; \ + delete m_curves; \ +} \ + \ +FLEXT_ATTRVAR_F(m_freq); \ +FLEXT_ATTRVAR_I(m_imethod); @@ -129,7 +185,7 @@ void chaos_dsp::m_signal(int n, t_sample *const *insigs, return; } - switch (m_method) + switch (m_imethod) { case 0: m_signal_n(n, insigs, outsigs); diff --git a/chaos/src/duffing_map.hpp b/chaos/src/duffing_map.hpp new file mode 100644 index 0000000..71b8cbd --- /dev/null +++ b/chaos/src/duffing_map.hpp @@ -0,0 +1,76 @@ +// +// +// 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" + +// duffing map: x1[n+1] = x2[n] +// x2[n+1] = -b*x1[n] + a*x2[n] - pow(x2,3) +// +// taken from Viktor Avrutin: AnT-Demos-4.669 + +class duffing_map: + public map_base +{ +public: + duffing_map() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + CHAOS_SYS_INIT(x1, 0.5); + CHAOS_SYS_INIT(x2, 0.5); + CHAOS_SYS_INIT(a, 0.5); + CHAOS_SYS_INIT(b, 0.5); + } + + ~duffing_map() + { + delete m_data; + } + + virtual void m_step() + { + data_t x1 = m_data[0], x2 = m_data[1]; + + m_data[0] = x2; + m_data[1] = - CHAOS_PARAMETER(b)*x1 + CHAOS_PARAMETER(a)*x2 + - x2*x2*x2; + } + + CHAOS_SYSVAR_FUNCS(x1,0); + CHAOS_SYSVAR_FUNCS(x2,1); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); +}; + +#define DUFFING_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); + +#define DUFFING_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); + diff --git a/chaos/src/duffing_map_dsp.cpp b/chaos/src/duffing_map_dsp.cpp new file mode 100644 index 0000000..39e1439 --- /dev/null +++ b/chaos/src/duffing_map_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 "duffing_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(duffing_map,DUFFING_MAP); diff --git a/chaos/src/duffing_map_msg.cpp b/chaos/src/duffing_map_msg.cpp new file mode 100644 index 0000000..a18817f --- /dev/null +++ b/chaos/src/duffing_map_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 "duffing_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(duffing_map,DUFFING_MAP); diff --git a/chaos/src/latoocarfian.hpp b/chaos/src/latoocarfian.hpp new file mode 100644 index 0000000..c2a31a1 --- /dev/null +++ b/chaos/src/latoocarfian.hpp @@ -0,0 +1,98 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "map_base.hpp" +#include + +// latoocarfian model: x1[n+1] = sin(x2[n]*b) + c*sin(x1[n]*b) +// x2[n+1] = sin(x1[n]*a) + d*sin(x2[n]*a) +// -3 < a,b < 3 +// -0.5 < c,d < 1.5 +// taken from Pickover: Chaos In Wonderland + +class latoocarfian + : public map_base +{ +public: + latoocarfian() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(x1,0.5); + CHAOS_SYS_INIT(x2,0); + CHAOS_SYS_INIT(a,-0.966918); + CHAOS_SYS_INIT(b,2.879879); + CHAOS_SYS_INIT(c,0.765145); + CHAOS_SYS_INIT(d,0.744728); + } + + ~latoocarfian() + { + delete m_data; + } + + virtual void m_step() + { + data_t x1 = m_data[0], x2 = m_data[1]; + data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b), + c = CHAOS_PARAMETER(c), d = CHAOS_PARAMETER(d); + + m_data[0] = sin(x2*b) + c*sin(x1*b); + m_data[1] = sin(x1*a) + d*sin(x2*a); + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + + CHAOS_SYSPAR_FUNCS_PRED(a,m_pred_1); + CHAOS_SYSPAR_FUNCS_PRED(b,m_pred_1); + CHAOS_SYSPAR_FUNCS_PRED(c,m_pred_2); + CHAOS_SYSPAR_FUNCS_PRED(d,m_pred_2); + + bool m_pred_1(t_float f) + { + return (f > -3.f) && (f < 3.f); + } + + bool m_pred_2(t_float f) + { + return (f > -0.5) && (f < 1.5); + } +}; + + +#define LATOOCARFIAN_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); \ +CHAOS_SYS_CALLBACKS(d); + +#define LATOOCARFIAN_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); \ +CHAOS_SYS_ATTRIBUTE(d); diff --git a/chaos/src/latoocarfian_dsp.cpp b/chaos/src/latoocarfian_dsp.cpp new file mode 100644 index 0000000..81c773d --- /dev/null +++ b/chaos/src/latoocarfian_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 "latoocarfian.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(latoocarfian,LATOOCARFIAN); diff --git a/chaos/src/latoocarfian_msg.cpp b/chaos/src/latoocarfian_msg.cpp new file mode 100644 index 0000000..92be013 --- /dev/null +++ b/chaos/src/latoocarfian_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 "latoocarfian.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(latoocarfian,LATOOCARFIAN); diff --git a/chaos/src/latoomutalpha.hpp b/chaos/src/latoomutalpha.hpp new file mode 100644 index 0000000..6926d1b --- /dev/null +++ b/chaos/src/latoomutalpha.hpp @@ -0,0 +1,88 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "map_base.hpp" +#include + +// latoocarfian model, mutation alpha: +// x1[n+1] = sin(x2[n]*b) + pow(sin(x1[n]*b),2) + pow(sin(x1[n]*b),3) +// x2[n+1] = sin(x1[n]*a) + pow(sin(x2[n]*a),2) + pow(sin(x2[n]*c),3) +// taken from Pickover: Chaos In Wonderland + +class latoomutalpha + : public map_base +{ +public: + latoomutalpha() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(x1,0.5); + CHAOS_SYS_INIT(x2,0.2); + CHAOS_SYS_INIT(a,-0.966918); + CHAOS_SYS_INIT(b,2.879879); + CHAOS_SYS_INIT(c,0.765145); + } + + ~latoomutalpha() + { + delete m_data; + } + + virtual void m_step() + { + data_t x1 = m_data[0], x2 = m_data[1]; + data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b), + c = CHAOS_PARAMETER(c); + data_t tmp1, tmp2; + + tmp1 = sin(x1*b); + m_data[0] = sin(x2*b) + tmp1*tmp1 + tmp1*tmp1*tmp1; + tmp1 = sin(x2*a); + tmp2 = sin(x2*c); + m_data[1] = sin(x1*a) + tmp1*tmp1 + tmp2*tmp2*tmp2; + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); +}; + + +#define LATOOMUTALPHA_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); + + +#define LATOOMUTALPHA_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); diff --git a/chaos/src/latoomutalpha_dsp.cpp b/chaos/src/latoomutalpha_dsp.cpp new file mode 100644 index 0000000..c028ac6 --- /dev/null +++ b/chaos/src/latoomutalpha_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 "latoomutalpha.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(latoomutalpha,LATOOMUTALPHA); diff --git a/chaos/src/latoomutalpha_msg.cpp b/chaos/src/latoomutalpha_msg.cpp new file mode 100644 index 0000000..0726708 --- /dev/null +++ b/chaos/src/latoomutalpha_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 "latoomutalpha.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(latoomutalpha,LATOOMUTALPHA); diff --git a/chaos/src/latoomutbeta.hpp b/chaos/src/latoomutbeta.hpp new file mode 100644 index 0000000..4940be1 --- /dev/null +++ b/chaos/src/latoomutbeta.hpp @@ -0,0 +1,83 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "map_base.hpp" +#include + +// latoocarfian model, mutation beta: +// x1[n+1] = sin(x2[n]*b) + pow(sin(x1[n]*b),2) +// x2[n+1] = sin(x1[n]*a) + pow(sin(x2[n]*a),2) +// taken from Pickover: Chaos In Wonderland + +class latoomutbeta + : public map_base +{ +public: + latoomutbeta() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(x1,0.5); + CHAOS_SYS_INIT(x2,0.5); + CHAOS_SYS_INIT(a,-0.966918); + CHAOS_SYS_INIT(b,2.879879); + } + + ~latoomutbeta() + { + delete m_data; + } + + virtual 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] = sin(x2*b) + tmp*tmp; + tmp = sin(x2*a); + m_data[1] = sin(x1*a) + tmp*tmp; + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); +}; + + +#define LATOOMUTBETA_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); + + +#define LATOOMUTBETA_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); + diff --git a/chaos/src/latoomutbeta_dsp.cpp b/chaos/src/latoomutbeta_dsp.cpp new file mode 100644 index 0000000..b0f803e --- /dev/null +++ b/chaos/src/latoomutbeta_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 "latoomutbeta.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(latoomutbeta,LATOOMUTBETA); diff --git a/chaos/src/latoomutbeta_msg.cpp b/chaos/src/latoomutbeta_msg.cpp new file mode 100644 index 0000000..41e5aaf --- /dev/null +++ b/chaos/src/latoomutbeta_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 "latoomutbeta.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(latoomutbeta,LATOOMUTBETA); diff --git a/chaos/src/latoomutgamma.hpp b/chaos/src/latoomutgamma.hpp new file mode 100644 index 0000000..b4f3bf8 --- /dev/null +++ b/chaos/src/latoomutgamma.hpp @@ -0,0 +1,83 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "map_base.hpp" +#include + +// latoocarfian model, mutation gamma: +// x1[n+1] = abs(sin(x2[n]*b)) + pow(sin(x1[n]*b),2) +// x2[n+1] = abs(sin(x1[n]*a)) + pow(sin(x2[n]*a),2) +// taken from Pickover: Chaos In Wonderland + +class latoomutgamma + : public map_base +{ +public: + latoomutgamma() + { + m_num_eq = 2; + m_data = new data_t[m_num_eq]; + + CHAOS_SYS_INIT(x1,0.5); + CHAOS_SYS_INIT(x2,0.5); + CHAOS_SYS_INIT(a,-0.966918); + CHAOS_SYS_INIT(b,2.879879); + } + + ~latoomutgamma() + { + delete m_data; + } + + virtual 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_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); \ +CHAOS_SYS_CALLBACKS(b); + + +#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/latoomutgamma_dsp.cpp b/chaos/src/latoomutgamma_dsp.cpp new file mode 100644 index 0000000..dbe625d --- /dev/null +++ b/chaos/src/latoomutgamma_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 "latoomutgamma.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(latoomutgamma,LATOOMUTGAMMA); diff --git a/chaos/src/latoomutgamma_msg.cpp b/chaos/src/latoomutgamma_msg.cpp new file mode 100644 index 0000000..1b1c20d --- /dev/null +++ b/chaos/src/latoomutgamma_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 "latoomutgamma.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(latoomutgamma,LATOOMUTGAMMA); 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); } diff --git a/chaos/src/main.cpp b/chaos/src/main.cpp index 84589f8..eabb8d4 100644 --- a/chaos/src/main.cpp +++ b/chaos/src/main.cpp @@ -31,13 +31,18 @@ void chaos_library_setup() CHAOS_ADD(coupled_logistic); CHAOS_ADD(driven_anharmonic); CHAOS_ADD(driven_van_der_pol); + CHAOS_ADD(duffing_map); CHAOS_ADD(gauss_map); CHAOS_ADD(henon); CHAOS_ADD(ikeda_laser_map); + CHAOS_ADD(latoocarfian); + CHAOS_ADD(latoomutalpha); + CHAOS_ADD(latoomutbeta); + CHAOS_ADD(latoomutgamma); CHAOS_ADD(logistic); CHAOS_ADD(lorenz); CHAOS_ADD(lozi_map); - CHAOS_ADD(roesser); + CHAOS_ADD(roessler); CHAOS_ADD(sine_map); CHAOS_ADD(standard_map); CHAOS_ADD(tent_map); -- cgit v1.2.1