本文整理汇总了C++中TimeSeries::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSeries::reserve方法的具体用法?C++ TimeSeries::reserve怎么用?C++ TimeSeries::reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindMotifSub
void BFFindMotif::FindMotifSub(std::deque<Point> &window)
{
size_t i = 0;
for(i = 0; i < window.size() - m_MotifLength; ++i)
{
double distance = 0.0;
bool newMotif = true;
TimeSeries ts;
ts.reserve(m_MotifLength);
if(m_SlideWindow.size() >= m_MotifLength) // Only process slide window larger than motif length
{
// Get time series
for(size_t j = i; j < i + m_MotifLength; ++j)
{
ts.push_back(window[j].second);
}
// Compare with candidate motif
for(size_t j = 0; j < m_CandidateMotif.size(); ++j)
{
distance = EuclideanDistance(m_CandidateMotif[j].second, ts);
if((2 * m_Radius > distance) && (m_Radius < distance)) // Neither new motif nor similar motif
{
newMotif = false;
}
else if(m_Radius > distance) // Similar motif
{
m_CandidateMotif[j].first++;
i += m_Step;
newMotif = false;
break; // Impossible to be similar with other candidates
}
}
if(true == newMotif) // New motif
{
m_CandidateMotif.push_back(make_pair<long long, TimeSeries>(1, ts));
i += m_Step;
}
}
else
{
cerr << "Window size:" << m_SlideWindow.size() << endl;
}
}
for(size_t k = 0; k < i; ++k)
{
window.pop_front();
}
}
示例2: if
void SIMMA:: FindMotifSub(long &bufferCount)
{
long lLastSize = m_K; // last size of candidate motif buffer
long step = 32;
size_t i = 0;
for(i = 0; i < m_SlideWindow.size() - m_MotifLength; ++i)
{
double distance = 0.0;
bool newMotif = true;
TimeSeries ts;
ts.reserve(m_MotifLength);
++bufferCount;
// Check buffer when size big enough
if(true == m_bBufferCheck)
{
if((2 * m_K < bufferCount) && (5 * m_K < (int)m_CandidateMotif.size()))
{
this->BufferCheck();
lLastSize = m_SlideWindow.size();
bufferCount = 0;
}
}
if(m_SlideWindow.size() >= m_MotifLength) // Only process slide window larger than motif length
{
// Get time series
for(size_t j = i; j < i + m_MotifLength; ++j)
{
ts.push_back(m_SlideWindow[j].second);
}
// Compare with candidate motif
for(size_t j = 0; j < m_CandidateMotif.size(); ++j)
{
distance = EuclideanDistance(m_CandidateMotif[j].second, ts);
if((2 * m_Radius > distance) && (m_Radius < distance)) // Neither new motif nor similar motif
{
newMotif = false;
}
else if(m_Radius > distance) // Similar motif
{
m_CandidateMotif[j].first++;
long jump = this->NonTrivialStep(i);
if(0 != jump)
i += jump;
else
i = m_SlideWindow.size() - m_MotifLength;
newMotif = false;
break; // Impossible to be similar with other candidates
}
}
// Check whether current time series is new motif
if(true == newMotif)
{
m_CandidateMotif.push_back(make_pair<long long, TimeSeries>(1, ts));
long jump = this->NonTrivialStep(i);
if(0 != jump)
i += jump;
else
i = m_SlideWindow.size() - m_MotifLength;
}
}
}
// Remove used elements
for(size_t k = 0; k < i; ++k)
{
m_SlideWindow.pop_front();
}
}