diff --git a/src/WPrime.cpp b/src/WPrime.cpp index b8487f0fa..641b2568b 100644 --- a/src/WPrime.cpp +++ b/src/WPrime.cpp @@ -466,61 +466,21 @@ WPrime::PCP() int WPrime::minForCP(int cp) { - QTime time; // for profiling performance of the code - time.start(); - - // input array contains the actual W' expenditure - // and will also contain non-zero values - double tau; - double totalBelowCP=0; - double countBelowCP=0; - QVector inputArray(last+1); - for (int i=0; i cp ? value-cp : 0; - - if (value < cp) { - totalBelowCP += value; - countBelowCP++; - } - } - - if (countBelowCP > 0) - tau = 546.00f * pow(E,-0.01*(CP - (totalBelowCP/countBelowCP))) + 316.00f; - else - tau = 546.00f * pow(E,-0.01*(CP)) + 316.00f; - - tau = int(tau); // round it down - - // STEP 2: ITERATE OVER DATA TO CREATE W' DATA SERIES // lets run forward from 0s to end of ride int min = WPRIME; - QVector myvalues(last+1); + double W = WPRIME; + for (int t=0; t<=last; t++) { - int stop = last / 2; + if(smoothed.value(t) < cp) { + W = W + (cp-smoothed.value(t))*(WPRIME-W)/WPRIME; + } else { + W = W + (cp-smoothed.value(t)); + } - WPrimeIntegrator a(inputArray, 0, stop, tau); - WPrimeIntegrator b(inputArray, stop+1, last, tau); - - a.start(); - b.start(); - - a.wait(); - b.wait(); - - // sum values - for (int t=0; t<=last; t++) - myvalues[t] = a.output[t] + b.output[t]; - - // now subtract WPRIME and work out minimum etc - for(int t=0; t <= last; t++) { - double value = WPRIME - myvalues[t]; - if (value < min) min = value; + if (W < min) min = W; } - //qDebug()<<"compute time="< &source, int begin, int end, double TAU) : - source(source), begin(begin), end(end), TAU(TAU) -{ - output.resize(source.size()); -} - -void -WPrimeIntegrator::run() -{ - // run from start to stop adding decay to end - for (int t=begin; t &source, int begin, int end, double TAU); - - // integrate from start to stop from source into output - // basically sums in the exponential decays, but we break it - // into threads to parallelise the work - void run(); - - QVector &source; - int begin, end; - double TAU; - - // resized to match source holds results - QVector output; -}; #endif