本文整理汇总了C++中boost::array::back方法的典型用法代码示例。如果您正苦于以下问题:C++ array::back方法的具体用法?C++ array::back怎么用?C++ array::back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::array
的用法示例。
在下文中一共展示了array::back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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))
;
}
示例3: setDimensions
/** @brief Set the dimensions of the image, allocate memory, etc.
\param dims Sizes of each non trival dimension (min=1, max=3), supposed in row major order.
n[0] varies slower than n[1], itself variing slower that n[3]
For a 3D image scanned with x faster than y faster than z, the dimensions must be given in reverse order
n[0]=dimz, n[1]=dimy, n[2]=dimx
*/
void Tracker::setDimensions(const boost::array<size_t,3> &dims)
{
//allocate main memory block for FFT.
// Last dimension has to be padded with extra values to allow real2complex and c2r fft
boost::array<size_t,3> paddedDims = dims;
paddedDims.back()= 2*(paddedDims.back()/2+1);
size_t memsize = 1;
memsize = accumulate(paddedDims.begin(),paddedDims.end(),1,multiplies<size_t>());
cout<<"Allocating a block of "<<sizeof(float) * memsize<<" bytes ... ";
data = (float*)fftwf_malloc(sizeof(float)* memsize);
assert(data);
//allocate memory.
centersMap.resize(dims);
paddedDims.back() = dims.back()/2 + 1;
FFTmask.resize(paddedDims);
//planning fft.
int n[3];
copy(dims.begin(),dims.end(),&(n[0]));
forward_plan = fftwf_plan_dft_r2c(dims.size(), &(n[0]), data, (fftwf_complex *)data, flags);
//n[2] = 2*(n[2]/2 +1);
backward_plan = fftwf_plan_dft_c2r(dims.size(), &(n[0]), (fftwf_complex *)data, data, flags);
}
示例4: Center
explicit Center(const Center<D-1> &c, const double &additional_coord): Center_base(c.r, c.intensity)
{
std::copy(c.coords.begin(), c.coords.end(), coords.begin());
coords.back() = additional_coord;
};