本文整理汇总了C++中parameters类的典型用法代码示例。如果您正苦于以下问题:C++ parameters类的具体用法?C++ parameters怎么用?C++ parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parameters类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: find_inliers
mat find_inliers(mat data, const parameters& params) {
uint_fast32_t n_inliers = 0;
double outlier_proportion;
uvec best_indices;
uvec indices = rand_indices(0, data.n_cols);
uint_fast32_t iter = 0;
uint_fast32_t iter_max = -1;
while (iter < iter_max) {
mat maybe_inliers = data.cols(indices.head(params.nfit_points));
mat model = params.model_function(maybe_inliers);
mat distances = params.distance_function(model, data);
uvec inliers = find(distances < params.distance_threshold);
if (inliers.n_elem > n_inliers) {
n_inliers = inliers.n_elem;
best_indices = inliers;
outlier_proportion = 1.0 - (double) inliers.n_elem / (double) data.n_cols;
iter_max = lround(
log(1.0 - 0.99) / log(1.0 - pow(1.0 - outlier_proportion, params.nfit_points))
);
}
indices = shuffle(indices); // generate new random indexes
++iter;
}
return data.cols(best_indices);
}
开发者ID:rodolfo-picoreti,项目名称:cv,代码行数:34,代码来源:ransac.hpp
示例2: fprintf
bool attack_cpa<real>::setup(crypto_instance *crypto, const parameters ¶ms)
{
if (!params.get("num_events", m_nevents) ||
!params.get("num_reports", m_nreports) ||
!params.get("byte", m_byte) ||
!params.get("offset", m_offset) ||
!params.get("bits", m_bits)) {
fprintf(stderr, "required parameters: byte, offset, bits\n");
return false;
}
m_mask = 0;
for (unsigned int i = m_offset; i < (m_offset + m_bits); ++i)
m_mask |= 1 << i;
m_crypto = crypto;
m_guesses = 1 << m_crypto->estimate_bits();
m_center = m_bits >> 1;
m_traces = 0;
// allocate storage for intermediate results in advance
m_t1.resize(m_nevents, 0);
m_t2.resize(m_nevents, 0);
m_w1.resize(m_guesses, 0);
m_w2.resize(m_guesses, 0);
m_tw.resize(m_guesses * m_nevents, 0);
m_dtemp.resize(m_guesses * m_nevents, 0);
m_maxes.resize(m_guesses * m_nreports, 0);
return true;
}
开发者ID:gcsmith,项目名称:attack-framework,代码行数:31,代码来源:attack_cpa.cpp
示例3: TRACE
object_ptr interpreter::make_text (parameters &command) {
TRACE ('f', command);
string first = shift(command);
string font = "";
double size = 12.0; //Default size is 12 for text
//If conversion succeeds, then next string on list is the fontname,
//otherwise the string that couldn't be converted to a double is
//the fontname.
try{
size = from_string<double>(first);
font = shift(command);
}
catch (runtime_error &error){
font = first;
}
//At this point, the rest of the words are text to be printed.
string textdata{};
parameters::const_iterator itor = command.begin();
parameters::const_iterator end = command.end();
--end;
for(; itor != end; ++itor){
textdata += *itor + ' ';
}textdata += *itor;//remove trailing space
return make_shared<text> (font, points(size), textdata);
}
开发者ID:rcalef,项目名称:Cpp_projects,代码行数:25,代码来源:interp.cpp
示例4: make_line
object_ptr interpreter::make_line (parameters &command) {
TRACE ('f', command);
if(command.size() > 2) throw runtime_error ("syntax error");
double length = from_string<double>(shift(command));
double thick = 2.0; //Default thickness of 2
if(command.size() != 0) thick = from_string<double>(shift(command));
return make_shared<line> (inches(length), points(thick));
}
开发者ID:rcalef,项目名称:Cpp_projects,代码行数:8,代码来源:interp.cpp
示例5: interpret
void interpreter::interpret (const parameters& params) {
DEBUGF ('i', params);
param begin = params.cbegin();
string command = *begin;
auto itor = interp_map.find (command);
if (itor == interp_map.end()) throw runtime_error ("syntax error");
interpreterfn func = itor->second;
func (++begin, params.cend());
}
开发者ID:bradbernard,项目名称:CMPS109,代码行数:9,代码来源:interp.cpp
示例6: config_error
datasource_ptr datasource_cache::create(const parameters& params, bool bind)
{
boost::optional<std::string> type = params.get<std::string>("type");
if ( ! type)
{
throw config_error(std::string("Could not create datasource. Required ") +
"parameter 'type' is missing");
}
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
#endif
datasource_ptr ds;
std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
if ( itr == plugins_.end() )
{
throw config_error(std::string("Could not create datasource. No plugin ") +
"found for type '" + * type + "' (searched in: " + plugin_directories() + ")");
}
if ( ! itr->second->handle())
{
throw std::runtime_error(std::string("Cannot load library: ") +
lt_dlerror());
}
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
#ifdef __GNUC__
__extension__
#endif
create_ds* create_datasource =
reinterpret_cast<create_ds*>(lt_dlsym(itr->second->handle(), "create"));
if (! create_datasource)
{
throw std::runtime_error(std::string("Cannot load symbols: ") +
lt_dlerror());
}
#ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Size=" << params.size();
parameters::const_iterator i = params.begin();
for (; i != params.end(); ++i)
{
MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: -- " << i->first << "=" << i->second;
}
#endif
ds = datasource_ptr(create_datasource(params, bind), datasource_deleter());
MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Datasource=" << ds << " type=" << type;
return ds;
}
开发者ID:PierceCountyWA,项目名称:mapnik,代码行数:56,代码来源:datasource_cache.cpp
示例7: make_rectangle
object_ptr interpreter::make_rectangle (parameters &command) {
TRACE ('f', command);
if(command.size() > 3) throw runtime_error ("syntax error");
double width = from_string<double>(shift(command));
double height = from_string<double>(shift(command));
double thick = 2.0; //Default thickness of 2
if(command.size() != 0) thick = from_string<double>(shift(command));
return make_shared<rectangle> (inches(width), inches(height),
points(thick));
}
开发者ID:rcalef,项目名称:Cpp_projects,代码行数:10,代码来源:interp.cpp
示例8: test_exceptions
static void test_exceptions() {
{
string s( "x$1?y" );
parameters const p( MAKE_PARAMS( "foo" ) );
ASSERT_EXCEPTION( p.substitute( &s ), invalid_argument );
}
{
string s( "x$1?{y" );
parameters const p( MAKE_PARAMS( "foo" ) );
ASSERT_EXCEPTION( p.substitute( &s ), invalid_argument );
}
}
开发者ID:alyst,项目名称:zorba,代码行数:12,代码来源:test_parameters.cpp
示例9: extract
static return_type extract(parameters const& params,
std::string const& name,
boost::optional<T> const& default_opt_value)
{
boost::optional<T> result(default_opt_value);
parameters::const_iterator itr = params.find(name);
if (itr != params.end())
{
util::apply_visitor(value_extractor_visitor<T>(result),itr->second);
}
return result;
}
开发者ID:Airphrame,项目名称:mapnik,代码行数:12,代码来源:params_impl.hpp
示例10: getstate
static boost::python::tuple
getstate(const parameters& p)
{
using namespace boost::python;
dict d;
parameters::const_iterator pos=p.begin();
while(pos!=p.end())
{
d[pos->first] = pos->second;
++pos;
}
return boost::python::make_tuple(d);
}
开发者ID:PetrDlouhy,项目名称:mapnik,代码行数:13,代码来源:mapnik_parameters.cpp
示例11: shape
shape_datasource::shape_datasource(const parameters ¶ms)
: shape_name_(params.get("file")),
type_(datasource::Vector),
file_length_(0),
indexed_(false),
desc_(params.get("name"))
{
try
{
shape_io shape(shape_name_);
init(shape);
for (int i=0;i<shape.dbf().num_fields();++i)
{
field_descriptor const& fd=shape.dbf().descriptor(i);
std::string fld_name=fd.name_;
switch (fd.type_)
{
case 'C':
case 'D':
case 'M':
case 'L':
desc_.add_descriptor(attribute_descriptor(fld_name,String));
break;
case 'N':
case 'F':
{
if (fd.dec_>0)
{
desc_.add_descriptor(attribute_descriptor(fld_name,Double,false,8));
}
else
{
desc_.add_descriptor(attribute_descriptor(fld_name,Integer,false,4));
}
break;
}
default:
//
std::clog << "unknown type "<<fd.type_<<"\n";
break;
}
}
}
catch (datasource_exception& ex)
{
std::clog<<ex.what()<<std::endl;
throw;
}
}
开发者ID:BackupTheBerlios,项目名称:mapnik-svn,代码行数:50,代码来源:shape.cpp
示例12: test_braces
static void test_braces() {
{
string s( "x${1}y" );
parameters const p( MAKE_PARAMS( "foo" ) );
ASSERT_NO_EXCEPTION( p.substitute( &s ) );
ASSERT_TRUE( s == "xfooy" );
}
{
string s( "x${ 1 }y" );
parameters const p( MAKE_PARAMS( "foo" ) );
ASSERT_NO_EXCEPTION( p.substitute( &s ) );
ASSERT_TRUE( s == "x foo y" );
}
{
string s( "x${1}y" );
parameters const p( MAKE_PARAMS( "" ) );
ASSERT_NO_EXCEPTION( p.substitute( &s ) );
ASSERT_TRUE( s == "xy" );
}
{
string s( "x${ 1 }y" );
parameters const p( MAKE_PARAMS( "" ) );
ASSERT_NO_EXCEPTION( p.substitute( &s ) );
ASSERT_TRUE( s == "xy" );
}
}
开发者ID:alyst,项目名称:zorba,代码行数:26,代码来源:test_parameters.cpp
示例13: interpret
void interpreter::interpret (const parameters& params) {
DEBUGF ('i', params);
param begin = params.cbegin();
// First word contains command name
// Either define, draw, border, or moveby
string command = *begin;
DEBUGF('i', command);
auto itor = interp_map.find (command);
if (itor == interp_map.end()) throw runtime_error ("syntax error");
interpreterfn func = itor->second;
for (auto i = begin; i != params.cend(); ++i) {
cout << *i << " ";
} cout << endl;
func (++begin, params.cend());
}
开发者ID:dkma1026,项目名称:cmps,代码行数:15,代码来源:interp.cpp
示例14: dict_params
boost::python::dict dict_params(parameters& p)
{
boost::python::dict d;
parameters::const_iterator pos=p.begin();
while(pos!=p.end())
{
boost::python::list vals;
pickle_value serializer( vals );
mapnik::value_holder val = pos->second;
boost::apply_visitor( serializer, val );
d[pos->first] = vals[0];
++pos;
}
return d;
}
开发者ID:netconstructor,项目名称:mapnik,代码行数:15,代码来源:mapnik_parameters.cpp
示例15: make_polygon
object_ptr interpreter::make_polygon (parameters &command) {
TRACE ('f', command);
double thick = 2.0; //Default thickness of 2
if (command.size() % 2 == 1){
thick = from_string<double>(command.back());
command.pop_back();
}
coordlist poly_points{};
while(!command.empty()){
double x = from_string<double>(shift(command));
double y = from_string<double>(shift(command));
poly_points.push_back({inches(x), inches(y)});
}
return make_shared<polygon> (poly_points, points(thick));
}
开发者ID:rcalef,项目名称:Cpp_projects,代码行数:15,代码来源:interp.cpp
示例16: list_params
boost::python::list list_params(parameters& p)
{
boost::python::list l;
parameters::const_iterator pos=p.begin();
while(pos!=p.end())
{
boost::python::list vals;
pickle_value serializer( vals );
mapnik::value_holder val = pos->second;
boost::apply_visitor( serializer, val );
l.append(boost::python::make_tuple(pos->first,vals[0]));
++pos;
}
return l;
}
开发者ID:netconstructor,项目名称:mapnik,代码行数:15,代码来源:mapnik_parameters.cpp
示例17: getstate
static boost::python::tuple
getstate(const parameters& p)
{
using namespace boost::python;
dict d;
parameters::const_iterator pos=p.begin();
while(pos!=p.end())
{
boost::python::list vals;
pickle_value serializer( vals );
mapnik::value_holder val = pos->second;
boost::apply_visitor( serializer, val );
d[pos->first] = vals[0];
++pos;
}
return boost::python::make_tuple(d);
}
开发者ID:netconstructor,项目名称:mapnik,代码行数:17,代码来源:mapnik_parameters.cpp
示例18: datasource
chained_datasource::chained_datasource(const parameters& params, bool _bind) :
datasource(params)
{
// Iterate over params and populate m_source_params
// from all parameters that start with "src_"
for (parameters::const_iterator iter=params.begin(); iter!=params.end(); iter++) {
const std::string &name(iter->first);
if (!boost::starts_with(name, "src_")) continue;
const std::string sub_name(name.substr(4));
source_params_[sub_name]=iter->second;
}
if (_bind) {
bind();
}
}
开发者ID:GunioRobot,项目名称:mapnik-rasterizers,代码行数:17,代码来源:chained_datasource.cpp
示例19: go
void go(parameters & params) {
tpie::file_stream<item_type> fs;
tpie::serialization_writer ss;
if (params.gen_tpie) fs.open(params.stream_name("tpie"));
if (params.gen_serialization) ss.open(params.stream_name("ser"));
tpie::stream_size_type numbers =
static_cast<tpie::stream_size_type>(params.megabytes
* 1024 * 1024 / sizeof(item_type));
boost::mt19937 rng(params.seed);
boost::uniform_01<> basedist;
boost::variate_generator<boost::mt19937, boost::uniform_01<> >
rng01(rng, basedist);
boost::exponential_distribution<> dist(2);
for (tpie::stream_size_type i = 0; i < numbers; ++i) {
item_type x = dist(rng01);
if (params.gen_tpie) fs.write(x);
if (params.gen_serialization) ss.serialize(x);
}
if (params.gen_tpie) fs.close();
if (params.gen_serialization) ss.close();
}
开发者ID:daniel-perry,项目名称:tpie,代码行数:21,代码来源:numbergen.cpp
示例20:
parameters::parameters(const parameters &rhs)
{
m_stud_mode = rhs.get_stud_rendering_mode();
m_mode = rhs.get_rendering_mode();
m_vbuffer_criteria = rhs.get_vbuffer_criteria();
m_shading = rhs.get_shading();
m_debug = rhs.get_debug();
m_culling = rhs.get_culling();
m_shader = rhs.get_shader();
}
开发者ID:bangkr,项目名称:Konstruktor,代码行数:10,代码来源:parameters.cpp
注:本文中的parameters类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论