From d1ed55f96f9cecc818844006fb36cd58ca70da5e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 16 Jun 2005 13:02:02 +0000 Subject: - parameter searching (broken) - misc. updates svn path=/trunk/externals/tb/; revision=3192 --- chaos/src/bernoulli_search.cpp | 24 ++++ chaos/src/bungalow_tent_search.cpp | 24 ++++ chaos/src/chaos.hpp | 17 +++ chaos/src/chaos_base.hpp | 16 ++- chaos/src/chaos_defs.hpp | 6 +- chaos/src/chaos_dsp.hpp | 55 +++++++-- chaos/src/chaos_search.hpp | 191 ++++++++++++++++++++++++++++++++ chaos/src/chua.hpp | 83 ++++++++++++-- chaos/src/chua_search.cpp | 24 ++++ chaos/src/circle_map_search.cpp | 24 ++++ chaos/src/coupled_logistic.hpp | 12 +- chaos/src/coupled_logistic_msg.cpp | 14 +-- chaos/src/coupled_logistic_search.cpp | 24 ++++ chaos/src/delayed_logistic.hpp | 92 +++++++++++++++ chaos/src/delayed_logistic__search.cpp | 24 ++++ chaos/src/delayed_logistic_dsp.cpp | 23 ++++ chaos/src/delayed_logistic_msg.cpp | 23 ++++ chaos/src/delayed_logistic_search.cpp | 24 ++++ chaos/src/driven_anharmonic_search.cpp | 24 ++++ chaos/src/driven_van_der_pol.hpp | 13 ++- chaos/src/driven_van_der_pol_search.cpp | 24 ++++ chaos/src/duffing_map_search.cpp | 24 ++++ chaos/src/gauss_map_search.cpp | 24 ++++ chaos/src/gaussian_map.hpp | 84 ++++++++++++++ chaos/src/gaussian_map_dsp.cpp | 23 ++++ chaos/src/gaussian_map_msg.cpp | 23 ++++ chaos/src/gaussian_map_search.cpp | 24 ++++ chaos/src/henon_map_search.cpp | 24 ++++ chaos/src/hydrogen.hpp | 156 ++++++++++++++++++++++++++ chaos/src/hydrogen_dsp.cpp | 23 ++++ chaos/src/hydrogen_msg.cpp | 23 ++++ chaos/src/hydrogen_search.cpp | 24 ++++ chaos/src/ikeda_laser_map_search.cpp | 24 ++++ chaos/src/latoocarfian.hpp | 12 +- chaos/src/latoocarfian_search.cpp | 24 ++++ chaos/src/latoomutalpha.hpp | 16 +-- chaos/src/latoomutalpha_search.cpp | 24 ++++ chaos/src/latoomutbeta.hpp | 13 +-- chaos/src/latoomutbeta_search.cpp | 24 ++++ chaos/src/latoomutgamma.hpp | 14 +-- chaos/src/latoomutgamma_search.cpp | 24 ++++ chaos/src/logistic_map.hpp | 4 +- chaos/src/logistic_search.cpp | 24 ++++ chaos/src/lorenz.hpp | 10 ++ chaos/src/lorenz_search.cpp | 24 ++++ chaos/src/lozi_map.hpp | 5 - chaos/src/lozi_map_search.cpp | 24 ++++ chaos/src/main.cpp | 3 + chaos/src/ode_base.hpp | 9 +- chaos/src/roessler.hpp | 10 +- chaos/src/roessler_search.cpp | 24 ++++ chaos/src/sine_map_search.cpp | 24 ++++ chaos/src/standard_map_search.cpp | 24 ++++ chaos/src/tent_map_search.cpp | 24 ++++ 54 files changed, 1504 insertions(+), 93 deletions(-) create mode 100644 chaos/src/bernoulli_search.cpp create mode 100644 chaos/src/bungalow_tent_search.cpp create mode 100644 chaos/src/chaos_search.hpp create mode 100644 chaos/src/chua_search.cpp create mode 100644 chaos/src/circle_map_search.cpp create mode 100644 chaos/src/coupled_logistic_search.cpp create mode 100644 chaos/src/delayed_logistic.hpp create mode 100644 chaos/src/delayed_logistic__search.cpp create mode 100644 chaos/src/delayed_logistic_dsp.cpp create mode 100644 chaos/src/delayed_logistic_msg.cpp create mode 100644 chaos/src/delayed_logistic_search.cpp create mode 100644 chaos/src/driven_anharmonic_search.cpp create mode 100644 chaos/src/driven_van_der_pol_search.cpp create mode 100644 chaos/src/duffing_map_search.cpp create mode 100644 chaos/src/gauss_map_search.cpp create mode 100644 chaos/src/gaussian_map.hpp create mode 100644 chaos/src/gaussian_map_dsp.cpp create mode 100644 chaos/src/gaussian_map_msg.cpp create mode 100644 chaos/src/gaussian_map_search.cpp create mode 100644 chaos/src/henon_map_search.cpp create mode 100644 chaos/src/hydrogen.hpp create mode 100644 chaos/src/hydrogen_dsp.cpp create mode 100644 chaos/src/hydrogen_msg.cpp create mode 100644 chaos/src/hydrogen_search.cpp create mode 100644 chaos/src/ikeda_laser_map_search.cpp create mode 100644 chaos/src/latoocarfian_search.cpp create mode 100644 chaos/src/latoomutalpha_search.cpp create mode 100644 chaos/src/latoomutbeta_search.cpp create mode 100644 chaos/src/latoomutgamma_search.cpp create mode 100644 chaos/src/logistic_search.cpp create mode 100644 chaos/src/lorenz_search.cpp create mode 100644 chaos/src/lozi_map_search.cpp create mode 100644 chaos/src/roessler_search.cpp create mode 100644 chaos/src/sine_map_search.cpp create mode 100644 chaos/src/standard_map_search.cpp create mode 100644 chaos/src/tent_map_search.cpp diff --git a/chaos/src/bernoulli_search.cpp b/chaos/src/bernoulli_search.cpp new file mode 100644 index 0000000..e4fc398 --- /dev/null +++ b/chaos/src/bernoulli_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "bernoulli_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(bernoulli, BERNOULLI); diff --git a/chaos/src/bungalow_tent_search.cpp b/chaos/src/bungalow_tent_search.cpp new file mode 100644 index 0000000..d76d195 --- /dev/null +++ b/chaos/src/bungalow_tent_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "bungalow_tent_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(bungalow_tent, BUNGALOW_TENT); diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp index 0f87b51..2e2eb8b 100644 --- a/chaos/src/chaos.hpp +++ b/chaos/src/chaos.hpp @@ -27,6 +27,8 @@ #include "chaos_defs.hpp" #include +#include + /* internal we can work with a higher precision than pd */ #ifdef DOUBLE_PRECISION typedef double data_t; @@ -36,6 +38,21 @@ 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/chaos_base.hpp b/chaos/src/chaos_base.hpp index 959afdf..5e2a99f 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -29,26 +29,32 @@ class chaos_base { public: - t_sample get_data(unsigned int i) + inline t_sample get_data(unsigned int i) { return (t_sample)m_data[i]; /* this is not save, but fast */ } - int get_num_eq() + inline int get_num_eq() { return m_num_eq; } - void m_perform() + inline void m_perform() { m_step(); + m_bash_denormals(); m_verify(); } - std::map attr_ind; + std::map attr_ind; + // TableAnyMap attr_ind; /* thomas fragen :-) */ // check the integrity of the system virtual void m_verify() + { + } + + inline void m_bash_denormals() { for (int i = 0; i != get_num_eq(); ++i) { @@ -58,7 +64,7 @@ public: #endif } }; - + data_t m_data[MAXDIMENSION]; // state of the system protected: diff --git a/chaos/src/chaos_defs.hpp b/chaos/src/chaos_defs.hpp index d9f60d8..bf8607c 100644 --- a/chaos/src/chaos_defs.hpp +++ b/chaos/src/chaos_defs.hpp @@ -97,7 +97,8 @@ data_t m_##NAME; #define CHAOS_SYS_CALLBACKS(NAME) \ -public:void get_##NAME(t_float &f) \ +public: \ +void get_##NAME(t_float &f) \ { \ f = m_system->get_##NAME(); \ } \ @@ -135,6 +136,9 @@ flext::SetSymbol(atom_##NAME, flext::MakeSymbol(#NAME)); \ System.Append(atom_##NAME); \ attr_ind[flext::MakeSymbol(#NAME)] = INDEX; +#define CHAOS_SYS_INIT_HIDDEN(NAME, VALUE, INDEX) \ +set_##NAME(VALUE); + #define CHAOS_PAR_INIT(NAME, VALUE) \ set_##NAME(VALUE); \ t_atom atom_##NAME; \ diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp index bb3c5fa..16e2820 100644 --- a/chaos/src/chaos_dsp.hpp +++ b/chaos/src/chaos_dsp.hpp @@ -28,13 +28,15 @@ template class chaos_dsp public: /* signal functions: */ - /* for frequency = sr/2 */ + /* for frequency = sr */ void m_signal_(int n, t_sample *const *insigs,t_sample *const *outsigs); /* sample & hold */ void m_signal_n(int n, t_sample *const *insigs,t_sample *const *outsigs); + /* sample & hold for high frequencies */ + void m_signal_n_hf(int n, t_sample *const *insigs,t_sample *const *outsigs); /* linear interpolation */ void m_signal_l(int n, t_sample *const *insigs,t_sample *const *outsigs); - /* cubic interpolatio */ + /* cubic interpolation */ void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs); virtual void m_signal(int n, t_sample *const *insigs,t_sample *const *outsigs) @@ -45,8 +47,9 @@ public: virtual void m_dsp(int n, t_sample *const *insigs,t_sample *const *outsigs) { m_sr = Samplerate(); + set_freq(m_freq); /* maybe we have to change the interpolation mode */ } - + void (thisType::*m_routine)(int n, t_sample *const *insigs,t_sample *const *outsigs); /* local data for system, output and interpolation */ @@ -63,6 +66,7 @@ public: float m_freq; /* frequency of oscillations */ float m_invfreq; /* inverse frequency */ int m_phase; /* phase counter */ + float m_fphase; /* phase for high frequency linear interpolation */ float m_sr; /* sample rate */ int m_imethod; /* interpolation method */ @@ -123,18 +127,22 @@ public: void set_freq(float f) { - if( (f >= 0) && (f <= m_sr*0.5) ) + if (f < 0) /* we can't go back in time :-) */ + f = -f; + + if( f <= m_sr * 0.5 ) { - if (m_freq == -1) + if (m_freq >= m_sr * 0.5) set_imethod(m_imethod); m_freq = f; m_invfreq = 1.f / f; } - else if (f == -1) + else if (f > m_sr * 0.5) { - m_freq = -1; + m_freq = f; + m_invfreq = 1.f / f; - m_routine = &thisType::m_signal_; + m_routine = &thisType::m_signal_n_hf; } else post("frequency out of range"); @@ -145,6 +153,7 @@ public: }; + /* create constructor / destructor */ #define CHAOS_DSP_INIT(SYSTEM, ATTRIBUTES) \ FLEXT_HEADER(SYSTEM##_dsp, chaos_dsp) \ @@ -228,9 +237,39 @@ void chaos_dsp::m_signal_(int n, t_sample *const *insigs, outsigs[j][i] = m_system->get_data(j); } } +} + + +template +void chaos_dsp::m_signal_n_hf(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system->get_num_eq(); + float phase = m_fphase; + + int offset = 0; + while (n) + { + while (phase <= 0) + { + m_system->m_perform(); + phase += m_sr * m_invfreq; + } + int next = (phase < n) ? int(ceilf (phase)) : n; + n -= next; + phase -=next; + + for (int i = 0; i != outlets; ++i) + { + SetSamples(outsigs[i]+offset, next, m_system->get_data(i)); + } + offset += next; + } + m_fphase = phase; } + template void chaos_dsp::m_signal_n(int n, t_sample *const *insigs, t_sample *const *outsigs) diff --git a/chaos/src/chaos_search.hpp b/chaos/src/chaos_search.hpp new file mode 100644 index 0000000..a7fc44d --- /dev/null +++ b/chaos/src/chaos_search.hpp @@ -0,0 +1,191 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "chaos_base.hpp" + +template class chaos_search + : public flext_base +{ + FLEXT_HEADER(chaos_search, flext_base); + +public: + + /* local data for system, output and interpolation */ + system * m_system; /* the system */ + + + data_t min[MAXDIMENSION]; /* minimal coordinates */ + data_t max[MAXDIMENSION]; /* maximal coordinates */ + data_t final[MAXDIMENSION]; /* initial coordinates for outlet */ + + data_t ly; /* lyapunov exponent */ + + int m_transient_steps; /* steps before starting the analysis */ + int m_asymptotic_steps; /* steps for the analysis */ + + + void get_tsteps(int &i) + { + i = m_transient_steps; + } + + void set_tsteps(int i) + { + if (i > 0) + m_transient_steps = i; + else + m_transient_steps = 0; + } + + void get_asteps(int &i) + { + i = m_asymptotic_steps; + } + + void set_asteps(int &i) + { + if (i > 0) + m_asymptotic_steps = i; + else + m_asymptotic_steps = 0; + } + + void print_results(void) + { + /* - send parameters to 1 + - send initial coordinates to 2 + - send minimal coordinates to 3 + - send lyapunov exponent to 4 + */ + + for (std::map::iterator it = m_system->attr_ind.begin(); + it != m_system->attr_ind.end(); ++it) + { + post("key %s", it->first->s_name); + post("value %f", m_system->get_data(it->second)); + } + } + + void m_search(); + + FLEXT_CALLBACK(m_bang); + FLEXT_CALLVAR_I(get_tsteps, set_tsteps); + FLEXT_CALLVAR_I(get_asteps, set_asteps); + FLEXT_THREAD(m_search); +}; + + +/* create constructor / destructor */ + +#define CHAOS_SEARCH_INIT(SYSTEM, ATTRIBUTES) \ +FLEXT_HEADER(SYSTEM##_search, chaos_search) \ + \ +SYSTEM##_search(int argc, t_atom* argv ) \ +{ \ + m_system = new SYSTEM; \ + \ + int size = m_system->get_num_eq(); \ + \ + \ + m_asymptotic_steps = 10000; \ + m_transient_steps = 100; \ + \ + AddOutList("parameters"); \ + AddOutList("initial coordinates"); \ + AddOutList("minimal coordinates"); \ + AddOutList("maximal coordinates"); \ + AddOutFloat("lyapunov exponent"); \ + \ + FLEXT_ADDATTR_VAR("transient_steps", get_tsteps, set_tsteps); \ + FLEXT_ADDATTR_VAR("steps", get_asteps, set_asteps); \ + ATTRIBUTES; \ + FLEXT_ADDMETHOD_(0,"search", m_search); \ +} \ + \ +~SYSTEM##_search() \ +{ \ + delete m_system; \ +} \ + \ +FLEXT_ATTRVAR_I(m_transient_steps); \ +FLEXT_ATTRVAR_I(m_asymptotic_steps); + + + +template +void chaos_search::m_search() +{ + int dimensions = m_system->get_num_eq(); + + ly = 0; + data_t diff_old = 0.1; + data_t last[MAXDIMENSION]; + + /* transient dynamics */ + for (int i = 0; i != m_transient_steps; ++i) + { + m_system->m_perform(); + } + + for (int i = 0; i != dimensions; ++i) + { + last[i] = min[i] = max[i] = m_system->m_data[i]; + } + + /* now we start the analysis */ + + for (int i = 0; i != m_asymptotic_steps; ++i) + { + + m_system->m_perform(); + + data_t diff = 0; + for (int j = 0; j != dimensions; ++j) + { + /* update min/max */ + data_t datum = m_system->m_data[j]; + if (datum > max[j]) + max[j] = datum; + else if (datum < min[j]) + min[j] = datum; + + /* sum up diff */ + diff += (last[j] - datum) * (last[j] - datum); + + last[j] = datum; + } + diff = sqrt(diff); + + if (diff < 0) + diff = -diff; + + ly += log(diff / diff_old); + diff_old = diff; + + /* todo: maybe some overflow checking */ + if (diff == 0) + break; + } + + + ly /= m_asymptotic_steps; + + print_results(); +} diff --git a/chaos/src/chua.hpp b/chaos/src/chua.hpp index e54df47..3d44708 100644 --- a/chaos/src/chua.hpp +++ b/chaos/src/chua.hpp @@ -28,7 +28,7 @@ // a*x (for -1 <= x <= 1 // b*x - a + b (for x < -1) // -// taken from Viktor Avrutin: lecture note +// taken from Viktor Avrutin: lecture notes class chua: public ode_base @@ -38,14 +38,17 @@ public: { CHAOS_PRECONSTRUCTOR; - CHAOS_SYS_INIT(x1,1,0); + 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,2); + CHAOS_SYS_INIT(x3,1,1); - CHAOS_PAR_INIT(a,1.4); - CHAOS_PAR_INIT(b,0.3); - CHAOS_PAR_INIT(alpha,0.3); - CHAOS_PAR_INIT(beta,0.3); + CHAOS_PAR_INIT(a,140); + CHAOS_PAR_INIT(b,30); + CHAOS_PAR_INIT(alpha,30); + CHAOS_PAR_INIT(beta,30); CHAOS_POSTCONSTRUCTOR; @@ -79,12 +82,74 @@ public: 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); - CHAOS_SYSPAR_FUNCS(a); - CHAOS_SYSPAR_FUNCS(b); + /* 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); }; diff --git a/chaos/src/chua_search.cpp b/chaos/src/chua_search.cpp new file mode 100644 index 0000000..65e8719 --- /dev/null +++ b/chaos/src/chua_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "chua.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(chua, CHUA); diff --git a/chaos/src/circle_map_search.cpp b/chaos/src/circle_map_search.cpp new file mode 100644 index 0000000..a34bbf8 --- /dev/null +++ b/chaos/src/circle_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "circle_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(circle_map, CIRCLE_MAP); diff --git a/chaos/src/coupled_logistic.hpp b/chaos/src/coupled_logistic.hpp index 7cc8602..d94ceee 100644 --- a/chaos/src/coupled_logistic.hpp +++ b/chaos/src/coupled_logistic.hpp @@ -22,7 +22,7 @@ // 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[n] - y[n]) -// 1 <= r <= 4 +// 0 <= r <= 4 // taken from Willi-Hans Steeb: Chaos and Fractals class coupled_logistic: @@ -54,6 +54,7 @@ public: 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); + m_verify(); } CHAOS_SYSPAR_FUNCS(e); @@ -76,9 +77,14 @@ public: data_t x = m_data[0]; data_t y = m_data[1]; if (!m_pred_xy(x)) - m_data[0] = 0.5; + m_data[0] = rand_range(0,0.08); if (!m_pred_xy(y)) - m_data[1] = 0.5; + m_data[1] = rand_range(0,0.08); + if (x == y) + { + m_data[0] += rand_range(0,0.2); + m_data[1] += -rand_range(0,0.2); + } } diff --git a/chaos/src/coupled_logistic_msg.cpp b/chaos/src/coupled_logistic_msg.cpp index 994a79d..15ef289 100644 --- a/chaos/src/coupled_logistic_msg.cpp +++ b/chaos/src/coupled_logistic_msg.cpp @@ -1,7 +1,7 @@ // // // chaos~ -// Copyright (C) 2004 Tim Blechmann +// 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 @@ -21,14 +21,4 @@ #include "coupled_logistic.hpp" #include "chaos_msg.hpp" -class coupled_logistic_msg: - public chaos_msg -{ - CHAOS_MSG_INIT(coupled_logistic, COUPLED_LOGISTIC_ATTRIBUTES); - - COUPLED_LOGISTIC_CALLBACKS; -}; - - - -FLEXT_LIB_V("coupled_logistic", coupled_logistic_msg); +CHAOS_MSG_CLASS(coupled_logistic,COUPLED_LOGISTIC) diff --git a/chaos/src/coupled_logistic_search.cpp b/chaos/src/coupled_logistic_search.cpp new file mode 100644 index 0000000..f75938f --- /dev/null +++ b/chaos/src/coupled_logistic_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "coupled_logistic.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(coupled_logistic, COUPLED_LOGISTIC); diff --git a/chaos/src/delayed_logistic.hpp b/chaos/src/delayed_logistic.hpp new file mode 100644 index 0000000..c78785f --- /dev/null +++ b/chaos/src/delayed_logistic.hpp @@ -0,0 +1,92 @@ +// +// +// 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" + +// delayed logistic map: x[n+1] = alpha * x[n] * (1 - x[n-1]) +// 0 < x[n] < 1 +// 0 <= alpha <= 4 +// taken from E. Atlee Jackson: Perspective of nonlinear dynamics (Vol. 2) + +class delayed_logistic: + public map_base +{ +public: + delayed_logistic() + { + CHAOS_PRECONSTRUCTOR; + + CHAOS_SYS_INIT(x, 0.5, 0); + + CHAOS_PAR_INIT(alpha, 3.8); + + CHAOS_POSTCONSTRUCTOR; + + m_delayed = get_x(); /* the initial state of the delay */ + } + + ~delayed_logistic() + { + + } + + virtual void m_step() + { + data_t x = m_data[0]; + data_t alpha = CHAOS_PARAMETER(alpha); + data_t delayed = m_delayed; + + m_delayed = x; + m_data[0] = alpha * x * (1.f - delayed); + + } + data_t m_delayed; + + CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); + bool m_pred_alpha(t_float f) + { + return (f > 0) && (f < 4); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); + bool m_pred_x(t_float f) + { + return (f > 0) && (f < 1); + } + + virtual void m_verify() + { + data_t x = m_data[0]; + if (m_pred_x(x)) + return; + m_data[0] = 0.5; + } +}; + +#define DELAYED_LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(alpha); \ +CHAOS_SYS_CALLBACKS(x); + +#define DELAYED_LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(alpha); \ +CHAOS_SYS_ATTRIBUTE(x); + diff --git a/chaos/src/delayed_logistic__search.cpp b/chaos/src/delayed_logistic__search.cpp new file mode 100644 index 0000000..c082637 --- /dev/null +++ b/chaos/src/delayed_logistic__search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "delayed_logistic_.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(delayed_logistic_, DELAYED_LOGISTIC_); diff --git a/chaos/src/delayed_logistic_dsp.cpp b/chaos/src/delayed_logistic_dsp.cpp new file mode 100644 index 0000000..1dec6d0 --- /dev/null +++ b/chaos/src/delayed_logistic_dsp.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "delayed_logistic.hpp" +#include "chaos_dsp.hpp" +CHAOS_DSP_CLASS(delayed_logistic,DELAYED_LOGISTIC); diff --git a/chaos/src/delayed_logistic_msg.cpp b/chaos/src/delayed_logistic_msg.cpp new file mode 100644 index 0000000..10c1b89 --- /dev/null +++ b/chaos/src/delayed_logistic_msg.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "delayed_logistic.hpp" +#include "chaos_msg.hpp" +CHAOS_MSG_CLASS(delayed_logistic,DELAYED_LOGISTIC); diff --git a/chaos/src/delayed_logistic_search.cpp b/chaos/src/delayed_logistic_search.cpp new file mode 100644 index 0000000..462e6bf --- /dev/null +++ b/chaos/src/delayed_logistic_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "delayed_logistic.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(delayed_logistic, DELAYED_LOGISTIC); diff --git a/chaos/src/driven_anharmonic_search.cpp b/chaos/src/driven_anharmonic_search.cpp new file mode 100644 index 0000000..f05ff85 --- /dev/null +++ b/chaos/src/driven_anharmonic_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "driven_anharmonic.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(driven_anharmonic, DRIVEN_ANHARMONIC); diff --git a/chaos/src/driven_van_der_pol.hpp b/chaos/src/driven_van_der_pol.hpp index 65290ee..6156eb0 100644 --- a/chaos/src/driven_van_der_pol.hpp +++ b/chaos/src/driven_van_der_pol.hpp @@ -37,7 +37,7 @@ public: { CHAOS_PRECONSTRUCTOR; - CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(method,2); CHAOS_PAR_INIT(dt,0.01); CHAOS_SYS_INIT(u1,0.8, 0); @@ -68,9 +68,16 @@ public: 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); + CHAOS_SYSVAR_FUNCS(u3, 2); CHAOS_SYSPAR_FUNCS(a); CHAOS_SYSPAR_FUNCS(k); @@ -82,6 +89,7 @@ public: 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); @@ -90,6 +98,7 @@ CHAOS_SYS_CALLBACKS(Omega); 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/driven_van_der_pol_search.cpp b/chaos/src/driven_van_der_pol_search.cpp new file mode 100644 index 0000000..63cc308 --- /dev/null +++ b/chaos/src/driven_van_der_pol_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "driven_van_der_pol.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(driven_van_der_pol, DRIVEN_VAN_DER_POL); diff --git a/chaos/src/duffing_map_search.cpp b/chaos/src/duffing_map_search.cpp new file mode 100644 index 0000000..d6d3168 --- /dev/null +++ b/chaos/src/duffing_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "duffing_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(duffing_map, DUFFING_MAP); diff --git a/chaos/src/gauss_map_search.cpp b/chaos/src/gauss_map_search.cpp new file mode 100644 index 0000000..db8206a --- /dev/null +++ b/chaos/src/gauss_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "gauss_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(gauss_map, GAUSS_MAP); diff --git a/chaos/src/gaussian_map.hpp b/chaos/src/gaussian_map.hpp new file mode 100644 index 0000000..5f5a4b1 --- /dev/null +++ b/chaos/src/gaussian_map.hpp @@ -0,0 +1,84 @@ +// +// +// 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" + + +// gaussian map: x[n+1] = exp(-b * x[n] * x[n]) + c +// +// taken from Robert C. Hilborn: Chaos and Nonlinear Dynamics + +class gaussian_map: + public map_base +{ +public: + gaussian_map() + { + CHAOS_PRECONSTRUCTOR; + + CHAOS_SYS_INIT(x, 0.5, 0); + + CHAOS_PAR_INIT(b,7); + CHAOS_PAR_INIT(c,0.5); + + CHAOS_POSTCONSTRUCTOR; + } + + ~gaussian_map() + { + + } + + virtual void m_step() + { + data_t data = m_data[0]; + + if (data == 0) + m_data[0] = 0.001; + else + m_data[0] = exp(-CHAOS_PARAMETER(b) * data * data) + + CHAOS_PARAMETER(c); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); + bool m_pred_x(t_float f) + { + return (f >= 0) && (f < 1); + } + + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); + +}; + +#define GAUSSIAN_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); + +#define GAUSSIAN_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); + + + diff --git a/chaos/src/gaussian_map_dsp.cpp b/chaos/src/gaussian_map_dsp.cpp new file mode 100644 index 0000000..d548dc0 --- /dev/null +++ b/chaos/src/gaussian_map_dsp.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "gaussian_map.hpp" +#include "chaos_dsp.hpp" +CHAOS_DSP_CLASS(gaussian_map,GAUSSIAN_MAP); diff --git a/chaos/src/gaussian_map_msg.cpp b/chaos/src/gaussian_map_msg.cpp new file mode 100644 index 0000000..e5aede1 --- /dev/null +++ b/chaos/src/gaussian_map_msg.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "gaussian_map.hpp" +#include "chaos_msg.hpp" +CHAOS_MSG_CLASS(gaussian_map,GAUSSIAN_MAP); diff --git a/chaos/src/gaussian_map_search.cpp b/chaos/src/gaussian_map_search.cpp new file mode 100644 index 0000000..16efd8e --- /dev/null +++ b/chaos/src/gaussian_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "gaussian_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(gaussian_map, GAUSSIAN_MAP); diff --git a/chaos/src/henon_map_search.cpp b/chaos/src/henon_map_search.cpp new file mode 100644 index 0000000..d7f3712 --- /dev/null +++ b/chaos/src/henon_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "henon_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(henon, HENON); diff --git a/chaos/src/hydrogen.hpp b/chaos/src/hydrogen.hpp new file mode 100644 index 0000000..886539c --- /dev/null +++ b/chaos/src/hydrogen.hpp @@ -0,0 +1,156 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + + +#include "ode_base.hpp" + +// hydrogen atom in a magnetic field + +class hydrogen + : public ode_base +{ + + +public: + hydrogen() + { + CHAOS_PRECONSTRUCTOR; + + CHAOS_PAR_INIT(method,2); + CHAOS_PAR_INIT(dt,0.01); + + CHAOS_SYS_INIT(mu,0.8, 0); + CHAOS_SYS_INIT(muv,0.6, 1); + CHAOS_SYS_INIT(nu,0.4, 2); + CHAOS_SYS_INIT(nuv,0.4, 3); + + CHAOS_PAR_INIT(etilde,-0.3); + + CHAOS_POSTCONSTRUCTOR; + ode_base_alloc(); + reset = 0; + } + + ~hydrogen() + { + ode_base_free(); + } + + virtual void m_system(data_t* deriv, data_t* data) + { + if (reset) + { + (this->*reset)(); + reset = 0; + } + + data_t mu = m_data[0], muv = m_data[1], nu = m_data[2], nuv = m_data[3]; + data_t E = CHAOS_PARAMETER(etilde); + + deriv[0] = muv; + deriv[1] = 2* E * mu - 0.25 * mu * nu * nu * (2*mu*mu+nu*nu); + deriv[2] = nuv; + deriv[3] = 2* E * nu - 0.25 * nu * mu * mu * (2*nu*nu+mu*mu); + } + + virtual void m_verify() + { + /* make sure to stay in the range of 2 pi */ + for (int i = 0; i != get_num_eq(); ++ i) + { + if (m_data[i] > 1) + m_data[i] = 1; + else if (m_data[i] < -1) + m_data[i] = -1; + } + } + + void reset_nuv() + { + data_t mu = m_data[0], muv = m_data[1], nu = m_data[2]; + data_t E = CHAOS_PARAMETER(etilde); + + m_data[1]= sqrt ( 2 * E * (mu*mu + nu*nu) - muv*muv - ( mu*mu * nu*nu * + ( mu*mu + nu*nu )) * 0.25); + +// if (fabs((data[3]))<1e-5) +// data[3]=0; + } + + void reset_muv() + { + data_t mu = m_data[0], nu = m_data[2], nuv = m_data[3]; + data_t E = CHAOS_PARAMETER(etilde); + + m_data[1]= sqrt ( 2 * E * (mu*mu + nu*nu) - nuv*nuv - ( mu*mu * nu*nu * + ( mu*mu + nu*nu )) * 0.25); + +// if (fabs((data[1]))<1e-5) +// data[1]=0; + } + + + /* hook into the predicate to reset the system */ + bool m_pred_pos(t_float f) + { + if (fabs(f) > 1) + return false; + reset = &hydrogen::reset_nuv; + return true; + } + + bool m_pred_nuv(t_float f) + { + reset = &hydrogen::reset_muv; + return true; + } + + bool m_pred_muv(t_float f) + { + reset = &hydrogen::reset_nuv; + return true; + } + + void (hydrogen::*reset)(void); + + CHAOS_SYSVAR_FUNCS_PRED(mu, 0, m_pred_pos); + CHAOS_SYSVAR_FUNCS_PRED(muv, 1, m_pred_nuv); + CHAOS_SYSVAR_FUNCS_PRED(nu, 2, m_pred_pos); + CHAOS_SYSVAR_FUNCS_PRED(nuv, 3, m_pred_muv); + + CHAOS_SYSPAR_FUNCS(etilde); +}; + + +#define HYDROGEN_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(mu); \ +CHAOS_SYS_CALLBACKS(muv); \ +CHAOS_SYS_CALLBACKS(nu); \ +CHAOS_SYS_CALLBACKS(nuv); \ +CHAOS_SYS_CALLBACKS(etilde); + +#define HYDROGEN_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(mu); \ +CHAOS_SYS_ATTRIBUTE(muv); \ +CHAOS_SYS_ATTRIBUTE(nu); \ +CHAOS_SYS_ATTRIBUTE(nuv); \ +CHAOS_SYS_ATTRIBUTE(etilde); diff --git a/chaos/src/hydrogen_dsp.cpp b/chaos/src/hydrogen_dsp.cpp new file mode 100644 index 0000000..118cbc4 --- /dev/null +++ b/chaos/src/hydrogen_dsp.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "hydrogen.hpp" +#include "chaos_dsp.hpp" +CHAOS_DSP_CLASS(hydrogen,HYDROGEN); diff --git a/chaos/src/hydrogen_msg.cpp b/chaos/src/hydrogen_msg.cpp new file mode 100644 index 0000000..b4da4b3 --- /dev/null +++ b/chaos/src/hydrogen_msg.cpp @@ -0,0 +1,23 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "hydrogen.hpp" +#include "chaos_msg.hpp" +CHAOS_MSG_CLASS(hydrogen,HYDROGEN); diff --git a/chaos/src/hydrogen_search.cpp b/chaos/src/hydrogen_search.cpp new file mode 100644 index 0000000..ab7e1c4 --- /dev/null +++ b/chaos/src/hydrogen_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "hydrogen.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(hydrogen, HYDROGEN); diff --git a/chaos/src/ikeda_laser_map_search.cpp b/chaos/src/ikeda_laser_map_search.cpp new file mode 100644 index 0000000..1370329 --- /dev/null +++ b/chaos/src/ikeda_laser_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "ikeda_laser_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(ikeda_laser_map, IKEDA_LASER_MAP); diff --git a/chaos/src/latoocarfian.hpp b/chaos/src/latoocarfian.hpp index 9884fd1..9bfba90 100644 --- a/chaos/src/latoocarfian.hpp +++ b/chaos/src/latoocarfian.hpp @@ -82,14 +82,10 @@ public: /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { - for (int i = 0; i != get_num_eq(); ++i) - { -#ifndef DOUBLE_PRECISION - if (PD_BIGORSMALL(m_data[i])) - m_data[i] = 0.01; -#endif - } - }; + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(0,0.1); + } }; diff --git a/chaos/src/latoocarfian_search.cpp b/chaos/src/latoocarfian_search.cpp new file mode 100644 index 0000000..c057301 --- /dev/null +++ b/chaos/src/latoocarfian_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "latoocarfian.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(latoocarfian, LATOOCARFIAN); diff --git a/chaos/src/latoomutalpha.hpp b/chaos/src/latoomutalpha.hpp index ca99c12..ff0cf9f 100644 --- a/chaos/src/latoomutalpha.hpp +++ b/chaos/src/latoomutalpha.hpp @@ -62,19 +62,15 @@ public: tmp2 = sin(x2*c); m_data[1] = sin(x1*a) + tmp1*tmp1 + tmp2*tmp2*tmp2; } - + /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { - for (int i = 0; i != get_num_eq(); ++i) - { -#ifndef DOUBLE_PRECISION - if (PD_BIGORSMALL(m_data[i])) - m_data[i] = 0.5; -#endif - } - }; - + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(0,0.1); + } + CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); diff --git a/chaos/src/latoomutalpha_search.cpp b/chaos/src/latoomutalpha_search.cpp new file mode 100644 index 0000000..0dfecc3 --- /dev/null +++ b/chaos/src/latoomutalpha_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "latoomutalpha.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(latoomutalpha, LATOOMUTALPHA); diff --git a/chaos/src/latoomutbeta.hpp b/chaos/src/latoomutbeta.hpp index e27e5a2..a3562c8 100644 --- a/chaos/src/latoomutbeta.hpp +++ b/chaos/src/latoomutbeta.hpp @@ -60,18 +60,13 @@ public: m_data[1] = sin(x1*a) + tmp*tmp; } - /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { - for (int i = 0; i != get_num_eq(); ++i) - { -#ifndef DOUBLE_PRECISION - if (PD_BIGORSMALL(m_data[i])) - m_data[i] = 0.01; -#endif - } - }; + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(0,0.1); + } CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); diff --git a/chaos/src/latoomutbeta_search.cpp b/chaos/src/latoomutbeta_search.cpp new file mode 100644 index 0000000..1fecfa5 --- /dev/null +++ b/chaos/src/latoomutbeta_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "latoomutbeta.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(latoomutbeta, LATOOMUTBETA); diff --git a/chaos/src/latoomutgamma.hpp b/chaos/src/latoomutgamma.hpp index fcdf6a6..b9c8c08 100644 --- a/chaos/src/latoomutgamma.hpp +++ b/chaos/src/latoomutgamma.hpp @@ -64,15 +64,11 @@ public: /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { - for (int i = 0; i != get_num_eq(); ++i) - { -#ifndef DOUBLE_PRECISION - if (PD_BIGORSMALL(m_data[i])) - m_data[i] = 0.01; -#endif - } - }; - + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(0,0.1); + } + CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); diff --git a/chaos/src/latoomutgamma_search.cpp b/chaos/src/latoomutgamma_search.cpp new file mode 100644 index 0000000..16e05c9 --- /dev/null +++ b/chaos/src/latoomutgamma_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "latoomutgamma.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(latoomutgamma, LATOOMUTGAMMA); diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 16e824e..c01abcc 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -51,14 +51,14 @@ public: } CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); - bool m_pred_alpha(t_float f) + bool m_pred_alpha(data_t f) { return (f > 0) && (f < 4); } CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); - bool m_pred_x(t_float f) + bool m_pred_x(data_t f) { return (f > 0) && (f < 1); } diff --git a/chaos/src/logistic_search.cpp b/chaos/src/logistic_search.cpp new file mode 100644 index 0000000..aaea340 --- /dev/null +++ b/chaos/src/logistic_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "logistic_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(logistic, LOGISTIC); diff --git a/chaos/src/lorenz.hpp b/chaos/src/lorenz.hpp index ee4e516..e94f027 100644 --- a/chaos/src/lorenz.hpp +++ b/chaos/src/lorenz.hpp @@ -63,6 +63,16 @@ public: deriv[1] = - x1 * x3 + CHAOS_PARAMETER(r) * x1 - x2; deriv[2] = x1 * x2 - CHAOS_PARAMETER(b) * x3; } + + + /* function has a fix point for x1 == x2 == x3 == 0 */ + 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(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); diff --git a/chaos/src/lorenz_search.cpp b/chaos/src/lorenz_search.cpp new file mode 100644 index 0000000..a7a9509 --- /dev/null +++ b/chaos/src/lorenz_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "lorenz.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(lorenz, LORENZ); diff --git a/chaos/src/lozi_map.hpp b/chaos/src/lozi_map.hpp index 3358cf5..b30a95b 100644 --- a/chaos/src/lozi_map.hpp +++ b/chaos/src/lozi_map.hpp @@ -60,11 +60,6 @@ public: m_data[1] = CHAOS_PARAMETER(b) * x; } - virtual void m_verify() - { - if (PD_BIGORSMALL(m_data[0])) - m_data[0] = 1; - } CHAOS_SYSVAR_FUNCS(x, 0); CHAOS_SYSVAR_FUNCS(y, 1); diff --git a/chaos/src/lozi_map_search.cpp b/chaos/src/lozi_map_search.cpp new file mode 100644 index 0000000..02f2db5 --- /dev/null +++ b/chaos/src/lozi_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "lozi_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(lozi_map, LOZI_MAP); diff --git a/chaos/src/main.cpp b/chaos/src/main.cpp index f781f7d..53bd62e 100644 --- a/chaos/src/main.cpp +++ b/chaos/src/main.cpp @@ -31,11 +31,14 @@ void chaos_library_setup() CHAOS_ADD(circle_map); CHAOS_ADD(coupled_logistic); CHAOS_ADD(chua); + CHAOS_ADD(delayed_logistic); CHAOS_ADD(driven_anharmonic); CHAOS_ADD(driven_van_der_pol); CHAOS_ADD(duffing_map); CHAOS_ADD(gauss_map); + CHAOS_ADD(gaussian_map); CHAOS_ADD(henon); + CHAOS_ADD(hydrogen); CHAOS_ADD(ikeda_laser_map); CHAOS_ADD(latoocarfian); CHAOS_ADD(latoomutalpha); diff --git a/chaos/src/ode_base.hpp b/chaos/src/ode_base.hpp index a15dc08..b7139d2 100644 --- a/chaos/src/ode_base.hpp +++ b/chaos/src/ode_base.hpp @@ -68,7 +68,7 @@ public: void ode_base_alloc() { int dimension = get_num_eq(); - + for (int i = 0; i != 3; ++i) { m_k[i] = new data_t[dimension]; @@ -87,15 +87,14 @@ public: } protected: - void (ode_base::*m_routine)(); + void (ode_base::*m_routine)(void); + unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */ data_t* m_k[3]; /* temporary arrays for runge kutta */ data_t* m_tmp; - virtual void m_system (data_t* deriv, data_t* data) - { - } + virtual void m_system (data_t* deriv, data_t* data) = 0; void rk1 (); void rk2 (); diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp index 3603a58..e2c55e0 100644 --- a/chaos/src/roessler.hpp +++ b/chaos/src/roessler.hpp @@ -34,11 +34,11 @@ public: CHAOS_PRECONSTRUCTOR; CHAOS_PAR_INIT(method,0); - CHAOS_PAR_INIT(dt,0.01); + CHAOS_PAR_INIT(dt,0.001); - CHAOS_SYS_INIT(x1,0,0); - CHAOS_SYS_INIT(x2,0,1); - CHAOS_SYS_INIT(x3,0,2); + CHAOS_SYS_INIT(x1,0.2,0); + CHAOS_SYS_INIT(x2,0.1,1); + CHAOS_SYS_INIT(x3,0.3,2); CHAOS_PAR_INIT(a,4); CHAOS_PAR_INIT(b,4); @@ -58,7 +58,7 @@ public: { data_t x1 = data[0], x2 = data[1], x3 = data[2]; - deriv[0] = - (x2 - x1); + deriv[0] = - (x2 + x3); deriv[1] = x1 + CHAOS_PARAMETER(a) * x2; deriv[2] = CHAOS_PARAMETER(b) + (x1 - CHAOS_PARAMETER(c)) * x3; } diff --git a/chaos/src/roessler_search.cpp b/chaos/src/roessler_search.cpp new file mode 100644 index 0000000..65596d0 --- /dev/null +++ b/chaos/src/roessler_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "roessler.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(roessler, ROESSLER); diff --git a/chaos/src/sine_map_search.cpp b/chaos/src/sine_map_search.cpp new file mode 100644 index 0000000..94fd2b9 --- /dev/null +++ b/chaos/src/sine_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "sine_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(sine_map, SINE_MAP); diff --git a/chaos/src/standard_map_search.cpp b/chaos/src/standard_map_search.cpp new file mode 100644 index 0000000..62bb535 --- /dev/null +++ b/chaos/src/standard_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "standard_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(standard_map, STANDARD_MAP); diff --git a/chaos/src/tent_map_search.cpp b/chaos/src/tent_map_search.cpp new file mode 100644 index 0000000..ac44587 --- /dev/null +++ b/chaos/src/tent_map_search.cpp @@ -0,0 +1,24 @@ +// +// +// 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, +// Boston, MA 02111-1307, USA. + +#include "tent_map.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(tent_map, TENT_MAP); -- cgit v1.2.1