[PD-cvs] externals/tb/chaos/src chaos.hpp, 1.10, 1.11 chua.hpp, 1.5, 1.6 driven_van_der_pol.hpp, 1.5, 1.6 duffing.hpp, 1.2, 1.3 latoomutgamma.hpp, 1.8, 1.9 linear_congruental.hpp, 1.3, 1.4 ode_base.hpp, 1.8, 1.9 tent_map.hpp, 1.8, 1.9
Tim Blechmann
timblech at users.sourceforge.net
Wed Sep 6 22:32:23 CEST 2006
Update of /cvsroot/pure-data/externals/tb/chaos/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22747
Modified Files:
chaos.hpp chua.hpp driven_van_der_pol.hpp duffing.hpp
latoomutgamma.hpp linear_congruental.hpp ode_base.hpp
tent_map.hpp
Log Message:
cleanups
Index: latoomutgamma.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/latoomutgamma.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** latoomutgamma.hpp 21 May 2006 19:17:04 -0000 1.8
--- latoomutgamma.hpp 6 Sep 2006 20:32:21 -0000 1.9
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 28,85 ****
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] = CHAOS_ABS(sin(x2*b)) + tmp*tmp;
! tmp = sin(x2*a);
! m_data[1] = CHAOS_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);
--- 28,85 ----
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);
Index: duffing.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/duffing.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** duffing.hpp 21 May 2006 18:34:34 -0000 1.2
--- duffing.hpp 6 Sep 2006 20:32:21 -0000 1.3
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 23,94 ****
// 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 = chaos_mod(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);
--- 23,94 ----
// 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);
Index: tent_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/tent_map.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** tent_map.hpp 21 May 2006 19:17:04 -0000 1.8
--- tent_map.hpp 6 Sep 2006 20:32:21 -0000 1.9
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 27,61 ****
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*CHAOS_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);
!
--- 27,61 ----
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);
!
Index: driven_van_der_pol.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/driven_van_der_pol.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** driven_van_der_pol.hpp 21 May 2006 18:34:34 -0000 1.5
--- driven_van_der_pol.hpp 6 Sep 2006 20:32:21 -0000 1.6
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 31,95 ****
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);
! }
!
- virtual 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);
- }
-
- 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);
! 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);
--- 31,95 ----
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);
Index: linear_congruental.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/linear_congruental.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** linear_congruental.hpp 21 May 2006 19:17:04 -0000 1.3
--- linear_congruental.hpp 6 Sep 2006 20:32:21 -0000 1.4
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 26,67 ****
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] = chaos_mod( 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);
--- 26,67 ----
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);
Index: chaos.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chaos.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** chaos.hpp 10 Aug 2006 21:23:33 -0000 1.10
--- chaos.hpp 6 Sep 2006 20:32:21 -0000 1.11
***************
*** 39,57 ****
#ifdef DOUBLE_PRECISION
typedef double data_t;
- #define CHAOS_ABS(x) fabs(x)
#else
typedef float data_t;
- #define CHAOS_ABS(x) fabsf(x)
#endif
- inline data_t chaos_mod(data_t x, data_t y)
- {
- #ifdef DOUBLE_PRECISION
- return fmod(x,y);
- #else
- return fmodf(x,y);
- #endif
- }
-
inline data_t rand_range(data_t low, data_t high)
{
--- 39,46 ----
***************
*** 59,64 ****
}
-
-
#define __chaos_hpp
#endif /* __chaos_hpp */
--- 48,51 ----
Index: ode_base.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/ode_base.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ode_base.hpp 21 May 2006 19:17:04 -0000 1.8
--- ode_base.hpp 6 Sep 2006 20:32:21 -0000 1.9
***************
*** 77,82 ****
data_t m_k2[dimensions];
data_t m_k3[dimensions];
! data_t m_tmp[dimensions];
! // data_t m_tmp[dimensions];
virtual void m_system (data_t* deriv, data_t* data) = 0;
--- 77,81 ----
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;
***************
*** 84,133 ****
void rk1()
{
! // m_system (m_k0, m_data);
! // for (int i = 0; i != dimensions; ++i)
! // m_data[i] += m_dt * m_k0[i];
}
void rk2()
{
! // m_system (m_k0, m_data);
! // for (int i = 0; i != dimensions; ++i)
! // m_k0[i] = m_k0[i] * 0.5 * m_dt + m_data[i];
! //
! // m_system (m_k1, m_k0);
! // for (int i = 0; i != dimensions; ++i)
! // m_data[i] += m_dt * m_k1[i];
}
void rk4()
{
! // m_system (m_k0, m_data);
! // for (int i = 0; i != dimensions; ++i)
! // {
! // m_k0[i] *= m_dt;
! // m_tmp[i] = 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] = 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] = 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)
! // m_data[i] += (m_k0[i] + 2. * (m_k1[i] + m_k2[i]) + m_k3[i])
! // / 6.;
}
};
--- 83,132 ----
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.;
}
};
Index: chua.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/chaos/src/chua.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** chua.hpp 21 May 2006 18:34:34 -0000 1.5
--- chua.hpp 6 Sep 2006 20:32:21 -0000 1.6
***************
*** 1,17 ****
! //
! //
// 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
--- 1,17 ----
! //
! //
// 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
***************
*** 24,165 ****
// 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 ( 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);
};
! #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);
--- 24,165 ----
// 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);
More information about the Pd-cvs
mailing list