本文整理汇总了C++中box::get_map方法的典型用法代码示例。如果您正苦于以下问题:C++ box::get_map方法的具体用法?C++ box::get_map怎么用?C++ box::get_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类box
的用法示例。
在下文中一共展示了box::get_map方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: map_box
box box_factory::map_box(box ratio, box b)
{
map<string, capd::interval> b_map = b.get_map();
map<string, capd::interval> res_map;
for(auto it = b_map.cbegin(); it != b_map.cend(); it++)
{
res_map.insert(make_pair(it->first, it->second.leftBound() + ratio.get_map()[it->first] * capd::intervals::width(it->second)));
}
return box(res_map);
}
示例2: get_keys_diff
box box_factory::get_keys_diff(box lhs, box rhs)
{
map<string, capd::interval> res;
map<string, capd::interval> lhs_map = lhs.get_map();
map<string, capd::interval> rhs_map = rhs.get_map();
for(auto it = lhs_map.cbegin(); it != lhs_map.cend(); it++)
{
if(rhs_map.find(it->first) == rhs_map.cend())
{
res.insert(make_pair(it->first, it->second));
}
}
return box(res);
}
示例3: while
// partitioning a box
vector<box> box_factory::partition(box b, double e)
{
// setting up a precision map
map<string, capd::interval> e_map;
map<string, capd::interval> edges = b.get_map();
for(auto it = edges.cbegin(); it != edges.cend(); it++)
{
e_map.insert(make_pair(it->first, capd::interval(e)));
}
// main algorithm
vector<box> q = {b};
vector<box> res;
while(!q.empty())
{
box tmp_b = q.front();
q.erase(q.cbegin());
vector<box> tmp_v = bisect(tmp_b, e_map);
if(tmp_v.empty())
{
res.push_back(tmp_b);
}
else
{
q.insert(q.cend(), tmp_v.cbegin(), tmp_v.cend());
}
}
return res;
}
示例4: sqrt
box box_factory::sqrt(box b)
{
map<string, capd::interval> b_map = b.get_map();
map<string, capd::interval> res;
for(auto it = b_map.cbegin(); it != b_map.cend(); it++)
{
res.insert(make_pair(it->first, capd::intervals::sqrt(it->second)));
}
return box(res);
}
示例5: bisect
/**
* Dividing the box in all n dimensions producing 2^n boxes of the same size
*/
std::vector<box> box_factory::bisect(box b)
{
std::map<std::string, capd::interval> e;
std::map<std::string, capd::interval> m = b.get_map();
for(auto it = m.cbegin(); it != m.cend(); it++)
{
e.insert(make_pair(it->first, capd::interval(0)));
}
return box_factory::bisect(b,e);
}
示例6: merge
box box_factory::merge(box lhs, box rhs)
{
std::map<std::string, capd::interval> m = lhs.get_map();
for(auto it = m.cbegin(); it != m.cend(); it++)
{
if(rhs.get_map().find(it->first) == rhs.get_map().cend())
{
std::stringstream s;
s << "Variables of the compared boxes are not the same";
throw std::invalid_argument(s.str());
}
}
int neq_counter = 0;
std::string neq_dim;
for(auto it = m.cbegin(); it != m.cend(); it++)
{
//std::cout << it->first << " " << it->second << std::endl;
if(it->second != rhs.get_map()[it->first])
{
neq_counter++;
neq_dim = it->first;
}
if(neq_counter > 1)
{
return box();
}
}
if(m[neq_dim].rightBound() == rhs.get_map()[neq_dim].leftBound())
{
m[neq_dim] = capd::interval(m[neq_dim].leftBound(), rhs.get_map()[neq_dim].rightBound());
return box(m);
}
else
{
if(m[neq_dim].leftBound() == rhs.get_map()[neq_dim].rightBound())
{
m[neq_dim] = capd::interval(rhs.get_map()[neq_dim].leftBound(), m[neq_dim].rightBound());
return box(m);
}
else
{
return box();
}
}
}
示例7: cartesian_product
/**
* Dividing the box in all n dimensions producing 2^n boxes of the same size
* according to the precision vector e
*/
std::vector<box> box_factory::bisect(box b, std::map<std::string, capd::interval> e)
{
std::map<std::string, std::vector<capd::interval>> tmp_m;
std::map<std::string, capd::interval> m = b.get_map();
for(auto it = m.cbegin(); it != m.cend(); it++)
{
if(capd::intervals::width(it->second) > e[it->first].leftBound())
{
std::vector<capd::interval> tmp_v;
tmp_v.push_back(capd::interval((it->second).leftBound(), (it->second).mid().rightBound()));
tmp_v.push_back(capd::interval((it->second).mid().leftBound(), (it->second).rightBound()));
tmp_m.insert(make_pair(it->first, tmp_v));
}
}
return box_factory::cartesian_product(tmp_m);
}
示例8: bisect
/**
* Dividing the box in all n dimensions producing 2^n boxes of the same size
*/
std::vector<box> box_factory::bisect(box b, vector<string> vars, double prec)
{
std::map<std::string, capd::interval> e;
std::map<std::string, capd::interval> m = b.get_map();
for(auto it = m.cbegin(); it != m.cend(); it++)
{
if(find(vars.begin(), vars.end(), it->first) != vars.end())
{
e.insert(make_pair(it->first, capd::interval(prec)));
}
else
{
e.insert(make_pair(it->first, capd::intervals::width(it->second)));
}
}
return box_factory::bisect(b,e);
}