コード例 #1
0
ファイル: test_Fftw.cpp プロジェクト: skaslev/EncinoWaves
  void operator()(tbb::blocked_range2d<int> i_range) const {
    ewav::Rand48_Engine r48;
    std::normal_distribution<float> gdist{0.0f, 1.0f};

    const float maxKmag = float(N / 2) * M_TAU / Domain;

    const float dk = float(1) * M_TAU / Domain;

    for (int j = i_range.rows().begin(); j != i_range.rows().end(); ++j) {
      // kj is the wave number in the j direction.
      int realJ = j <= (N / 2) ? j : j - N;
      float kj  = float(realJ) * M_TAU / Domain;

      for (int i = i_range.cols().begin(); i != i_range.cols().end(); ++i) {
        // ki is the wave number in the i direction
        float ki = float(i) * M_TAU / Domain;

        // Magnitude of the wave vector.
        float kMag = std::hypot(ki, kj);

        // Index into the array.
        std::size_t index = (std::size_t(j) * StrideJ) + i;

        // If the wavenumber is zero, or we're in the outer ring,
        // set it to zero.
        if ((i == 0 && realJ == 0) || (kMag > maxKmag)) {
          Spectral[index] = Cf(0.0, 0.0);
        } else {
          r48.seed(ewav::SeedFromWavenumber(Imath::V2f(ki, kj), Seed));
          Spectral[index] = dk * dk * Cf(gdist(r48), gdist(r48));
        }
      }
    }
  }
コード例 #2
0
ファイル: void_grid_eval.cpp プロジェクト: ManyClaw/ManyClaw
  void operator()(const tbb::blocked_range2d<unsigned>& r) const
  {
    unsigned col, row;
    const int num_ghost = rp_grid_params.num_ghost;
    const int num_eqn = rp_grid_params.num_eqn;
    const int num_aux = rp_grid_params.num_aux;
    const int num_wave = rp_grid_params.num_wave;

    FieldIndexer fi(nx, ny, num_ghost, num_eqn);
    FieldIndexer fi_aux(nx, ny, num_ghost, num_aux);
    EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);

    for(row = r.rows().begin(); row != r.rows().end(); ++row){
      for(col = r.cols().begin(); col != std::min(r.cols().end(), efi.num_col_edge_normal() + 1); ++col) {
        rp(q + fi.idx(row, col-1), q + fi.idx(row, col),
           aux + fi_aux.idx(row, col-1), aux + fi_aux.idx(row, col), aux_global, 0,
           amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
           wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));

        rp(q + fi.idx(row-1, col), q + fi.idx(row, col),
           aux + fi_aux.idx(row-1, col), aux + fi_aux.idx(row, col), aux_global, 1,
           amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
           wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
      }
    }
  }
コード例 #3
0
ファイル: block_image.hpp プロジェクト: tosh914/tcpp2
		void operator()( const tbb::blocked_range2d<int>& range ) const {
			for( int block_row = range.rows().begin(); block_row != range.rows().end(); ++block_row ) {
				for( int block_col = range.cols().begin(); block_col != range.cols().end(); ++block_col ) {
					typename std::map<std::pair<int, int>, cv::Rect_<int> >::const_iterator block_itr
						= block_image_.block_rects_.find( std::pair<int, int>(block_row, block_col));
					const cv::Rect_<int>& block_rect = block_itr->second;
					DrawBlock( block_rect, block_image_.mean_array_.coeff( block_row, block_col ) );
				}
			}
		}
コード例 #4
0
ファイル: block_image.hpp プロジェクト: tosh914/tcpp2
		/**
		 * @brief operator() for tbb::parallel_for()
		 * @param[in] range tbb::blocked_range2d<int>
		 */
		void operator()( const tbb::blocked_range2d<int>& range ) const {
			for( int block_row = range.rows().begin(); block_row != range.rows().end(); ++block_row ) {
				for( int block_col = range.cols().begin(); block_col != range.cols().end(); ++block_col ) {
					cv::Rect_<int> block_rect;
					GetBlockROI( block_row, block_col, block_rect );
					block_image_.mean_array_.coeffRef( block_row, block_col ) = GetMeanBrightness( block_rect );
					block_image_.block_rects_[std::pair<int, int>( block_row, block_col )] = block_rect;
				}
			}
		}
コード例 #5
0
	// overload () so it starts updating the cell states
	void operator()(const tbb::blocked_range2d<size_t>& r) const
	{
		/**
		@Desc : Overloaded parenthesis () operator
		@param1 : TBB 2D blocked range
		*/

		// Update each cell that the current thread manages
		for (size_t i = r.cols().begin(); i != r.cols().end(); ++i)
		{
			for (size_t j = r.rows().begin(); j != r.rows().end(); ++j)
				UpdateState(i, j, g_quad[i][j]);
		}
	}
コード例 #6
0
 void operator () (const tbb::blocked_range2d<int> &range) const {
     int i,j;
     for(i=range.rows().begin(); i<range.rows().end(); i++) {
         for(j=range.cols().begin(); j<range.cols().end(); j++) {
             // TODO replace this by a reducer
             int k,l;
             int dot_product = 0;
             for(k=0; k<FILTERSIDE; k++){
                 for(l=0; l<FILTERSIDE; l++){
                     dot_product = dot_product + image[i+k][j+l]*filter[k][l];
                 }
             }
             image3[i+FILTERSIDE/2][j+FILTERSIDE/2] = image[i+FILTERSIDE/2][j+FILTERSIDE/2] + dot_product;
         }
     }
 }
コード例 #7
0
ファイル: Convolve.cpp プロジェクト: francoisgfx/msc-project
MSC_NAMESPACE_BEGIN

void Convolve::operator()(const tbb::blocked_range2d< size_t > &r) const
{
  m_filter->convolve(
    m_image->width,
    m_image->height,
    m_image->base * m_image->base,
    r.rows().begin(),
    r.rows().end(),
    r.cols().begin(),
    r.cols().end(),
    &(m_image->samples[0]),
    &(m_image->pixels[0])
    );
}
コード例 #8
0
ファイル: rgb.cpp プロジェクト: ribalda/gerbil
	void operator()(const tbb::blocked_range2d<int> &r) const
	{
		typedef cv::Point3_<GenSOM::value_type> Point3;

		// iterate over all pixels in range
		float done = 0;
		float total = (lookup.height * lookup.width);
		for (int y = r.rows().begin(); y < r.rows().end(); ++y) {
			for (int x = r.cols().begin(); x < r.cols().end(); ++x) {
				SOMClosestN::resultAccess closest =
						lookup.closestN(cv::Point2i(x, y));
				Point3 weighted(0, 0, 0);
				std::vector<DistIndexPair>::const_iterator it = closest.first;
				for (int k = 0; it != closest.last; ++k, ++it) {
					size_t somidx = it->index;
					Point3 pos = vec2Point3(lookup.som.getCoord(somidx));
					weighted += weights[k] * pos;
				}
				if (posToBGR) { // 3D coord -> BGR color
					// for 2D SOM: weighted.z == 0 -> use only G and R
					Point3 tmp = weighted;
					weighted.x = tmp.z;  // B
					weighted.y = tmp.y;  // G
					weighted.z = tmp.x;  // R
				}
				output(y, x) = weighted;
				done++;
				if (po && ((int)done % 1000 == 0)) {
					if (!po->update(done / total, true))
						return; // abort if told so. This is thread-save.
					done = 0;
				}
			}
		}
		if (po)
			po->update(done / total, true);
	}
コード例 #9
0
ファイル: fractal.cpp プロジェクト: Phatcat/mangos
 void operator()( tbb::blocked_range2d<int> &r ) const {
     if ( v->next_frame() )
         f.render_rect( r.cols().begin(), r.rows().begin(), r.cols().end(), r.rows().end() );
 }
コード例 #10
0
ファイル: trace.tbb.cpp プロジェクト: BigR-Lab/CodeRes_Cpp
    void operator() (const tbb::blocked_range2d<int> &r) const
    {
       // task-local storage
        unsigned int serial = 1;
        unsigned int mboxsize = sizeof(unsigned int)*(max_objectid() + 20);
        unsigned int * local_mbox = (unsigned int *) alloca(mboxsize);
        memset(local_mbox,0,mboxsize);
#ifdef MARK_RENDERING_AREA
        // compute thread number while first task run
        thread_id_t::reference thread_id = thread_ids.local();
        if (thread_id == -1) thread_id = thread_number++;
        // choose thread color
        int pos = thread_id % NUM_COLORS;
        if(video->running) {
            drawing_area drawing(r.cols().begin(), totaly-r.rows().end(), r.cols().end() - r.cols().begin(), r.rows().end()-r.rows().begin());
            for (int i = 1, y = r.rows().begin(); y != r.rows().end(); ++y, i++) {
                drawing.set_pos(0, drawing.size_y-i);
                for (int x = r.cols().begin(); x != r.cols().end(); x++) {
                    int d = (y % 3 == 0) ? 2 : 1;
                    drawing.put_pixel(video->get_color(colors[pos][0]/d, colors[pos][1]/d, colors[pos][2]/d));
                }
            }
        }
#endif
        if(video->next_frame()) {
            drawing_area drawing(r.cols().begin(), totaly-r.rows().end(), r.cols().end() - r.cols().begin(), r.rows().end()-r.rows().begin());
            for (int i = 1, y = r.rows().begin(); y != r.rows().end(); ++y, i++) {
                drawing.set_pos(0, drawing.size_y-i);
                for (int x = r.cols().begin(); x != r.cols().end(); x++) {
#ifdef MARK_RENDERING_AREA
                    float alpha = y==r.rows().begin()||y==r.rows().end()-1||x==r.cols().begin()||x==r.cols().end()-1
                                ? border_alpha : inner_alpha;
                    color_t c = render_one_pixel (x, y, local_mbox, serial, startx, stopx, starty, stopy, colors[pos], alpha);
#else
                    color_t c = render_one_pixel (x, y, local_mbox, serial, startx, stopx, starty, stopy);
#endif
                    drawing.put_pixel(c);
                }
            }
        }
    }