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


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

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


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

示例1: if

void
diy::detail::KDTreeSamplingPartition<Block,Point>::
operator()(Block* b, const diy::ReduceProxy& srp, const KDTreePartners& partners) const
{
    int dim;
    if (srp.round() < partners.rounds())
        dim = partners.dim(srp.round());
    else
        dim = partners.dim(srp.round() - 1);

    if (srp.round() == partners.rounds())
        update_links(b, srp, dim, partners.sub_round(srp.round() - 2), partners.swap_rounds(), partners.wrap, partners.domain); // -1 would be the "uninformative" link round
    else if (partners.swap_round(srp.round()) && partners.sub_round(srp.round()) < 0)       // link round
    {
        dequeue_exchange(b, srp, dim);         // from the swap round
        split_to_neighbors(b, srp, dim);
    }
    else if (partners.swap_round(srp.round()))
    {
        Samples samples;
        receive_samples(b, srp, samples);
        enqueue_exchange(b, srp, dim, samples);
    } else if (partners.sub_round(srp.round()) == 0)
    {
        if (srp.round() > 0)
        {
            int prev_dim = dim - 1;
            if (prev_dim < 0)
                prev_dim += dim_;
            update_links(b, srp, prev_dim, partners.sub_round(srp.round() - 2), partners.swap_rounds(), partners.wrap, partners.domain);    // -1 would be the "uninformative" link round
        }

        compute_local_samples(b, srp, dim);
    } else if (partners.sub_round(srp.round()) < (int) partners.histogram.rounds()/2)     // we are reusing partners class, so really we are talking about the samples rounds here
    {
        Samples samples;
        add_samples(b, srp, samples);
        srp.enqueue(srp.out_link().target(0), samples);
    } else
    {
        Samples samples;
        add_samples(b, srp, samples);
        if (samples.size() != 1)
        {
            // pick the median
            std::nth_element(samples.begin(), samples.begin() + samples.size()/2, samples.end());
            std::swap(samples[0], samples[samples.size()/2]);
            //std::sort(samples.begin(), samples.end());
            //samples[0] = (samples[samples.size()/2] + samples[samples.size()/2 + 1])/2;
            samples.resize(1);
        }
        forward_samples(b, srp, samples);
    }
}
开发者ID:sujin-philip,项目名称:diy2,代码行数:54,代码来源:kdtree-sampling.hpp

示例2: filter

	void filter(const marker::Set& refMarkers) {
		if (markers == NULL) {
			throw invalid_argument("Markers in sample set are missing.");
		}
		
		// flag markers for removal
		markers->filter(refMarkers);
		
		if (samples.size() > 0) {
		
			// Create copy of samples with only unflagged markers
			
			// Shallow copy current samples (copy pointers)
			Samples oldSamples = samples;
			
			// clear current data
			samples.clear();
			byNames.clear();
			
			// pre-allocate space
			samples.resize(oldSamples.size());
			for (size_t sampleIndex = 0; sampleIndex < oldSamples.size(); ++sampleIndex) {
				// iterate through chromosomes
				for (size_t chromIndex = 0; chromIndex < oldSamples[0]->size(); ++chromIndex) {
					// resize chromosome to be as big as chromosome from old sample
					samples[sampleIndex]->resizeChromosome(chromIndex, (*oldSamples[sampleIndex])[chromIndex].size());
				}
			}
			
			// copy data from unflagged markers
			const size_t chromEnd = markers->size();
			vector<size_t> validMarkersCounts(chromEnd);
			for (size_t chromIndex = 0; chromIndex < chromEnd; ++chromIndex) {
				const size_t numMarkers = (*markers)[chromIndex].size();
				validMarkersCounts[chromIndex] = 0;
				for (size_t markerIndex = 0; markerIndex < numMarkers; ++markerIndex) {
					// only copy unflagged markers
					if (!(*markers)[chromIndex][markerIndex]->flag) {
						// copy marker values from oldSamples
						const size_t numSamples = oldSamples.size();
						for (size_t sampleIndex = 0; sampleIndex < numSamples; ++sampleIndex) {
							(*samples[sampleIndex])[chromIndex][validMarkersCounts[chromIndex]] = (*oldSamples[sampleIndex])[chromIndex][markerIndex];
						}
						++validMarkersCounts[chromIndex];
					}
				}
			}
			
			// shrink new sample chromosomes to match new size
			SamplesIterator it, end = samples.end();
			for (it = samples.begin(); it != end; ++it) {
				for (size_t chromIndex = 0; chromIndex < chromEnd; ++chromIndex) {
					(**it).resizeChromosome(chromIndex, validMarkersCounts[chromIndex]);
				}
			}
			
			// clear old samples
			end = oldSamples.end();
			for (it = oldSamples.begin(); it != end; ++it) {
				delete (*it);
			}
			
		}
		
		// remove flagged markers
		markers->clean();
		
	}
开发者ID:djhshih,项目名称:genomic,代码行数:68,代码来源:RawSampleSet.hpp


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