• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ range_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: operator

 void operator()( const range_t& r ) {
     count_t end = r.end();
     volatile count_t anchor = 0;
     for( count_t i = r.begin(); i < end; ++i )
         anchor += i;
     my_sum = anchor;
 }
开发者ID:kevinushey,项目名称:RcppParallel,代码行数:7,代码来源:perf_sched.cpp


示例2: additive_noise

        bool additive_noise(
                const range_t<tscalar>& noise_range,
                const gauss_kernel_t<tscalar>& kernel,
                const range_t<tscalar>& output_range,
                tmatrix& src, tgetter getter, tsetter setter)
        {
                random_t<tscalar> noiser(noise_range.min(), noise_range.max());

                // create random noise map
                typename tensor::matrix_types_t<tscalar>::tmatrix noisemap(src.rows(), src.cols());
                tensor::transform(noisemap, noisemap, [&] (tvalue) { return noiser(); });

                // smooth the noise map
                inplace_separable_filter(kernel, range_t<tscalar>(noiser.min(), noiser.max()), noisemap,
                         [] (tscalar v) { return v; },
                         [] (tscalar, tscalar v) { return v; });

                // add the noise map to the input matrix
                tensor::transform(src, noisemap, src, [&] (tvalue value, tscalar noise)
                {
                        return setter(value, math::cast<tvalue>(output_range.clamp(noise + getter(value))));
                });

                // OK
                return true;
        }
开发者ID:0x0all,项目名称:nanocv,代码行数:26,代码来源:noise.hpp


示例3: run

 void run ( const range_t& r, Partitioner& p ) const {
     count_t end = r.end();
     if ( my_depth > 1 )
         for ( count_t i = r.begin(); i < end; ++i )
             tbb::parallel_for( range_t(0, IterRange, IterGrain), NestingForBody(my_depth - 1), p );
     else
         for ( count_t i = r.begin(); i < end; ++i )
             tbb::parallel_for( range_t(0, IterRange, IterGrain), SimpleForBody(), p );
 }
开发者ID:kevinushey,项目名称:RcppParallel,代码行数:9,代码来源:perf_sched.cpp


示例4: operator

 void operator()(const range_t& range) {
     const size_t i_end = range.end();
     if(!range.empty()) {
         for(size_t i = range.begin(); i != i_end; ++i) {
             if(closerToExtremum(points[i])) {
                 extrXPoint = points[i];
             }
         }
     }
 }
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:10,代码来源:convex_hull_sample.cpp


示例5: operator

    void operator()(const range_t& range) const {
        util::rng the_rng(range.begin());
        const size_t i_end = range.end();
        size_t count = 0;
#if USECONCVEC
            points.grow_to_at_least(i_end);
#else // Locked enlarge to a not thread-safe STD::VECTOR
            grow_vector_to_at_least(pushBackMutex,points,i_end);
#endif // USECONCVEC

        for(size_t i = range.begin(); i != i_end; ++i) {
            points[i]=util::GenerateRNDPoint<double>(count,the_rng,util::rng::max_rand);
        }
    }
开发者ID:Chalenko,项目名称:PCM,代码行数:14,代码来源:convex_hull_bench.cpp


示例6: screen_rect

void Audio::paint(Painter& painter) {
	const auto r = screen_rect();

	constexpr int db_min = -96;
	constexpr int db_max = 0;
	constexpr int db_delta = db_max - db_min;
	const range_t<int> x_rms_range { 0, r.width() - 1 };
	const auto x_rms = x_rms_range.clip((rms_db_ - db_min) * r.width() / db_delta);
	const range_t<int> x_max_range { x_rms + 1, r.width() };
	const auto x_max = x_max_range.clip((max_db_ - db_min) * r.width() / db_delta);

	const Rect r0 {
		static_cast<ui::Coord>(r.left()), r.top(),
		static_cast<ui::Dim>(x_rms), r.height()
	};
	painter.fill_rectangle(
		r0,
		Color::green()
	);

	const Rect r1 {
		static_cast<ui::Coord>(r.left() + x_rms), r.top(),
		1, r.height()
	};
	painter.fill_rectangle(
		r1,
		Color::black()
	);

	const Rect r2 {
		static_cast<ui::Coord>(r.left() + x_rms + 1), r.top(),
		static_cast<ui::Dim>(x_max - (x_rms + 1)), r.height()
	};
	painter.fill_rectangle(
		r2,
		Color::red()
	);

	const Rect r3 {
		static_cast<ui::Coord>(r.left() + x_max), r.top(),
		static_cast<ui::Dim>(r.width() - x_max), r.height()
	};
	painter.fill_rectangle(
		r3,
		Color::black()
	);
}
开发者ID:CCrashBandicot,项目名称:portapack-hackrf,代码行数:47,代码来源:ui_audio.cpp


示例7: paintMid

void TracePlot::paintMid(QPainter &painter, QRect &rect, range_t<off_t> sampleRange)
{
    int samplesPerColumn = sampleRange.length() / rect.width();
    int samplesPerTile = tileWidth * samplesPerColumn;
    off_t tileID = sampleRange.minimum / samplesPerTile;
    off_t tileOffset = sampleRange.minimum % samplesPerTile; // Number of samples to skip from first image tile
    int xOffset = tileOffset / samplesPerColumn; // Number of columns to skip from first image tile

    // Paint first (possibly partial) tile
    painter.drawPixmap(
        QRect(rect.x(), rect.y(), tileWidth - xOffset, height()),
        getTile(tileID++, samplesPerTile),
        QRect(xOffset, 0, tileWidth - xOffset, height())
    );

    // Paint remaining tiles
    for (int x = tileWidth - xOffset; x < rect.right(); x += tileWidth) {
        painter.drawPixmap(
            QRect(x, rect.y(), tileWidth, height()),
            getTile(tileID++, samplesPerTile)
        );
    }
}
开发者ID:EvanKrall,项目名称:inspectrum,代码行数:23,代码来源:traceplot.cpp


示例8: drawTile

void TracePlot::drawTile(QString key, const QRect &rect, range_t<off_t> sampleRange)
{
    QImage image(rect.size(), QImage::Format_ARGB32);
    image.fill(Qt::transparent);

    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);

	auto firstSample = sampleRange.minimum;
	auto length = sampleRange.length();

	// Is it a 2-channel (complex) trace?
    if (auto src = dynamic_cast<SampleSource<std::complex<float>>*>(sampleSource.get())) {
        auto samples = src->getSamples(firstSample, length);
        if (samples == nullptr)
            return;

        painter.setPen(Qt::red);
        plotTrace(painter, rect, reinterpret_cast<float*>(samples.get()), length, 2);
        painter.setPen(Qt::blue);
        plotTrace(painter, rect, reinterpret_cast<float*>(samples.get())+1, length, 2);

    // Otherwise is it single channel?
    } else if (auto src = dynamic_cast<SampleSource<float>*>(sampleSource.get())) {
        auto samples = src->getSamples(firstSample, length);
        if (samples == nullptr)
            return;

        painter.setPen(Qt::green);
        plotTrace(painter, rect, samples.get(), length, 1);
    } else {
    	throw std::runtime_error("TracePlot::paintMid: Unsupported source type");
    }

    emit imageReady(key, image);
}
开发者ID:EvanKrall,项目名称:inspectrum,代码行数:36,代码来源:traceplot.cpp


示例9: inplace_separable_filter

        bool inplace_separable_filter(const tkernel& kernel, const range_t<tscalar>& range,
                tmatrix& src, tgetter getter, tsetter setter)
        {
                const int rows = static_cast<int>(src.rows());
                const int cols = static_cast<int>(src.cols());

                const int ksize = static_cast<int>(kernel.size());
                const int krad = ksize / 2;

                if (ksize != (2 * krad + 1))
                {
                        return false;
                }

                std::vector<tscalar> buff(std::max(rows, cols));

                // horizontal filter
                for (int r = 0; r < rows; r ++)
                {
                        for (int c = 0; c < cols; c ++)
                        {
                                buff[c] = math::cast<tscalar>(getter(src(r, c)));
                        }

                        for (int c = 0; c < cols; c ++)
                        {
                                tscalar v = 0;
                                for (int k = -krad; k <= krad; k ++)
                                {
                                        const int cc = math::clamp(k + c, 0, cols - 1);
                                        v += kernel[k + krad] * buff[cc];
                                }

                                src(r, c) = setter(src(r, c), math::cast<tvalue>(range.clamp(v)));
                        }
                }

                // vertical filter
                for (int c = 0; c < cols; c ++)
                {
                        for (int r = 0; r < rows; r ++)
                        {
                                buff[r] = math::cast<tscalar>(getter(src(r, c)));
                        }

                        for (int r = 0; r < rows; r ++)
                        {
                                tscalar v = 0;
                                for (int k = -krad; k <= krad; k ++)
                                {
                                        const int rr = math::clamp(k + r, 0, rows - 1);
                                        v += kernel[k + krad] * buff[rr];
                                }

                                src(r, c) = setter(src(r, c), math::cast<tvalue>(range.clamp(v)));
                        }
                }

                // OK
                return true;
        }
开发者ID:0x0all,项目名称:nanocv,代码行数:61,代码来源:filter.hpp


示例10: screen_rect

void RSSI::paint(Painter& painter) {
    const auto r = screen_rect();

    constexpr int rssi_sample_range = 256;
    constexpr float rssi_voltage_min = 0.4;
    constexpr float rssi_voltage_max = 2.2;
    constexpr float adc_voltage_max = 3.3;
    constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
    constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max;
    constexpr int raw_delta = raw_max - raw_min;
    const range_t<int> x_avg_range { 0, r.width() - 1 };
    const auto x_avg = x_avg_range.clip((avg_ - raw_min) * r.width() / raw_delta);
    const range_t<int> x_min_range { 0, x_avg };
    const auto x_min = x_min_range.clip((min_ - raw_min) * r.width() / raw_delta);
    const range_t<int> x_max_range { x_avg + 1, r.width() };
    const auto x_max = x_max_range.clip((max_ - raw_min) * r.width() / raw_delta);

    const Rect r0 {
        static_cast<ui::Coord>(r.left()), r.top(),
        static_cast<ui::Dim>(x_min), r.height()
    };
    painter.fill_rectangle(
        r0,
        Color::blue()
    );

    const Rect r1 {
        static_cast<ui::Coord>(r.left() + x_min), r.top(),
        static_cast<ui::Dim>(x_avg - x_min), r.height()
    };
    painter.fill_rectangle(
        r1,
        Color::red()
    );

    const Rect r2 {
        static_cast<ui::Coord>(r.left() + x_avg), r.top(),
        1, r.height()
    };
    painter.fill_rectangle(
        r2,
        Color::white()
    );

    const Rect r3 {
        static_cast<ui::Coord>(r.left() + x_avg + 1), r.top(),
        static_cast<ui::Dim>(x_max - (x_avg + 1)), r.height()
    };
    painter.fill_rectangle(
        r3,
        Color::red()
    );

    const Rect r4 {
        static_cast<ui::Coord>(r.left() + x_max), r.top(),
        static_cast<ui::Dim>(r.width() - x_max), r.height()
    };
    painter.fill_rectangle(
        r4,
        Color::black()
    );

    if (pwmrssi_enabled) {
        const range_t<int> pwmrssi_avg_range { 0, 96 };
        const auto pwmrssi_avg = pwmrssi_avg_range.clip((avg_ - raw_min) * 96 / raw_delta);
        baseband::set_pwmrssi(pwmrssi_avg, true);
    }
}
开发者ID:furrtek,项目名称:portapack-havoc,代码行数:68,代码来源:ui_rssi.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ranges类代码示例发布时间:2022-05-31
下一篇:
C++ range类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap