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


C++ data_t::resize方法代码示例

本文整理汇总了C++中data_t::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ data_t::resize方法的具体用法?C++ data_t::resize怎么用?C++ data_t::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data_t的用法示例。


在下文中一共展示了data_t::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

	bool bin_index_t::file_node::first(data_t& key,data_t& val) const
	{
		open_index_file();

		index_t ind;
		if(!first_item(root_page,ind))return false;

		key=ind.key;
		key.resize(key_len);
		val.resize(ind.data_len);
		load_data(ind.data_offset,val);
		return true;
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:13,代码来源:bin_index.cpp

示例2: runtime_error

	void points2bin(const points_t& pts,data_t& bin)
	{
		bin.resize(pts.size()*2);
		for(unsigned i=0;i<pts.size();i++)
		{
			const point& p=pts[i];
			if(p.x<=-128||p.x>127||p.y<=-128||p.y>127)
				throw std::runtime_error("points2bin(): invalid point: ("+
				boost::lexical_cast<std::string>(p.x)+","
				+boost::lexical_cast<std::string>(p.y)+")");

			char x=p.x;
			char y=p.y;

			bin[i*2]=*reinterpret_cast<const unsigned char*>(&x);
			bin[i*2+1]=*reinterpret_cast<const unsigned char*>(&y);
		}
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:18,代码来源:solution_tree_utils.cpp

示例3: prepare_impulse_response

/** This is an autarc function to precalculate the frequency 
 * domain filter partitions that a \b Convolver needs. It does 
 * not require an instantiation of a \b Convolver. However, it is 
 * not very efficient since an FFT plan is created with every call.
 * @param container place to store the partitions.
 * @param filter impulse response of the filter
 * @param filter_size size of the impulse response
 * @param partition_size size of the partitions (this is the 
 * partition size that the outside world sees, internally it is twice as long)
 */
void Convolver::prepare_impulse_response(data_t& container, const float *filter,
		const unsigned int filter_size, const unsigned int partition_size)
{

	// find out how many complete partitions we have
	unsigned int no_of_partitions = filter_size / partition_size;

	// if there is even one more
	if (filter_size % partition_size)
		no_of_partitions++;

	// empty container
	container.clear();

	// allocate memory
	container.resize(2 * no_of_partitions * partition_size, 0.0f);

	// define temporary buffers
	data_t fft_buffer;
	data_t zeros;

	// allocate memory and initialize to 0
	fft_buffer.resize(2 * partition_size, 0.0f);
	zeros.resize(2 * partition_size, 0.0f);

	// create fft plans for halfcomplex data format
	fftwf_plan fft_plan = fftwf_plan_r2r_1d(2 * partition_size, &fft_buffer[0],
			&fft_buffer[0], FFTW_R2HC, FFTW_ESTIMATE);

	// convert filter partitionwise to frequency domain

	/////// process complete partitions //////////////

	for (unsigned int partition = 0u; partition < no_of_partitions - 1;
			partition++)
	{
		std::copy(filter + partition * partition_size,
				filter + (partition + 1) * partition_size, fft_buffer.begin());

		// zero pad
		std::copy(zeros.begin(), zeros.begin() + partition_size,
				fft_buffer.begin() + partition_size);

		// fft
		fftwf_execute(fft_plan);
		sort_coefficients(fft_buffer, 2 * partition_size);

		// add the partition to the filter
		std::copy(fft_buffer.begin(), fft_buffer.begin() + 2 * partition_size,
				container.begin() + 2 * partition * partition_size);

	}

	////// end process complete partitions

	//// process potentially incomplete last partition ////////////

	// zeros
	std::copy(zeros.begin(), zeros.end(), fft_buffer.begin());

	// add filter coefficients
	std::copy(filter + (no_of_partitions - 1) * partition_size,
			filter + filter_size, fft_buffer.begin());

	// fft
	fftwf_execute(fft_plan);
	sort_coefficients(fft_buffer, 2 * partition_size);

	// add the partition to the filter
	std::copy(fft_buffer.begin(), fft_buffer.end(),
			container.begin() + 2 * (no_of_partitions - 1) * partition_size);

	///// end process potentially incomplete partition ////////

	// clean up
	fftwf_destroy_plan(fft_plan);
}
开发者ID:flair2005,项目名称:avrs,代码行数:87,代码来源:convolver.cpp


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