Mercurial > hg > nnls-chroma
diff NNLSChroma.cpp @ 29:da3195577172 matthiasm-plugin
* Revert to the previous version of nnls.c[c], which used single-precision floats (better for us).
But we don't like the static local variables -- change those for thread-safety.
author | Chris Cannam |
---|---|
date | Thu, 21 Oct 2010 20:50:22 +0100 |
parents | 690bd9148467 |
children | cf8898a0174c |
line wrap: on
line diff
--- a/NNLSChroma.cpp Thu Oct 21 20:19:29 2010 +0100 +++ b/NNLSChroma.cpp Thu Oct 21 20:50:22 2010 +0100 @@ -827,7 +827,7 @@ f6.hasTimestamp = true; f6.timestamp = f2.timestamp; - double b[256]; + float b[256]; bool some_b_greater_zero = false; float sumb = 0; @@ -861,7 +861,7 @@ } } else { - double x[84+1000]; + float x[84+1000]; for (int i = 1; i < 1084; ++i) x[i] = 1.0; vector<int> signifIndex; int index=0; @@ -875,22 +875,20 @@ f3.values.push_back(0); // fill the values, change later index++; } - double rnorm; - double w[84+1000]; - double zz[84+1000]; + float rnorm; + float w[84+1000]; + float zz[84+1000]; int indx[84+1000]; int mode; int dictsize = 256*signifIndex.size(); // cerr << "dictsize is " << dictsize << "and values size" << f3.values.size()<< endl; - double *curr_dict = new double[dictsize]; + float *curr_dict = new float[dictsize]; for (unsigned iNote = 0; iNote < signifIndex.size(); ++iNote) { for (unsigned iBin = 0; iBin < 256; iBin++) { curr_dict[iNote * 256 + iBin] = 1.0 * m_dict[signifIndex[iNote] * 256 + iBin]; } } - int sz = signifIndex.size(); - int nn = nNote; - NNLS(curr_dict, &nn, &nn, &sz, b, x, &rnorm, w, zz, indx, &mode); + nnls(curr_dict, nNote, nNote, signifIndex.size(), b, x, &rnorm, w, zz, indx, &mode); delete [] curr_dict; for (unsigned iNote = 0; iNote < signifIndex.size(); ++iNote) { f3.values[signifIndex[iNote]] = x[iNote];