Mercurial > hg > qm-dsp
changeset 268:9aedf5ea8c35
* remove exceptions from Polyfit, return bool instead of int from isModeMinor
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 07 Feb 2008 10:01:38 +0000 |
parents | d7b81af99b5e |
children | a63c7b6191b5 |
files | dsp/keydetection/GetKeyMode.cpp dsp/keydetection/GetKeyMode.h maths/Polyfit.h qm-dsp.pro |
diffstat | 4 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/keydetection/GetKeyMode.cpp Fri Feb 01 16:46:36 2008 +0000 +++ b/dsp/keydetection/GetKeyMode.cpp Thu Feb 07 10:01:38 2008 +0000 @@ -290,7 +290,7 @@ } -int GetKeyMode::isModeMinor( int key ) +bool GetKeyMode::isModeMinor( int key ) { return (key > 12); }
--- a/dsp/keydetection/GetKeyMode.h Fri Feb 01 16:46:36 2008 +0000 +++ b/dsp/keydetection/GetKeyMode.h Thu Feb 07 10:01:38 2008 +0000 @@ -44,7 +44,7 @@ double *getKeyStrengths() { return m_keyStrengths; } - int isModeMinor( int key ); + bool isModeMinor( int key ); protected:
--- a/maths/Polyfit.h Fri Feb 01 16:46:36 2008 +0000 +++ b/maths/Polyfit.h Thu Feb 07 10:01:38 2008 +0000 @@ -40,10 +40,10 @@ // Modified by CLandone for VC6 Aug 2004 /////////////////////////////////////////////////////////////////////////////// +#include <iostream> using std::vector; - class TPolyFit { typedef vector<vector<double> > Matrix; @@ -116,12 +116,18 @@ zeroise(g, nterms); zeroise(a, nterms, nterms); zeroise(xmatr, npoints, nterms); - if(nterms < 1) - throw "PolyFit called with less than one term"; - if(npoints < 2) - throw "PolyFit called with less than two points"; - if(npoints != y.size()) - throw "PolyFit called with x and y of unequal size"; + if (nterms < 1) { + std::cerr << "ERROR: PolyFit called with less than one term" << std::endl; + return 0; + } + if(npoints < 2) { + std::cerr << "ERROR: PolyFit called with less than two points" << std::endl; + return 0; + } + if(npoints != y.size()) { + std::cerr << "ERROR: PolyFit called with x and y of unequal size" << std::endl; + return 0; + } for(i = 0; i < npoints; ++i) { // { setup x matrix } @@ -247,7 +253,8 @@ { if(index [k][2] != 0) { - throw "Error in GaussJordan: matrix is singular"; + std::cerr << "ERROR: Error in PolyFit::GaussJordan: matrix is singular" << std::endl; + return false; } } @@ -290,8 +297,10 @@ { for(int k = 0; k < ncol; ++k) { - if(index[k][2] > 0) - throw "Error in GaussJordan2: matrix is singular"; + if(index[k][2] > 0) { + std::cerr << "ERROR: Error in PolyFit::GaussJordan2: matrix is singular" << std::endl; + return false; + } if(index[k][2] < 0 && fabs(b[j][k]) > big) {
--- a/qm-dsp.pro Fri Feb 01 16:46:36 2008 +0000 +++ b/qm-dsp.pro Thu Feb 07 10:01:38 2008 +0000 @@ -4,7 +4,7 @@ OBJECTS_DIR = tmp_obj MOC_DIR = tmp_moc -linux-g++:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG -O3 -march=pentium3 -mfpmath=sse -msse -ffast-math +linux-g++:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG -O3 -fno-exceptions -fPIC -march=pentium3 -mfpmath=sse -msse -ffast-math #DEPENDPATH += base \ # dsp/chromagram \