src/UCRDTW_kNN_serial.cpp
/// LB_Keogh 2: Create Envelop for the data
/// Note that the envelops have been created (in main function) when each data point has been read.
///
/// Variable Explanation,
/// tz: Z-normalized data
/// qo: sorted query
/// cb: (output) current bound at each position. Used later for early abandoning in DTW.
/// l,u: lower and upper envelop of the current data
LB_Keogh 2: Create Envelop for the data
Note that the envelops have been created (in main function) when each data point has been read.

Variable Explanation,
tz: Z-normalized data
qo: sorted query
cb: (output) current bound at each position. Used later for early abandoning in DTW.
l,u: lower and upper envelop of the current data
LB_Keogh 2 : Create Envelop for the data Note that the envelops have been created ( in main function ) when each data point has been read . Variable Explanation tz : Z - normalized data qo : sorted query cb : ( output ) current bound at each position . Used later for early abandoning in DTW . l u : lower and upper envelop of the current data
double lb_keogh_data_cumulative(int * order, double * tz, double * qo, double * cb, double * l, double * u, int len,
        double mean, double std, double best_so_far = INF)
{
    double lb = 0;
    double uu,ll,d;
    for (int i = 0; i < len && lb < best_so_far; i++)
    {
        uu = (u[order[i]] - mean) / std;
        ll = (l[order[i]] - mean) / std;
        d = 0;
        if (qo[i] > uu)
            d = dist(qo[i], uu);
        else
        {   if(qo[i] < ll)
                d = dist(qo[i], ll);
        }
        lb += d;
        cb[order[i]] = d;
    }
    return lb;
}
double lb_keogh_data_cumulative ( int * order , double * tz , double * qo , double * cb , double * l , double * u , int len , double mean , double std , double best_so_far = INF ) { double lb = 0 ; double uu , ll , d ; for ( int i = 0 ; i < len && lb < best_so_far ; i ++ ) { uu = ( u [ order [ i ] ] - mean ) / std ; ll = ( l [ order [ i ] ] - mean ) / std ; d = 0 ; if ( qo [ i ] > uu ) d = dist ( qo [ i ] , uu ) ; else { if ( qo [ i ] < ll ) d = dist ( qo [ i ] , ll ) ; } lb += d ; cb [ order [ i ] ] = d ; } return lb ; }
LB_Keogh 2: Create Envelop for the data
Note that the envelops have been created (in main function) when each data point has been read.
LB_Keogh 2 : Create Envelop for the data Note that the envelops have been created ( in main function ) when each data point has been read .