diff --git a/src/WPrime.cpp b/src/WPrime.cpp index be515b407..ec5c71fa0 100644 --- a/src/WPrime.cpp +++ b/src/WPrime.cpp @@ -159,40 +159,31 @@ WPrime::setRide(RideFile *input) TAU = int(TAU); // round it down - //qDebug()<<"data preparation took"< myvalues(last+1); + + int stop = last / 2; + + 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++) { - - // for each value in the input array apply the decay - // and integrate across the target output, but lets - // bound it; - // input is 0 then don't bother adding lots of zeroes - // only integrate WprimeDecayPeriod into the future, as per the spreadsheet - // stop integrating when it has decayed to less than 0.1 watts (exponential sum) - xvalues[t] = double(t)/60.00f; - - if (inputArray[t] <= 0) continue; - - for (int i=0; i myvalues(last+1); - for (int t=0; t<=last; t++) { + int stop = last / 2; - // for each value in the input array apply the decay - // and integrate across the target output, but lets - // bound it; - // input is 0 then don't bother adding lots of zeroes - // only integrate WprimeDecayPeriod into the future, as per the spreadsheet - // stop integrating when it has decayed to less than 0.1 watts (exponential sum) - if (inputArray[t] <= 0) continue; + WPrimeIntegrator a(inputArray, 0, stop, tau); + WPrimeIntegrator b(inputArray, stop+1, last, tau); - for (int i=0; i +#include #include // smoothing #include @@ -76,4 +77,21 @@ class WPrime { int last; }; +class WPrimeIntegrator : public QThread +{ + public: + WPrimeIntegrator(QVector &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