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


C++ blocked_range::end方法代码示例

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


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

示例1: operator

  void operator()(const tbb::blocked_range<int> &range) const {
    fptype price;
    int begin = range.begin();
    int end = range.end();

    for (int i=begin; i!=end; i++) {
      /* Calling main function to calculate option value based on 
       * Black & Scholes's equation.
       */

      price = BlkSchlsEqEuroNoDiv( sptprice[i], strike[i],
                                   rate[i], volatility[i], otime[i], 
                                   otype[i], 0);
      prices[i] = price;

#ifdef ERR_CHK 
      fptype priceDelta = data[i].DGrefval - price;
      if( fabs(priceDelta) >= 1e-5 ){
        fprintf(stderr,"Error on %d. Computed=%.5f, Ref=%.5f, Delta=%.5f\n",
               i, price, data[i].DGrefval, priceDelta);
        numError ++;
      }
#endif
    }
  }
开发者ID:artintal,项目名称:goa2,代码行数:25,代码来源:blackscholes.m4.cpp

示例2: operator

    void operator () (const tbb::blocked_range<int> &range) const {
        for(int i=range.begin(); i<range.end(); i++) {
            list_node *node;
            if (addok(head, i, column)) {
                // add the node

#ifdef QUIT_ON_SOLUTION // QUIT as soon as a solution is found
                if (node!=NULL && solution == NULL) {
#endif
                    list_node new_node;
                    new_node.next = head;
                    new_node.row  = i;
                    if (column+1<SIZE) {
#ifdef CUTOFF
                        if (column+1>=CUTOFF_LEVEL)
                            ser_nqueens_rec(column+1, &new_node);
                        else
                            nqueens_rec(column+1, &new_node);
#else
                        nqueens_rec(column+1, &new_node);
#endif

                    } else { // found a solution 
                        //solution = &new_node;
                        solution_count++; //atomic
                        //abort()
                    }
#ifdef QUIT_ON_SOLUTION // QUIT as soon as a solution is found
                }
#endif
            } // end if addok
        // else do nothing -- dead computation branch
        }
    }
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3: operator

    void operator()( const tbb::blocked_range<int> &r ) const {
        T one = 1;

        for (int i = r.begin(); i < r.end(); ++i) {
            locals.local().push_back( one );
        }
    }
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:7,代码来源:test_combinable.cpp

示例4: do_expression

void colorx_node_t::do_expression( const tbb::blocked_range<int>& range, const Imath::Box2i& area, const render::context_t& context)
{
	std::string color_expr = get_value<std::string>( param( expr_param_name()));
	image_expression_t expr( color_expr, this, color_context);
	RAMEN_ASSERT( expr.isValid());

	expr.setup_variables( this, context);
	image::const_image_view_t src = input_as<image_node_t>()->const_subimage_view( area);
	image::image_view_t dst = subimage_view( area);
	
	SeVec3d& cvar = expr.vec_vars["Cs"].val;
	double& avar = expr.vars["As"].val;
	double *out_avar = expr.get_local_var_ref( "Ao", &avar);

	for( int y = range.begin(); y < range.end(); ++y)
	{
		image::const_image_view_t::x_iterator src_it( src.row_begin( y));
		image::image_view_t::x_iterator dst_it( dst.row_begin( y));

		for( int x = 0, xe = src.width(); x < xe; ++x)
		{
			cvar[0] = boost::gil::get_color( *src_it, boost::gil::red_t());
			cvar[1] = boost::gil::get_color( *src_it, boost::gil::green_t());
			cvar[2] = boost::gil::get_color( *src_it, boost::gil::blue_t());
			avar = boost::gil::get_color( *src_it, boost::gil::alpha_t());

			SeVec3d result = expr.evaluate();
			*dst_it++ = image::pixel_t( result[0], result[1], result[2], *out_avar);
			++src_it;
		}
	}
}
开发者ID:JohanAberg,项目名称:Ramen,代码行数:32,代码来源:colorx_node.cpp

示例5: operator

  void operator()(const tbb::blocked_range<int>& range) const {
    GraphType::SrcSeedList seed_remove_list[2];

    /* compute cuts for each seed using the precomputation graph */
    for (int fg_idx = range.begin(); fg_idx != range.end(); ++fg_idx) {
      // copy the precomputation graph
      GraphType* g_fg_precomp = new GraphType(*g_precomp);
      (*g_fgs_precomp)[fg_idx] = g_fg_precomp;

      // get the fg seeds sans the current seed
      generate_seed_fix_list(seed_remove_list, *fg_nodes, fg_idx);
      // transform all S trees (sans the current seed) to sink
      g_fg_precomp->transform_seed_trees(fg_idx, seed_remove_list);

      g_fg_precomp->check_tree_integrity();

      // generate visualization after the seed tree transformation
      g_fg_precomp->generate_graph_visualization(
          node_rows, ((boost::format("graph1_%d") % (fg_idx + 1)).str()));

      // compute the cut after the precomputation for this seed
      int flow_fg_precomp = run_print_maxflow(g_fg_precomp, *fg_nodes,
                                              node_rows, true);

      // generate visualization after cut computation (and generate final pdf)
      g_fg_precomp->generate_graph_visualization(
          node_rows, ((boost::format("graph2_%d") % (fg_idx + 1)).str()));
      g_fg_precomp->generate_pdf_graphs(
          (boost::format("fg%d_precomp") % (fg_idx + 1)).str());
    }
  }
开发者ID:Cloud-CV,项目名称:object-proposals,代码行数:31,代码来源:test_seedsolve.cpp

示例6: operator

 /** Increments counter once for each iteration in the iteration space. */
 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         //! Every 8th access is a write access
         const bool write = (i%8)==7;
         bool okay = true;
         bool lock_kept = true;
         if( (i/8)&1 ) {
             // Try implicit acquire and explicit release
             typename I::mutex_type::scoped_lock lock(invariant.mutex,write);
             execute_aux(lock, i, write, /*ref*/okay, /*ref*/lock_kept);
             lock.release();
         } else {
             // Try explicit acquire and implicit release
             typename I::mutex_type::scoped_lock lock;
             lock.acquire(invariant.mutex,write);
             execute_aux(lock, i, write, /*ref*/okay, /*ref*/lock_kept);
         }
         if( !okay ) {
             REPORT( "ERROR for %s at %ld: %s %s %s %s\n",invariant.mutex_name, long(i),
                     write     ? "write,"                  : "read,",
                     write     ? (i%16==7?"downgrade,":"") : (i%8==3?"upgrade,":""),
                     lock_kept ? "lock kept,"              : "lock not kept,", // TODO: only if downgrade/upgrade
                     (i/8)&1   ? "impl/expl"               : "expl/impl" );
         }
     }
 }
开发者ID:artog,项目名称:Raytracer,代码行数:27,代码来源:test_mutex.cpp

示例7: operator

	void operator()(const tbb::blocked_range<int>& r) const
	{
		int begin = r.begin(),
			end = r.end();

		double dmax;
		
		//
		// Define precision(epsilon value)
		double e = .001;
		
		do
		{
			dmax = .0;
			for(int i = begin; i != end; ++i){
				for (int j = 1; j < N; ++j){
					temp_matrix[i][j] = 0.25*(tmatrix[i][j - 1] + tmatrix[i][j + 1] + tmatrix[i - 1][j] + tmatrix[i + 1][j]);
					double diff = fabs(temp_matrix[i][j] - tmatrix[i][j]);
					if (dmax < diff)
						dmax = diff;
					
					tmatrix[i][j] = temp_matrix[i][j];
				}
			}
		} while (dmax > e);
	}
开发者ID:VladGribinchuk,项目名称:CPP_IntelCilk,代码行数:26,代码来源:DerichletTask_usingTBB_Algorithm.cpp

示例8: computeCovarianceMatrix

template <typename PointInT, typename PointOutT> void
pcl::TBB_NormalEstimationTBB<PointInT, PointOutT>::operator () (const tbb::blocked_range <size_t> &r) const
{
  float vpx, vpy, vpz;
  feature_->getViewPoint (vpx, vpy, vpz);
  // Iterating over the entire index vector
  for (size_t idx = r.begin (); idx != r.end (); ++idx)
  {
    std::vector<int> nn_indices (feature_->getKSearch ());
    std::vector<float> nn_dists (feature_->getKSearch ());

    feature_->searchForNeighbors ((*feature_->getIndices ())[idx], feature_->getSearchParameter (), nn_indices, nn_dists);

    // 16-bytes aligned placeholder for the XYZ centroid of a surface patch
    Eigen::Vector4f xyz_centroid;
    // Estimate the XYZ centroid
    compute3DCentroid (*feature_->getSearchSurface (), nn_indices, xyz_centroid);

    // Placeholder for the 3x3 covariance matrix at each surface patch
    EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix;
    // Compute the 3x3 covariance matrix
    computeCovarianceMatrix (*feature_->getSearchSurface (), nn_indices, xyz_centroid, covariance_matrix);

    // Get the plane normal and surface curvature
    solvePlaneParameters (covariance_matrix,
                          output_.points[idx].normal[0], output_.points[idx].normal[1], output_.points[idx].normal[2], output_.points[idx].curvature);

    flipNormalTowardsViewpoint<PointInT> (feature_->getSearchSurface ()->points[idx], vpx, vpy, vpz,
                                          output_.points[idx].normal[0], output_.points[idx].normal[1], output_.points[idx].normal[2]);
  }
}
开发者ID:jonaswitt,项目名称:nestk,代码行数:31,代码来源:normal_3d_tbb.hpp

示例9: operator

    void operator () (const tbb::blocked_range<int> &range) const {
        int i; 
        PARTITIONER partitioner;
        for (i=range.begin(); i<range.end(); i++) {
            //printf("Outer Loop Body[%d<=%d<%d]=[0,%d]\n", range.begin(), i, range.end(), degrees[currentLevelSet[i]]);
#ifdef SEQUENTIAL_INNER
            for(int j=0; j<degrees[currentLevelSet[i]]; j++) {
                int oldGatek;
                int freshNode,currentEdge;

                currentEdge = vertices[currentLevelSet[i]]+j;
                // let's handle one edge
#ifdef XBOFILE
                freshNode = edges[currentEdge][1]; // 0 RTM, value was prefetched
#else
                freshNode = edges[currentEdge];    // 0 RTM, value was prefetched
#endif
                oldGatek = -1;
                // test gatekeeper 
                oldGatek = gatekeeper[freshNode].fetch_and_increment();
                if (oldGatek == 0) { // destination vertex unvisited!
                    // increment newLevelIndex atomically
                    int myIndex = newLevelIndex.fetch_and_increment();
                    // store fresh node in new level
                    newLevelSet[myIndex] = freshNode;
 
                    level[freshNode] = currentLevel + 1;
                } // end if freshNode
            }
#else
            tbb::parallel_for (tbb::blocked_range<int>(0,degrees[currentLevelSet[i]],INNER_GRAINSIZE), innerLoopBody(i), partitioner);
#endif
        }
    }
开发者ID:atzannes,项目名称:TBBBenchmarks,代码行数:34,代码来源:bfs.cpp

示例10: operator

MSC_NAMESPACE_BEGIN

void RayBoundingbox::operator()(const tbb::blocked_range< size_t >& r)
{
  size_t begin = r.begin();
  size_t end = r.end();

  m_value.min[0] = m_data[begin].org[0];
  m_value.min[1] = m_data[begin].org[1];
  m_value.min[2] = m_data[begin].org[2];
  m_value.max[0] = m_data[begin].org[0];
  m_value.max[1] = m_data[begin].org[1];
  m_value.max[2] = m_data[begin].org[2];

  for(size_t index = begin; index < end; ++index)
  {
    if(m_data[index].org[0] < m_value.min[0])
      m_value.min[0] = m_data[index].org[0];
    if(m_data[index].org[1] < m_value.min[1])
      m_value.min[1] = m_data[index].org[1];
    if(m_data[index].org[2] < m_value.min[2])
      m_value.min[2] = m_data[index].org[2];

    if(m_data[index].org[0] > m_value.max[0])
      m_value.max[0] = m_data[index].org[0];
    if(m_data[index].org[1] > m_value.max[1])
      m_value.max[1] = m_data[index].org[1];
    if(m_data[index].org[2] > m_value.max[2])
      m_value.max[2] = m_data[index].org[2];
  }
}
开发者ID:francoisgfx,项目名称:msc-project,代码行数:31,代码来源:RayBoundingbox.cpp

示例11: operator

    void operator() (tbb::blocked_range<int> const &r) const {
#define USE_SIMD
#ifdef USE_SIMD
        if (_srcDesc.length==4 and _srcDesc.stride==4 and _dstDesc.stride==4) {

            // SIMD fast path for aligned primvar data (4 floats)
            int offset = _offsets[r.begin()];
            ComputeStencilKernel<4>(_vertexSrc, _vertexDst,
                _sizes, _indices+offset, _weights+offset, r.begin(), r.end());

        } else if (_srcDesc.length==8 and _srcDesc.stride==4 and _dstDesc.stride==4) {

            // SIMD fast path for aligned primvar data (8 floats)
            int offset = _offsets[r.begin()];
            ComputeStencilKernel<8>(_vertexSrc, _vertexDst,
                _sizes, _indices+offset, _weights+offset, r.begin(), r.end());

        } else {
#else
        {
#endif
            int const * sizes = _sizes;
            int const * indices = _indices;
            float const * weights = _weights;

            if (r.begin()>0) {
                sizes += r.begin();
                indices += _offsets[r.begin()];
                weights += _offsets[r.begin()];
            }

            // Slow path for non-aligned data
            float * result = (float*)alloca(_srcDesc.length * sizeof(float));

            for (int i=r.begin(); i<r.end(); ++i, ++sizes) {

                clear(result, _dstDesc);

                for (int j=0; j<*sizes; ++j) {
                    addWithWeight(result, _vertexSrc, *indices++, *weights++, _srcDesc);
                }

                copy(_vertexDst, i, result, _dstDesc);
            }
        }
    }
};
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:47,代码来源:tbbKernel.cpp

示例12: computeWithDerivative

    void computeWithDerivative(tbb::blocked_range<int> const &r) const {
        float wP[20], wDs[20], wDt[20];
        BufferAdapter<const float> srcT(_src + _srcDesc.offset,
                                        _srcDesc.length,
                                        _srcDesc.stride);
        BufferAdapter<float> dstT(_dst + _dstDesc.offset
                                       + r.begin() * _dstDesc.stride,
                                  _dstDesc.length,
                                  _dstDesc.stride);
        BufferAdapter<float> dstDuT(_dstDu + _dstDuDesc.offset
                                       + r.begin() * _dstDuDesc.stride,
                                  _dstDuDesc.length,
                                  _dstDuDesc.stride);
        BufferAdapter<float> dstDvT(_dstDv + _dstDvDesc.offset
                                       + r.begin() * _dstDvDesc.stride,
                                  _dstDvDesc.length,
                                  _dstDvDesc.stride);

        for (int i = r.begin(); i < r.end(); ++i) {
            PatchCoord const &coord = _patchCoords[i];
            PatchArray const &array = _patchArrayBuffer[coord.handle.arrayIndex];

            int patchType = array.GetPatchType();
            Far::PatchParam const & param =
                _patchParamBuffer[coord.handle.patchIndex];

            int numControlVertices = 0;
            if (patchType == Far::PatchDescriptor::REGULAR) {
                Far::internal::GetBSplineWeights(param,
                                                 coord.s, coord.t, wP, wDs, wDt);
                numControlVertices = 16;
            } else if (patchType == Far::PatchDescriptor::GREGORY_BASIS) {
                Far::internal::GetGregoryWeights(param,
                                                 coord.s, coord.t, wP, wDs, wDt);
                numControlVertices = 20;
            } else if (patchType == Far::PatchDescriptor::QUADS) {
                Far::internal::GetBilinearWeights(param,
                                                  coord.s, coord.t, wP, wDs, wDt);
                numControlVertices = 4;
            } else {
                assert(0);
            }

            const int *cvs =
                &_patchIndexBuffer[array.indexBase + coord.handle.vertIndex];

            dstT.Clear();
            dstDuT.Clear();
            dstDvT.Clear();
            for (int j = 0; j < numControlVertices; ++j) {
                dstT.AddWithWeight(srcT[cvs[j]], wP[j]);
                dstDuT.AddWithWeight(srcT[cvs[j]], wDs[j]);
                dstDvT.AddWithWeight(srcT[cvs[j]], wDt[j]);
            }
            ++dstT;
            ++dstDuT;
            ++dstDvT;
        }
    }
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:59,代码来源:tbbKernel.cpp

示例13: operator

	void operator()(const tbb::blocked_range<short>& range) const {
		for (short labelid=range.begin(); labelid!=range.end(); ++labelid) {
			// Compute mask.
			// For big images it might make sense to parallelize this on a
			// smaller granularity (pixel ranges).
			// And it might be a good idea to cache these.
			cv::Mat1b mask(labels == labelid);

			if(tbb::task::self().is_cancelled()) {
				//GGDBGM("aborted through tbb cancel." << endl);
				return;
			}

			// transform mask into icon
			cv::Mat1b masktrf = cv::Mat1b::zeros(iconSizecv);
			cv::warpAffine(mask, masktrf, trafo, iconSizecv, CV_INTER_AREA);

			if(tbb::task::self().is_cancelled()) {
				//GGDBGM("aborted through tbb cancel." << endl);
				return;
			}
			// The rest is probably too fast to allow checking for cancellation.

			QColor color = ctx.colors.at(labelid);

			// Fill icon with solid color in ARGB format.
			cv::Vec4b argb(0, color.red(), color.green(), color.blue());
			cv::Mat4b icon = cv::Mat4b(iconSizecv.height,
									   iconSizecv.width,
									   argb);

			// Now apply alpha channel.
			// Note: this is better than OpenCV's mask functionality as it
			// preserves the antialiasing!

			// Make ARGB 'array' which is interleaved to a true ARGB image
			// using mixChannels.
			const cv::Mat1b zero = cv::Mat1b::zeros(iconSizecv.height,
													iconSizecv.width);
			const cv::Mat in[] = {masktrf, zero, zero, zero};
			// Copy only the alpha channel (0) of the in array into the
			// alpha channel (0) of the ARGB icon.
			const int mix[] = {0,0};
			// 4 input matrices, 1 dest, 1 mix-pair
			cv::mixChannels(in,4, &icon,1, mix,1);
			// convert the result to a QImage
			QImage qimage = Mat2QImage(icon);

			/* draw a border (alternative: the icon view could do this) */
			QPainter p(&qimage);
			QPen pen(color);
			// ensure border visibility, fixed to 1px
			pen.setWidthF(1.f);
			p.setPen(pen);
			p.drawRect(brect);

			ctx.icons[labelid] = qimage;
		}
	}
开发者ID:ajaskier,项目名称:gerbil,代码行数:59,代码来源:icontask.cpp

示例14: operator

 /** Increments counter once for each iteration in the iteration space. */
 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         typename C::mutex_type::ScopedLock lock(counter.mutex, i);
         counter.value = counter.value+1;
         if( D>0 )
             for( int j=0; j<D; ++j ) __TBB_Yield();
     }
 }
开发者ID:adiog,项目名称:tbb,代码行数:9,代码来源:test_concurrent_monitor.cpp

示例15: operator

    void operator()( const tbb::blocked_range<int> &r ) const {
        T one;
        test_helper<T>::set(one, 1);

        for (int i = r.begin(); i < r.end(); ++i) {
            locals.local().push_back( one );
        }
    }
开发者ID:glycerine,项目名称:shore-mt,代码行数:8,代码来源:test_enumerable_thread_specific.cpp


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