本文整理汇总了C++中range类的典型用法代码示例。如果您正苦于以下问题:C++ range类的具体用法?C++ range怎么用?C++ range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了range类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_sigma
// The constructor uses the appropriate settings in the config file to
// properly set up the sensor model for the specified "phase" of the LGMD
// input signal.
SensorModel::SensorModel(const std::string& lgmd_phase)
: m_sigma(0.0f), m_name(lgmd_phase)
{
const range<float> lgmd_range =
get_conf(locust_model(), "spike_range", make_range(0.0f, 800.0f)) ;
// Get the LGMD ranges for the columns of the sensor model
m_lgmd_ranges = string_to_deque<float>(
conf<std::string>(lgmd_phase + "_lgmd_ranges", "0 800")) ;
if (m_lgmd_ranges.size() < 2) { // crappy configuration!
m_lgmd_ranges.clear() ;
m_lgmd_ranges.push_back(lgmd_range.min()) ;
m_lgmd_ranges.push_back(lgmd_range.max()) ;
}
sort(m_lgmd_ranges.begin(), m_lgmd_ranges.end()) ;
if (m_lgmd_ranges.front() > lgmd_range.min())
m_lgmd_ranges.push_front(lgmd_range.min()) ;
if (m_lgmd_ranges.back() < lgmd_range.max())
m_lgmd_ranges.push_back(lgmd_range.max()) ;
// Figure out how many rows and columns the sensor model's probability
// table has and allocate space for the required number of elements.
// Initialize the probability table using a uniform distribution.
const int C = m_lgmd_ranges.size() - 1 ;
const int R = column_size() ;
const int N = R * C ;
m_prob.reserve(N) ;
std::fill_n(std::back_inserter(m_prob), N, 1.0f/N) ;
// Apply Gabbiani model to obtain causal probabilities and Gaussian
// blur neighbouring bins in each row.
update(clamp(conf(lgmd_phase + "_sigma", 1.0f),
0.1f, static_cast<float>(row_size()))) ;
}
示例2: prob_label
// Quick helper to return a label for the current range of probability
// values used for scaling the texels used to represent the sensor
// model's probabilities.
static std::string prob_label(const range<float>& prob_range)
{
std::ostringstream str ;
str << "P-range: ["
<< prob_range.min() << ", " << prob_range.max() << ']' ;
return str.str() ;
}
示例3: new
void MipsELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
ArrayRef<uint8_t> symContent,
ArrayRef<uint8_t> secContent,
range<Elf_Rel_Iter> rels) {
const auto value = this->getSymbolValue(symbol);
for (Elf_Rel_Iter rit = rels.begin(), eit = rels.end(); rit != eit; ++rit) {
if (rit->r_offset < value || value + symContent.size() <= rit->r_offset)
continue;
auto r = new (this->_readerStorage) MipsELFReference<ELFT>(value, *rit);
this->addReferenceToSymbol(r, symbol);
this->_references.push_back(r);
auto addend = readAddend(*rit, secContent);
auto pairRelType = getPairRelocation(*rit);
if (pairRelType != llvm::ELF::R_MIPS_NONE) {
addend <<= 16;
auto mit = findMatchingRelocation(pairRelType, rit, eit);
if (mit != eit)
addend += int16_t(readAddend(*mit, secContent));
else
// FIXME (simon): Show detailed warning.
llvm::errs() << "lld warning: cannot matching LO16 relocation\n";
}
this->_references.back()->setAddend(addend);
}
}
示例4: operator
void operator()(const range& r) const{
for (int i = r.begin(); i != r.end(); ++i) {
if (compareWord(word, words[i])) {
cout << words[i] << endl;
}
}
}
示例5: jacobi_kernel_wrapper
void jacobi_kernel_wrapper(range const & y_range, size_t n, vector<double> & dst, vector<double> const & src) {
for(size_t y = y_range.begin(); y < y_range.end(); ++y) {
double * dst_ptr = &dst[y * n];
const double * src_ptr = &src[y * n];
jacobi_kernel( dst_ptr, src_ptr, n );
}
}
示例6: invalid_argument
double_block_type::double_block_type(const range &bounds,
const offset_multiplier &ls)
: bounds_(bounds), ls_(ls) {
if (bounds.has_low() || bounds.has_high())
if (ls.has_offset() || ls.has_multiplier())
throw std::invalid_argument("Block type cannot have both a bound and"
"an offset/multiplier.");
}
示例7: jacobi_kernel_wrap
void jacobi_kernel_wrap(
range const & r,
crs_matrix<double> const & A,
std::vector<double> & x_dst, std::vector<double> const & x_src, std::vector<double> const & b)
{
for(std::size_t row = r.begin(); row < r.end(); ++row)
{
jacobi_kernel_nonuniform(A, x_dst, x_src, b, row);
}
}
示例8: del
void database::del(range key)
{
assert(_db);
struct slice sk;
sk.data = const_cast<char*>(key.begin());
sk.len = key.size();
::db_remove(_db, &sk);
}
示例9: is_mergeable
inline bool is_mergeable (const range<iter1_t> &src1,
const range<iter2_t> &src2, compare comp )
{ //---------------------------- begin ------------------------------------
typedef typename iterator_traits<iter1_t>::value_type type1 ;
typedef typename iterator_traits<iter2_t>::value_type type2 ;
static_assert ( std::is_same<type1, type2>::value,
"Incompatible iterators\n");
//---------------------------- begin --------------------------------------
return comp ( *(src2.front()), *(src1.back()));
};
示例10: operator
__forceinline NodeRef operator() (const PrimRef* prims, const range<size_t>& set, const FastAllocator::CachedAllocator& alloc) const
{
size_t n = set.size();
size_t items = Primitive::blocks(n);
size_t start = set.begin();
Primitive* accel = (Primitive*) alloc.malloc1(items*sizeof(Primitive),BVH::byteAlignment);
typename BVH::NodeRef node = BVH::encodeLeaf((char*)accel,items);
for (size_t i=0; i<items; i++) {
accel[i].fill(prims,start,set.end(),bvh->scene);
}
return node;
}
示例11: init_move
inline range<Iter2_t> init_move ( const range<Iter2_t> & dest,
const range<Iter1_t> & src)
{ //------------- static checking ------------------------------------------
typedef typename iterator_traits<Iter1_t>::value_type type1 ;
typedef typename iterator_traits<Iter2_t>::value_type type2 ;
static_assert ( std::is_same<type1, type2>::value,
"Incompatible iterators\n");
//------------------------------- begin ----------------------------------
if ( src.size() == 0 ) return range<Iter2_t>(dest.first, dest.first);
init_move(dest.first ,src.first, src.last );
return range<Iter2_t>(dest.first, dest.first + src.size()) ;
};
示例12: OffsetRange
void OffsetRange(range& ioRange, cell inOffset, SplitType what, int split, int shift)
{
bool wasSpecial = false;
if (shift < 0 && what != noSplit)
if (what == hSplit)
{
if (abs(ioRange.left) >= split && abs(ioRange.right) <= split - shift)
ioRange.Set(0, 0, 0, 0);
else if (abs(ioRange.left) >= split && abs(ioRange.left) <= split - shift)
{
if (ioRange.left < 0)
ioRange.left = -split;
else
ioRange.left = split;
OffsetCell(ioRange.BotRight(), inOffset, what, split, shift);
wasSpecial = true;
}
else if (abs(ioRange.right) >= split && abs(ioRange.right) <= split - shift)
{
if (ioRange.right < 0)
ioRange.right = -split + 1;
else
ioRange.right = split - 1;
OffsetCell(ioRange.TopLeft(), inOffset, what, split, shift);
wasSpecial = true;
}
}
else if (what == vSplit)
{
if (abs(ioRange.top) >= split && abs(ioRange.bottom) <= split - shift)
ioRange.Set(0, 0, 0, 0);
else if (abs(ioRange.top) >= split && abs(ioRange.top) <= split - shift)
{
if (ioRange.top < 0)
ioRange.top = -split;
else
ioRange.top = split;
OffsetCell(ioRange.BotRight(), inOffset, what, split, shift);
wasSpecial = true;
}
else if (abs(ioRange.bottom) >= split && abs(ioRange.bottom) <= split - shift)
{
if (ioRange.bottom < 0)
ioRange.bottom = -split + 1;
else
ioRange.bottom = split - 1;
OffsetCell(ioRange.TopLeft(), inOffset, what, split, shift);
wasSpecial = true;
}
}
if (!wasSpecial)
{
OffsetCell(ioRange.TopLeft(), inOffset, what, split, shift);
OffsetCell(ioRange.BotRight(), inOffset, what, split, shift);
}
} /* OffsetRange */
示例13: generic_par_for_wg
void generic_par_for_wg(range<Dimensions> k_range,
range<Dimensions> workgroup_size) {
queue my_queue;
// the product of all Dimensions e.g. 10*10*10 for {10,10,10}
auto linr_size = k_range.size(), linwg_size = workgroup_size.size();
// these will simply have the group, local and global linear ids assigned to
// them
auto group_lin = buffer<int>(linr_size / linwg_size);
auto loc_lin = buffer<int>(linr_size);
auto gl_lin = buffer<int>(linr_size);
my_queue.submit([&](handler &cgh) {
auto group_lin_acc = group_lin.get_access<access::mode::write>(cgh);
auto loc_lin_acc = loc_lin.get_access<access::mode::write>(cgh);
auto gl_lin_acc = gl_lin.get_access<access::mode::read_write>(cgh);
cgh.parallel_for_work_group<kernel_name>(
nd_range<Dimensions>(k_range, workgroup_size),
[=](group<Dimensions> group) {
group_lin_acc[group.get_linear_id()] = group.get_linear_id();
group.parallel_for_work_item([=](h_item<Dimensions> tile) {
loc_lin_acc[tile.get_global_linear_id()] =
tile.get_local_linear_id();
gl_lin_acc[tile.get_global_linear_id()] =
tile.get_global_linear_id();
});
});
});
auto loc_lin_out = loc_lin.get_access<access::mode::read>();
auto group_lin_out = group_lin.get_access<access::mode::read>();
auto gl_lin_out = gl_lin.get_access<access::mode::read>();
for (int i = 0; i < linr_size / linwg_size; ++i) {
BOOST_CHECK(group_lin_out[i] == i); // group id
}
for (int i = 0; i < linr_size; ++i) {
BOOST_CHECK(gl_lin_out[i] == i); // w1 global id
BOOST_CHECK(loc_lin_out[i] == loc_lin_out[i] % linwg_size); // local id
}
/* We must wait for for the queue to finish as none of buffer's destruction
is blocking.
*/
my_queue.wait();
}
示例14: add
void database::add(range key, range data)
{
assert(_db);
struct slice sk, sv;
sk.data = const_cast<char*>(key.begin());
sk.len = key.size();
sv.data = const_cast<char*>(data.begin());
sv.len = data.size();
if (::db_add(_db, &sk, &sv) == 0)
{
throw exception("error adding to ness backend");
}
}
示例15: read
[[nodiscard]]
inline size_t read(std::istream& Stream, const range<char*>& Buffer)
{
{
const auto Exceptions = Stream.exceptions();
Stream.exceptions(Exceptions & ~(Stream.failbit | Stream.eofbit));
SCOPE_EXIT{ Stream.exceptions(Exceptions); };
Stream.read(Buffer.data(), Buffer.size());
if (!Stream.bad() && Stream.eof())
Stream.clear();
}
return Stream.gcount();
}