当前位置: 首页>>代码示例>>C++>>正文


C++ TimeSeries::reserve方法代码示例

本文整理汇总了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();
	}
	
}
开发者ID:markatango,项目名称:otsm,代码行数:55,代码来源:motif.cpp

示例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();
	}
}
开发者ID:markatango,项目名称:otsm,代码行数:78,代码来源:motif.cpp


注:本文中的TimeSeries::reserve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。