[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461
andrei zavada
johnhommer at gmail.com
Fri Nov 16 00:50:36 UTC 2012
The following commit has been merged in the master branch:
commit 0a7b7b8025aa271cbf799a0885937321149ee05e
Author: andrei zavada <johnhommer at gmail.com>
Date: Sun Oct 28 01:13:52 2012 +0300
don't cache course in CRecording to ensure filters dirtiness is noticed
diff --git a/src/expdesign/recording.cc b/src/expdesign/recording.cc
index 1bf0d29..07c5c47 100644
--- a/src/expdesign/recording.cc
+++ b/src/expdesign/recording.cc
@@ -28,10 +28,7 @@ CRecording (sigfile::CSource& F, int sig_no,
fft_params.pagesize),
uc_params {NAN, NAN, NAN, NAN},
_status (0), // not computed
- _source (F), _sig_no (sig_no),
- _cached_metric (sigfile::TMetricType::invalid),
- _cached_freq_from (NAN),
- _cached_freq_upto (NAN)
+ _source (F), _sig_no (sig_no)
{
// if ( F.signal_type(sig_no) == sigfile::SChannel::TType::eeg ) {
// CBinnedPower::compute();
diff --git a/src/expdesign/recording.hh b/src/expdesign/recording.hh
index a75a728..c9b5d3a 100644
--- a/src/expdesign/recording.hh
+++ b/src/expdesign/recording.hh
@@ -93,13 +93,8 @@ class CRecording
return _source.recording_time() * _source.samplerate(_sig_no);
}
- // cut through, and cache it please
template <typename T>
- const valarray<T>
- course( sigfile::TMetricType metric, double freq_from, double freq_upto);
-
- template <typename T>
- const valarray<T>
+ valarray<T>
course( sigfile::TMetricType metric, double freq_from, double freq_upto) const;
bool have_uc_determined() const
@@ -116,12 +111,6 @@ class CRecording
sigfile::CSource&
_source;
int _sig_no;
-
- private:
- sigfile::TMetricType
- _cached_metric;
- double _cached_freq_from,
- _cached_freq_upto;
};
@@ -251,52 +240,23 @@ class CSCourse
template <typename T>
-const valarray<T>
-CRecording::
-course( sigfile::TMetricType metric, double freq_from, double freq_upto)
- {
- static valarray<T>
- _cached_course;
- if ( metric == _cached_metric &&
- freq_from == _cached_freq_from &&
- freq_upto == _cached_freq_upto &&
- _cached_course.size() == 0 )
- return _cached_course;
- else {
- _cached_metric = metric;
- _cached_freq_from = freq_from;
- _cached_freq_upto = freq_upto;
- switch ( _cached_metric ) {
- case sigfile::TMetricType::Psd:
- return _cached_course =
- CBinnedPower::course<T>( freq_from, freq_upto);
- case sigfile::TMetricType::Mc:
- return _cached_course =
- CBinnedMC::course<T>(
- min( (size_t)((freq_from) / bandwidth),
- CBinnedMC::bins()-1));
- default:
- return _cached_course;
- }
- }
- }
-
-template <typename T>
-const valarray<T>
+valarray<T>
CRecording::
course( sigfile::TMetricType metric, double freq_from, double freq_upto) const
- {
- switch ( metric ) {
- case sigfile::TMetricType::Psd:
- return CBinnedPower::course<T>( freq_from, freq_upto);
- case sigfile::TMetricType::Mc:
- return CBinnedMC::course<T>(
- min( (size_t)((freq_from) / bandwidth),
- CBinnedMC::bins()-1));
- default:
- return valarray<T> (0);
- }
+{
+ switch ( metric ) {
+ case sigfile::TMetricType::Psd:
+ return (((CBinnedPower*)this)->compute(),
+ CBinnedPower::course<T>( freq_from, freq_upto));
+ case sigfile::TMetricType::Mc:
+ return (((CBinnedMC*)this)->compute(),
+ CBinnedMC::course<T>(
+ min( (size_t)((freq_from) / bandwidth),
+ CBinnedMC::bins()-1)));
+ default:
+ throw invalid_argument ("CRecording::course: bad metric");
}
+}
inline const char* CSCourse::subject() const { return _mm_list.front()->subject(); }
--
Sleep experiment manager
More information about the debian-med-commit
mailing list