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


C++ pn函数代码示例

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


在下文中一共展示了pn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pn

long long pn(long long n, long long x)
{
    long long s;
    if(n==0)
        s=1;
    else if(n==1)
        s=x;
    else
        s=((2*n-1)*x*pn(n-1,x)-(n-1)*pn(n-2,x))/n;
    return s;
}
开发者ID:zning1994,项目名称:practice,代码行数:11,代码来源:递归法求n阶勒让德多项式前10项的值.c

示例2: assert

void vis_brd::_drw_fld(int i, int j, bool hlght)
{
	assert(0 <= i && 0 <= j);
	assert(i < snpsht_.get_wdth() && j < snpsht_.get_hght());
	plr_clr p = snpsht_.get_cell(i + j * snpsht_.get_wdth());
	static const int spc = fld_sz / 8;

	QPainter pnt(this);

	/**
	 * Step 1: Draw the bounding rectangle.
	 */
	if (hlght == false)
	{
		QPen pn(Qt::black);
		pn.setWidth(wdt);
		pnt.setBrush(QColor(250, 250, 200));
		pnt.setPen(pn);
	}
	else
	{
		QPen pn(Qt::red);
		pn.setWidth(wdt);
		pnt.setBrush(QColor(250, 250, 225));
		pnt.setPen(pn);
	}

	int fr_x = i * fld_sz + wdt / 2;
	int fr_y = j * fld_sz + wdt / 2;

	pnt.drawRect(fr_x, fr_y, fld_sz, fld_sz);

	/**
	 * Step 2: Draw the circle.
	 */
	{
		QPen pn(Qt::black);
		pn.setWidth(wdt);
		if (p == pc_wht)
			pnt.setBrush(QBrush(Qt::red));
		else if (p == pc_blc)
			pnt.setBrush(QBrush(Qt::black));
		pnt.setPen(pn);
	}

	if (p != pc_free)
		pnt.drawEllipse(fr_x + spc, fr_y + spc, fld_sz - 2 * spc, fld_sz - 2 * spc);
}
开发者ID:NikolaYolov,项目名称:fmi-reversi,代码行数:48,代码来源:vis_brd.cpp

示例3: pn

static void pn (const te_expr *n, int depth) {
    printf("%*s", depth, "");

    if (n->bound) {
        printf("bound %p\n", n->bound);
    } else if (n->left == 0 && n->right == 0) {
        printf("%f\n", n->value);
    } else if (n->left && n->right == 0) {
        printf("f1 %p\n", n->left);
        pn(n->left, depth+1);
    } else {
        printf("f2 %p %p\n", n->left, n->right);
        pn(n->left, depth+1);
        pn(n->right, depth+1);
    }
}
开发者ID:cguebert,项目名称:Panda,代码行数:16,代码来源:tinyexpr.c

示例4: main

int main(int argc, char** argv)
{
	ros::init(argc, argv, "USB2_F_7001_node");
	ros::NodeHandle n;
	ros::NodeHandle pn("~");
	
	rx_pub = n.advertise<can_msgs::CANFrame>("/can_bus_rx", 10);
    ros::Subscriber tx_sub = n.subscribe<can_msgs::CANFrame>("/can_bus_tx", 10, CANFrameToSend);
	
	std::string port;
	//pn.param<std::string>("port", port, "/dev/ttyUSB0");
	pn.param<std::string>("port", port, "/dev/serial/by-id/usb-LAWICEL_CANUSB_LWVPMVC4-if00-port0"); 
    int bit_rate;
	pn.param("bit_rate", bit_rate, 5);
    
    can_usb_adapter = new USB2_F_7001(&port, &CANFrameReceived);
    
    ROS_INFO("USB2_F_7001 -- Opening CAN bus...");
    if( !can_usb_adapter->openCANBus((USB2_F_7001_BitRate)bit_rate) )
    {
        ROS_FATAL("USB2_F_7001 -- Failed to open the CAN bus!");
		ROS_BREAK();
    }
    ROS_INFO("USB2_F_7001 -- The CAN bus is now open!");
    
	ros::spin();
    
    delete can_usb_adapter;
    
  	return(0);
}
开发者ID:kyoto-u-shinobi,项目名称:kamui,代码行数:31,代码来源:USB2_F_7001_node.cpp

示例5: main

int main(int argc, char** argv)
{
	ros::init(argc, argv, "kinect_simulated_tilt");
	ros::NodeHandle n;
	ros::NodeHandle pn("~");

	ros::Duration(0.5).sleep();
	ros::Publisher tilt_pub = n.advertise<std_msgs::Float64>("cur_tilt_angle", 10);
	ros::Subscriber sub_tilt_angle = n.subscribe("tilt_angle", 10, setTiltAngle);
	ros::Rate loop_rate(30);

	while (ros::ok()) {
		// tilt angle
		std_msgs::Float64 angle_msg;
		angle_msg.data = pitch * 180.0 / M_PI;

		//send the joint state and transform
		tilt_pub.publish(angle_msg);

		ros::spinOnce();

		// This will adjust as needed per iteration
		loop_rate.sleep();
	}

	return 0;
}
开发者ID:youbot-hackathon,项目名称:youbot-apps,代码行数:27,代码来源:kinect_simulated_tilt.cpp

示例6: main

int main(int argc, char** argv)
{
  	ros::init(argc, argv, "roomba_tf_setup");
  	ros::NodeHandle n;
  	ros::NodeHandle pn("~");
  	
  	std::string base_frame_id;
	std::string laser_frame_id;
	std::string nose_frame_id;
	pn.param<std::string>("base_frame_id", base_frame_id, "base_link");
	pn.param<std::string>("laser_frame_id", laser_frame_id, "base_laser");
	pn.param<std::string>("nose_frame_id", nose_frame_id, "base_nose");

  	ros::Rate r(50);

  	tf::TransformBroadcaster broadcaster;

  	while(n.ok())
	{
    		broadcaster.sendTransform(tf::StampedTransform(tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.065, 0.000, 0.240)),
        	ros::Time::now(), base_frame_id.c_str(), laser_frame_id.c_str()));
        	
        	broadcaster.sendTransform(tf::StampedTransform(tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.120, 0.000, 0.160)),
        	ros::Time::now(), base_frame_id.c_str(), nose_frame_id.c_str()));
		
    		r.sleep();
  	}
}
开发者ID:AlfaroP,项目名称:isr-uc-ros-pkg,代码行数:28,代码来源:tf_broadcaster_nose.cpp

示例7: diagnosticPub_

SickTimCommon::SickTimCommon(AbstractParser* parser) :
    diagnosticPub_(NULL), expectedFrequency_(15.0), parser_(parser)
    // FIXME All Tims have 15Hz?
{
  dynamic_reconfigure::Server<sick_tim::SickTimConfig>::CallbackType f;
  f = boost::bind(&sick_tim::SickTimCommon::update_config, this, _1, _2);
  dynamic_reconfigure_server_.setCallback(f);

  // datagram publisher (only for debug)
  ros::NodeHandle pn("~");
  pn.param<bool>("publish_datagram", publish_datagram_, false);
  if (publish_datagram_)
    datagram_pub_ = nh_.advertise<std_msgs::String>("datagram", 1000);

  // scan publisher
  pub_ = nh_.advertise<sensor_msgs::LaserScan>("scan", 1000);

  diagnostics_.setHardwareID("none");   // set from device after connection
  diagnosticPub_ = new diagnostic_updater::DiagnosedPublisher<sensor_msgs::LaserScan>(pub_, diagnostics_,
          // frequency should be target +- 10%.
          diagnostic_updater::FrequencyStatusParam(&expectedFrequency_, &expectedFrequency_, 0.1, 10),
          // timestamp delta can be from 0.0 to 1.3x what it ideally is.
          diagnostic_updater::TimeStampStatusParam(-1, 1.3 * 1.0/expectedFrequency_));
  ROS_ASSERT(diagnosticPub_ != NULL);
}
开发者ID:uobirlab,项目名称:BARC_pioneer,代码行数:25,代码来源:sick_tim_common.cpp

示例8: Q_D

void QDeclarativeRectangle::generateRoundedRect()
{
    Q_D(QDeclarativeRectangle);
    if (d->rectImage.isNull()) {
        const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
        const int radius = qCeil(d->radius);    //ensure odd numbered width/height so we get 1-pixel center

        QString key = QLatin1String("q_") % QString::number(pw) % d->color.name() % QString::number(d->color.alpha(), 16) % QLatin1Char('_') % QString::number(radius);
        if (d->pen && d->pen->isValid())
            key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16);

        if (!QPixmapCache::find(key, &d->rectImage)) {
            d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
            d->rectImage.fill(Qt::transparent);
            QPainter p(&(d->rectImage));
            p.setRenderHint(QPainter::Antialiasing);
            if (d->pen && d->pen->isValid()) {
                QPen pn(QColor(d->pen->color()), d->pen->width());
                p.setPen(pn);
            } else {
                p.setPen(Qt::NoPen);
            }
            p.setBrush(d->color);
            if (pw%2)
                p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
            else
                p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);

            // end painting before inserting pixmap
            // to pixmap cache to avoid a deep copy
            p.end();
            QPixmapCache::insert(key, d->rectImage);
        }
    }
}
开发者ID:maxxant,项目名称:qt,代码行数:35,代码来源:qdeclarativerectangle.cpp

示例9: pn

/**
 * Prints an integer value
 * @param input The unsigned value.
 */
void pn(unsigned int input)
{
	int ldb = input % 10;
	int n = (int) input / 10;
	if (input > 9) pn(n);
	printChar(ldb + 48);
}
开发者ID:yannickulrich,项目名称:LionOS.core,代码行数:11,代码来源:screen.c

示例10: JointTrajectoryGenerator

    JointTrajectoryGenerator(std::string name) : 
      as_(ros::NodeHandle(), "joint_trajectory_generator",
          boost::bind(&JointTrajectoryGenerator::executeCb, this, _1),
          false),
      ac_("joint_trajectory_action"),
      got_state_(false)
      {
        ros::NodeHandle n;
        state_sub_ = n.subscribe("state", 1, &JointTrajectoryGenerator::jointStateCb, this);

        ros::NodeHandle pn("~");
        pn.param("max_acc", max_acc_, 0.5);
        pn.param("max_vel", max_vel_, 5.0);

        // Load Robot Model
        ROS_DEBUG("Loading robot model");
        std::string xml_string;
        ros::NodeHandle nh_toplevel;
        if (!nh_toplevel.getParam(std::string("/robot_description"), xml_string))
          throw ros::Exception("Could not find paramter robot_description on parameter server");

        if(!robot_model_.initString(xml_string)) 
          throw ros::Exception("Could not parse robot model");

        ros::Rate r(10.0);
        while(!got_state_){
          ros::spinOnce();
          r.sleep();
        }

        ac_.waitForServer();
        as_.start();
        ROS_INFO("%s: Initialized",name.c_str());
      }
开发者ID:PR2,项目名称:pr2_common_actions,代码行数:34,代码来源:joint_trajectory_generator.cpp

示例11: main

int main(int argc, char *argv[])
{
    ros::init(argc, argv, "kml_extractor_node");
    ros::NodeHandle n;
    ros::NodeHandle pn("~");

    signal(SIGINT, sigintHandler);

    std::string header_file_path, footer_file_path;
    pn.param<std::string>("kml_file", kml_filename, "out.kml");
    pn.param<std::string>("coordinates_filename", coordinates_utm_filename, "coordinates_utm.txt");
    pn.param<std::string>("header_file_path", header_file_path, "/home/joao/catkin_ws_isrobotcar/src/kml_extractor/src/header.yaml");
    pn.param<std::string>("footer_file_path", footer_file_path, "/home/joao/catkin_ws_isrobotcar/src/kml_extractor/src/footer.yaml");

    kml_file.open(kml_filename.c_str(), std::ios_base::out | std::ios_base::trunc);
    coordinates_utm_file.open(coordinates_utm_filename.c_str(), std::ios_base::out | std::ios_base::trunc);
    std::ifstream header_kml(header_file_path.c_str());
    footer_kml.open(footer_file_path.c_str(), std::ios_base::in);

    while(header_kml.good())
    {
        char c = header_kml.get();       // get character from file
            if (header_kml.good())
             kml_file << c;
    }
    kml_file << std::endl;

    ros::Subscriber fix_sub = n.subscribe("fix", 30, callbackFix);
    ros::Subscriber odom_sub = n.subscribe("odom", 30, callbackOdom);

    ros::spin();

    return 0;
}
开发者ID:idaohang,项目名称:ros_gps_useful_tools,代码行数:34,代码来源:kml_extractor_node.cpp

示例12: key

  db_err udb_server::find_dbr_cb(const char *key_str, const char *pn_str,
                                 http_response *rsp)
  {
    std::string key(key_str);
    std::string pn(pn_str);
    db_record *dbr = seeks_proxy::_user_db->find_dbr(key,pn);
    if (!dbr)
      {
        return DB_ERR_NO_REC;
      }
    else
      {
        // serialize dbr.
        std::string str;
        dbr->serialize(str);

        // fill up response.
        size_t body_size = str.length() * sizeof(char);
        if (!rsp->_body)
          rsp->_body = (char*)std::malloc(body_size);
        rsp->_content_length = body_size;
        for (size_t i=0; i<str.length(); i++)
          rsp->_body[i] = str[i];
        delete dbr;
        return SP_ERR_OK;
      }
  }
开发者ID:TetragrammatonHermit,项目名称:seeks,代码行数:27,代码来源:udb_server.cpp

示例13: main

int
main (int argc, char **argv)
{
  ros::init (argc, argv, "pgr_camera");

  typedef dynamic_reconfigure::Server < pgr_camera_driver::PGRCameraConfig > Server;
  Server server;

  try
  {
    boost::shared_ptr < PGRCameraNode > pn (new PGRCameraNode (ros::NodeHandle(),ros::NodeHandle("~")));

    Server::CallbackType f = boost::bind (&PGRCameraNode::configure, pn, _1, _2);
    server.setCallback (f);

    ros::spin ();

  } catch (std::runtime_error & e)
  {
    ROS_FATAL ("Uncaught exception: '%s', aborting.", e.what ());
    ROS_BREAK ();
  }

  return 0;

}
开发者ID:ccny-ros-pkg,项目名称:ccny_camera_drivers,代码行数:26,代码来源:pgr_camera_node.cpp

示例14: dF2du

rowvec dF2du(unsigned row, irowvec causes, const DataPairs &data, const gmat &sigma, vec u){

  // Attaining variance covariance matrix etc. (conditional on u)
  vmat cond_sig = sigma(causes);
  vec cond_mean = cond_sig.proj*u;

  rowvec alp = data.alpha_get(row, causes);
  rowvec gam = data.gamma_get(row, causes);
  colvec alpgam = alp.t() - gam.t();

  double cdf = pn(alpgam, cond_mean, cond_sig.vcov);

  vec ll = sqrt(diagvec(cond_sig.vcov));
  mat Lambda = diagmat(ll);
  mat iLambda = diagmat(1/ll);
  mat R = iLambda*cond_sig.vcov*iLambda;
  mat LR = Lambda*R;
  double r = R(0,1);

  vec ytilde = iLambda*(alpgam - cond_mean);
  vecmat D = Dbvn(ytilde(0),ytilde(1),r);
  mat M = -LR*D.V;

  vec dcdfdu = trans(cond_sig.proj)*cond_sig.inv*M;

  rowvec dF2du_1 = data.dpiduMarg_get(row, causes(0), 0)*data.piMarg_get(row, causes(1), 1)*cdf ;
  rowvec dF2du_2 = data.dpiduMarg_get(row, causes(1), 1)*data.piMarg_get(row, causes(0), 0)*cdf;
  vec dF2du_3 = data.piMarg_get(row, causes(0), 0)*data.piMarg_get(row, causes(1), 1)*dcdfdu;

  rowvec dF2du = dF2du_1 + dF2du_2 + dF2du_3.t();
  return(dF2du);
};
开发者ID:kkholst,项目名称:mcif,代码行数:32,代码来源:functions.cpp

示例15: TEST_F

TEST_F(PubNubCppTest, PubNubInitDone) {
	{
		PubNub pn("demo", "demo", &cb, NULL);
		EXPECT_TRUE(initCalled);
	}
	EXPECT_TRUE(doneCalled);
}
开发者ID:Ashar786,项目名称:c,代码行数:7,代码来源:pubnubcpptest.cpp


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