示例#1
0
        void loop_start(float * newSpec) {
            memcpy(this_spectrum, newSpec, sizeof(float) * FREQUENCY_LENGTH);

            current = NO_PEAK;
            for (int i = 0; i < FREQUENCY_LENGTH; ++i) {
                current.update(i, this_spectrum[i]);
            }

            this_attr.sum = sum_over(Range::around(current));
            this_attr.sdev = sdev_over();
            this_attr.sdratio = sdev_except( FULL_RANGE, Range::around(current)) / this_attr.sdev;
        }
/*
 * compute the stress:
 * \f[
 *   \sigma = \sum_{e \in E} \left( d_e - \sum_{s \in S(e)} |s| \right)^2
 * \f]
 */
double computeStress(const Edges& es) {
    return sum_over(es.begin(),es.end(),0.0,ComputeStress());
}