Update of /cvsroot/pure-data/externals/chaos/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6658
Modified Files: bernoulli_map.hpp bungalow_tent_map.hpp chaos.hpp chaos_base.hpp circle_map.hpp gauss_map.hpp henon_map.hpp ikeda_laser_map.hpp logistic_map.hpp lorenz.hpp lozi_map.hpp sine_map.hpp standard_map.hpp tent_map.hpp Log Message: base class macros
Index: henon_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/henon_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** henon_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- henon_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 31,40 **** public: henon() - : m_a(1.4), m_b(0.3) { m_num_eq = 2; m_data = new data_t[1]; ! set_x(0.f); ! set_y(0.f); }
--- 31,42 ---- public: henon() { m_num_eq = 2; m_data = new data_t[1]; ! ! CHAOS_SYS_INIT(x,0); ! CHAOS_SYS_INIT(y,0); ! CHAOS_SYS_INIT(a,1.4); ! CHAOS_SYS_INIT(b,0.3); }
*************** *** 49,121 **** data_t y = m_data[1]; ! m_data[0] = 1 + y - m_a * x * x; ! m_data[1] = m_b * x; ! }
! void set_x(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_x() ! { ! return (t_float)m_data[0]; ! } ! ! ! void set_y(t_float f) ! { ! m_data[1] = (data_t) f; ! } ! ! t_float get_y() ! { ! return (t_float)m_data[1]; ! } ! ! ! void set_a(t_float f) ! { ! m_a = (data_t) f; ! } ! ! t_float get_a() ! { ! return (t_float)m_a; ! } ! ! ! void set_b(t_float f) ! { ! if (f != 0) ! m_b = (data_t) f; ! else ! post("value for b %f out of range", f); ! }
! t_float get_b() { ! return (t_float)m_b; } - - private: - data_t m_a; - data_t m_b; };
! #define HENON_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \ ! FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \ ! FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
- #define HENON_ATTRIBUTES \ - MAP_ATTRIBUTES; \ - FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \ - FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \ - FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \ - FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y); --- 51,83 ---- 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);
Index: lorenz.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/lorenz.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** lorenz.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- lorenz.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 31,41 **** public: logistic() - : m_sigma(16), m_b(4), m_r(40) { m_num_eq = 3; m_data = new data_t[3]; ! set_x1(0.8f); ! set_x2(0.8f); ! set_x3(0.8f); set_method(0); } --- 31,45 ---- public: logistic() { m_num_eq = 3; m_data = new data_t[3]; ! ! CHAOS_SYS_INIT(x1,0.8); ! CHAOS_SYS_INIT(x2,0.8); ! CHAOS_SYS_INIT(x3,0.8); ! CHAOS_SYS_INIT(sigma,16); ! CHAOS_SYS_INIT(b,4); ! CHAOS_SYS_INIT(r,40); ! set_method(0); } *************** *** 50,150 **** data_t x1 = data[0], x2 = data[1], x3 = data[2]; ! deriv[0] = m_sigma * (x2 - x1); ! deriv[1] = - x1 * x3 + m_r * x1 - x2; ! deriv[3] = x1 * x2 - m_b * x3; ! } ! ! void set_x1(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_x1() ! { ! return (t_float)m_data[0]; ! } ! ! void set_x2(t_float f) ! { ! m_data[1] = (data_t) f; ! } ! ! t_float get_x2() ! { ! return (t_float)m_data[1]; ! } ! ! void set_x3(t_float f) ! { ! m_data[2] = (data_t) f; ! } ! ! t_float get_x3() ! { ! return (t_float)m_data[2]; ! } ! ! ! void set_sigma(t_float f) ! { ! if (f > 0) ! m_sigma = (data_t) f; ! else ! post("value for sigma %f out of range", f); ! } ! ! t_float get_sigma() ! { ! return (t_float)m_sigma; ! } ! ! ! void set_r(t_float f) ! { ! if (f > 0) ! m_r = (data_t) f; ! else ! post("value for r %f out of range", f); }
! t_float get_r() ! { ! return (t_float)m_r; ! }
! void set_b(t_float f) ! { ! if (f > 0) ! m_b = (data_t) f; ! else ! post("value for b %f out of range", f); ! }
! t_float get_b() { ! return (t_float)m_b; }
- - private: - data_t m_sigma, m_r, m_b; };
! #define LORENZ_CALLBACKS \ ! ODE_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_sigma, m_system->set_sigma); \ ! FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \ ! FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \ ! FLEXT_CALLVAR_F(m_system->get_x1, m_system->set_x1); \ ! FLEXT_CALLVAR_F(m_system->get_x2, m_system->set_x2); \ ! FLEXT_CALLVAR_F(m_system->get_x3, m_system->set_x3);
! #define LORENZ_ATTRIBUTES \ ! ODE_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("sigma",m_system->get_sigma, m_system->set_sigma); \ ! FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \ ! FLEXT_ADDATTR_VAR("b",m_system->get_g, m_system->set_g); \ ! FLEXT_ADDATTR_VAR("x1",m_system->get_x1, m_system->set_x1); \ ! FLEXT_ADDATTR_VAR("x2",m_system->get_x2, m_system->set_x2); \ ! FLEXT_ADDATTR_VAR("x3",m_system->get_x3, m_system->set_x3); --- 54,93 ---- 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[3] = x1 * x2 - CHAOS_PARAMETER(b) * x3; }
! 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);
Index: tent_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/tent_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tent_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- tent_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 34,38 **** m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5); }
--- 34,38 ---- m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(x, 0.5); }
*************** *** 51,63 **** m_data[0] = 2.f * (1.f - data); } };
! #define LOGISTIC_CALLBACKS \ ! MAP_CALLBACKS \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
- #define LOGISTIC_ATTRIBUTES \ - MAP_ATTRIBUTES \ - FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 51,70 ---- m_data[0] = 2.f * (1.f - data); } + + CHAOS_SYSPAR_FUNCS_PRED(x, m_pred_x); + bool m_pred_x(t_float f) + { + return (f >= 0) && (f < 1); + } };
! #define LOGISTIC_CALLBACKS \ ! MAP_CALLBACKS \ ! CHAOS_SYS_CALLBACKS(x); ! ! #define LOGISTIC_ATTRIBUTES \ ! MAP_ATTRIBUTES \ ! CHAOS_SYS_ATTRIBUTE(x);
Index: chaos.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/chaos.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** chaos.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- chaos.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 23,27 **** #define FLEXT_ATTRIBUTES 1
! #include "flext.h"
/* internal we can work with a higher precision than pd */ --- 23,27 ---- #define FLEXT_ATTRIBUTES 1
! //#include "flext.h"
/* internal we can work with a higher precision than pd */
Index: sine_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/sine_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** sine_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- sine_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 35,39 **** m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5); }
--- 35,39 ---- m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(x,0); }
*************** *** 48,72 **** }
! void set_x(t_float f) ! { ! if ( (f >= 0) && (f <= 1)) ! m_data[0] = (data_t) f; ! else ! post("value for x %f out of range", f); ! }
! t_float get_x() { ! return (t_float)m_data[0]; } - };
! #define SINE_CALLBACKS \ ! MAP_CALLBACKS \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
- #define SINE_ATTRIBUTES \ - MAP_ATTRIBUTES \ - FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 48,66 ---- }
! CHAOS_SYSVAR_FUNCS_PRED(x, m_pred);
! bool m_pred(t_float f) { ! return (f >= 0) && (f <= 1); } };
! #define SINE_CALLBACKS \ ! MAP_CALLBACKS \ ! CHAOS_SYS_CALLBACKS(x); ! ! #define SINE_ATTRIBUTES \ ! MAP_ATTRIBUTES \ ! CHAOS_SYS_ATTRIBUTE(x);
Index: bungalow_tent_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/bungalow_tent_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** bungalow_tent_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- bungalow_tent_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 38,46 **** public: bungalow_tent() - : m_r(0.5) { m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5f); }
--- 38,46 ---- public: bungalow_tent() { m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(x, 0.5); ! CHAOS_SYS_INIT(r, 0.5); }
*************** *** 53,57 **** { data_t x = m_data[0]; ! data_t r = m_r; if ( x < - 0.5) --- 53,57 ---- { data_t x = m_data[0]; ! data_t r = CHAOS_PARAMETER(r); if ( x < - 0.5) *************** *** 78,121 **** }
! void set_x(t_float f) ! { ! if ( (f > -1) && (f < 1)) ! m_data[0] = (data_t) f; ! else ! post("value for x %f out of range", f); ! } ! ! t_float get_x() ! { ! return (t_float)m_data[0]; ! } ! ! void set_r(t_float f) { ! if ( (f > -.5) && (f < 1)) ! m_data[0] = (data_t) f; ! else ! post("value for r %f out of range", f); }
! t_float get_r() { ! return (t_float)m_data[0]; } - - private: - data_t m_r; - };
! #define BUNGALOW_TENT_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \ ! ! ! #define BUNGALOW_TENT_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \ ! FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); --- 78,101 ---- }
! CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); ! bool m_pred_x(t_float f) { ! return (f >= -1) && (f < 1); }
! CHAOS_SYSVAR_FUNCS_PRED(r, 0, 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)
Index: lozi_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/lozi_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** lozi_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- lozi_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 31,40 **** public: lozi() - : m_a(1.4), m_b(0.3) { m_num_eq = 2; m_data = new data_t[1]; ! set_x(0.5); ! set_y(0.5); }
--- 31,41 ---- public: lozi() { m_num_eq = 2; m_data = new data_t[1]; ! CHAOS_SYS_INIT(x,0); ! CHAOS_SYS_INIT(y,0); ! CHAOS_SYS_INIT(a,1.4); ! CHAOS_SYS_INIT(b,0.3); }
*************** *** 50,126 **** if (x > 0) ! m_data[0] = 1 + y - m_a * x; else ! m_data[0] = 1 + y + m_a * x; ! m_data[1] = m_b * x; }
! void set_x(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_x() ! { ! return (t_float)m_data[0]; ! } ! ! ! void set_y(t_float f) ! { ! m_data[1] = (data_t) f; ! } ! ! t_float get_y() ! { ! return (t_float)m_data[1]; ! } ! ! ! void set_a(t_float f) ! { ! m_a = (data_t) f; ! } ! ! t_float get_a() ! { ! return (t_float)m_a; ! } ! ! ! void set_b(t_float f) ! { ! if (f != 0) ! m_b = (data_t) f; ! else ! post("value for b %f out of range", f); ! }
! t_float get_b() { ! return (t_float)m_b; } - - - private: - data_t m_a; - data_t m_b; };
! #define LOZI_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \ ! FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \ ! FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
! #define LOZI_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \ ! FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \ ! FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \ ! FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y); --- 51,86 ---- 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_CALLBACKS \ ! MAP_CALLBACKS; \ ! CHAOS_SYS_CALLBACKS(a); \ ! CHAOS_SYS_CALLBACKS(b); \ ! CHAOS_SYS_CALLBACKS(x); \ ! CHAOS_SYS_CALLBACKS(y);
! #define LOZI_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! CHAOS_SYS_ATTRIBUTE(a); \ ! CHAOS_SYS_ATTRIBUTE(b); \ ! CHAOS_SYS_ATTRIBUTE(x); \ ! CHAOS_SYS_ATTRIBUTE(y);
Index: logistic_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/logistic_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** logistic_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- logistic_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 30,38 **** public: logistic() - : m_alpha(3.8) { m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5f); }
--- 30,38 ---- public: logistic() { m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(alpha, 3.8); ! CHAOS_SYS_INIT(x, 0.5); }
*************** *** 45,91 **** { data_t data = m_data[0]; ! data_t alpha = m_alpha; m_data[0] = alpha * data * (1.f - data); }
! void set_alpha(t_float f) ! { ! if ( (f > 0) && (f < 4)) ! m_alpha = (data_t) f; ! else ! post("value for alpha %f out of range", f); ! } ! ! t_float get_alpha() ! { ! return (t_float)m_alpha; ! } ! ! void set_x(t_float f) { ! if ( (f > 0) && (f < 1)) ! m_data[0] = (data_t) f; ! else ! post("value for x %f out of range", f); }
! t_float get_x() { ! return (t_float)m_data[0]; } - - private: - data_t m_alpha; };
! #define LOGISTIC_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_alpha, m_system->set_alpha); \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); ! ! #define LOGISTIC_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("alpha",m_system->get_alpha, m_system->set_alpha); \ ! FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 45,74 ---- { data_t data = m_data[0]; ! data_t alpha = CHAOS_PARAMETER(alpha); m_data[0] = alpha * data * (1.f - data); }
! 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, m_pred_x); ! ! bool m_pred_x(t_float f) { ! return (f > 0) && (f < 1); } };
! #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);
Index: bernoulli_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/bernoulli_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** bernoulli_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- bernoulli_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 33,40 **** m_num_eq = 1: m_data = new data_t[1]; ! set_x(0.5f); }
! ~bernoulli() { delete m_data; --- 33,40 ---- m_num_eq = 1: m_data = new data_t[1]; ! CHAOS_SYS_INIT(x,0.5) }
! ~Bernoulli() { delete m_data; *************** *** 51,75 **** }
! void set_x(t_float f) ! { ! if ( (f >= 0) && (f < 1)) ! m_data[0] = (data_t) f; ! else ! post("value for x %f out of range", f); ! } ! ! t_float get_x() { ! return (t_float)m_data[0]; } };
! #define BERNOULLI_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
- #define BERNOULLI_ATTRIBUTES \ - MAP_ATTRIBUTES; \ - FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 51,68 ---- }
! 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);
Index: circle_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/circle_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** circle_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- circle_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 30,38 **** public: circle_map() - : m_omega(0.4), m_r(1) { m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5); }
--- 30,39 ---- public: circle_map() { m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(omega, 0.4); ! CHAOS_SYS_INIT(r, 1); ! CHAOS_SYS_INIT(x, 0.5); }
*************** *** 45,106 **** { data_t x = m_data[0]; ! data_t omega = m_omega; ! data_t r = m_r; m_data[0] = x + omega - r / (2.f * M_PI) * sin (2.f * M_PI * x); }
! void set_x(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_x() ! { ! return (t_float)m_data[0]; ! } ! ! void set_r(t_float f) ! { ! m_r = (data_t) f; ! } ! ! ! t_float get_r() ! { ! return (t_float)m_r; ! } ! ! ! void set_omega (t_float f) ! { ! m_omega = (data_t) f; ! } ! ! t_float get_omega() ! { ! return (t_float)m_omega; ! } ! ! ! private: ! data_t m_omega; ! data_t m_r; };
! #define CIRCLE_MAP_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_ATTRVAR_F(m_system->m_omega); \ ! FLEXT_ATTRVAR_F(m_system->m_r); \ ! FLEXT_CALLVAR_F(m_system->get_omega, m_system->set_omega); \ ! FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
! #define CIRCLE_MAP_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR1("omega",m_system->m_omega); \ ! FLEXT_ADDATTR_VAR1("r",m_system->m_r); \ ! FLEXT_ADDATTR_VAR("omega",m_system->get_omega, m_system->set_omega); \ ! FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \ ! FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 46,71 ---- { 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);
Index: chaos_base.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/chaos_base.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** chaos_base.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- chaos_base.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 1,3 **** ! // // // chaos~ --- 1,3 ---- ! a// // // chaos~ *************** *** 37,41 **** }
- /* prototype for system function */ virtual void m_step();
--- 37,40 ---- *************** *** 52,55 **** --- 51,143 ---- FLEXT_ADDATTR_GET("dimension",m_system->get_num_eq);
+ + + // 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) \ + public: \ + CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \ + CHAOS_SYS_GETFUNC(NAME, NR) + + #define CHAOS_SYSVAR_FUNCS(NAME, NR) \ + public: \ + 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) \ + public: \ + CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \ + CHAOS_PAR_GETFUNC(NAME) \ + private: \ + data_t m_##NAME; \ + public: + + #define CHAOS_SYSPAR_FUNCS(NAME) \ + public: \ + CHAOS_PAR_SETFUNC(NAME) \ + CHAOS_PAR_GETFUNC(NAME) \ + private: \ + data_t m_##NAME; \ + public: + + + #define CHAOS_SYS_CALLBACKS(NAME) \ + FLEXT_CALLVAR_F(m_system->get_##NAME, m_system->set_##NAME); + + #define CHAOS_SYS_ATTRIBUTE(NAME) \ + FLEXT_ADDATTR_VAR(#NAME,m_system->get_##NAME, m_system->set_##NAME); + + #define CHAOS_SYS_INIT(NAME, VALUE) \ + set_##NAME(VALUE); + + #define CHAOS_PARAMETER(NAME) m_##NAME + + #define __chaos_base_hpp #endif /* __chaos_base_hpp */
Index: standard_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/standard_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** standard_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- standard_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 32,41 **** public: standard() - : m_k(0.8) { m_num_eq = 2; m_data = new data_t[2]; ! set_I(0.1); ! set_theta(0.2); }
--- 32,42 ---- public: standard() { m_num_eq = 2; m_data = new data_t[2]; ! ! CHAOS_SYS_INIT(I,0.1); ! CHAOS_SYS_INIT(theta,0.2); ! CHAOS_SYS_INIT(k, 0.8); }
*************** *** 49,54 **** data_t I = m_data[0]; data_t theta = m_data[1]; ! m_data[0] = I + m_k * sin(theta); theta = theta + I + k * sin(theta);
--- 50,56 ---- 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);
*************** *** 77,130 ****
! void set_I(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_I() ! { ! return (t_float)m_data[0]; ! } ! ! ! void set_theta(t_float f) ! { ! if ( (f >= 0) && (f < 2*M_PI)) ! m_data[1] = (data_t) f; ! else ! post("value for theta %f out of range", f); ! } ! ! t_float get_theta() ! { ! return (t_float)m_data[1]; ! } ! ! ! void set_k(t_float f) ! { ! m_k = (data_t) f; ! }
! t_float get_k() { ! return (t_float)m_k; }
! private: ! data_t m_k; };
! #define STANDARD_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_I, m_system->set_I); \ ! FLEXT_CALLVAR_F(m_system->get_theta, m_system->set_theta); \ ! FLEXT_CALLVAR_F(m_system->get_k, m_system->set_k);
! #define STANDARD_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("I",m_system->get_I, m_system->set_I); \ ! FLEXT_ADDATTR_VAR("theta",m_system->get_theta, m_system->set_theta); \ ! FLEXT_ADDATTR_VAR("k",m_system->get_k, m_system->set_k); --- 79,104 ----
! 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(I, 1); };
! #define STANDARD_CALLBACKS \ ! MAP_CALLBACKS; \ ! CHAOS_SYS_CALLBACKS(I); \ ! CHAOS_SYS_CALLBACKS(theta); \ ! CHAOS_SYS_CALLBACKS(k);
! #define STANDARD_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! CHAOS_SYS_ATTRIBUTE(I); \ ! CHAOS_SYS_ATTRIBUTE(theta); \ ! CHAOS_SYS_ATTRIBUTE(k);
Index: gauss_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/gauss_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gauss_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- gauss_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 34,38 **** m_num_eq = 1; m_data = new data_t[1]; ! set_x(0.5); }
--- 34,38 ---- m_num_eq = 1; m_data = new data_t[1]; ! CHAOS_SYS_INIT(x,0.5); }
*************** *** 52,77 **** }
! void set_x(t_float f) ! { ! if ( (f >= 0) && (f < 1)) ! m_data[0] = (data_t) f; ! else ! post("value for x %f out of range", f); ! } ! ! t_float get_x() { ! return (t_float)m_data[0]; } - };
! #define GAUSS_CALLBACKS \ ! MAP_CALLBACKS; \ ! FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
- #define GAUSS_ATTRIBUTES \ - MAP_ATTRIBUTES; \ - FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
--- 52,70 ---- }
! CHAOS_SYSVAR_FUNCS_PRED(x, 0, m_pred_x); ! bool m_pred_x(t_float f) { ! return (f >= 0) && (f < 1); } };
! #define GAUSS_CALLBACKS \ ! MAP_CALLBACKS; \ ! CHAOS_SYS_CALLBACKS(x); ! ! #define GAUSS_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! CHAOS_SYS_ATTRIBUTE(x);
Index: ikeda_laser_map.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/chaos/src/ikeda_laser_map.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ikeda_laser_map.hpp 21 Dec 2004 09:22:10 -0000 1.1.1.1 --- ikeda_laser_map.hpp 23 Dec 2004 10:07:17 -0000 1.2 *************** *** 37,46 **** public: ikeda() - : m_c1(0.4), m_c2(0.9), m_c3(9), m_roh(0.85) { m_num_eq = 2; m_data = new data_t[2]; ! set_x(0.5); ! set_y(0.5); }
--- 37,49 ---- public: ikeda() { m_num_eq = 2; m_data = new data_t[2]; ! CHAOS_SYS_INIT(c1,0.4); ! CHAOS_SYS_INIT(c2,0.9); ! CHAOS_SYS_INIT(c3,9); ! CHAOS_SYS_INIT(roh,0.85); ! CHAOS_SYS_INIT(x,0.5); ! CHAOS_SYS_INIT(y,0.5); }
*************** *** 55,153 **** data_t y = m_data[1]; ! data_t tau = m_c1 - m_c3 / (1 + x*x + y*y); data_t cos_tau = cos(tau); data_t sin_tau = sin(tau);
! m_data[0] = m_roh + m_c2 * (x * cos_tau - y * sin_tau); ! m_data[1] = m_c2 * (x * sin_tau + y * cos_tau); } ! ! void set_x(t_float f) ! { ! m_data[0] = (data_t) f; ! } ! ! t_float get_x() ! { ! return (t_float)m_data[0]; ! } ! ! void set_y(t_float f) ! { ! m_data[1] = (data_t) f; ! } ! ! t_float get_y() ! { ! return (t_float)m_data[1]; ! } ! ! ! void set_c1(t_float f) ! { ! m_c1 = (data_t) f; ! } ! ! t_float get_c1() ! { ! return (t_float)m_c1; ! } ! ! ! void set_c2(t_float f) ! { ! m_c2[1] = (data_t) f; ! } ! ! t_float get_c2() ! { ! return (t_float)m_c2; ! } ! ! ! void set_c3(t_float f) ! { ! m_c3 = (data_t) f; ! } ! ! t_float get_c3() ! { ! return (t_float)m_c3; ! } ! ! ! void set_roh(t_float f) ! { ! m_roh = (data_t) f; ! } ! ! t_float get_roh() ! { ! return (t_float)m_roh; ! } ! ! private: ! data_t m_c1, m_c2, m_c3, m_roh; ! };
- #define IKEDA_CALLBACKS \ - MAP_CALLBACKS; \ - FLEXT_CALLVAR_F(m_system->get_c1, m_system->set_c1); \ - FLEXT_CALLVAR_F(m_system->get_c2, m_system->set_c2); \ - FLEXT_CALLVAR_F(m_system->get_c3, m_system->set_c3); \ - FLEXT_CALLVAR_F(m_system->get_roh, m_system->set_roh); \ - FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \ - FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y); \
! #define IKEDA_ATTRIBUTES \ ! MAP_ATTRIBUTES; \ ! FLEXT_ADDATTR_VAR("c1",m_system->get_c1, m_system->set_c1); \ ! FLEXT_ADDATTR_VAR("c2",m_system->get_c2, m_system->set_c2); \ ! FLEXT_ADDATTR_VAR("c3",m_system->get_c3, m_system->set_c3); \ ! FLEXT_ADDATTR_VAR("roh",m_system->get_roh, m_system->set_roh); \ ! FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \ ! FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y); --- 58,97 ---- 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_PAR_FUNCS(c1); ! CHAOS_PAR_FUNCS(c2); ! CHAOS_PAR_FUNCS(c3); ! CHAOS_PAR_FUNCS(roh);
+ };
+ #define IKEDA_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_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);