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


C++ array::front方法代码示例

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


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

示例1: gain_interp

static double gain_interp(double gain, boost::array<double, 17> db_vector, boost::array<double, 17> volts_vector) {
    double volts;
    gain = uhd::clip<double>(gain, db_vector.front(), db_vector.back()); //let's not get carried away here

    boost::uint8_t gain_step = 0;
    //find which bin we're in
    for(size_t i = 0; i < db_vector.size()-1; i++) {
        if(gain >= db_vector[i] && gain <= db_vector[i+1]) gain_step = i;
    }

    //find the current slope for linear interpolation
    double slope = (volts_vector[gain_step + 1] - volts_vector[gain_step])
                / (db_vector[gain_step + 1] - db_vector[gain_step]);

    //the problem here is that for gains approaching the maximum, the voltage slope becomes infinite
    //i.e., a small change in gain requires an infinite change in voltage
    //to cope, we limit the slope

    if(slope == std::numeric_limits<double>::infinity())
        return volts_vector[gain_step];

    //use the volts per dB slope to find the final interpolated voltage
    volts = volts_vector[gain_step] + (slope * (gain - db_vector[gain_step]));

    UHD_LOGV(often) << "Gain interp: gain: " << gain << ", gain_step: " << int(gain_step) << ", slope: " << slope << ", volts: " << volts << std::endl;

    return volts;
}
开发者ID:Gabotero,项目名称:UHD,代码行数:28,代码来源:db_tvrx.cpp

示例2:

static uhd::dict<std::string, gain_range_t> get_tvrx_gain_ranges(void) {
    double rfmax = 0.0, rfmin = FLT_MAX;
    BOOST_FOREACH(const std::string range, tvrx_rf_gains_db.keys()) {
        double my_max = tvrx_rf_gains_db[range].back(); //we're assuming it's monotonic
        double my_min = tvrx_rf_gains_db[range].front(); //if it's not this is wrong wrong wrong
        if(my_max > rfmax) rfmax = my_max;
        if(my_min < rfmin) rfmin = my_min;
    }

    double ifmin = tvrx_if_gains_db.front();
    double ifmax = tvrx_if_gains_db.back();

    return map_list_of
        ("RF", gain_range_t(rfmin, rfmax, (rfmax-rfmin)/4096.0))
        ("IF", gain_range_t(ifmin, ifmax, (ifmax-ifmin)/4096.0))
    ;
}
开发者ID:Gabotero,项目名称:UHD,代码行数:17,代码来源:db_tvrx.cpp


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