Improving finite IR class (SetDirac) and re-implementing a little improved...

Improving finite IR class (SetDirac) and re-implementing a little improved StringToDoubleVec parser, which is still far from solid
parent 0fbfa942
...@@ -78,6 +78,9 @@ namespace ITABase ...@@ -78,6 +78,9 @@ namespace ITABase
*/ */
void Init( const int iLength, const float fSampleRate, const bool bZeroInit = true ); void Init( const int iLength, const float fSampleRate, const bool bZeroInit = true );
//! Set a dirac pulse / delta function (first sample 1, rest 0)
void SetDirac();
private: private:
//! Disable this Init method from sample buffer //! Disable this Init method from sample buffer
......
...@@ -52,6 +52,7 @@ public: ...@@ -52,6 +52,7 @@ public:
bool StringToFloatVec( const std::string& s, std::vector<float>& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); bool StringToFloatVec( const std::string& s, std::vector<float>& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true );
bool StringToDoubleVec( const std::string& s, std::vector<double>& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); bool StringToDoubleVec( const std::string& s, std::vector<double>& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true );
bool StringToStringVec( const std::string& s, std::vector< std::string >& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); bool StringToStringVec( const std::string& s, std::vector< std::string >& v, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true );
void StringToDoubleVecNoRegex( const std::string& s, std::vector< double >& v );
private: private:
int m_iOpts; int m_iOpts;
...@@ -180,7 +181,7 @@ ITA_BASE_API std::vector<unsigned int> StringToUIntVec( const std::string& s, st ...@@ -180,7 +181,7 @@ ITA_BASE_API std::vector<unsigned int> StringToUIntVec( const std::string& s, st
ITA_BASE_API std::vector<float> StringToFloatVec( const std::string& s, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); ITA_BASE_API std::vector<float> StringToFloatVec( const std::string& s, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true );
//! std::string nach double-Liste parsen (Parse-Fehler werden in ITAExceptions umgesetzt) //! std::string nach double-Liste parsen (Parse-Fehler werden in ITAExceptions umgesetzt)
ITA_BASE_API std::vector<double> StringToDoubleVec( const std::string& s, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); ITA_BASE_API std::vector<double> StringToDoubleVec( const std::string& s );
//! std::string nach String-Liste parsen (Parse-Fehler werden in ITAExceptions umgesetzt) //! std::string nach String-Liste parsen (Parse-Fehler werden in ITAExceptions umgesetzt)
ITA_BASE_API std::vector< std::string > StringToStringVec( const std::string& s, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true ); ITA_BASE_API std::vector< std::string > StringToStringVec( const std::string& s, std::string sSeparatorRegex = "\\s*,\\s*", bool bMatchCase = true );
......
...@@ -40,3 +40,8 @@ float CFiniteImpulseResponse::GetNyquistFrequency() const ...@@ -40,3 +40,8 @@ float CFiniteImpulseResponse::GetNyquistFrequency() const
{ {
return GetSampleRate() / 2.0f; return GetSampleRate() / 2.0f;
} }
void ITABase::CFiniteImpulseResponse::SetDirac()
{
Identity();
}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include <iomanip> #include <iomanip>
#include <numeric> #include <numeric>
#include <sstream> #include <sstream>
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <ITAConstants.h> #include <ITAConstants.h>
#include <ITAException.h> #include <ITAException.h>
...@@ -57,7 +61,7 @@ std::string nTimes( std::string s, unsigned int n ) ...@@ -57,7 +61,7 @@ std::string nTimes( std::string s, unsigned int n )
return result; return result;
} }
std::string BoolToString( bool bValue ) std::string BoolToString( bool bValue )
{ {
std::stringstream ssStream; std::stringstream ssStream;
ssStream << bValue; ssStream << bValue;
...@@ -224,7 +228,7 @@ std::string ComplexFloatArrayToString( const float* pfValues, size_t count, int ...@@ -224,7 +228,7 @@ std::string ComplexFloatArrayToString( const float* pfValues, size_t count, int
std::string s; std::string s;
if( count > 0 ) { if( count > 0 ) {
for( size_t i = 0; i < count; i++ ) { for( size_t i = 0; i < count; i++ ) {
if( i>0 ) s += sSeparator; if( i > 0 ) s += sSeparator;
s += FloatToString( pfValues[ 2 * i ], iPrecision ); s += FloatToString( pfValues[ 2 * i ], iPrecision );
if( pfValues[ 2 * i + 1 ] < 0 ) if( pfValues[ 2 * i + 1 ] < 0 )
s += FloatToString( pfValues[ 2 * i + 1 ], iPrecision ) + "i"; s += FloatToString( pfValues[ 2 * i + 1 ], iPrecision ) + "i";
...@@ -346,9 +350,10 @@ std::vector<float> StringToFloatVec( const std::string& s, std::string sSeparato ...@@ -346,9 +350,10 @@ std::vector<float> StringToFloatVec( const std::string& s, std::string sSeparato
return v; return v;
} }
std::vector<double> StringToDoubleVec( const std::string& s, std::string sSeparatorRegex, bool bMatchCase ) { std::vector<double> StringToDoubleVec( const std::string& s )
std::vector<double> v; {
g_oDefaultConversion.StringToDoubleVec( s, v, sSeparatorRegex, bMatchCase ); std::vector< double > v;
g_oDefaultConversion.StringToDoubleVecNoRegex( s, v );
return v; return v;
} }
...@@ -662,7 +667,26 @@ bool ITAConversion::StringToFloatVec( const std::string& s, std::vector<float>& ...@@ -662,7 +667,26 @@ bool ITAConversion::StringToFloatVec( const std::string& s, std::vector<float>&
return true; return true;
} }
bool ITAConversion::StringToDoubleVec( const std::string& s, std::vector<double>& v, std::string sSeparatorRegex, bool bMatchCase ) { template <class Container>
void split1( const std::string& str, Container& cont )
{
}
void ITAConversion::StringToDoubleVecNoRegex( const std::string& s, std::vector< double >& v )
{
v.clear();
std::string sDouble;
double dVal;
std::stringstream ss( s );
while( std::getline( ss, sDouble, ',' ) )
if( StringToDouble( sDouble, dVal ) )
v.push_back( dVal );
}
bool ITAConversion::StringToDoubleVec( const std::string& s, std::vector<double>& v, std::string sSeparatorRegex, bool bMatchCase )
{
// [fwe 2008-07-09] TODO: Diese Implementierung ist mal eben gebaut und hemdsärmelig! Verbessern! // [fwe 2008-07-09] TODO: Diese Implementierung ist mal eben gebaut und hemdsärmelig! Verbessern!
pcrecpp::RE_Options re_opts; pcrecpp::RE_Options re_opts;
re_opts.set_multiline( true ); re_opts.set_multiline( true );
...@@ -831,7 +855,7 @@ std::string timeToString( const double dSeconds ) ...@@ -831,7 +855,7 @@ std::string timeToString( const double dSeconds )
} }
*/ */
sprintf(buf, "%i min %0.1f s ", (int) dSeconds, fmodf((float) dSeconds, 60.0f)); sprintf( buf, "%i min %0.1f s ", ( int ) dSeconds, fmodf( ( float ) dSeconds, 60.0f ) );
return std::string( buf ); return std::string( buf );
#endif // WIN32 #endif // WIN32
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment