diff options
Diffstat (limited to 'chaos')
123 files changed, 6104 insertions, 0 deletions
diff --git a/chaos/SConstruct b/chaos/SConstruct new file mode 100644 index 0000000..e02934e --- /dev/null +++ b/chaos/SConstruct @@ -0,0 +1,158 @@ +# scons script for flext build system +# 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. + +import sys + +env = Environment(CCFLAGS = '-DFLEXT_SYS_PD -DFLEXT_THREADS') + +env.SConsignFile() +env.CacheDir('./obj') + +opt = Options(['options.cache']) +opt.AddOptions( + BoolOption('debug', 'Build with debugging symbols', False), + ('optimize', 'Optimize for specific architecture', None), + BoolOption('icc', 'Build with intel c compiler', False), + BoolOption('simd', 'build with simd instructions', False), + BoolOption('cmem', 'build with normal memory allocation', True), + ('prefix', 'install prefix', '/usr/local'), + ('flext_path', 'flext path', None), + ('pd_path', 'pd path', None), + ) + +opt.Update(env) + +opt.Save('options.cache',env) +Help(opt.GenerateHelpText(env)) + +if env['icc']: + env.Replace(CC="icc", + SHCC="icc", + CXX="icc", + LINK="icc", + SHCXX="icc", + SHLINK="icc", + ) + env.Append(LINKFLAGS="-static-libcxa") + + env.Append(CCFLAGS=' -ip') + env.Append(LINKFLAGS='-ip') + print "Using intel c compiler" + + +if env['cmem']: + env.Append(CPPDEFINES=['FLEXT_USE_CMEM']) + + +if env.Dictionary().has_key('flext_path'): + env.Append(CPPPATH=[env['flext_path']]) +else: + env.Append(CPPPATH=['../../grill/flext/source']) + + +if env.Dictionary().has_key('pd_path'): + env.Append(CPPPATH=[env['pd_path']]) + +if env.Dictionary().has_key('simd') and env['simd']: + env.Append(CCFLAGS=' -mfpmath=sse -msse -mmmx -msse2') + +if env.Dictionary().has_key('optimize'): + if env['optimize']: + env.Append(CCFLAGS=' -O3 '+env['optimize']) + env.Append(LINKFLAGS=' -O3 '+env['optimize']) + +if env.Dictionary().has_key('debug') and env['debug']: + env.Append(CCFLAGS=' -g ') + env.Append(CPPDEFINES=['_DEBUG']) + env.Append(LIBS = 'flext-pd_d') + env.Append(LINKFLAGS=' -g') +else: + env.Append(LIBS = 'flext-pd') + env.Append(CPPDEFINES="NDEBUG") + +env.Append(CPPDEFINES=['FLEXT_SHARED']) + +###################################################################### +# +# read package.txt +# + +packagefile = open('./package.txt', 'r') + +desc = {} +line = packagefile.readline() +while line != "": + line = line.strip() + if len(line) > 0 and line[0] != '#' : + var, data = line.split('=') + + if len(data) == 0: + line = packagefile.readline() + continue + + while data [-1] == '\\': + nextline = packagefile.readline() + nextline = nextline.strip() + data = data + " " + nextline + + data = data.replace("\\", "") + desc[var] = data + + + line = packagefile.readline() +packagefile.close() + + +name = desc["NAME"] +if not desc.has_key("SRCDIR"): + desc["SRCDIR"] = "." + +sources = map (lambda x: desc["SRCDIR"] + '/' + x, + desc["SRCS"].split()) + +if desc.has_key("INCPATH"): + env.Append(CPPPATH=desc["INCPATH"].strip().replace("-I", "").split()) + + + +###################################################################### +# +# run custom.py +# +try: + sys.path.append("./build/") + import custom + try: + env, sources, headers = custom.custom(env,desc,sources) + except: + env, sources = custom.custom(env,desc,sources) +except: + pass + + + +###################################################################### +# +# build +# + +external = env.SharedLibrary(name, sources, SHLIBPREFIX='', SHLIBSUFFIX='.pd_linux') + +prefix = env['prefix'] +install = env.Install(prefix+'/lib/pd/extra',external) +env.Alias('install', install) diff --git a/chaos/package.txt b/chaos/package.txt new file mode 100644 index 0000000..c132783 --- /dev/null +++ b/chaos/package.txt @@ -0,0 +1,128 @@ +NAME=chaos +SRCDIR=src +BUILDTYPE=multi + +#PRECOMPILE=chaos.hpp + +SRCS= \ +main.cpp \ +bernoulli_dsp.cpp \ +bernoulli_msg.cpp \ +bernoulli_search.cpp \ +bungalow_tent_dsp.cpp \ +bungalow_tent_msg.cpp \ +bungalow_tent_search.cpp \ +chaos_base.cpp \ +chaos_dsp.cpp \ +chua_dsp.cpp \ +chua_msg.cpp \ +chua_search.cpp \ +circle_map_dsp.cpp \ +circle_map_msg.cpp \ +circle_map_search.cpp \ +coupled_logistic_dsp.cpp \ +coupled_logistic_msg.cpp \ +coupled_logistic_search.cpp \ +delayed_logistic_dsp.cpp \ +delayed_logistic_msg.cpp \ +delayed_logistic_search.cpp \ +driven_anharmonic_dsp.cpp \ +driven_anharmonic_msg.cpp \ +driven_anharmonic_search.cpp \ +driven_van_der_pol_dsp.cpp \ +driven_van_der_pol_msg.cpp \ +driven_van_der_pol_search.cpp \ +duffing_dsp.cpp \ +duffing_msg.cpp \ +duffing_search.cpp \ +duffing_map_dsp.cpp \ +duffing_map_msg.cpp \ +duffing_map_search.cpp \ +gauss_map_dsp.cpp \ +gauss_map_msg.cpp \ +gauss_map_search.cpp \ +gaussian_map_dsp.cpp \ +gaussian_map_msg.cpp \ +gaussian_map_search.cpp \ +henon_map_dsp.cpp \ +henon_map_msg.cpp \ +henon_map_search.cpp \ +hydrogen_dsp.cpp \ +hydrogen_msg.cpp \ +hydrogen_search.cpp \ +ikeda_laser_map_dsp.cpp \ +ikeda_laser_map_msg.cpp \ +ikeda_laser_map_search.cpp \ +latoocarfian_dsp.cpp \ +latoocarfian_msg.cpp \ +latoocarfian_search.cpp \ +latoomutalpha_dsp.cpp \ +latoomutalpha_msg.cpp \ +latoomutalpha_search.cpp \ +latoomutbeta_dsp.cpp \ +latoomutbeta_msg.cpp \ +latoomutbeta_search.cpp \ +latoomutgamma_dsp.cpp \ +latoomutgamma_msg.cpp \ +latoomutgamma_search.cpp \ +linear_congruental_dsp.cpp \ +linear_congruental_msg.cpp \ +linear_congruental_search.cpp \ +logistic_dsp.cpp \ +logistic_msg.cpp \ +logistic_search.cpp \ +lorenz_dsp.cpp \ +lorenz_msg.cpp \ +lorenz_search.cpp \ +lozi_map_dsp.cpp \ +lozi_map_msg.cpp \ +lozi_map_search.cpp \ +ode_base.cpp \ +roessler_dsp.cpp \ +roessler_msg.cpp \ +roessler_search.cpp \ +sine_map_dsp.cpp \ +sine_map_msg.cpp \ +sine_map_search.cpp \ +standard_map_dsp.cpp \ +standard_map_msg.cpp \ +standard_map_search.cpp \ +tent_map_dsp.cpp \ +tent_map_msg.cpp \ +tent_map_search.cpp \ + + +HDRS= \ +bernoulli_map.hpp \ +bungalow_tent_map.hpp \ +chaos.hpp \ +chaos_base.hpp \ +chaos_defs.hpp \ +chaos_dsp.hpp \ +chaos_msg.hpp \ +chaos_search.hpp \ +chua.hpp \ +circle_map.hpp \ +coupled_logistic.hpp \ +delayed_logistic.hpp \ +driven_anharmonic.hpp \ +driven_van_der_pol.hpp \ +duffing_map.hpp \ +gauss_map.hpp \ +gaussian_map.hpp \ +henon_map.hpp \ +hydrogen.hpp \ +ikeda_laser_map.hpp \ +latoocarfian.hpp \ +latoomutalpha.hpp \ +latoomutbeta.hpp \ +latoomutgamma.hpp \ +logistic_map.hpp \ +lorenz.hpp \ +lozi_map.hpp \ +map_base.hpp \ +ode_base.hpp \ +roessler.hpp \ +sine_map.hpp \ +standard_map.hpp \ +tent_map.hpp diff --git a/chaos/src/bernoulli_dsp.cpp b/chaos/src/bernoulli_dsp.cpp new file mode 100644 index 0000000..3cf9480 --- /dev/null +++ b/chaos/src/bernoulli_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 "bernoulli_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(bernoulli, BERNOULLI); diff --git a/chaos/src/bernoulli_map.hpp b/chaos/src/bernoulli_map.hpp new file mode 100644 index 0000000..781011b --- /dev/null +++ b/chaos/src/bernoulli_map.hpp @@ -0,0 +1,65 @@ +// +// +// 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" + +// bernoulli map: x[n+1] = 2 * x[n] mod 1 +// 0 <= x[n] < 1 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class bernoulli: + public map_base<1> +{ +public: + + bernoulli() + { + CHAOS_SYS_INIT(x,0.5,0); + } + + void m_step() + { + data_t x = m_data[0]; + + if (x <= 0) + x = 0.00001; //stability + + if (x < 0.5f) + m_data[0] = 2.f * x; + else + m_data[0] = 2.f * x - 1.f; + } + + CHAOS_SYSVAR_FUNCS_PRED(x,0,m_pred_x); + bool m_pred_x(t_float f) + { + return (f >= 0) && (f < 1); + } +}; + + +#define BERNOULLI_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x); + + +#define BERNOULLI_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x); diff --git a/chaos/src/bernoulli_msg.cpp b/chaos/src/bernoulli_msg.cpp new file mode 100644 index 0000000..8e07ed5 --- /dev/null +++ b/chaos/src/bernoulli_msg.cpp @@ -0,0 +1,34 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "bernoulli_map.hpp" +#include "chaos_msg.hpp" + +class bernoulli_msg: + public chaos_msg<bernoulli> +{ + CHAOS_MSG_INIT(bernoulli, BERNOULLI_ATTRIBUTES); + + BERNOULLI_CALLBACKS; +}; + + + +FLEXT_LIB_V("bernoulli", bernoulli_msg); 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_dsp.cpp b/chaos/src/bungalow_tent_dsp.cpp new file mode 100644 index 0000000..111a96a --- /dev/null +++ b/chaos/src/bungalow_tent_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 "bungalow_tent_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(bungalow_tent,BUNGALOW_TENT); diff --git a/chaos/src/bungalow_tent_map.hpp b/chaos/src/bungalow_tent_map.hpp new file mode 100644 index 0000000..492b6d5 --- /dev/null +++ b/chaos/src/bungalow_tent_map.hpp @@ -0,0 +1,94 @@ +// +// +// 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" + +// bungalow_tent map: x[n+1] = 1 + 2 * r + 2 * (r + 1) * x[n] +// (for -1 <= x[n] < -0.5f) +// 1 + 2 * (1 - r) * (x[n]) +// (for -0.5 <= x[n] < 0) +// 1 + 2 * (r - 1) * (x[n]) +// (for 0 <= x[n] < 0.5) +// 1 + 2 * r - 2 * (r + 1) * (x[n]) +// (for 0.5 <= x[n] < 1) +// -1 <= x[n] < 1 +// -0.5 <= r < 1 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class bungalow_tent: + public map_base<1> +{ +public: + bungalow_tent() + { + CHAOS_SYS_INIT(x, 0.6,0); + CHAOS_PAR_INIT(r, 0.5); + } + + void m_step() + { + data_t x = m_data[0]; + data_t r = CHAOS_PARAMETER(r); + + if ( x < - 0.5) + { + m_data[0] = 1 + 2 * r + 2 * (r + 1) * x; + return; + } + if ( x < 0) + { + m_data[0] = 1 + 2 * (1 - r) * x; + return; + } + if ( x < 0.5) + { + m_data[0] = 1 + 2 * (r - 1) * x; + return; + } + else + { + m_data[0] = 1 + 2 * r - 2 * (r + 1) * x; + return; + } + + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); + bool m_pred_x(t_float f) + { + return (f >= -1) && (f < 1); + } + + CHAOS_SYSPAR_FUNCS_PRED(r, m_pred_r); + bool m_pred_r(t_float f) + { + return (f >= -0.5) && (f < 1); + } +}; + +#define BUNGALOW_TENT_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(r); + +#define BUNGALOW_TENT_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x) \ +CHAOS_SYS_ATTRIBUTE(r) diff --git a/chaos/src/bungalow_tent_msg.cpp b/chaos/src/bungalow_tent_msg.cpp new file mode 100644 index 0000000..6c3ae7e --- /dev/null +++ b/chaos/src/bungalow_tent_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 "bungalow_tent_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(bungalow_tent, BUNGALOW_TENT); 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 new file mode 100644 index 0000000..259f56e --- /dev/null +++ b/chaos/src/chaos.hpp @@ -0,0 +1,51 @@ +// +// +// 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. + +#ifndef __chaos_hpp + +#define FLEXT_ATTRIBUTES 1 + +#define _USE_MATH_DEFINES /* tg says: define this before including cmath */ +#include "flext.h" +#include "assert.h" +#include "chaos_defs.hpp" +#include <cmath> + +#include <cstdlib> + +#if FLEXT_SYS != FLEXT_SYS_PD +#define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \ + (((*(unsigned int*)&(f))&0x60000000)==0x60000000)) +#endif + +/* internal we can work with a higher precision than pd */ +#ifdef DOUBLE_PRECISION +typedef double data_t; +#else +typedef float data_t; +#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.cpp b/chaos/src/chaos_base.cpp new file mode 100644 index 0000000..9f8cad3 --- /dev/null +++ b/chaos/src/chaos_base.cpp @@ -0,0 +1,21 @@ +// +// +// 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. + + diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp new file mode 100644 index 0000000..d18a507 --- /dev/null +++ b/chaos/src/chaos_base.hpp @@ -0,0 +1,79 @@ +// +// +// chaos~ +// Copyright (C) 2004, 2006 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. + +#ifndef __chaos_base_hpp + +#include "chaos.hpp" +#include <map> + +template <int dimensions> +class chaos_base +{ +public: + chaos_base() + { + } + + inline t_sample get_data(unsigned int i) + { + assert(i<dimensions); + return (t_sample)m_data[i]; /* this is not save, but fast */ + } + + inline int get_num_eq() const + { + return dimensions; + } + +// inline void m_perform() +// { +// m_step(); +// m_bash_denormals(); +// m_verify(); +// } + + std::map<const t_symbol*,int> attr_ind; + + // check the integrity of the system + inline void m_verify() + { + } + + inline void m_bash_denormals() + { + for (int i = 0; i != dimensions; ++i) + { +#ifndef DOUBLE_PRECISION + if (PD_BIGORSMALL(m_data[i])) + m_data[i] = 0; +#endif + } + }; + + data_t m_data[dimensions]; // state of the system + +protected: +// void m_step() = 0; // iteration + flext::AtomList Parameter; // parameter + flext::AtomList System; // system +}; + +#define __chaos_base_hpp +#endif /* __chaos_base_hpp */ diff --git a/chaos/src/chaos_defs.hpp b/chaos/src/chaos_defs.hpp new file mode 100644 index 0000000..c4e68a5 --- /dev/null +++ b/chaos/src/chaos_defs.hpp @@ -0,0 +1,221 @@ +// +// +// 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. + +#ifndef __chaos_defs_hpp + + +// macros for simplified system state functions +#define CHAOS_SYS_SETFUNC(NAME, NR) \ + void set_##NAME(t_float f) \ + { \ + m_data[NR] = (data_t) f; \ + } + +#define CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \ + void set_##NAME(t_float f) \ + { \ + if ( PRED(f) ) \ + m_data[NR] = (data_t) f; \ + else \ + post("value for dimension " #NAME " %f out of range", f); \ + } + +#define CHAOS_SYS_GETFUNC(NAME, NR) \ + t_float get_##NAME() \ + { \ + return (t_float)m_data[NR]; \ + } + +/* to be called in the public part */ +#define CHAOS_SYSVAR_FUNCS_PRED(NAME, NR, PRED) \ +CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \ +CHAOS_SYS_GETFUNC(NAME, NR) + +#define CHAOS_SYSVAR_FUNCS(NAME, NR) \ +CHAOS_SYS_SETFUNC(NAME, NR) \ +CHAOS_SYS_GETFUNC(NAME, NR) + + + +// macros for simplified system parameter functions +#define CHAOS_PAR_SETFUNC(NAME) \ + void set_##NAME(t_float f) \ + { \ + m_##NAME = (data_t) f; \ + } + +#define CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \ + void set_##NAME(t_float f) \ + { \ + if ( PRED(f) ) \ + m_##NAME = (data_t) f; \ + else \ + post("value for parameter " #NAME " %f out of range", f); \ + } + +#define CHAOS_PAR_GETFUNC(NAME) \ + t_float get_##NAME() \ + { \ + return (t_float)m_##NAME; \ + } + + +#define CHAOS_SYSPAR_FUNCS_PRED(NAME, PRED) \ +CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \ +CHAOS_PAR_GETFUNC(NAME) \ +data_t m_##NAME; + + +#define CHAOS_SYSPAR_FUNCS(NAME) \ +public: \ +CHAOS_PAR_SETFUNC(NAME) \ +CHAOS_PAR_GETFUNC(NAME) \ +data_t m_##NAME; + + +#define CHAOS_SYSPAR_FUNCS_I(NAME) \ +CHAOS_PAR_SETFUNC(NAME) \ +CHAOS_PAR_GETFUNC(NAME) \ +data_t m_##NAME; + + +#define CHAOS_SYS_CALLBACKS(NAME) \ +public: \ +void get_##NAME(t_float &f) \ +{ \ + f = m_system.get_##NAME(); \ +} \ +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: \ +void get_##NAME(int &i) \ +{ \ + i = m_system.get_##NAME(); \ +} \ +void set_##NAME(int &i) \ +{ \ + m_system.set_##NAME(i); \ +} \ +FLEXT_CALLVAR_I(get_##NAME, set_##NAME); + + +#define CHAOS_SYS_ATTRIBUTE(NAME) \ +FLEXT_ADDATTR_VAR(#NAME,get_##NAME, set_##NAME); + + +#define CHAOS_INIT(NAME, VALUE) \ +set_##NAME(VALUE); + +#define CHAOS_SYS_INIT(NAME, VALUE, INDEX) \ +set_##NAME(VALUE); \ +t_atom atom_##NAME; \ +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; \ +flext::SetSymbol(atom_##NAME, flext::MakeSymbol(#NAME)); \ +Parameter.Append(atom_##NAME); + + +#define CHAOS_PARAMETER(NAME) m_##NAME + + + + +/* macros for class generation */ +#define CHAOS_DSP_CLASS(CLASSNAME,CLASSNAME_UC) \ +class CLASSNAME##_dsp: \ + public chaos_dsp<CLASSNAME> \ +{ \ + CHAOS_DSP_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_DSP_V(#CLASSNAME"~", CLASSNAME##_dsp); + + +#define CHAOS_DSP_CLASS_NAME(CLASSNAME,CLASSNAME_UC, NAME) \ +class CLASSNAME##_dsp: \ + public chaos_dsp<CLASSNAME> \ +{ \ + CHAOS_DSP_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_DSP_V(#NAME, CLASSNAME##_dsp); + + +#define CHAOS_MSG_CLASS(CLASSNAME,CLASSNAME_UC) \ +class CLASSNAME##_msg: \ + public chaos_msg<CLASSNAME> \ +{ \ + CHAOS_MSG_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#CLASSNAME, CLASSNAME##_msg); + + +#define CHAOS_MSG_CLASS_NAME(CLASSNAME,CLASSNAME_UC, NAME) \ +class CLASSNAME##_msg: \ + public chaos_msg<CLASSNAME> \ +{ \ + CHAOS_MSG_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#NAME, CLASSNAME##_msg); + +#define CHAOS_SEARCH_CLASS(CLASSNAME,CLASSNAME_UC) \ +class CLASSNAME##_search: \ + public chaos_search<CLASSNAME> \ +{ \ + CHAOS_SEARCH_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#CLASSNAME"_search", CLASSNAME##_search); + + +#define CHAOS_SEARCH_CLASS_NAME(CLASSNAME,CLASSNAME_UC, NAME) \ +class CLASSNAME##_msg: \ + public chaos_search<CLASSNAME> \ +{ \ + CHAOS_SEARCH_INIT(CLASSNAME, CLASSNAME_UC##_ATTRIBUTES); \ + CLASSNAME_UC##_CALLBACKS; \ +}; \ +FLEXT_LIB_V(#NAME, CLASSNAME##_msg); + + + +#define CHAOS_ADD(NAME) \ +FLEXT_DSP_SETUP(NAME##_dsp); \ +FLEXT_SETUP(NAME##_msg); \ +FLEXT_SETUP(NAME##_search); + +#define __chaos_defs_hpp +#endif /* __chaos_defs_hpp */ diff --git a/chaos/src/chaos_dsp.cpp b/chaos/src/chaos_dsp.cpp new file mode 100644 index 0000000..2040312 --- /dev/null +++ b/chaos/src/chaos_dsp.cpp @@ -0,0 +1,22 @@ +// +// +// 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 "chaos_dsp.hpp" diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp new file mode 100644 index 0000000..6ca9ce4 --- /dev/null +++ b/chaos/src/chaos_dsp.hpp @@ -0,0 +1,532 @@ +// +// +// 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 "chaos_base.hpp" + +template <class system> +class chaos_dsp + : public flext_dsp +{ + FLEXT_HEADER(chaos_dsp, flext_dsp); + +protected: + chaos_dsp(int argc, t_atom* argv) + { + m_sr = 44100; /* assume default sampling rate */ + 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_INIT(freq, GetAInt(argv[0])); + } + else + { + CHAOS_INIT(freq, 440); + } + + if (argc > 1) + { + CHAOS_INIT(imethod, GetAInt(argv[1])); + } + else + { + CHAOS_INIT(imethod, 0); + } + m_phase = 0; + } + + ~chaos_dsp() + { + delete[] m_values; + delete[] m_slopes; + delete[] m_nextvalues; + delete[] m_nextmidpts; + delete[] m_curves; + } + +public: + /* signal functions: */ + /* 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); + /* linear interpolation for high frequencies */ + void m_signal_l_hf(int n, t_sample *const *insigs,t_sample *const *outsigs); + /* cubic interpolation */ + void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs); + /* cubic interpolation for high frequencies */ + void m_signal_c_hf(int n, t_sample *const *insigs,t_sample *const *outsigs); + + virtual void CbSignal() + { + (this->*m_routine)(Blocksize(),InSig(),OutSig()); + } + + virtual bool CbDsp() + { + m_sr = Samplerate(); + set_freq(m_freq); /* maybe we have to change the interpolation mode */ + return true; + } + + void (thisType::*m_routine)(int n, t_sample *const *insigs,t_sample *const *outsigs); + + /* local data for system, output and interpolation */ + system m_system; /* the system */ + + t_sample * m_values; /* actual value */ + t_sample * m_slopes; /* actual slope for cubic interpolation */ + + t_sample * m_nextvalues; + t_sample * m_nextmidpts; + t_sample * m_curves; + + /* local data for signal functions */ + float m_freq; /* frequency of oscillations */ + float m_invfreq; /* inverse frequency */ + float m_phase; /* phase */ + float m_sr; /* sample rate */ + + int m_imethod; /* interpolation method */ + + void get_imethod(int &i) + { + i = m_imethod; + } + + void set_imethod(int i) + { + int imethod = m_imethod; + if( (i >= 0) && (i <= 2) ) + { + m_imethod = i; + switch (i) + { + case 0: + m_routine = &thisType::m_signal_n; + break; + case 1: + m_routine = &thisType::m_signal_l; + break; + case 2: + m_routine = &thisType::m_signal_c; + break; + } + } + else + { + post("interpolation method out of range"); + return; + } + + if (imethod == 0) + for (int j = 0; j != m_system.get_num_eq(); ++j) + { + m_values[j] = m_system.get_data(j); + m_slopes[j] = 0; + } + + if(i == 2 && imethod != 2) + { + for (int j = 0; j != m_system.get_num_eq(); ++j) + { + m_phase = 0; /* reschedule to avoid click, find a better way later*/ + m_nextvalues[j] = m_values[j]; + m_nextmidpts[j] = m_values[j]; + } + } + set_freq(m_freq); + } + + void get_freq(float &f) + { + f = m_freq; + } + + void set_freq(float f) + { + if (f < 0) /* we can't go back in time :-) */ + f = -f; + + if( f <= m_sr * 0.01 ) + { + switch(m_imethod) + { + case 0: + m_routine = &thisType::m_signal_n; + break; + case 1: + m_routine = &thisType::m_signal_l; + break; + case 2: + m_routine = &thisType::m_signal_c; + break; + default: + assert(false); + } + } + else + { + switch(m_imethod) + { + case 0: + m_routine = &thisType::m_signal_n_hf; + break; + case 1: + m_routine = &thisType::m_signal_l_hf; + break; + case 2: + m_routine = &thisType::m_signal_c_hf; + break; + default: + assert(false); + } + } + + m_freq = f; + m_invfreq = 1.f / f; + } + + 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>) \ + \ +SYSTEM##_dsp(int argc, t_atom* argv): \ + chaos_dsp<SYSTEM>(argc, argv) \ +{ \ + ATTRIBUTES; \ +} \ + \ +FLEXT_ATTRVAR_F(m_freq); \ +FLEXT_ATTRVAR_I(m_imethod); + + + +template <class system> +void chaos_dsp<system>::m_signal_(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + for (int i = 0; i!=n; ++i) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + for (int j = 0; j != outlets; ++j) + { + outsigs[j][i] = m_system.get_data(j); + } + } +} + + +template <class system> +void chaos_dsp<system>::m_signal_n_hf(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + float phase = m_phase; + + int offset = 0; + while (n) + { + while (phase <= 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + 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_phase = phase; +} + + +template <class system> +void chaos_dsp<system>::m_signal_n(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + int phase = int(m_phase); + + int offset = 0; + while (n) + { + if (phase == 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + phase = int (m_sr * m_invfreq); + } + + int next = (phase < n) ? 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_phase = phase; +} + +/* linear and cubic interpolation adapted from supercollider by James McCartney */ +template <class system> +void chaos_dsp<system>::m_signal_l(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + int phase = int(m_phase); + + int i = 0; + + while (n) + { + if (phase == 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + phase = int (m_sr * m_invfreq); + + for (int j = 0; j != outlets; ++j) + m_slopes[j] = (m_system.get_data(j) - m_values[j]) / phase; + } + + int next = (phase < n) ? phase : n; + n -= next; + phase -=next; + + while (next--) + { + for (int j = 0; j != outlets; ++j) + { + outsigs[j][i] = m_values[j]; + m_values[j]+=m_slopes[j]; + } + ++i; + } + } + m_phase = phase; +} + + + +template <class system> +void chaos_dsp<system>::m_signal_l_hf(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + float phase = m_phase; + + int i = 0; + + while (n) + { + if (phase <= 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + phase = m_sr * m_invfreq; + + for (int j = 0; j != outlets; ++j) + m_slopes[j] = (m_system.get_data(j) - m_values[j]) / phase; + } + + int next = (phase < n) ? int(ceilf (phase)) : n; + n -= next; + phase -=next; + + while (next--) + { + for (int j = 0; j != outlets; ++j) + { + outsigs[j][i] = m_values[j]; + m_values[j]+=m_slopes[j]; + } + ++i; + } + } + m_phase = phase; +} + + +template <class system> +void chaos_dsp<system>::m_signal_c(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + int phase = int(m_phase); + + int i = 0; + + while (n) + { + if (phase == 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + phase = int (m_sr * m_invfreq); + phase = (phase > 2) ? phase : 2; + + for (int j = 0; j != outlets; ++j) + { + t_sample value = m_nextvalues[j]; + m_nextvalues[j]= m_system.get_data(j); + + m_values[j] = m_nextmidpts[j]; + m_nextmidpts[j] = (m_nextvalues[j] + value) * 0.5f; + + float fseglen = (float)phase; + m_curves[j] = 2.f * (m_nextmidpts[j] - m_values[j] - + fseglen * m_slopes[j]) + / (fseglen * fseglen + fseglen); + } + } + + int next = (phase < n) ? phase : n; + n -= next; + phase -=next; + + while (next--) + { + for (int j = 0; j != outlets; ++j) + { + outsigs[j][i] = m_values[j]; + m_slopes[j]+=m_curves[j]; + m_values[j]+=m_slopes[j]; + } + ++i; + } + } + m_phase = phase; +} + + +template <class system> +void chaos_dsp<system>::m_signal_c_hf(int n, t_sample *const *insigs, + t_sample *const *outsigs) +{ + int outlets = m_system.get_num_eq(); + + float phase = m_phase; + + int i = 0; + + while (n) + { + if (phase == 0) + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + + phase = int (m_sr * m_invfreq); + phase = (phase > 2) ? phase : 2; + + for (int j = 0; j != outlets; ++j) + { + t_sample value = m_nextvalues[j]; + m_nextvalues[j]= m_system.get_data(j); + + m_values[j] = m_nextmidpts[j]; + m_nextmidpts[j] = (m_nextvalues[j] + value) * 0.5f; + + float fseglen = (float)phase; + m_curves[j] = 2.f * (m_nextmidpts[j] - m_values[j] - + fseglen * m_slopes[j]) + / (fseglen * fseglen + fseglen); + } + } + + int next = (phase < n) ? int(ceilf (phase)) : n; + n -= next; + phase -=next; + + while (next--) + { + for (int j = 0; j != outlets; ++j) + { + outsigs[j][i] = m_values[j]; + m_slopes[j]+=m_curves[j]; + m_values[j]+=m_slopes[j]; + } + ++i; + } + } + m_phase = phase; +} diff --git a/chaos/src/chaos_msg.hpp b/chaos/src/chaos_msg.hpp new file mode 100644 index 0000000..915d6a1 --- /dev/null +++ b/chaos/src/chaos_msg.hpp @@ -0,0 +1,70 @@ +// +// +// 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 "chaos_base.hpp" + +template <class system> +class chaos_msg: + public flext_base +{ + FLEXT_HEADER(chaos_msg, flext_base); + +protected: + chaos_msg(int argc, t_atom* argv) + { + int size = m_system.get_num_eq(); + + for (int i = 0; i != size; ++i) + AddOutFloat(); + FLEXT_ADDBANG(0, m_bang); + } + +public: + + system m_system; /* the system */ + + void m_bang() + { + m_system.m_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + + int outlets = m_system.get_num_eq(); + + while (outlets--) + { + ToOutFloat(outlets, m_system.get_data(outlets)); + } + } + + FLEXT_CALLBACK(m_bang); +}; + + +/* create constructor / destructor */ +#define CHAOS_MSG_INIT(SYSTEM, ATTRIBUTES) \ +FLEXT_HEADER(SYSTEM##_msg, chaos_msg<SYSTEM>) \ + \ +SYSTEM##_msg(int argc, t_atom* argv ): \ +chaos_msg<SYSTEM>(argc, argv) \ +{ \ + ATTRIBUTES; \ +} diff --git a/chaos/src/chaos_search.hpp b/chaos/src/chaos_search.hpp new file mode 100644 index 0000000..fded6bc --- /dev/null +++ b/chaos/src/chaos_search.hpp @@ -0,0 +1,190 @@ +// +// +// 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" + +#define MAXDIMENSION 5 + +template <class system> 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<const t_symbol*,int>::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>) \ + \ +SYSTEM##_search(int argc, t_atom* argv ) \ +{ \ + 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); \ +} \ + \ + \ +FLEXT_ATTRVAR_I(m_transient_steps); \ +FLEXT_ATTRVAR_I(m_asymptotic_steps); + + + +template <class system> +void chaos_search<system>::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_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + } + + 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_step(); + m_system.m_bash_denormals(); + m_system.m_verify(); + + 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 new file mode 100644 index 0000000..7669a24 --- /dev/null +++ b/chaos/src/chua.hpp @@ -0,0 +1,165 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" + +// chua system: dx1/dt = alpha * (x2 - x1 - h(x1)) +// dx2/dt = x1 - x2 + x3 +// dx3/dt = - beta * x2 +// +// with h(x) = b*x + a - b (for x > 1) +// a*x (for -1 <= x <= 1 +// b*x - a + b (for x < -1) +// +// taken from Viktor Avrutin: lecture notes + +class chua: + public ode_base<3> +{ +public: + chua() + { + CHAOS_PAR_INIT(method,2); + CHAOS_PAR_INIT(dt,0.05); + + CHAOS_SYS_INIT(x1,1,1); + CHAOS_SYS_INIT(x2,1,1); + CHAOS_SYS_INIT(x3,1,1); + + CHAOS_PAR_INIT(a,140); + CHAOS_PAR_INIT(b,30); + CHAOS_PAR_INIT(alpha,30); + CHAOS_PAR_INIT(beta,30); + } + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t x1 = data[0]; + data_t x2 = data[1]; + data_t x3 = data[2]; + + data_t a = CHAOS_PARAMETER(a), b = CHAOS_PARAMETER(b); + + data_t h; + + if (x1 > 1) + h = b*x1 + a - b; + else if (x1 < -1) + h = b*x1 - a + b; + else + h = a*x1; + + deriv[0] = CHAOS_PARAMETER(alpha) * (x2 - x1 - h); + deriv[1] = x1 - x2 + x3; + deriv[2] = - CHAOS_PARAMETER(beta) * x2; + } + + virtual void m_verify() + { + data_t x1 = m_data[0]; + data_t x2 = m_data[1]; + data_t x3 = m_data[2]; + + if ( std::abs(x3) < 1e-10) + x3 = 0; + + if (x1 == 0 && x2 == 0 && x3 == 0) /* fixpoint at (0,0,0) */ + { + reset(); + return; + } + else + { + data_t c = m_c; + if (m_c) + { + data_t mc = - c; + if (x1 == c && x3 == mc) /* fixpoint at (c,0,-c) */ + { + reset(); + return; + } + if (x1 == mc && x3 == c) /* fixpoint at (-c,0,c) */ + { + reset(); + return; + } + } + } + } + + inline void reset() + { + m_data[0] = rand_range(-1,1); + m_data[1] = rand_range(-1,1); + m_data[2] = rand_range(-1,1); + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + CHAOS_SYSVAR_FUNCS(x3, 2); + + /* due to stability issues, we hook into the predicates */ + data_t m_c; + bool m_pred_a(data_t a) + { + data_t b = CHAOS_PARAMETER(b); + m_c = (b - a) / (b + 1); + return true; + } + + bool m_pred_b(data_t b) + { + if (b == -1) + m_c = 0; + else + { + data_t a = CHAOS_PARAMETER(a); + m_c = (b - a) / (b + 1); + } + return true; + } + + CHAOS_SYSPAR_FUNCS_PRED(a, m_pred_a); + CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b); + CHAOS_SYSPAR_FUNCS(alpha); + CHAOS_SYSPAR_FUNCS(beta); +}; + + +#define CHUA_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(alpha); \ +CHAOS_SYS_CALLBACKS(beta); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(x3); + +#define CHUA_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(alpha); \ +CHAOS_SYS_ATTRIBUTE(beta); \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(x3); diff --git a/chaos/src/chua_dsp.cpp b/chaos/src/chua_dsp.cpp new file mode 100644 index 0000000..6ae151c --- /dev/null +++ b/chaos/src/chua_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 "chua.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(chua,CHUA); diff --git a/chaos/src/chua_msg.cpp b/chaos/src/chua_msg.cpp new file mode 100644 index 0000000..b00aa7f --- /dev/null +++ b/chaos/src/chua_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 "chua.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(chua,CHUA); 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.hpp b/chaos/src/circle_map.hpp new file mode 100644 index 0000000..c58391a --- /dev/null +++ b/chaos/src/circle_map.hpp @@ -0,0 +1,68 @@ +// +// +// 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 <cmath> + +// circle_map map: x[n+1] = x[n] + omega - r / (2*pi) * sin (2 * pi * x [n]) +// +// taken from Willi-Hans Steeb: Chaos and Fractals + +class circle_map: + public map_base<1> +{ +public: + circle_map() + { + CHAOS_SYS_INIT(x, 0.4,0); + + CHAOS_PAR_INIT(omega, 0.1); + CHAOS_PAR_INIT(r, 3); + } + + + void m_step() + { + data_t x = m_data[0]; + data_t omega = CHAOS_PARAMETER(omega); + data_t r = CHAOS_PARAMETER(r); + + m_data[0] = x + omega - r / (2.f * M_PI) * sin (2.f * M_PI * x); + } + + CHAOS_SYSVAR_FUNCS(x,0); + CHAOS_SYSPAR_FUNCS(r); + CHAOS_SYSPAR_FUNCS(omega); +}; + +#define CIRCLE_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(omega); \ +CHAOS_SYS_CALLBACKS(r); \ +CHAOS_SYS_CALLBACKS(x); + + +#define CIRCLE_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(omega); \ +CHAOS_SYS_ATTRIBUTE(r); \ +CHAOS_SYS_ATTRIBUTE(x); + diff --git a/chaos/src/circle_map_dsp.cpp b/chaos/src/circle_map_dsp.cpp new file mode 100644 index 0000000..e5ddef4 --- /dev/null +++ b/chaos/src/circle_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 "circle_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(circle_map, CIRCLE_MAP) diff --git a/chaos/src/circle_map_msg.cpp b/chaos/src/circle_map_msg.cpp new file mode 100644 index 0000000..7fa6c9b --- /dev/null +++ b/chaos/src/circle_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 "circle_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(circle_map, CIRCLE_MAP); 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 new file mode 100644 index 0000000..048aae1 --- /dev/null +++ b/chaos/src/coupled_logistic.hpp @@ -0,0 +1,96 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "map_base.hpp" + +// coupled_logistic map: x[n+1] = r * x[n] * (1 - x[n]) + e * (y[n] - x[n]) +// y[n+1] = r * y[n] * (1 - y[n]) + e * (x[n] - y[n]) +// 0 <= r <= 4 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class coupled_logistic: + public map_base<2> +{ +public: + coupled_logistic() + { + CHAOS_PAR_INIT(e, 0.06); + CHAOS_PAR_INIT(r, 3.7); + + CHAOS_SYS_INIT(x, 0.1,0); + CHAOS_SYS_INIT(y, 0.2,1); + } + + virtual inline void m_step() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + data_t e = CHAOS_PARAMETER(e); + data_t r = CHAOS_PARAMETER(r); + m_data[0] = r * x * (1.f - x) + e * (y - x); + m_data[1] = r * y * (1.f - y) + e * (x - y); + m_verify(); + } + + CHAOS_SYSPAR_FUNCS(e); + CHAOS_SYSPAR_FUNCS_PRED(r, m_pred_r); + static bool m_pred_r(t_float f) + { + return (f > 0) && (f < 4); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_xy); + CHAOS_SYSVAR_FUNCS_PRED(y, 0, m_pred_xy); + + static bool m_pred_xy(t_float f) + { + return (f > 0) && (f < 1); + } + + inline void m_verify() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + if (!m_pred_xy(x)) + m_data[0] = rand_range(0,0.08); + if (!m_pred_xy(y)) + 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); + } + } +}; + +#define COUPLED_LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(e); \ +CHAOS_SYS_CALLBACKS(r); \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); + +#define COUPLED_LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(e); \ +CHAOS_SYS_ATTRIBUTE(r); \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); + diff --git a/chaos/src/coupled_logistic_dsp.cpp b/chaos/src/coupled_logistic_dsp.cpp new file mode 100644 index 0000000..166ca79 --- /dev/null +++ b/chaos/src/coupled_logistic_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "coupled_logistic.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(coupled_logistic, COUPLED_LOGISTIC) + diff --git a/chaos/src/coupled_logistic_msg.cpp b/chaos/src/coupled_logistic_msg.cpp new file mode 100644 index 0000000..15ef289 --- /dev/null +++ b/chaos/src/coupled_logistic_msg.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_msg.hpp" + +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..d7f7539 --- /dev/null +++ b/chaos/src/delayed_logistic.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" + +// 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<1> +{ +public: + delayed_logistic() + { + CHAOS_SYS_INIT(x, 0.5, 0); + CHAOS_PAR_INIT(alpha, 3.8); + + m_delayed = get_x(); /* the initial state of the delay */ + } + + + + 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.hpp b/chaos/src/driven_anharmonic.hpp new file mode 100644 index 0000000..7d6bfd6 --- /dev/null +++ b/chaos/src/driven_anharmonic.hpp @@ -0,0 +1,102 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" +#include <cmath> + +// driven anharmonic: +// d2u/dt2 + a * du/dt + b*u + c * u*u*u = k1 + k2*cos(Omega*t) +// equivalent: +// du1/dt = u2 +// du2/dt = -a*u2 - b*u1 -c*u*u*u + k1 + k2*cos(Omega*t) +// taken from Willi-Hans Steeb: Chaos and Fractals + +class driven_anharmonic + : public ode_base<2> +{ +public: + driven_anharmonic() + { + CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(dt,0.01); + + CHAOS_SYS_INIT(u1,0,0); + CHAOS_SYS_INIT(u2,1,1); + + CHAOS_PAR_INIT(a,1); + CHAOS_PAR_INIT(b,-10); + CHAOS_PAR_INIT(c,100); + CHAOS_PAR_INIT(Omega,3.5); + CHAOS_PAR_INIT(k1,0.01); + CHAOS_PAR_INIT(k2,1); + + m_t = 0; + } + + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t u1 = data[0], u2 = data[1]; + + deriv[0] = u2; + deriv[1] = - CHAOS_PARAMETER(a) * u2 - CHAOS_PARAMETER(b) * u1 - + CHAOS_PARAMETER(c) * u1*u1*u1 + CHAOS_PARAMETER(k1) + + CHAOS_PARAMETER(k2) * cos (CHAOS_PARAMETER(Omega) * m_t); + m_t += m_dt; + + if (m_t > 2 * M_PI) + m_t = fmod(m_t, (data_t)(M_PI*2)); + } + + data_t m_t; + + CHAOS_SYSVAR_FUNCS(u1, 0); + CHAOS_SYSVAR_FUNCS(u2, 1); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); + CHAOS_SYSPAR_FUNCS(k1); + CHAOS_SYSPAR_FUNCS(k2); + CHAOS_SYSPAR_FUNCS(Omega); +}; + + +#define DRIVEN_ANHARMONIC_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(u1); \ +CHAOS_SYS_CALLBACKS(u2); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); \ +CHAOS_SYS_CALLBACKS(k1); \ +CHAOS_SYS_CALLBACKS(k2); \ +CHAOS_SYS_CALLBACKS(Omega); + +#define DRIVEN_ANHARMONIC_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(u1); \ +CHAOS_SYS_ATTRIBUTE(u2); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); \ +CHAOS_SYS_ATTRIBUTE(k1); \ +CHAOS_SYS_ATTRIBUTE(k2); \ +CHAOS_SYS_ATTRIBUTE(Omega); diff --git a/chaos/src/driven_anharmonic_dsp.cpp b/chaos/src/driven_anharmonic_dsp.cpp new file mode 100644 index 0000000..c26deaf --- /dev/null +++ b/chaos/src/driven_anharmonic_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "driven_anharmonic.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(driven_anharmonic, DRIVEN_ANHARMONIC); + diff --git a/chaos/src/driven_anharmonic_msg.cpp b/chaos/src/driven_anharmonic_msg.cpp new file mode 100644 index 0000000..934b0f0 --- /dev/null +++ b/chaos/src/driven_anharmonic_msg.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "driven_anharmonic.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(driven_anharmonic, DRIVEN_ANHARMONIC); + diff --git a/chaos/src/driven_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 new file mode 100644 index 0000000..31c2e2d --- /dev/null +++ b/chaos/src/driven_van_der_pol.hpp @@ -0,0 +1,95 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" +#include <cmath> + +// driven van_der_pol: +// d2u/dt2 + a*(u*u -1)*du/dt + u = k * cos(Omega*t) +// equivalent: +// du1/dt = u2 +// du2/dt = -a*(u1*u1 - 1)*u2 - u1 + k*cos(u3) +// du3/dt = Omega +// taken from Willi-Hans Steeb: Chaos and Fractals + +class driven_van_der_pol + : public ode_base<3> +{ +public: + driven_van_der_pol() + { + CHAOS_PAR_INIT(method,2); + CHAOS_PAR_INIT(dt,0.01); + + CHAOS_SYS_INIT(u1,0.8, 0); + CHAOS_SYS_INIT(u2,0.6, 1); + CHAOS_SYS_INIT(u3,0.4, 2); + + CHAOS_PAR_INIT(a,5); + CHAOS_PAR_INIT(Omega,2.466); + CHAOS_PAR_INIT(k,5); + } + + + + void m_system(data_t* deriv, data_t* data) + { + data_t u1 = data[0], u2 = data[1], u3 = data[2]; + + deriv[0] = u2; + deriv[1] = - CHAOS_PARAMETER(a) * (u1*u1 -1) * u2 - u1 + + CHAOS_PARAMETER(k)*cos(u3); + deriv[2] = CHAOS_PARAMETER(Omega); + } + + void m_verify() + { + /* make sure to stay in the range of 2 pi */ + if (m_data[2] > 2*M_PI) + m_data[2] = std::fmod(m_data[2], data_t(2*M_PI)); + } + + CHAOS_SYSVAR_FUNCS(u1, 0); + CHAOS_SYSVAR_FUNCS(u2, 1); + CHAOS_SYSVAR_FUNCS(u3, 2); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(k); + CHAOS_SYSPAR_FUNCS(Omega); +}; + + +#define DRIVEN_VAN_DER_POL_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(u1); \ +CHAOS_SYS_CALLBACKS(u2); \ +CHAOS_SYS_CALLBACKS(u3); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(k); \ +CHAOS_SYS_CALLBACKS(Omega); + +#define DRIVEN_VAN_DER_POL_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(u1); \ +CHAOS_SYS_ATTRIBUTE(u2); \ +CHAOS_SYS_ATTRIBUTE(u3); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(k); \ +CHAOS_SYS_ATTRIBUTE(Omega); diff --git a/chaos/src/driven_van_der_pol_dsp.cpp b/chaos/src/driven_van_der_pol_dsp.cpp new file mode 100644 index 0000000..e0787ae --- /dev/null +++ b/chaos/src/driven_van_der_pol_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "driven_van_der_pol.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(driven_van_der_pol, DRIVEN_VAN_DER_POL); + diff --git a/chaos/src/driven_van_der_pol_msg.cpp b/chaos/src/driven_van_der_pol_msg.cpp new file mode 100644 index 0000000..488d96e --- /dev/null +++ b/chaos/src/driven_van_der_pol_msg.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "driven_van_der_pol.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(driven_van_der_pol, DRIVEN_VAN_DER_POL); + diff --git a/chaos/src/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.hpp b/chaos/src/duffing.hpp new file mode 100644 index 0000000..b5d931c --- /dev/null +++ b/chaos/src/duffing.hpp @@ -0,0 +1,94 @@ +// +// +// 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" + +// duffing equation: dx/dt = y +// dy/dt = x * (1 - x^2) + R*cos(omega * t) - gamma * y +// + + +class duffing: + public ode_base<2> +{ +public: + duffing() + { + CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(dt,0.01); + + CHAOS_SYS_INIT(x, 0.5, 0); + CHAOS_SYS_INIT(y, 0.5, 1); + + CHAOS_PAR_INIT(R, 0.4); + CHAOS_PAR_INIT(omega, 1); + CHAOS_PAR_INIT(gamma, 0.25); + + t = 0; + } + + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t x = data[0], y = data[1]; + + deriv[0] = y; + deriv[1] = x * (1 - x*x) + + CHAOS_PARAMETER(R) * cos( CHAOS_PARAMETER(omega) * t) - + CHAOS_PARAMETER(gamma) * y; + t += CHAOS_PARAMETER(dt); + t = std::fmod(t, data_t(M_PI)); + } + + virtual void m_verify() + { + if (m_data[0] == 0 && m_data[1] == 0 && m_data[2] == 0) + for (int i = 0; i != 3; ++i) + m_data[i] = rand_range(0,3); + } + + + CHAOS_SYSVAR_FUNCS(x,0); + CHAOS_SYSVAR_FUNCS(y,1); + + CHAOS_SYSPAR_FUNCS(R); + CHAOS_SYSPAR_FUNCS(omega); + CHAOS_SYSPAR_FUNCS(gamma); + +private: + data_t t; +}; + +#define DUFFING_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); \ +CHAOS_SYS_CALLBACKS(R); \ +CHAOS_SYS_CALLBACKS(gamma); \ +CHAOS_SYS_CALLBACKS(omega); + +#define DUFFING_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); \ +CHAOS_SYS_ATTRIBUTE(R); \ +CHAOS_SYS_ATTRIBUTE(gamma); \ +CHAOS_SYS_ATTRIBUTE(omega); + diff --git a/chaos/src/duffing_dsp.cpp b/chaos/src/duffing_dsp.cpp new file mode 100644 index 0000000..c2c89c1 --- /dev/null +++ b/chaos/src/duffing_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 "duffing.hpp" +#include "chaos_dsp.hpp" +CHAOS_DSP_CLASS(duffing,DUFFING); diff --git a/chaos/src/duffing_map.hpp b/chaos/src/duffing_map.hpp new file mode 100644 index 0000000..2670b7d --- /dev/null +++ b/chaos/src/duffing_map.hpp @@ -0,0 +1,71 @@ +// +// +// 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<2> +{ +public: + duffing_map() + { + CHAOS_SYS_INIT(x1, 0.5, 0); + CHAOS_SYS_INIT(x2, 0.5, 1); + CHAOS_PAR_INIT(a, 0.5); + CHAOS_PAR_INIT(b, 0.5); + } + + + + 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/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/duffing_msg.cpp b/chaos/src/duffing_msg.cpp new file mode 100644 index 0000000..08f4109 --- /dev/null +++ b/chaos/src/duffing_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 "duffing.hpp" +#include "chaos_msg.hpp" +CHAOS_MSG_CLASS(duffing,DUFFING); diff --git a/chaos/src/duffing_search.cpp b/chaos/src/duffing_search.cpp new file mode 100644 index 0000000..13d5cdd --- /dev/null +++ b/chaos/src/duffing_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.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(duffing, DUFFING); diff --git a/chaos/src/gauss_map.hpp b/chaos/src/gauss_map.hpp new file mode 100644 index 0000000..7e16bea --- /dev/null +++ b/chaos/src/gauss_map.hpp @@ -0,0 +1,66 @@ +// +// +// 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 <cmath> + +// gauss map: x[n+1] = 0 (for x[n] = 0) +// fmod(1 / x[n], 1) (else) +// 0 <= x[n] < 1 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class gauss_map: + public map_base<1> +{ +public: + gauss_map() + { + CHAOS_SYS_INIT(x,0.5, 0); + } + + + void m_step() + { + data_t data = m_data[0]; + + if (data == 0) + m_data[0] = 0.001; + else + m_data[0] = fmod(1.f / data, 1); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); + bool m_pred_x(t_float f) + { + return (f >= 0) && (f < 1); + } +}; + +#define GAUSS_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x); + +#define GAUSS_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x); + + + diff --git a/chaos/src/gauss_map_dsp.cpp b/chaos/src/gauss_map_dsp.cpp new file mode 100644 index 0000000..f9d849e --- /dev/null +++ b/chaos/src/gauss_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 "gauss_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(gauss_map, GAUSS_MAP); diff --git a/chaos/src/gauss_map_msg.cpp b/chaos/src/gauss_map_msg.cpp new file mode 100644 index 0000000..6d00da6 --- /dev/null +++ b/chaos/src/gauss_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 "gauss_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(gauss_map, GAUSS_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..7793814 --- /dev/null +++ b/chaos/src/gaussian_map.hpp @@ -0,0 +1,77 @@ +// +// +// 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<1> +{ +public: + gaussian_map() + { + CHAOS_SYS_INIT(x, 0.5, 0); + + CHAOS_PAR_INIT(b,7); + CHAOS_PAR_INIT(c,0.5); + } + + + + 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.hpp b/chaos/src/henon_map.hpp new file mode 100644 index 0000000..b7ca5bf --- /dev/null +++ b/chaos/src/henon_map.hpp @@ -0,0 +1,77 @@ +// +// +// 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" + +// henon map: x[n+1] = y[n] + 1 - a * x[n] * x[n] +// y[n+1] = b * x[n] +// b != 0 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class henon: + public map_base<2> +{ +public: + henon() + { + CHAOS_SYS_INIT(x,0,0); + CHAOS_SYS_INIT(y,0,1); + + CHAOS_PAR_INIT(a,1.4); + CHAOS_PAR_INIT(b,0.3); + } + + + void m_step() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + + m_data[0] = 1 + y - CHAOS_PARAMETER(a) * x * x; + m_data[1] = CHAOS_PARAMETER(b) * x; + } + + CHAOS_SYSVAR_FUNCS(x, 0); + CHAOS_SYSVAR_FUNCS(y, 1); + + CHAOS_SYSPAR_FUNCS(a); + + CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b); + bool m_pred_b(t_float f) + { + return (f != 0); + } +}; + + +#define HENON_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); + +#define HENON_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); + diff --git a/chaos/src/henon_map_dsp.cpp b/chaos/src/henon_map_dsp.cpp new file mode 100644 index 0000000..7d73412 --- /dev/null +++ b/chaos/src/henon_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 "henon_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS_NAME(henon, HENON, henon~); diff --git a/chaos/src/henon_map_msg.cpp b/chaos/src/henon_map_msg.cpp new file mode 100644 index 0000000..e70624f --- /dev/null +++ b/chaos/src/henon_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 "henon_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS_NAME(henon, HENON, henon); 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..cec6ae3 --- /dev/null +++ b/chaos/src/hydrogen.hpp @@ -0,0 +1,148 @@ +// +// +// 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<4> +{ + + +public: + hydrogen() + { + 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); + + reset = 0; + } + + + 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.hpp b/chaos/src/ikeda_laser_map.hpp new file mode 100644 index 0000000..534a9de --- /dev/null +++ b/chaos/src/ikeda_laser_map.hpp @@ -0,0 +1,91 @@ +// +// +// 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 <cmath> + +// ikeda laser map: z[n+1] = roh + c2 * z[n] * +// exp (j * (c1 - c3 / (1 + abs(z) * abs(z)))) +// z is complex +// +// equal: x[n+1] = roh + c2 * (x[n] * cos(tau) - y[n] * sin (tau)) +// y[n+1] = c2 * (x[n] * sin(tau) + y[n] * cos(tau)) +// tau = c1 - (c2 / (1 + x*x + y*y)) +// +// taken from Willi-Hans Steeb: Chaos and Fractals + +class ikeda_laser_map: + public map_base<1> +{ +public: + ikeda_laser_map() + { + CHAOS_PAR_INIT(c1,0.4); + CHAOS_PAR_INIT(c2,0.9); + CHAOS_PAR_INIT(c3,9); + CHAOS_PAR_INIT(roh,0.85); + + CHAOS_SYS_INIT(x,0.5,0); + CHAOS_SYS_INIT(y,0.5,1); + } + + void m_step() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + + data_t tau = CHAOS_PARAMETER(c1) - + CHAOS_PARAMETER(c3) / (1 + x*x + y*y); + data_t cos_tau = cos(tau); + data_t sin_tau = sin(tau); + + m_data[0] = CHAOS_PARAMETER(roh) + CHAOS_PARAMETER(c2) + * (x * cos_tau - y * sin_tau); + m_data[1] = CHAOS_PARAMETER(c2) * (x * sin_tau + y * cos_tau); + } + + CHAOS_SYSVAR_FUNCS(x, 0); + CHAOS_SYSVAR_FUNCS(y, 1); + + CHAOS_SYSPAR_FUNCS(c1); + CHAOS_SYSPAR_FUNCS(c2); + CHAOS_SYSPAR_FUNCS(c3); + CHAOS_SYSPAR_FUNCS(roh); + +}; + + +#define IKEDA_LASER_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(c1); \ +CHAOS_SYS_CALLBACKS(c2); \ +CHAOS_SYS_CALLBACKS(c3); \ +CHAOS_SYS_CALLBACKS(roh); \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); + +#define IKEDA_LASER_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(c1); \ +CHAOS_SYS_ATTRIBUTE(c2); \ +CHAOS_SYS_ATTRIBUTE(c3); \ +CHAOS_SYS_ATTRIBUTE(roh); \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); diff --git a/chaos/src/ikeda_laser_map_dsp.cpp b/chaos/src/ikeda_laser_map_dsp.cpp new file mode 100644 index 0000000..fe2339b --- /dev/null +++ b/chaos/src/ikeda_laser_map_dsp.cpp @@ -0,0 +1,26 @@ +// +// +// 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 "ikeda_laser_map.hpp" +#include "chaos_dsp.hpp" + + +CHAOS_DSP_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, ikeda~); + diff --git a/chaos/src/ikeda_laser_map_msg.cpp b/chaos/src/ikeda_laser_map_msg.cpp new file mode 100644 index 0000000..e1c318d --- /dev/null +++ b/chaos/src/ikeda_laser_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 "ikeda_laser_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, ikeda); 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 new file mode 100644 index 0000000..1329bd3 --- /dev/null +++ b/chaos/src/latoocarfian.hpp @@ -0,0 +1,99 @@ +// +// +// 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 <cmath> + +// 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<2> +{ +public: + latoocarfian() + { + CHAOS_SYS_INIT(x1,0.5,0); + CHAOS_SYS_INIT(x2,0,1); + + CHAOS_PAR_INIT(a,-0.966918); + CHAOS_PAR_INIT(b,2.879879); + CHAOS_PAR_INIT(c,0.765145); + CHAOS_PAR_INIT(d,0.744728); + } + + 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); + } + + /* function has a fix point for x1 == x2 == 0 */ + virtual void m_verify() + { + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(0,0.1); + } +}; + + +#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/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 new file mode 100644 index 0000000..bfe76e4 --- /dev/null +++ b/chaos/src/latoomutalpha.hpp @@ -0,0 +1,90 @@ +// +// +// 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 <cmath> + +// 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<2> +{ +public: + latoomutalpha() + { + CHAOS_SYS_INIT(x1,0.5,0); + CHAOS_SYS_INIT(x2,0.2,1); + + CHAOS_PAR_INIT(a,-0.966918); + CHAOS_PAR_INIT(b,2.879879); + CHAOS_PAR_INIT(c,0.765145); + } + + + 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; + } + + /* function has a fix point for x1 == x2 == 0 */ + virtual void m_verify() + { + 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); + + 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/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 new file mode 100644 index 0000000..c1a42b5 --- /dev/null +++ b/chaos/src/latoomutbeta.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" +#include <cmath> + +// 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<2> +{ +public: + latoomutbeta() + { + CHAOS_SYS_INIT(x1,0.5,0); + CHAOS_SYS_INIT(x2,0.5,1); + + CHAOS_PAR_INIT(a,-0.966918); + CHAOS_PAR_INIT(b,2.879879); + } + + 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; + } + + /* function has a fix point for x1 == x2 == 0 */ + virtual void m_verify() + { + 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); + + 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/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 new file mode 100644 index 0000000..040a071 --- /dev/null +++ b/chaos/src/latoomutgamma.hpp @@ -0,0 +1,85 @@ +// +// +// 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 <cmath> + +// 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<2> +{ +public: + latoomutgamma() + { + CHAOS_SYS_INIT(x1,0.5,0); + CHAOS_SYS_INIT(x2,0.5,1); + + CHAOS_PAR_INIT(a,-0.966918); + CHAOS_PAR_INIT(b,2.879879); + } + + 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] = std::abs(sin(x2*b)) + tmp*tmp; + tmp = sin(x2*a); + m_data[1] = std::abs(sin(x1*a)) + tmp*tmp; + } + + + /* function has a fix point for x1 == x2 == 0 */ + void m_verify() + { + if (m_data[0] == 0 && m_data[1] == 0) + for (int i = 0; i != 2; ++i) + m_data[i] = rand_range(-1,1); + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + + 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/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/linear_congruental.hpp b/chaos/src/linear_congruental.hpp new file mode 100644 index 0000000..9c6310f --- /dev/null +++ b/chaos/src/linear_congruental.hpp @@ -0,0 +1,67 @@ +// +// +// 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" + +// tent map: x[n+1] = A*x[n] + B mod C +// +// taken from Julien C. Sprott, Chaos and Time-Series Analysis + +class linear_congruental: + public map_base<2> +{ +public: + linear_congruental() + { + CHAOS_SYS_INIT(x, 0, 0); + + CHAOS_PAR_INIT(A, 1741); + CHAOS_PAR_INIT(B, 54773); + CHAOS_PAR_INIT(C, 259200); + } + + void m_step() + { + data_t x = m_data[0]; + + m_data[0] = std::fmod( CHAOS_PARAMETER(A) * x + CHAOS_PARAMETER(B), CHAOS_PARAMETER(C)); + } + + CHAOS_SYSVAR_FUNCS(x,0); + + CHAOS_SYSPAR_FUNCS(A); + CHAOS_SYSPAR_FUNCS(B); + CHAOS_SYSPAR_FUNCS(C); +}; + +#define LINEAR_CONGRUENTAL_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(A); \ +CHAOS_SYS_CALLBACKS(B); \ +CHAOS_SYS_CALLBACKS(C); \ +CHAOS_SYS_CALLBACKS(x); + +#define LINEAR_CONGRUENTAL_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(A); \ +CHAOS_SYS_ATTRIBUTE(B); \ +CHAOS_SYS_ATTRIBUTE(C); \ +CHAOS_SYS_ATTRIBUTE(x); + diff --git a/chaos/src/linear_congruental_dsp.cpp b/chaos/src/linear_congruental_dsp.cpp new file mode 100644 index 0000000..df36059 --- /dev/null +++ b/chaos/src/linear_congruental_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 "linear_congruental.hpp" +#include "chaos_dsp.hpp" +CHAOS_DSP_CLASS(linear_congruental,LINEAR_CONGRUENTAL); diff --git a/chaos/src/linear_congruental_msg.cpp b/chaos/src/linear_congruental_msg.cpp new file mode 100644 index 0000000..5b15d99 --- /dev/null +++ b/chaos/src/linear_congruental_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 "linear_congruental.hpp" +#include "chaos_msg.hpp" +CHAOS_MSG_CLASS(linear_congruental,LINEAR_CONGRUENTAL); diff --git a/chaos/src/linear_congruental_search.cpp b/chaos/src/linear_congruental_search.cpp new file mode 100644 index 0000000..f3a09a2 --- /dev/null +++ b/chaos/src/linear_congruental_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 "linear_congruental.hpp" +#include "chaos_search.hpp" + +CHAOS_SEARCH_CLASS(linear_congruental, LINEAR_CONGRUENTAL); diff --git a/chaos/src/logistic_dsp.cpp b/chaos/src/logistic_dsp.cpp new file mode 100644 index 0000000..6a88748 --- /dev/null +++ b/chaos/src/logistic_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 "logistic_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(logistic, LOGISTIC); diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp new file mode 100644 index 0000000..2d19855 --- /dev/null +++ b/chaos/src/logistic_map.hpp @@ -0,0 +1,79 @@ +// +// +// 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" + +// logistic map: x[n+1] = alpha * x[n] * (1 - x[n]) +// 0 < x[n] < 1 +// 0 <= alpha <= 4 + +class logistic: + public map_base<1> +{ +public: + logistic() + { + CHAOS_PAR_INIT(alpha, 3.8); + CHAOS_SYS_INIT(x, 0.5,0); + } + + ~logistic() + { + } + + void m_step() + { + data_t x = m_data[0]; + data_t alpha = CHAOS_PARAMETER(alpha); + m_data[0] = alpha * x * (1.f - x); + } + + CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); + 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(data_t 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 LOGISTIC_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(alpha); \ +CHAOS_SYS_CALLBACKS(x); + +#define LOGISTIC_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(alpha); \ +CHAOS_SYS_ATTRIBUTE(x); + diff --git a/chaos/src/logistic_msg.cpp b/chaos/src/logistic_msg.cpp new file mode 100644 index 0000000..60fef89 --- /dev/null +++ b/chaos/src/logistic_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 "logistic_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(logistic, LOGISTIC); 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 new file mode 100644 index 0000000..cf0fa14 --- /dev/null +++ b/chaos/src/lorenz.hpp @@ -0,0 +1,101 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" + +// lorenz model: dx1/dt = sigma * (x2 - x1) +// dx2/dt = - x1 * x3 + r * x1 - x2 +// dx3/dt = x1 * x2 - b * x3 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class lorenz + : public ode_base<3> +{ +public: + lorenz() + { + CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(dt,0.01); + + CHAOS_SYS_INIT(x1,0.8,0); + CHAOS_SYS_INIT(x2,0.7,1); + CHAOS_SYS_INIT(x3,0.6,2); + + CHAOS_PAR_INIT(sigma,16); + CHAOS_PAR_INIT(b,4); + CHAOS_PAR_INIT(r,40); + } + + ~lorenz() + { + } + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t x1 = data[0], x2 = data[1], x3 = data[2]; + + deriv[0] = CHAOS_PARAMETER(sigma) * (x2 - x1); + 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); + CHAOS_SYSVAR_FUNCS(x3, 2); + + CHAOS_SYSPAR_FUNCS_PRED(sigma, m_pred); + CHAOS_SYSPAR_FUNCS_PRED(b, m_pred); + CHAOS_SYSPAR_FUNCS_PRED(r, m_pred); + + bool m_pred (t_float f) + { + return (f > 0); + } + +}; + + +#define LORENZ_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(x3); \ +CHAOS_SYS_CALLBACKS(sigma); \ +CHAOS_SYS_CALLBACKS(r); \ +CHAOS_SYS_CALLBACKS(b); + +#define LORENZ_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(x3); \ +CHAOS_SYS_ATTRIBUTE(sigma); \ +CHAOS_SYS_ATTRIBUTE(r); \ +CHAOS_SYS_ATTRIBUTE(b); diff --git a/chaos/src/lorenz_dsp.cpp b/chaos/src/lorenz_dsp.cpp new file mode 100644 index 0000000..e1b8ad1 --- /dev/null +++ b/chaos/src/lorenz_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 "lorenz.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(lorenz, LORENZ); diff --git a/chaos/src/lorenz_msg.cpp b/chaos/src/lorenz_msg.cpp new file mode 100644 index 0000000..09b02e8 --- /dev/null +++ b/chaos/src/lorenz_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 "lorenz.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(lorenz, LORENZ); 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 new file mode 100644 index 0000000..07656d2 --- /dev/null +++ b/chaos/src/lozi_map.hpp @@ -0,0 +1,80 @@ +// +// +// 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" + +// lozi map: x[n+1] = y[n] + 1 - a * abs(x[n]) +// y[n+1] = b * x[n] +// b != 0 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class lozi_map: + public map_base<2> +{ +public: + lozi_map() + { + CHAOS_SYS_INIT(x,0,0); + CHAOS_SYS_INIT(y,0,1); + + CHAOS_PAR_INIT(a,1.4); + CHAOS_PAR_INIT(b,0.3); + } + + void m_step() + { + data_t x = m_data[0]; + data_t y = m_data[1]; + + if (x > 0) + m_data[0] = 1 + y - CHAOS_PARAMETER(a) * x; + else + m_data[0] = 1 + y + CHAOS_PARAMETER(a) * x; + + m_data[1] = CHAOS_PARAMETER(b) * x; + + } + + CHAOS_SYSVAR_FUNCS(x, 0); + CHAOS_SYSVAR_FUNCS(y, 1); + + CHAOS_SYSPAR_FUNCS(a); + + CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b); + bool m_pred_b(t_float f) + { + return (f != 0); + } +}; + + +#define LOZI_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(x); \ +CHAOS_SYS_CALLBACKS(y); + +#define LOZI_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(x); \ +CHAOS_SYS_ATTRIBUTE(y); diff --git a/chaos/src/lozi_map_dsp.cpp b/chaos/src/lozi_map_dsp.cpp new file mode 100644 index 0000000..06c603d --- /dev/null +++ b/chaos/src/lozi_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 "lozi_map.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS_NAME(lozi_map, LOZI_MAP, lozi~); diff --git a/chaos/src/lozi_map_msg.cpp b/chaos/src/lozi_map_msg.cpp new file mode 100644 index 0000000..719cf61 --- /dev/null +++ b/chaos/src/lozi_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 "lozi_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS_NAME(lozi_map, LOZI_MAP, lozi); 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 new file mode 100644 index 0000000..354f68a --- /dev/null +++ b/chaos/src/main.cpp @@ -0,0 +1,59 @@ +// +// +// 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 "chaos.hpp" +#include "chaos_defs.hpp" + +void chaos_library_setup() +{ + post("\nchaos~ version 0.01, compiled on "__DATE__); + post("(C)2005 Tim Blechmann, www.mokabar.tk\n\n"); + + + CHAOS_ADD(bernoulli); + CHAOS_ADD(bungalow_tent); + 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); + 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); + CHAOS_ADD(latoomutbeta); + CHAOS_ADD(latoomutgamma); + CHAOS_ADD(linear_congruental); + CHAOS_ADD(logistic); + CHAOS_ADD(lorenz); + CHAOS_ADD(lozi_map); + CHAOS_ADD(roessler); + CHAOS_ADD(sine_map); + CHAOS_ADD(standard_map); + CHAOS_ADD(tent_map); +} + +FLEXT_LIB_SETUP(chaos, chaos_library_setup); diff --git a/chaos/src/map_base.hpp b/chaos/src/map_base.hpp new file mode 100644 index 0000000..afc89fb --- /dev/null +++ b/chaos/src/map_base.hpp @@ -0,0 +1,40 @@ +// +// +// 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. + + +#ifndef __map_base_hpp + +#include "chaos_base.hpp" + +template <int dimensions> +class map_base + : public chaos_base<dimensions> +{ +protected: + void m_step() + { + } +}; + +#define MAP_CALLBACKS +#define MAP_ATTRIBUTES + +#define __map_base_hpp +#endif /* __map_base_hpp */ diff --git a/chaos/src/ode_base.cpp b/chaos/src/ode_base.cpp new file mode 100644 index 0000000..004a1b3 --- /dev/null +++ b/chaos/src/ode_base.cpp @@ -0,0 +1,23 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" + + diff --git a/chaos/src/ode_base.hpp b/chaos/src/ode_base.hpp new file mode 100644 index 0000000..42478bc --- /dev/null +++ b/chaos/src/ode_base.hpp @@ -0,0 +1,144 @@ +// +// +// 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. + + +#ifndef __ode_base_hpp + +#include "chaos_base.hpp" + +template <int dimensions> +class ode_base: + public chaos_base<dimensions> +{ +public: + + void set_method(int i) + { + if (i >= 0 && i < 4) + { + m_method = (unsigned char) i; + switch (i) + { + case 0: + m_routine = &ode_base<dimensions>::rk1; + break; + case 1: + m_routine = &ode_base<dimensions>::rk2; + break; + case 2: + m_routine = &ode_base<dimensions>::rk4; + } + } + else + post("no such method"); + } + + t_int get_method() + { + return (int) m_method; + } + + CHAOS_SYSPAR_FUNCS_PRED(dt, m_pred_dt); + + bool m_pred_dt(t_float f) + { + return (f >= 0); + } + + void m_step() + { + (this->*m_routine)(); + } + +protected: + void (ode_base<dimensions>::*m_routine)(void); + + unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */ + + data_t m_k0[dimensions]; + data_t m_k1[dimensions]; + data_t m_k2[dimensions]; + data_t m_k3[dimensions]; + data_t m_tmp[dimensions]; + + virtual void m_system (data_t* deriv, data_t* data) = 0; + + void rk1() + { + m_system (m_k0, chaos_base<dimensions>::m_data); + for (int i = 0; i != dimensions; ++i) + chaos_base<dimensions>::m_data[i] += m_dt * m_k0[i]; + } + + void rk2() + { + for (int i = 0; i != dimensions; ++i) + m_k0[i] = m_k0[i] * 0.5 * m_dt + chaos_base<dimensions>::m_data[i]; + + m_system (m_k0, chaos_base<dimensions>::m_data); + m_system (m_k1, m_k0); + for (int i = 0; i != dimensions; ++i) + chaos_base<dimensions>::m_data[i] += m_dt * m_k1[i]; + } + + void rk4() + { + m_system (m_k0, chaos_base<dimensions>::m_data); + for (int i = 0; i != dimensions; ++i) + { + m_k0[i] *= m_dt; + m_tmp[i] = chaos_base<dimensions>::m_data[i] + 0.5 * m_k0[i]; + } + + m_system (m_k1, m_tmp); + for (int i = 0; i != dimensions; ++i) + { + m_k1[i] *= m_dt; + m_tmp[i] = chaos_base<dimensions>::m_data[i] + 0.5 * m_k1[i]; + } + + m_system (m_k2, m_tmp); + for (int i = 0; i != dimensions; ++i) + { + m_k2[i] *= m_dt; + m_tmp[i] = chaos_base<dimensions>::m_data[i] + m_k2[i]; + } + + m_system (m_k3, m_tmp); + for (int i = 0; i != dimensions; ++i) + m_k3[i] *= m_dt; + + for (int i = 0; i != dimensions; ++i) + chaos_base<dimensions>::m_data[i] += (m_k0[i] + 2. * (m_k1[i] + m_k2[i]) + m_k3[i]) + / 6.; + } +}; + +#define ODE_CALLBACKS \ +CHAOS_SYS_CALLBACKS_I(method); \ +CHAOS_SYS_CALLBACKS(dt); + +#define ODE_ATTRIBUTES \ +CHAOS_SYS_ATTRIBUTE(method); \ +CHAOS_SYS_ATTRIBUTE(dt); + + +#define __ode_base_hpp +#endif /* __ode_base_hpp */ diff --git a/chaos/src/roessler.hpp b/chaos/src/roessler.hpp new file mode 100644 index 0000000..aa03a47 --- /dev/null +++ b/chaos/src/roessler.hpp @@ -0,0 +1,82 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "ode_base.hpp" + +// roessler model: dx1/dt = - (x2 + x3) +// dx2/dt = x1 + a * x2 +// dx3/dt = b + (x1 - c) * x3 +// taken from Peitgen / J�rgens / Saupe: Chaos and Fractals + +class roessler + : public ode_base<3> +{ +public: + roessler() + { + CHAOS_PAR_INIT(method,0); + CHAOS_PAR_INIT(dt,0.001); + + 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); + CHAOS_PAR_INIT(c,4); + } + + + virtual void m_system(data_t* deriv, data_t* data) + { + data_t x1 = data[0], x2 = data[1], x3 = data[2]; + + deriv[0] = - (x2 + x3); + deriv[1] = x1 + CHAOS_PARAMETER(a) * x2; + deriv[2] = CHAOS_PARAMETER(b) + (x1 - CHAOS_PARAMETER(c)) * x3; + } + + CHAOS_SYSVAR_FUNCS(x1, 0); + CHAOS_SYSVAR_FUNCS(x2, 1); + CHAOS_SYSVAR_FUNCS(x3, 2); + + CHAOS_SYSPAR_FUNCS(a); + CHAOS_SYSPAR_FUNCS(b); + CHAOS_SYSPAR_FUNCS(c); +}; + + +#define ROESSLER_CALLBACKS \ +ODE_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(x1); \ +CHAOS_SYS_CALLBACKS(x2); \ +CHAOS_SYS_CALLBACKS(x3); \ +CHAOS_SYS_CALLBACKS(a); \ +CHAOS_SYS_CALLBACKS(b); \ +CHAOS_SYS_CALLBACKS(c); + +#define ROESSLER_ATTRIBUTES \ +ODE_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(x1); \ +CHAOS_SYS_ATTRIBUTE(x2); \ +CHAOS_SYS_ATTRIBUTE(x3); \ +CHAOS_SYS_ATTRIBUTE(a); \ +CHAOS_SYS_ATTRIBUTE(b); \ +CHAOS_SYS_ATTRIBUTE(c); diff --git a/chaos/src/roessler_dsp.cpp b/chaos/src/roessler_dsp.cpp new file mode 100644 index 0000000..e5ee834 --- /dev/null +++ b/chaos/src/roessler_dsp.cpp @@ -0,0 +1,24 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "roessler.hpp" +#include "chaos_dsp.hpp" + +CHAOS_DSP_CLASS(roessler,ROESSLER); diff --git a/chaos/src/roessler_msg.cpp b/chaos/src/roessler_msg.cpp new file mode 100644 index 0000000..aad1bf6 --- /dev/null +++ b/chaos/src/roessler_msg.cpp @@ -0,0 +1,24 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "roessler.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(roessler,ROESSLER); diff --git a/chaos/src/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.hpp b/chaos/src/sine_map.hpp new file mode 100644 index 0000000..d7043f4 --- /dev/null +++ b/chaos/src/sine_map.hpp @@ -0,0 +1,64 @@ +// +// +// 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 <cmath> + +// sine map: x[n+1] = sin(pi * x) +// 0 <= x[n] <= 1 +// taken from Willi-Hans Steeb: Chaos and Fractals + +class sine_map: + public map_base<1> +{ + +public: + sine_map() + { + CHAOS_SYS_INIT(x,0,0); + } + + ~sine_map() + { + + } + + void m_step() + { + m_data[0] = sin (M_PI * m_data[0]); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred); + + bool m_pred(t_float f) + { + return (f >= 0) && (f <= 1); + } +}; + +#define SINE_MAP_CALLBACKS \ +MAP_CALLBACKS \ +CHAOS_SYS_CALLBACKS(x); + +#define SINE_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES \ +CHAOS_SYS_ATTRIBUTE(x); + + diff --git a/chaos/src/sine_map_dsp.cpp b/chaos/src/sine_map_dsp.cpp new file mode 100644 index 0000000..b1ca11e --- /dev/null +++ b/chaos/src/sine_map_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "sine_map.hpp" +#include "chaos_dsp.hpp" + + +CHAOS_DSP_CLASS(sine_map, SINE_MAP); diff --git a/chaos/src/sine_map_msg.cpp b/chaos/src/sine_map_msg.cpp new file mode 100644 index 0000000..aacc51c --- /dev/null +++ b/chaos/src/sine_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 "sine_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(sine_map, SINE_MAP); 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.hpp b/chaos/src/standard_map.hpp new file mode 100644 index 0000000..399484b --- /dev/null +++ b/chaos/src/standard_map.hpp @@ -0,0 +1,102 @@ +// +// +// 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 <cmath> + +// standard map: I[n+1] = I[n] + k * sin(theta[n]) +// theta[n+1] = theta[n] + I[n] + k * sin(theta[n]) +// 0 <= theta <= 2*pi +// taken from Willi-Hans Steeb: Chaos and Fractals + +class standard_map: + public map_base<2> +{ +public: + standard_map() + { + CHAOS_SYS_INIT(I,0.1,0); + CHAOS_SYS_INIT(theta,0.2,1); + + CHAOS_PAR_INIT(k, 0.8); + } + + ~standard_map() + { + + } + + void m_step() + { + data_t I = m_data[0]; + data_t theta = m_data[1]; + data_t k = CHAOS_PARAMETER(k); + + m_data[0] = I + k * sin(theta); + theta = theta + I + k * sin(theta); + + if (theta > 2 * M_PI) + { + do + { + theta -= 2*M_PI; + } + while (theta > 2 * M_PI); + goto put_data; + } + + if (theta < 0) + { + do + { + theta += 2*M_PI; + } + while (theta < 0); + } + + put_data: + m_data[1] = theta; + } + + + CHAOS_SYSVAR_FUNCS(I, 0); + + CHAOS_SYSVAR_FUNCS_PRED(theta, 1, m_pred_theta); + bool m_pred_theta(t_float f) + { + return (f >= 0) && (f < 2*M_PI); + } + + CHAOS_SYSPAR_FUNCS(k); +}; + + +#define STANDARD_MAP_CALLBACKS \ +MAP_CALLBACKS; \ +CHAOS_SYS_CALLBACKS(I); \ +CHAOS_SYS_CALLBACKS(theta); \ +CHAOS_SYS_CALLBACKS(k); + + +#define STANDARD_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES; \ +CHAOS_SYS_ATTRIBUTE(I); \ +CHAOS_SYS_ATTRIBUTE(theta); \ +CHAOS_SYS_ATTRIBUTE(k); diff --git a/chaos/src/standard_map_dsp.cpp b/chaos/src/standard_map_dsp.cpp new file mode 100644 index 0000000..c16276c --- /dev/null +++ b/chaos/src/standard_map_dsp.cpp @@ -0,0 +1,25 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include "standard_map.hpp" +#include "chaos_dsp.hpp" + + +CHAOS_DSP_CLASS(standard_map, STANDARD_MAP); diff --git a/chaos/src/standard_map_msg.cpp b/chaos/src/standard_map_msg.cpp new file mode 100644 index 0000000..92c1084 --- /dev/null +++ b/chaos/src/standard_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 "standard_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS(standard_map, STANDARD_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.hpp b/chaos/src/tent_map.hpp new file mode 100644 index 0000000..b0961ee --- /dev/null +++ b/chaos/src/tent_map.hpp @@ -0,0 +1,61 @@ +// +// +// 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" + +// tent map: x[n+1] = 1 - 2*abs(x[n]) +// -1 < x[n] < 1 +// taken from Julien C. Sprott, Strange Attractors: Creating Patterns in Chaos + + +class tent_map: + public map_base<1> +{ +public: + tent_map() + { + CHAOS_SYS_INIT(x, 0.6,0); + } + + + void m_step() + { + data_t data = m_data[0]; + + m_data[0] = 1 - 2*std::abs(data); + } + + CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); + bool m_pred_x(t_float f) + { + return (f > -1) && (f < 1); + } +}; + + +#define TENT_MAP_CALLBACKS \ +MAP_CALLBACKS \ +CHAOS_SYS_CALLBACKS(x); + +#define TENT_MAP_ATTRIBUTES \ +MAP_ATTRIBUTES \ +CHAOS_SYS_ATTRIBUTE(x); + + diff --git a/chaos/src/tent_map_dsp.cpp b/chaos/src/tent_map_dsp.cpp new file mode 100644 index 0000000..0abf7d5 --- /dev/null +++ b/chaos/src/tent_map_dsp.cpp @@ -0,0 +1,26 @@ +// +// +// 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 "tent_map.hpp" +#include "chaos_dsp.hpp" + + + +CHAOS_DSP_CLASS_NAME(tent_map, TENT_MAP, tent~); diff --git a/chaos/src/tent_map_msg.cpp b/chaos/src/tent_map_msg.cpp new file mode 100644 index 0000000..b2d5d8d --- /dev/null +++ b/chaos/src/tent_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 "tent_map.hpp" +#include "chaos_msg.hpp" + +CHAOS_MSG_CLASS_NAME(tent_map, TENT_MAP, tent); 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); |