Update of /cvsroot/pure-data/externals/chaos/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7115
Modified Files:
Makefile.am bernoulli_map.hpp bungalow_tent_map.hpp chaos.hpp
chaos_base.hpp chaos_dsp.hpp chaos_msg.hpp circle_map.hpp
coupled_logistic.hpp gauss_map.hpp henon_map.hpp
henon_map_dsp.cpp henon_map_msg.cpp ikeda_laser_map.hpp
ikeda_laser_map_dsp.cpp ikeda_laser_map_msg.cpp
logistic_map.hpp lozi_map.hpp lozi_map_dsp.cpp
lozi_map_msg.cpp main.cpp map_base.hpp ode_base.cpp
ode_base.hpp roessler.hpp sine_map.hpp standard_map.hpp
tent_map.hpp tent_map_dsp.cpp tent_map_msg.cpp
Added Files:
chua.hpp chua_dsp.cpp chua_msg.cpp
Log Message:
speedup using function pointers
Index: lozi_map_msg.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/lozi_map_msg.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** lozi_map_msg.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- lozi_map_msg.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(lozi_map, LOZI_MAP, "lozi");
--- 22,24 ----
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(lozi_map, LOZI_MAP, lozi);
Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/main.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** main.cpp 28 Dec 2004 12:38:45 -0000 1.7
--- main.cpp 1 Jan 2005 11:06:58 -0000 1.8
***************
*** 30,33 ****
--- 30,34 ----
CHAOS_ADD(circle_map);
CHAOS_ADD(coupled_logistic);
+ CHAOS_ADD(chua);
CHAOS_ADD(driven_anharmonic);
CHAOS_ADD(driven_van_der_pol);
Index: ode_base.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/ode_base.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ode_base.cpp 24 Dec 2004 15:31:14 -0000 1.2
--- ode_base.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 73,90 ****
}
- void ode_base::m_step()
- {
- switch (m_method)
- {
- case 0:
- rk1();
- break;
- case 1:
- rk2();
- break;
- case 2:
- rk4();
- break;
- }
-
- }
--- 73,74 ----
--- NEW FILE: chua_msg.cpp ---
//
//
// chaos~
// Copyright (C) 2004 Tim Blechmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include "chua.hpp"
#include "chaos_msg.hpp"
CHAOS_MSG_CLASS(chua,CHUA);
Index: henon_map_dsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/henon_map_dsp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** henon_map_dsp.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- henon_map_dsp.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_dsp.hpp"
! CHAOS_DSP_CLASS_NAME(henon, HENON, "henon~");
--- 22,24 ----
#include "chaos_dsp.hpp"
! CHAOS_DSP_CLASS_NAME(henon, HENON, henon~);
Index: Makefile.am
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Makefile.am 28 Dec 2004 12:38:45 -0000 1.7
--- Makefile.am 1 Jan 2005 11:06:58 -0000 1.8
***************
*** 6,9 ****
--- 6,10 ----
circle_map_dsp.cpp circle_map_msg.cpp \
coupled_logistic_dsp.cpp coupled_logistic_msg.cpp \
+ chua_dsp.cpp chua_msg.cpp \
driven_anharmonic_dsp.cpp driven_anharmonic_msg.cpp \
driven_van_der_pol_dsp.cpp driven_van_der_pol_msg.cpp \
Index: tent_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/tent_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tent_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- tent_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 21,28 ****
#include "map_base.hpp"
! // tent map: x[n+1] = 2 * x[n] (for 0 < x <= 0.5)
! // 2 * (1 - x[n]) (else)
! // 0 <= x[n] < 1
! // taken from Willi-Hans Steeb: Chaos and Fractals
class tent_map:
--- 21,28 ----
#include "map_base.hpp"
! // tent map: x[n+1] = 1 - 2*abs(x[n])
! // -1 < x[n] < 1
! // taken from Julien C. Sprott, Strange Attractors: Creating Patterns in Chaos
!
class tent_map:
***************
*** 33,38 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
! CHAOS_SYS_INIT(x, 0.5);
}
--- 33,38 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
! CHAOS_SYS_INIT(x, 0.6);
}
***************
*** 45,59 ****
{
data_t data = m_data[0];
!
! if (data < 0.5f)
! m_data[0] = 2.f * data;
! else
! 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);
}
};
--- 45,56 ----
{
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);
}
};
Index: map_base.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/map_base.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** map_base.hpp 24 Dec 2004 23:20:22 -0000 1.2
--- map_base.hpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 27,31 ****
: public chaos_base
{
!
};
--- 27,34 ----
: public chaos_base
{
! protected:
! virtual void m_step()
! {
! }
};
Index: tent_map_dsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/tent_map_dsp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tent_map_dsp.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- tent_map_dsp.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 24,26 ****
! CHAOS_DSP_CLASS_NAME(tent_map, TENT_MAP, "tent~");
--- 24,26 ----
! CHAOS_DSP_CLASS_NAME(tent_map, TENT_MAP, tent~);
Index: sine_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/sine_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sine_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- sine_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 34,38 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x,0);
}
--- 34,38 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x,0);
}
Index: ikeda_laser_map_dsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/ikeda_laser_map_dsp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ikeda_laser_map_dsp.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- ikeda_laser_map_dsp.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 23,26 ****
! CHAOS_DSP_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, "ikeda");
--- 23,26 ----
! CHAOS_DSP_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, ikeda~);
Index: henon_map_msg.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/henon_map_msg.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** henon_map_msg.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- henon_map_msg.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(henon, HENON, "henon");
--- 22,24 ----
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(henon, HENON, henon);
Index: tent_map_msg.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/tent_map_msg.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tent_map_msg.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- tent_map_msg.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(tent_map, TENT_MAP, "tent");
--- 22,24 ----
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(tent_map, TENT_MAP, tent);
Index: bungalow_tent_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/bungalow_tent_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** bungalow_tent_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- bungalow_tent_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 40,44 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x, 0.6);
CHAOS_SYS_INIT(r, 0.5);
--- 40,44 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x, 0.6);
CHAOS_SYS_INIT(r, 0.5);
Index: circle_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/circle_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** circle_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- circle_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 34,38 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
CHAOS_SYS_INIT(omega, 0.1);
CHAOS_SYS_INIT(r, 3);
--- 34,38 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(omega, 0.1);
CHAOS_SYS_INIT(r, 3);
Index: standard_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/standard_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** standard_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- standard_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 34,38 ****
{
m_num_eq = 2;
! m_data = new data_t[2];
CHAOS_SYS_INIT(I,0.1);
--- 34,38 ----
{
m_num_eq = 2;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(I,0.1);
Index: gauss_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/gauss_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** gauss_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- gauss_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 35,39 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x,0.5);
}
--- 35,39 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x,0.5);
}
--- NEW FILE: chua_dsp.cpp ---
//
//
// chaos~
// Copyright (C) 2004 Tim Blechmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include "chua.hpp"
#include "chaos_dsp.hpp"
CHAOS_DSP_CLASS(chua,CHUA);
Index: lozi_map_dsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/lozi_map_dsp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** lozi_map_dsp.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- lozi_map_dsp.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_dsp.hpp"
! CHAOS_DSP_CLASS_NAME(lozi_map, LOZI_MAP, "lozi");
--- 22,24 ----
#include "chaos_dsp.hpp"
! CHAOS_DSP_CLASS_NAME(lozi_map, LOZI_MAP, lozi~);
Index: chaos_msg.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/chaos_msg.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** chaos_msg.hpp 27 Dec 2004 14:44:11 -0000 1.1
--- chaos_msg.hpp 1 Jan 2005 11:06:58 -0000 1.2
***************
*** 33,37 ****
void m_bang()
{
! m_system->m_step();
int outlets = m_system->get_num_eq();
--- 33,37 ----
void m_bang()
{
! m_system->m_perform();
int outlets = m_system->get_num_eq();
Index: henon_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/henon_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** henon_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- henon_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 33,37 ****
{
m_num_eq = 2;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x,0);
--- 33,37 ----
{
m_num_eq = 2;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x,0);
Index: chaos_base.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/chaos_base.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** chaos_base.hpp 27 Dec 2004 22:55:41 -0000 1.4
--- chaos_base.hpp 1 Jan 2005 11:06:58 -0000 1.5
***************
*** 37,50 ****
}
! virtual void m_step()
{
}
data_t * m_data; // state of the system
protected:
int m_num_eq; // number of equations of the system
};
#define CHAOS_CALLBACKS \
public: \
--- 37,65 ----
}
! void m_perform()
{
+ m_step();
+ m_verify();
}
+ 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;
+ #endif
+ }
+ };
+
data_t * m_data; // state of the system
protected:
+ virtual void m_step();
int m_num_eq; // number of equations of the system
};
+
#define CHAOS_CALLBACKS \
public: \
Index: ikeda_laser_map_msg.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/ikeda_laser_map_msg.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ikeda_laser_map_msg.cpp 27 Dec 2004 22:55:41 -0000 1.2
--- ikeda_laser_map_msg.cpp 1 Jan 2005 11:06:58 -0000 1.3
***************
*** 22,24 ****
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, "ikeda~");
--- 22,24 ----
#include "chaos_msg.hpp"
! CHAOS_MSG_CLASS_NAME(ikeda_laser_map, IKEDA_LASER_MAP, ikeda);
Index: coupled_logistic.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/coupled_logistic.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** coupled_logistic.hpp 27 Dec 2004 22:55:41 -0000 1.1
--- coupled_logistic.hpp 1 Jan 2005 11:06:58 -0000 1.2
***************
*** 33,37 ****
{
m_num_eq = 2;
! m_data = new data_t[2];
CHAOS_SYS_INIT(e, 0.06);
CHAOS_SYS_INIT(r, 3.7);
--- 33,37 ----
{
m_num_eq = 2;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(e, 0.06);
CHAOS_SYS_INIT(r, 3.7);
Index: chaos.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/chaos.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** chaos.hpp 28 Dec 2004 12:38:45 -0000 1.5
--- chaos.hpp 1 Jan 2005 11:06:58 -0000 1.6
***************
*** 25,28 ****
--- 25,29 ----
#include "flext.h"
#include "chaos_defs.hpp"
+ #include <cmath>
/* internal we can work with a higher precision than pd */
Index: chaos_dsp.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/chaos_dsp.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** chaos_dsp.hpp 28 Dec 2004 12:38:45 -0000 1.6
--- chaos_dsp.hpp 1 Jan 2005 11:06:58 -0000 1.7
***************
*** 38,42 ****
void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs);
! virtual void m_signal(int n, t_sample *const *insigs,t_sample *const *outsigs);
virtual void m_dsp(int n, t_sample *const *insigs,t_sample *const *outsigs)
--- 38,45 ----
void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs);
! virtual void m_signal(int n, t_sample *const *insigs,t_sample *const *outsigs)
! {
! (this->*m_routine)(n,insigs,outsigs);
! }
virtual void m_dsp(int n, t_sample *const *insigs,t_sample *const *outsigs)
***************
*** 44,48 ****
m_sr = Samplerate();
}
!
/* local data for system, output and interpolation */
--- 47,52 ----
m_sr = Samplerate();
}
!
! void (thisType::*m_routine)(int n, t_sample *const *insigs,t_sample *const *outsigs);
/* local data for system, output and interpolation */
***************
*** 58,61 ****
--- 62,66 ----
/* local data for signal functions */
float m_freq; /* frequency of oscillations */
+ float m_invfreq; /* inverse frequency */
int m_phase; /* phase counter */
float m_sr; /* sample rate */
***************
*** 63,67 ****
int m_imethod; /* interpolation method */
! int get_imethod(int &i)
{
i = m_imethod;
--- 68,72 ----
int m_imethod; /* interpolation method */
! void get_imethod(int &i)
{
i = m_imethod;
***************
*** 71,75 ****
--- 76,94 ----
{
if( (i >= 0) && (i <= 2) )
+ {
m_imethod = i;
+ switch (i)
+ {
+ case 0:
+ m_routine = &thisType::m_signal_n;
+ break;
+ case 1:
+ m_routine = &thisType::m_signal_l;
+ break;
+ case 2:
+ m_routine = &thisType::m_signal_c;
+ break;
+ }
+ }
else
{
***************
*** 89,93 ****
}
! int get_freq(float &f)
{
f = m_freq;
--- 108,112 ----
}
! void get_freq(float &f)
{
f = m_freq;
***************
*** 97,101 ****
--- 116,123 ----
{
if( (f >= 0) && (f <= m_sr*0.5) )
+ {
m_freq = f;
+ m_invfreq = 1.f / f;
+ }
else
post("frequency out of range");
***************
*** 113,117 ****
SYSTEM##_dsp(int argc, t_atom* argv ) \
{ \
! m_sr = 44100; /* assume default sampling rate (for max frequency) */ \
m_system = new SYSTEM; \
\
--- 135,139 ----
SYSTEM##_dsp(int argc, t_atom* argv ) \
{ \
! m_sr = 44100; /* assume default sampling rate */ \
m_system = new SYSTEM; \
\
***************
*** 177,204 ****
template <class system>
- void chaos_dsp<system>::m_signal(int n, t_sample *const *insigs,
- t_sample *const *outsigs)
- {
- if (m_freq >= m_sr * 0.5)
- {
- m_signal_(n, insigs, outsigs);
- return;
- }
-
- switch (m_imethod)
- {
- case 0:
- m_signal_n(n, insigs, outsigs);
- return;
- case 1:
- m_signal_l(n, insigs, outsigs);
- return;
- case 2:
- m_signal_c(n, insigs, outsigs);
- return;
- }
- }
-
- template <class system>
void chaos_dsp<system>::m_signal_(int n, t_sample *const *insigs,
t_sample *const *outsigs)
--- 199,202 ----
***************
*** 208,212 ****
for (int i = 0; i!=n; ++i)
{
! m_system->m_step();
for (int j = 0; j != outlets; ++j)
{
--- 206,210 ----
for (int i = 0; i!=n; ++i)
{
! m_system->m_perform();
for (int j = 0; j != outlets; ++j)
{
***************
*** 231,236 ****
if (phase == 0)
{
! m_system->m_step();
! phase = int (m_sr / m_freq);
}
--- 229,234 ----
if (phase == 0)
{
! m_system->m_perform();
! phase = int (m_sr * m_invfreq);
}
***************
*** 267,272 ****
if (phase == 0)
{
! m_system->m_step();
! phase = int (m_sr / m_freq);
for (int j = 0; j != outlets; ++j)
--- 265,270 ----
if (phase == 0)
{
! m_system->m_perform();
! phase = int (m_sr * m_invfreq);
for (int j = 0; j != outlets; ++j)
***************
*** 306,311 ****
if (phase == 0)
{
! m_system->m_step();
! phase = int (m_sr / m_freq);
phase = (phase > 2) ? phase : 2;
--- 304,309 ----
if (phase == 0)
{
! m_system->m_perform();
! phase = int (m_sr * m_invfreq);
phase = (phase > 2) ? phase : 2;
Index: ode_base.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/ode_base.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ode_base.hpp 24 Dec 2004 23:20:22 -0000 1.3
--- ode_base.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 31,35 ****
--- 31,48 ----
{
if (i >=0 && i <4)
+ {
m_method = (unsigned char) i;
+ switch (i)
+ {
+ case 0:
+ m_routine = &ode_base::rk1;
+ break;
+ case 1:
+ m_routine = &ode_base::rk2;
+ break;
+ case 2:
+ m_routine = &ode_base::rk4;
+ }
+ }
else
post("no such method");
***************
*** 48,52 ****
}
! virtual void m_step();
void ode_base_alloc()
--- 61,68 ----
}
! virtual void m_step()
! {
! (this->*m_routine)();
! }
void ode_base_alloc()
***************
*** 68,76 ****
delete m_k[i];
}
-
delete m_tmp;
}
protected:
unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */
--- 84,92 ----
delete m_k[i];
}
delete m_tmp;
}
protected:
+ void (ode_base::*m_routine)();
unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */
Index: lozi_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/lozi_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lozi_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- lozi_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 33,37 ****
{
m_num_eq = 2;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x,0);
CHAOS_SYS_INIT(y,0);
--- 33,37 ----
{
m_num_eq = 2;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x,0);
CHAOS_SYS_INIT(y,0);
Index: logistic_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/logistic_map.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** logistic_map.hpp 28 Dec 2004 12:38:45 -0000 1.5
--- logistic_map.hpp 1 Jan 2005 11:06:58 -0000 1.6
***************
*** 22,26 ****
// logistic map: x[n+1] = alpha * x[n] * (1 - x[n])
! // 0 <= x[n] < 1
// 0 <= alpha <= 4
--- 22,26 ----
// logistic map: x[n+1] = alpha * x[n] * (1 - x[n])
! // 0 < x[n] < 1
// 0 <= alpha <= 4
***************
*** 44,50 ****
virtual void m_step()
{
! data_t data = m_data[0];
data_t alpha = CHAOS_PARAMETER(alpha);
! m_data[0] = alpha * data * (1.f - data);
}
--- 44,50 ----
virtual void m_step()
{
! data_t x = m_data[0];
data_t alpha = CHAOS_PARAMETER(alpha);
! m_data[0] = alpha * x * (1.f - x);
}
***************
*** 61,64 ****
--- 61,72 ----
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;
+ }
};
Index: bernoulli_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/bernoulli_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** bernoulli_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- bernoulli_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 32,36 ****
{
m_num_eq = 1;
! m_data = new data_t[1];
CHAOS_SYS_INIT(x,0.5);
}
--- 32,36 ----
{
m_num_eq = 1;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x,0.5);
}
--- NEW FILE: chua.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 "ode_base.hpp"
// chua system: dx1/dt = alpha * (x2 - x1 - h(x1))
// dx2/dt = x1 - x2 + x3
// dx3/dt = - beta * x2
//
// with h(x) = b*x + a - b (for x > 1)
// a*x (for -1 <= x <= 1
// b*x - a + b (for x < -1)
//
// taken from Viktor Avrutin: lecture note
class chua:
public ode_base
{
public:
chua()
{
m_num_eq = 3;
m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(x1,1);
CHAOS_SYS_INIT(x2,1);
CHAOS_SYS_INIT(x3,1);
CHAOS_SYS_INIT(a,1.4);
CHAOS_SYS_INIT(b,0.3);
CHAOS_SYS_INIT(alpha,0.3);
CHAOS_SYS_INIT(beta,0.3);
ode_base_alloc();
}
~chua()
{
ode_base_free();
delete m_data;
}
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;
}
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);
};
#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);
Index: roessler.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/roessler.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** roessler.hpp 27 Dec 2004 22:55:41 -0000 1.1
--- roessler.hpp 1 Jan 2005 11:06:58 -0000 1.2
***************
*** 42,45 ****
--- 42,46 ----
CHAOS_SYS_INIT(b,4);
CHAOS_SYS_INIT(c,4);
+ CHAOS_SYS_INIT(dt,0.01);
ode_base_alloc();
Index: ikeda_laser_map.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/chaos/src/ikeda_laser_map.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ikeda_laser_map.hpp 27 Dec 2004 14:44:11 -0000 1.3
--- ikeda_laser_map.hpp 1 Jan 2005 11:06:58 -0000 1.4
***************
*** 39,43 ****
{
m_num_eq = 2;
! m_data = new data_t[2];
CHAOS_SYS_INIT(c1,0.4);
CHAOS_SYS_INIT(c2,0.9);
--- 39,43 ----
{
m_num_eq = 2;
! m_data = new data_t[m_num_eq];
CHAOS_SYS_INIT(c1,0.4);
CHAOS_SYS_INIT(c2,0.9);