本文整理汇总了C++中TimeSeries::length方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSeries::length方法的具体用法?C++ TimeSeries::length怎么用?C++ TimeSeries::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<int>
Distance::topK(const TimeSeries &ts, int k) {
const TimeSeriesCollection *db = this->collection;
int ts_length = ts.length();
for (int i = 0; i < db->sequences.size(); i++) {
ts_length = std::min(ts_length, (int)db->sequences[i].length());
}
// Get distances
std::vector<std::pair<int, float> > pairs;
for (int i = 0; i < db->sequences.size(); i++) {
float d = this->distance(ts, db->sequences[i], ts_length);
pairs.push_back(std::make_pair(i, d));
}
// Sort by value
std::sort(pairs.begin(), pairs.end(), comp);
// Return the indexes of top K.
std::vector<int> ret;
for (int i = 0; i < k; i++) {
ret.push_back(pairs[i].first);
}
return ret;
}
示例2: calcCost
double
Distance::DTW(const TimeSeries &ts1, const TimeSeries &ts2) {
int len1 = ts1.length();
int len2 = ts2.length();
double *table_d = new double[len1 * len2];
double *table_g = new double[len1 * len2];
calcCost(ts1, ts2, table_d, table_g, len1, len2);
calcGamma(table_d, table_g, len1, len2);
double dist = calcSum(table_d, table_g, len1, len2);
delete[] table_d;
delete[] table_g;
return dist;
}