From 5233c01a26329306c9f1d08c1a39733aee2cc518 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 21 Dec 2004 09:22:10 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r2423, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/tb/; revision=2424 --- chaos/src/chaos_base.hpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 chaos/src/chaos_base.hpp (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp new file mode 100644 index 0000000..231580b --- /dev/null +++ b/chaos/src/chaos_base.hpp @@ -0,0 +1,55 @@ +// +// +// chaos~ +// Copyright (C) 2004 Tim Blechmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#ifndef __chaos_base_hpp + +#include "chaos.hpp" + +class chaos_base +{ + +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; + } + + /* prototype for system function */ + 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 \ +FLEXT_CALLGET_F(m_system->get_num_eq); + +#define CHAOS_ATTRIBUTES \ +FLEXT_ADDATTR_GET("dimension",m_system->get_num_eq); + +#define __chaos_base_hpp +#endif /* __chaos_base_hpp */ -- cgit v1.2.1 From 404bfef9e23dfc3166cb2005367e7e8a41863914 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 23 Dec 2004 10:07:17 +0000 Subject: base class macros svn path=/trunk/externals/tb/; revision=2426 --- chaos/src/chaos_base.hpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 231580b..a42e275 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -1,4 +1,4 @@ -// +a// // // chaos~ // Copyright (C) 2004 Tim Blechmann @@ -36,7 +36,6 @@ public: return m_num_eq; } - /* prototype for system function */ virtual void m_step(); data_t * m_data; // state of the system @@ -51,5 +50,94 @@ FLEXT_CALLGET_F(m_system->get_num_eq); #define CHAOS_ATTRIBUTES \ 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 */ -- cgit v1.2.1 From 45932d6b4b33ecd4f4dc2e7eab9f210dfa46cc34 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 24 Dec 2004 15:31:14 +0000 Subject: xmas's changes svn path=/trunk/externals/tb/; revision=2427 --- chaos/src/chaos_base.hpp | 103 ++++++----------------------------------------- 1 file changed, 12 insertions(+), 91 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index a42e275..795383e 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -1,4 +1,4 @@ -a// +// // // chaos~ // Copyright (C) 2004 Tim Blechmann @@ -21,6 +21,7 @@ a// #ifndef __chaos_base_hpp #include "chaos.hpp" +#include "chaos_defs.hpp" class chaos_base { @@ -36,7 +37,9 @@ public: return m_num_eq; } - virtual void m_step(); + virtual void m_step() + { + } data_t * m_data; // state of the system @@ -45,98 +48,16 @@ protected: }; #define CHAOS_CALLBACKS \ -FLEXT_CALLGET_F(m_system->get_num_eq); - -#define CHAOS_ATTRIBUTES \ -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); +void get_dimension(int &i) \ +{ \ + i = m_system->get_num_eq(); \ +} \ +FLEXT_CALLGET_I(get_dimension); -#define CHAOS_SYS_INIT(NAME, VALUE) \ -set_##NAME(VALUE); +#define CHAOS_ATTRIBUTES \ +FLEXT_ADDATTR_GET("dimension",get_dimension); -#define CHAOS_PARAMETER(NAME) m_##NAME #define __chaos_base_hpp -- cgit v1.2.1 From 6963657b3f3ee4321394953a2cc67cd7386cce2d Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 27 Dec 2004 22:55:41 +0000 Subject: additions and better code reuse svn path=/trunk/externals/tb/; revision=2433 --- chaos/src/chaos_base.hpp | 1 - 1 file changed, 1 deletion(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 795383e..ce6fc11 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -21,7 +21,6 @@ #ifndef __chaos_base_hpp #include "chaos.hpp" -#include "chaos_defs.hpp" class chaos_base { -- cgit v1.2.1 From 2a0d532e5965402f19f74f70dfdcc7efd1055b15 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 1 Jan 2005 11:06:58 +0000 Subject: speedup using function pointers svn path=/trunk/externals/tb/; revision=2439 --- chaos/src/chaos_base.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index ce6fc11..a2072d0 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -36,16 +36,31 @@ public: return m_num_eq; } - virtual void m_step() + 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: \ void get_dimension(int &i) \ -- cgit v1.2.1 From 2393d5bab1917825e806871d9050ca54dc3041f3 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 12 Feb 2005 08:58:21 +0000 Subject: stability improvement and others svn path=/trunk/externals/tb/; revision=2568 --- chaos/src/chaos_base.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index a2072d0..3e11201 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -56,7 +56,7 @@ public: data_t * m_data; // state of the system protected: - virtual void m_step(); + virtual void m_step() = 0; int m_num_eq; // number of equations of the system }; -- cgit v1.2.1 From 2434290915cda6ed855e4dc2249312153b995817 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 9 Jun 2005 12:52:17 +0000 Subject: changed initialisation svn path=/trunk/externals/tb/; revision=3145 --- chaos/src/chaos_base.hpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 3e11201..959afdf 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -21,6 +21,9 @@ #ifndef __chaos_base_hpp #include "chaos.hpp" +#include + +#define MAXDIMENSION 5 // this should be enough for the first class chaos_base { @@ -42,6 +45,9 @@ public: m_verify(); } + std::map attr_ind; + + // check the integrity of the system virtual void m_verify() { for (int i = 0; i != get_num_eq(); ++i) @@ -52,14 +58,25 @@ public: #endif } }; - - data_t * m_data; // state of the system + + data_t m_data[MAXDIMENSION]; // state of the system protected: - virtual void m_step() = 0; - int m_num_eq; // number of equations of the system + virtual void m_step() = 0; // iteration + int m_num_eq; // number of equations of the system + flext::AtomList Parameter; // parameter + flext::AtomList System; // system }; +#define CHAOS_PRECONSTRUCTOR \ + /* dummy */ + +#define CHAOS_POSTCONSTRUCTOR \ +m_num_eq = System.Count(); + +#define CHAOS_DESTRUCTOR \ + + #define CHAOS_CALLBACKS \ public: \ @@ -69,6 +86,7 @@ void get_dimension(int &i) \ } \ FLEXT_CALLGET_I(get_dimension); + #define CHAOS_ATTRIBUTES \ FLEXT_ADDATTR_GET("dimension",get_dimension); -- cgit v1.2.1 From d1ed55f96f9cecc818844006fb36cd58ca70da5e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 16 Jun 2005 13:02:02 +0000 Subject: - parameter searching (broken) - misc. updates svn path=/trunk/externals/tb/; revision=3192 --- chaos/src/chaos_base.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 959afdf..5e2a99f 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -29,26 +29,32 @@ class chaos_base { public: - t_sample get_data(unsigned int i) + inline t_sample get_data(unsigned int i) { return (t_sample)m_data[i]; /* this is not save, but fast */ } - int get_num_eq() + inline int get_num_eq() { return m_num_eq; } - void m_perform() + inline void m_perform() { m_step(); + m_bash_denormals(); m_verify(); } - std::map attr_ind; + std::map 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) { @@ -58,7 +64,7 @@ public: #endif } }; - + data_t m_data[MAXDIMENSION]; // state of the system protected: -- cgit v1.2.1 From ef53e19b3d9019b1b1f3345390f55ae9229ce390 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 22 Oct 2005 15:11:45 +0000 Subject: cleanups and new system svn path=/trunk/externals/tb/; revision=3750 --- chaos/src/chaos_base.hpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 5e2a99f..5c87bed 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -27,14 +27,20 @@ class chaos_base { - public: + chaos_base(int n): + m_num_eq(n) + { + m_data = new data_t[n]; + } + + 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() + inline int get_num_eq() const { return m_num_eq; } @@ -65,25 +71,15 @@ public: } }; - data_t m_data[MAXDIMENSION]; // state of the system + data_t * m_data; // state of the system protected: virtual void m_step() = 0; // iteration - int m_num_eq; // number of equations of the system + const int m_num_eq; // number of equations of the system flext::AtomList Parameter; // parameter flext::AtomList System; // system }; -#define CHAOS_PRECONSTRUCTOR \ - /* dummy */ - -#define CHAOS_POSTCONSTRUCTOR \ -m_num_eq = System.Count(); - -#define CHAOS_DESTRUCTOR \ - - - #define CHAOS_CALLBACKS \ public: \ void get_dimension(int &i) \ -- cgit v1.2.1 From 13cba7a7997e318fbba01a36912219355e387d52 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 21 May 2006 18:34:34 +0000 Subject: rewrote most stuff using templates svn path=/trunk/externals/tb/; revision=5105 --- chaos/src/chaos_base.hpp | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 5c87bed..4b984d9 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -1,7 +1,7 @@ // // // chaos~ -// Copyright (C) 2004 Tim Blechmann +// Copyright (C) 2004, 2006 Tim Blechmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,26 +23,23 @@ #include "chaos.hpp" #include -#define MAXDIMENSION 5 // this should be enough for the first - +template class chaos_base { public: - chaos_base(int n): - m_num_eq(n) + chaos_base() { - m_data = new data_t[n]; } - inline t_sample get_data(unsigned int i) { + assert(i attr_ind; - // TableAnyMap attr_ind; /* thomas fragen :-) */ // check the integrity of the system - virtual void m_verify() + inline void m_verify() { } inline void m_bash_denormals() { - for (int i = 0; i != get_num_eq(); ++i) + for (int i = 0; i != dimensions; ++i) { #ifndef DOUBLE_PRECISION if (PD_BIGORSMALL(m_data[i])) @@ -71,28 +67,13 @@ public: } }; - data_t * m_data; // state of the system + data_t m_data[dimensions]; // state of the system protected: - virtual void m_step() = 0; // iteration - const int m_num_eq; // number of equations of the system + virtual void m_step() = 0; // iteration flext::AtomList Parameter; // parameter flext::AtomList System; // system }; -#define CHAOS_CALLBACKS \ -public: \ -void get_dimension(int &i) \ -{ \ - i = m_system->get_num_eq(); \ -} \ -FLEXT_CALLGET_I(get_dimension); - - -#define CHAOS_ATTRIBUTES \ -FLEXT_ADDATTR_GET("dimension",get_dimension); - - - #define __chaos_base_hpp #endif /* __chaos_base_hpp */ -- cgit v1.2.1 From 2c157bd8aa1f5387169cc0c0910d36c8068c4068 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 21 May 2006 19:17:04 +0000 Subject: improved inlining for maps svn path=/trunk/externals/tb/; revision=5106 --- chaos/src/chaos_base.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'chaos/src/chaos_base.hpp') diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp index 4b984d9..d18a507 100644 --- a/chaos/src/chaos_base.hpp +++ b/chaos/src/chaos_base.hpp @@ -42,12 +42,12 @@ public: return dimensions; } - inline void m_perform() - { - m_step(); - m_bash_denormals(); - m_verify(); - } +// inline void m_perform() +// { +// m_step(); +// m_bash_denormals(); +// m_verify(); +// } std::map attr_ind; @@ -70,7 +70,7 @@ public: data_t m_data[dimensions]; // state of the system protected: - virtual void m_step() = 0; // iteration +// void m_step() = 0; // iteration flext::AtomList Parameter; // parameter flext::AtomList System; // system }; -- cgit v1.2.1