Update of /cvsroot/pure-data/externals/tb/chaos/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23299
Modified Files: chaos.hpp chaos_base.hpp chaos_defs.hpp chaos_dsp.hpp chua.hpp coupled_logistic.hpp coupled_logistic_msg.cpp driven_van_der_pol.hpp latoocarfian.hpp latoomutalpha.hpp latoomutbeta.hpp latoomutgamma.hpp logistic_map.hpp lorenz.hpp lozi_map.hpp main.cpp ode_base.hpp roessler.hpp Added Files: bernoulli_search.cpp bungalow_tent_search.cpp chaos_search.hpp chua_search.cpp circle_map_search.cpp coupled_logistic_search.cpp delayed_logistic.hpp delayed_logistic__search.cpp delayed_logistic_dsp.cpp delayed_logistic_msg.cpp delayed_logistic_search.cpp driven_anharmonic_search.cpp driven_van_der_pol_search.cpp duffing_map_search.cpp gauss_map_search.cpp gaussian_map.hpp gaussian_map_dsp.cpp gaussian_map_msg.cpp gaussian_map_search.cpp henon_map_search.cpp hydrogen.hpp hydrogen_dsp.cpp hydrogen_msg.cpp hydrogen_search.cpp ikeda_laser_map_search.cpp latoocarfian_search.cpp latoomutalpha_search.cpp latoomutbeta_search.cpp latoomutgamma_search.cpp logistic_search.cpp lorenz_search.cpp lozi_map_search.cpp roessler_search.cpp sine_map_search.cpp standard_map_search.cpp tent_map_search.cpp Log Message: - parameter searching (broken) - misc. updates
--- NEW FILE: delayed_logistic_msg.cpp --- // // // 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);
Index: coupled_logistic.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/coupled_logistic.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** coupled_logistic.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- coupled_logistic.hpp 16 Jun 2005 13:02:01 -0000 1.4 *************** *** 23,27 **** // coupled_logistic map: x[n+1] = r * x[n] * (1 - x[n]) + e * (y[n] - x[n]) // y[n+1] = r * y[n] * (1 - y[n]) + e * (x[n] - y[n]) ! // 1 <= r <= 4 // taken from Willi-Hans Steeb: Chaos and Fractals
--- 23,27 ---- // 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
*************** *** 55,58 **** --- 55,59 ---- m_data[0] = r * x * (1.f - x) + e * (y - x); m_data[1] = r * y * (1.f - y) + e * (x - y); + m_verify(); }
*************** *** 77,83 **** data_t y = m_data[1]; if (!m_pred_xy(x)) ! m_data[0] = 0.5; if (!m_pred_xy(y)) ! m_data[1] = 0.5; }
--- 78,89 ---- 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); ! } }
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/main.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main.cpp 9 Jun 2005 12:52:17 -0000 1.10 --- main.cpp 16 Jun 2005 13:02:02 -0000 1.11 *************** *** 32,40 **** --- 32,43 ---- CHAOS_ADD(coupled_logistic); CHAOS_ADD(chua); + CHAOS_ADD(delayed_logistic); CHAOS_ADD(driven_anharmonic); CHAOS_ADD(driven_van_der_pol); CHAOS_ADD(duffing_map); CHAOS_ADD(gauss_map); + CHAOS_ADD(gaussian_map); CHAOS_ADD(henon); + CHAOS_ADD(hydrogen); CHAOS_ADD(ikeda_laser_map); CHAOS_ADD(latoocarfian);
--- NEW FILE: gaussian_map.hpp --- // // // chaos~ // Copyright (C) 2004 Tim Blechmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA.
#include "map_base.hpp"
// gaussian map: x[n+1] = exp(-b * x[n] * x[n]) + c // // taken from Robert C. Hilborn: Chaos and Nonlinear Dynamics
class gaussian_map: public map_base { public: gaussian_map() { CHAOS_PRECONSTRUCTOR; CHAOS_SYS_INIT(x, 0.5, 0);
CHAOS_PAR_INIT(b,7); CHAOS_PAR_INIT(c,0.5);
CHAOS_POSTCONSTRUCTOR; }
~gaussian_map() { }
virtual void m_step() { data_t data = m_data[0];
if (data == 0) m_data[0] = 0.001; else m_data[0] = exp(-CHAOS_PARAMETER(b) * data * data) + CHAOS_PARAMETER(c); }
CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); bool m_pred_x(t_float f) { return (f >= 0) && (f < 1); }
CHAOS_SYSPAR_FUNCS(b); CHAOS_SYSPAR_FUNCS(c);
};
#define GAUSSIAN_MAP_CALLBACKS \ MAP_CALLBACKS; \ CHAOS_SYS_CALLBACKS(x); \ CHAOS_SYS_CALLBACKS(b); \ CHAOS_SYS_CALLBACKS(c);
#define GAUSSIAN_MAP_ATTRIBUTES \ MAP_ATTRIBUTES; \ CHAOS_SYS_ATTRIBUTE(x); \ CHAOS_SYS_ATTRIBUTE(b); \ CHAOS_SYS_ATTRIBUTE(c);
--- NEW FILE: chua_search.cpp --- // // // 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);
--- NEW FILE: gaussian_map_search.cpp --- // // // 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);
--- NEW FILE: delayed_logistic__search.cpp --- // // // 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_);
Index: latoomutbeta.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/latoomutbeta.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** latoomutbeta.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- latoomutbeta.hpp 16 Jun 2005 13:02:02 -0000 1.4 *************** *** 61,76 **** }
- /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { ! for (int i = 0; i != get_num_eq(); ++i) ! { ! #ifndef DOUBLE_PRECISION ! if (PD_BIGORSMALL(m_data[i])) ! m_data[i] = 0.01; ! #endif ! } ! };
CHAOS_SYSVAR_FUNCS(x1, 0); --- 61,71 ---- }
/* 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);
--- NEW FILE: henon_map_search.cpp --- // // // 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);
--- NEW FILE: gaussian_map_msg.cpp --- // // // 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);
Index: latoomutgamma.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/latoomutgamma.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** latoomutgamma.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- latoomutgamma.hpp 16 Jun 2005 13:02:02 -0000 1.4 *************** *** 65,77 **** virtual void m_verify() { ! for (int i = 0; i != get_num_eq(); ++i) ! { ! #ifndef DOUBLE_PRECISION ! if (PD_BIGORSMALL(m_data[i])) ! m_data[i] = 0.01; ! #endif ! } ! }; ! CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); --- 65,73 ---- 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);
Index: lozi_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/lozi_map.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** lozi_map.hpp 9 Jun 2005 12:52:17 -0000 1.5 --- lozi_map.hpp 16 Jun 2005 13:02:02 -0000 1.6 *************** *** 61,69 **** } - virtual void m_verify() - { - if (PD_BIGORSMALL(m_data[0])) - m_data[0] = 1; - } CHAOS_SYSVAR_FUNCS(x, 0); --- 61,64 ----
--- NEW FILE: delayed_logistic_dsp.cpp --- // // // 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);
--- NEW FILE: circle_map_search.cpp --- // // // 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);
Index: coupled_logistic_msg.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/coupled_logistic_msg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** coupled_logistic_msg.cpp 27 Dec 2004 22:55:41 -0000 1.1 --- coupled_logistic_msg.cpp 16 Jun 2005 13:02:01 -0000 1.2 *************** *** 2,6 **** // // chaos~ ! // Copyright (C) 2004 Tim Blechmann // // This program is free software; you can redistribute it and/or modify --- 2,6 ---- // // chaos~ ! // Copyright (C) 2005 Tim Blechmann // // This program is free software; you can redistribute it and/or modify *************** *** 22,34 **** #include "chaos_msg.hpp"
! class coupled_logistic_msg: ! public chaos_msg<coupled_logistic> ! { ! CHAOS_MSG_INIT(coupled_logistic, COUPLED_LOGISTIC_ATTRIBUTES); ! ! COUPLED_LOGISTIC_CALLBACKS; ! }; ! ! ! ! FLEXT_LIB_V("coupled_logistic", coupled_logistic_msg); --- 22,24 ---- #include "chaos_msg.hpp"
! CHAOS_MSG_CLASS(coupled_logistic,COUPLED_LOGISTIC)
--- NEW FILE: sine_map_search.cpp --- // // // 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);
--- NEW FILE: hydrogen_dsp.cpp --- // // // 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);
--- NEW FILE: hydrogen.hpp --- // // // chaos~ // Copyright (C) 2005 Tim Blechmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA.
#include "ode_base.hpp"
// hydrogen atom in a magnetic field
class hydrogen : public ode_base {
public: hydrogen() { CHAOS_PRECONSTRUCTOR;
CHAOS_PAR_INIT(method,2); CHAOS_PAR_INIT(dt,0.01);
CHAOS_SYS_INIT(mu,0.8, 0); CHAOS_SYS_INIT(muv,0.6, 1); CHAOS_SYS_INIT(nu,0.4, 2); CHAOS_SYS_INIT(nuv,0.4, 3); CHAOS_PAR_INIT(etilde,-0.3);
CHAOS_POSTCONSTRUCTOR; ode_base_alloc(); reset = 0; } ~hydrogen() { ode_base_free(); }
virtual void m_system(data_t* deriv, data_t* data) { if (reset) { (this->*reset)(); reset = 0; } data_t mu = m_data[0], muv = m_data[1], nu = m_data[2], nuv = m_data[3]; data_t E = CHAOS_PARAMETER(etilde); deriv[0] = muv; deriv[1] = 2* E * mu - 0.25 * mu * nu * nu * (2*mu*mu+nu*nu); deriv[2] = nuv; deriv[3] = 2* E * nu - 0.25 * nu * mu * mu * (2*nu*nu+mu*mu); } virtual void m_verify() { /* make sure to stay in the range of 2 pi */ for (int i = 0; i != get_num_eq(); ++ i) { if (m_data[i] > 1) m_data[i] = 1; else if (m_data[i] < -1) m_data[i] = -1; } }
void reset_nuv() { data_t mu = m_data[0], muv = m_data[1], nu = m_data[2]; data_t E = CHAOS_PARAMETER(etilde); m_data[1]= sqrt ( 2 * E * (mu*mu + nu*nu) - muv*muv - ( mu*mu * nu*nu * ( mu*mu + nu*nu )) * 0.25); // if (fabs((data[3]))<1e-5) // data[3]=0; }
void reset_muv() { data_t mu = m_data[0], nu = m_data[2], nuv = m_data[3]; data_t E = CHAOS_PARAMETER(etilde);
m_data[1]= sqrt ( 2 * E * (mu*mu + nu*nu) - nuv*nuv - ( mu*mu * nu*nu * ( mu*mu + nu*nu )) * 0.25); // if (fabs((data[1]))<1e-5) // data[1]=0; }
/* hook into the predicate to reset the system */ bool m_pred_pos(t_float f) { if (fabs(f) > 1) return false; reset = &hydrogen::reset_nuv; return true; }
bool m_pred_nuv(t_float f) { reset = &hydrogen::reset_muv; return true; }
bool m_pred_muv(t_float f) { reset = &hydrogen::reset_nuv; return true; } void (hydrogen::*reset)(void); CHAOS_SYSVAR_FUNCS_PRED(mu, 0, m_pred_pos); CHAOS_SYSVAR_FUNCS_PRED(muv, 1, m_pred_nuv); CHAOS_SYSVAR_FUNCS_PRED(nu, 2, m_pred_pos); CHAOS_SYSVAR_FUNCS_PRED(nuv, 3, m_pred_muv);
CHAOS_SYSPAR_FUNCS(etilde); };
#define HYDROGEN_CALLBACKS \ ODE_CALLBACKS; \ CHAOS_SYS_CALLBACKS(mu); \ CHAOS_SYS_CALLBACKS(muv); \ CHAOS_SYS_CALLBACKS(nu); \ CHAOS_SYS_CALLBACKS(nuv); \ CHAOS_SYS_CALLBACKS(etilde);
#define HYDROGEN_ATTRIBUTES \ ODE_ATTRIBUTES; \ CHAOS_SYS_ATTRIBUTE(mu); \ CHAOS_SYS_ATTRIBUTE(muv); \ CHAOS_SYS_ATTRIBUTE(nu); \ CHAOS_SYS_ATTRIBUTE(nuv); \ CHAOS_SYS_ATTRIBUTE(etilde);
--- NEW FILE: latoomutbeta_search.cpp --- // // // 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);
--- NEW FILE: standard_map_search.cpp --- // // // 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);
--- NEW FILE: gauss_map_search.cpp --- // // // 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);
--- NEW FILE: driven_anharmonic_search.cpp --- // // // 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);
Index: logistic_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/logistic_map.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** logistic_map.hpp 9 Jun 2005 12:52:17 -0000 1.7 --- logistic_map.hpp 16 Jun 2005 13:02:02 -0000 1.8 *************** *** 52,56 ****
CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); ! bool m_pred_alpha(t_float f) { return (f > 0) && (f < 4); --- 52,56 ----
CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); ! bool m_pred_alpha(data_t f) { return (f > 0) && (f < 4); *************** *** 59,63 **** CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); ! bool m_pred_x(t_float f) { return (f > 0) && (f < 1); --- 59,63 ---- CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); ! bool m_pred_x(data_t f) { return (f > 0) && (f < 1);
--- NEW FILE: lorenz_search.cpp --- // // // 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);
Index: chaos_base.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chaos_base.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** chaos_base.hpp 9 Jun 2005 12:52:17 -0000 1.7 --- chaos_base.hpp 16 Jun 2005 13:02:01 -0000 1.8 *************** *** 30,54 ****
public: ! t_sample get_data(unsigned int i) { return (t_sample)m_data[i]; /* this is not save, but fast */ }
! int get_num_eq() { return m_num_eq; }
! void m_perform() { m_step(); m_verify(); }
! std::map<const t_symbol*,int> attr_ind; // check the integrity of the system virtual void m_verify() { for (int i = 0; i != get_num_eq(); ++i) { --- 30,60 ----
public: ! inline t_sample get_data(unsigned int i) { return (t_sample)m_data[i]; /* this is not save, but fast */ }
! inline int get_num_eq() { return m_num_eq; }
! inline void m_perform() { m_step(); + m_bash_denormals(); m_verify(); }
! std::map<const t_symbol*,int> attr_ind; ! // TableAnyMap attr_ind; /* thomas fragen :-) */ // check the integrity of the system virtual void m_verify() { + } + + inline void m_bash_denormals() + { for (int i = 0; i != get_num_eq(); ++i) { *************** *** 59,63 **** } }; ! data_t m_data[MAXDIMENSION]; // state of the system
--- 65,69 ---- } }; ! data_t m_data[MAXDIMENSION]; // state of the system
--- NEW FILE: coupled_logistic_search.cpp --- // // // 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);
--- NEW FILE: latoocarfian_search.cpp --- // // // 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);
Index: driven_van_der_pol.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/driven_van_der_pol.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** driven_van_der_pol.hpp 9 Jun 2005 12:52:17 -0000 1.2 --- driven_van_der_pol.hpp 16 Jun 2005 13:02:02 -0000 1.3 *************** *** 38,42 **** CHAOS_PRECONSTRUCTOR;
! CHAOS_PAR_INIT(method,0); CHAOS_PAR_INIT(dt,0.01);
--- 38,42 ---- CHAOS_PRECONSTRUCTOR;
! CHAOS_PAR_INIT(method,2); CHAOS_PAR_INIT(dt,0.01);
*************** *** 69,75 **** } CHAOS_SYSVAR_FUNCS(u1, 0); CHAOS_SYSVAR_FUNCS(u2, 1); ! CHAOS_SYSVAR_FUNCS(u3, 2);
CHAOS_SYSPAR_FUNCS(a); --- 69,82 ---- } + virtual void m_verify() + { + /* make sure to stay in the range of 2 pi */ + if (m_data[2] > 2*M_PI) + m_data[2] = chaos_mod(m_data[2], 2*M_PI); + } + CHAOS_SYSVAR_FUNCS(u1, 0); CHAOS_SYSVAR_FUNCS(u2, 1); ! CHAOS_SYSVAR_FUNCS(u3, 2);
CHAOS_SYSPAR_FUNCS(a); *************** *** 83,86 **** --- 90,94 ---- CHAOS_SYS_CALLBACKS(u1); \ CHAOS_SYS_CALLBACKS(u2); \ + CHAOS_SYS_CALLBACKS(u3); \ CHAOS_SYS_CALLBACKS(a); \ CHAOS_SYS_CALLBACKS(k); \ *************** *** 91,94 **** --- 99,103 ---- CHAOS_SYS_ATTRIBUTE(u1); \ CHAOS_SYS_ATTRIBUTE(u2); \ + CHAOS_SYS_ATTRIBUTE(u3); \ CHAOS_SYS_ATTRIBUTE(a); \ CHAOS_SYS_ATTRIBUTE(k); \
--- NEW FILE: latoomutgamma_search.cpp --- // // // 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);
--- NEW FILE: driven_van_der_pol_search.cpp --- // // // 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);
--- NEW FILE: delayed_logistic_search.cpp --- // // // 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);
--- NEW FILE: bungalow_tent_search.cpp --- // // // 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);
--- NEW FILE: roessler_search.cpp --- // // // 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);
Index: roessler.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/roessler.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** roessler.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- roessler.hpp 16 Jun 2005 13:02:02 -0000 1.4 *************** *** 35,43 ****
CHAOS_PAR_INIT(method,0); ! CHAOS_PAR_INIT(dt,0.01);
! CHAOS_SYS_INIT(x1,0,0); ! CHAOS_SYS_INIT(x2,0,1); ! CHAOS_SYS_INIT(x3,0,2);
CHAOS_PAR_INIT(a,4); --- 35,43 ----
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); *************** *** 59,63 **** data_t x1 = data[0], x2 = data[1], x3 = data[2]; ! deriv[0] = - (x2 - x1); deriv[1] = x1 + CHAOS_PARAMETER(a) * x2; deriv[2] = CHAOS_PARAMETER(b) + (x1 - CHAOS_PARAMETER(c)) * x3; --- 59,63 ---- 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;
--- NEW FILE: hydrogen_msg.cpp --- // // // 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);
Index: chaos_defs.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chaos_defs.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** chaos_defs.hpp 9 Jun 2005 12:52:17 -0000 1.4 --- chaos_defs.hpp 16 Jun 2005 13:02:01 -0000 1.5 *************** *** 98,102 ****
#define CHAOS_SYS_CALLBACKS(NAME) \ ! public:void get_##NAME(t_float &f) \ { \ f = m_system->get_##NAME(); \ --- 98,103 ----
#define CHAOS_SYS_CALLBACKS(NAME) \ ! public: \ ! void get_##NAME(t_float &f) \ { \ f = m_system->get_##NAME(); \ *************** *** 136,139 **** --- 137,143 ---- 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); \
--- NEW FILE: tent_map_search.cpp --- // // // 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);
Index: chaos_dsp.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chaos_dsp.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** chaos_dsp.hpp 9 Jun 2005 12:52:17 -0000 1.9 --- chaos_dsp.hpp 16 Jun 2005 13:02:01 -0000 1.10 *************** *** 29,39 ****
/* signal functions: */ ! /* for frequency = sr/2 */ 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); /* linear interpolation */ void m_signal_l(int n, t_sample *const *insigs,t_sample *const *outsigs); ! /* cubic interpolatio */ void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs); --- 29,41 ----
/* 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); ! /* cubic interpolation */ void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs); *************** *** 46,51 **** { m_sr = Samplerate(); } ! void (thisType::*m_routine)(int n, t_sample *const *insigs,t_sample *const *outsigs); --- 48,54 ---- { m_sr = Samplerate(); + set_freq(m_freq); /* maybe we have to change the interpolation mode */ } ! void (thisType::*m_routine)(int n, t_sample *const *insigs,t_sample *const *outsigs); *************** *** 64,67 **** --- 67,71 ---- float m_invfreq; /* inverse frequency */ int m_phase; /* phase counter */ + float m_fphase; /* phase for high frequency linear interpolation */ float m_sr; /* sample rate */ *************** *** 124,139 **** void set_freq(float f) { ! if( (f >= 0) && (f <= m_sr*0.5) ) { ! if (m_freq == -1) set_imethod(m_imethod); m_freq = f; m_invfreq = 1.f / f; } ! else if (f == -1) { ! m_freq = -1;
! m_routine = &thisType::m_signal_; } else --- 128,147 ---- void set_freq(float f) { ! if (f < 0) /* we can't go back in time :-) */ ! f = -f; ! ! if( f <= m_sr * 0.5 ) { ! if (m_freq >= m_sr * 0.5) set_imethod(m_imethod); m_freq = f; m_invfreq = 1.f / f; } ! else if (f > m_sr * 0.5) { ! m_freq = f; ! m_invfreq = 1.f / f;
! m_routine = &thisType::m_signal_n_hf; } else *************** *** 146,149 **** --- 154,158 ----
+ /* create constructor / destructor */ #define CHAOS_DSP_INIT(SYSTEM, ATTRIBUTES) \ *************** *** 229,235 **** --- 238,274 ---- } } + } + + + 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_fphase; + int offset = 0; + while (n) + { + while (phase <= 0) + { + m_system->m_perform(); + phase += m_sr * m_invfreq; + } + int next = (phase < n) ? int(ceilf (phase)) : n; + n -= next; + phase -=next; + + for (int i = 0; i != outlets; ++i) + { + SetSamples(outsigs[i]+offset, next, m_system->get_data(i)); + } + offset += next; + } + m_fphase = phase; }
+ template <class system> void chaos_dsp<system>::m_signal_n(int n, t_sample *const *insigs,
Index: ode_base.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/ode_base.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ode_base.hpp 1 Jan 2005 11:06:58 -0000 1.4 --- ode_base.hpp 16 Jun 2005 13:02:02 -0000 1.5 *************** *** 69,73 **** { int dimension = get_num_eq(); ! for (int i = 0; i != 3; ++i) { --- 69,73 ---- { int dimension = get_num_eq(); ! for (int i = 0; i != 3; ++i) { *************** *** 88,92 ****
protected: ! void (ode_base::*m_routine)(); unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */
--- 88,93 ----
protected: ! void (ode_base::*m_routine)(void); ! unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */
*************** *** 94,100 **** data_t* m_tmp;
! virtual void m_system (data_t* deriv, data_t* data) ! { ! }
void rk1 (); --- 95,99 ---- data_t* m_tmp;
! virtual void m_system (data_t* deriv, data_t* data) = 0;
void rk1 ();
--- NEW FILE: gaussian_map_dsp.cpp --- // // // 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);
--- NEW FILE: logistic_search.cpp --- // // // 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);
--- NEW FILE: delayed_logistic.hpp --- // // // chaos~ // Copyright (C) 2004 Tim Blechmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA.
#include "map_base.hpp"
// delayed logistic map: x[n+1] = alpha * x[n] * (1 - x[n-1]) // 0 < x[n] < 1 // 0 <= alpha <= 4 // taken from E. Atlee Jackson: Perspective of nonlinear dynamics (Vol. 2)
class delayed_logistic: public map_base { public: delayed_logistic() { CHAOS_PRECONSTRUCTOR;
CHAOS_SYS_INIT(x, 0.5, 0);
CHAOS_PAR_INIT(alpha, 3.8);
CHAOS_POSTCONSTRUCTOR;
m_delayed = get_x(); /* the initial state of the delay */ }
~delayed_logistic() { }
virtual void m_step() { data_t x = m_data[0]; data_t alpha = CHAOS_PARAMETER(alpha); data_t delayed = m_delayed;
m_delayed = x; m_data[0] = alpha * x * (1.f - delayed); } data_t m_delayed;
CHAOS_SYSPAR_FUNCS_PRED(alpha, m_pred_alpha); bool m_pred_alpha(t_float f) { return (f > 0) && (f < 4); }
CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); bool m_pred_x(t_float f) { return (f > 0) && (f < 1); }
virtual void m_verify() { data_t x = m_data[0]; if (m_pred_x(x)) return; m_data[0] = 0.5; } };
#define DELAYED_LOGISTIC_CALLBACKS \ MAP_CALLBACKS; \ CHAOS_SYS_CALLBACKS(alpha); \ CHAOS_SYS_CALLBACKS(x);
#define DELAYED_LOGISTIC_ATTRIBUTES \ MAP_ATTRIBUTES; \ CHAOS_SYS_ATTRIBUTE(alpha); \ CHAOS_SYS_ATTRIBUTE(x);
Index: latoocarfian.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/latoocarfian.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** latoocarfian.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- latoocarfian.hpp 16 Jun 2005 13:02:02 -0000 1.4 *************** *** 83,94 **** virtual void m_verify() { ! for (int i = 0; i != get_num_eq(); ++i) ! { ! #ifndef DOUBLE_PRECISION ! if (PD_BIGORSMALL(m_data[i])) ! m_data[i] = 0.01; ! #endif ! } ! }; };
--- 83,90 ---- 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); ! } };
--- NEW FILE: bernoulli_search.cpp --- // // // 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);
Index: chua.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chua.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** chua.hpp 9 Jun 2005 12:52:17 -0000 1.2 --- chua.hpp 16 Jun 2005 13:02:01 -0000 1.3 *************** *** 29,33 **** // b*x - a + b (for x < -1) // ! // taken from Viktor Avrutin: lecture note
class chua: --- 29,33 ---- // b*x - a + b (for x < -1) // ! // taken from Viktor Avrutin: lecture notes
class chua: *************** *** 39,50 **** CHAOS_PRECONSTRUCTOR;
! CHAOS_SYS_INIT(x1,1,0); CHAOS_SYS_INIT(x2,1,1); ! CHAOS_SYS_INIT(x3,1,2);
! CHAOS_PAR_INIT(a,1.4); ! CHAOS_PAR_INIT(b,0.3); ! CHAOS_PAR_INIT(alpha,0.3); ! CHAOS_PAR_INIT(beta,0.3); CHAOS_POSTCONSTRUCTOR; --- 39,53 ---- CHAOS_PRECONSTRUCTOR;
! 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); CHAOS_POSTCONSTRUCTOR; *************** *** 80,89 **** }
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(alpha); CHAOS_SYSPAR_FUNCS(beta); --- 83,154 ---- }
+ virtual void m_verify() + { + data_t x1 = m_data[0]; + data_t x2 = m_data[1]; + data_t x3 = m_data[2]; + + if ( CHAOS_ABS(x3) < 1e-10) + x3 = 0; + + if (x1 == 0 && x2 == 0 && x3 == 0) /* fixpoint at (0,0,0) */ + { + reset(); + return; + } + else + { + data_t c = m_c; + if (m_c) + { + data_t mc = - c; + if (x1 == c && x3 == mc) /* fixpoint at (c,0,-c) */ + { + reset(); + return; + } + if (x1 == mc && x3 == c) /* fixpoint at (-c,0,c) */ + { + reset(); + return; + } + } + } + } + + inline void reset() + { + m_data[0] = rand_range(-1,1); + m_data[1] = rand_range(-1,1); + m_data[2] = rand_range(-1,1); + } + CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); CHAOS_SYSVAR_FUNCS(x3, 2);
! /* due to stability issues, we hook into the predicates */ ! data_t m_c; ! bool m_pred_a(data_t a) ! { ! data_t b = CHAOS_PARAMETER(b); ! m_c = (b - a) / (b + 1); ! return true; ! } ! ! bool m_pred_b(data_t b) ! { ! if (b == -1) ! m_c = 0; ! else ! { ! data_t a = CHAOS_PARAMETER(a); ! m_c = (b - a) / (b + 1); ! } ! return true; ! } ! ! CHAOS_SYSPAR_FUNCS_PRED(a, m_pred_a); ! CHAOS_SYSPAR_FUNCS_PRED(b, m_pred_b); CHAOS_SYSPAR_FUNCS(alpha); CHAOS_SYSPAR_FUNCS(beta);
Index: lorenz.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/lorenz.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** lorenz.hpp 9 Jun 2005 12:52:17 -0000 1.7 --- lorenz.hpp 16 Jun 2005 13:02:02 -0000 1.8 *************** *** 64,67 **** --- 64,77 ---- 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);
--- NEW FILE: lozi_map_search.cpp --- // // // 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);
--- NEW FILE: latoomutalpha_search.cpp --- // // // 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);
--- NEW FILE: hydrogen_search.cpp --- // // // 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);
Index: latoomutalpha.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/latoomutalpha.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** latoomutalpha.hpp 9 Jun 2005 12:52:17 -0000 1.3 --- latoomutalpha.hpp 16 Jun 2005 13:02:02 -0000 1.4 *************** *** 63,79 **** m_data[1] = sin(x1*a) + tmp1*tmp1 + tmp2*tmp2*tmp2; } ! /* function has a fix point for x1 == x2 == 0 */ virtual void m_verify() { ! for (int i = 0; i != get_num_eq(); ++i) ! { ! #ifndef DOUBLE_PRECISION ! if (PD_BIGORSMALL(m_data[i])) ! m_data[i] = 0.5; ! #endif ! } ! }; ! CHAOS_SYSVAR_FUNCS(x1, 0); CHAOS_SYSVAR_FUNCS(x2, 1); --- 63,75 ---- 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);
Index: chaos.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chaos.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** chaos.hpp 12 Feb 2005 08:58:20 -0000 1.7 --- chaos.hpp 16 Jun 2005 13:02:01 -0000 1.8 *************** *** 28,31 **** --- 28,33 ---- #include <cmath>
+ #include <cstdlib> + /* internal we can work with a higher precision than pd */ #ifdef DOUBLE_PRECISION *************** *** 37,40 **** --- 39,57 ---- #endif
+ inline data_t chaos_mod(data_t x, data_t y) + { + #ifdef DOUBLE_PRECISION + return fmod(x,y); + #else + return fmodf(x,y); + #endif + } + + inline data_t rand_range(data_t low, data_t high) + { + return low + ( (rand() * (high - low)) / RAND_MAX); + } + +
#define __chaos_hpp
--- NEW FILE: duffing_map_search.cpp --- // // // 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);
--- NEW FILE: chaos_search.hpp --- // // // chaos~ // Copyright (C) 2005 Tim Blechmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA.
#include "chaos_base.hpp"
template <class 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 ) \ { \ m_system = new SYSTEM; \ \ int size = m_system->get_num_eq(); \ \ \ m_asymptotic_steps = 10000; \ m_transient_steps = 100; \ \ AddOutList("parameters"); \ AddOutList("initial coordinates"); \ AddOutList("minimal coordinates"); \ AddOutList("maximal coordinates"); \ AddOutFloat("lyapunov exponent"); \ \ FLEXT_ADDATTR_VAR("transient_steps", get_tsteps, set_tsteps); \ FLEXT_ADDATTR_VAR("steps", get_asteps, set_asteps); \ ATTRIBUTES; \ FLEXT_ADDMETHOD_(0,"search", m_search); \ } \ \ ~SYSTEM##_search() \ { \ delete m_system; \ } \ \ FLEXT_ATTRVAR_I(m_transient_steps); \ FLEXT_ATTRVAR_I(m_asymptotic_steps);
template <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_perform(); }
for (int i = 0; i != dimensions; ++i) { last[i] = min[i] = max[i] = m_system->m_data[i]; } /* now we start the analysis */
for (int i = 0; i != m_asymptotic_steps; ++i) { m_system->m_perform(); data_t diff = 0; for (int j = 0; j != dimensions; ++j) { /* update min/max */ data_t datum = m_system->m_data[j]; if (datum > max[j]) max[j] = datum; else if (datum < min[j]) min[j] = datum; /* sum up diff */ diff += (last[j] - datum) * (last[j] - datum); last[j] = datum; } diff = sqrt(diff); if (diff < 0) diff = -diff;
ly += log(diff / diff_old); diff_old = diff; /* todo: maybe some overflow checking */ if (diff == 0) break; }
ly /= m_asymptotic_steps; print_results(); }
--- NEW FILE: ikeda_laser_map_search.cpp --- // // // 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);