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


C++ parameters类代码示例

本文整理汇总了C++中parameters的典型用法代码示例。如果您正苦于以下问题:C++ parameters类的具体用法?C++ parameters怎么用?C++ parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 &params)
{
    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 &params)
	: 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


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