您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stod函数代码示例

51自学网 2021-06-03 08:23:56
  C++
这篇教程C++ stod函数代码示例写得很实用,希望能帮到您。

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

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

示例1: stod

 void Response::get_header( const string& name, double& value, const double default_value ) const {     try     {         value = stod( get_header( name ) );     }     catch ( const invalid_argument& )     {         value = default_value;     } }
开发者ID:AbdelghaniDr,项目名称:restbed,代码行数:11,


示例2: snprintf

int DatabaseInterface::getFlowData(string experimentName, int flowID,		string label, list<double>& value_list){	int rc = 0; 							//control output flag	int experimentID;	double value; 							//rows values	char strFlowId[INT_BUFFER_SIZE]; 		// FlowID string	char strExperimentId[INT_BUFFER_SIZE]; 	// FlowID string	char* sql = NULL; 						//SQL char[] query	string string_sql; 						//SQL string query	sqlite3_stmt *res; 						//database handle	this->getTraceData(experimentName, "experimentName", &experimentID);	//convert flowID and experimentID to string	snprintf(strFlowId, sizeof(strFlowId), "%d", flowID);	snprintf(strExperimentId, sizeof(strExperimentId), "%d", experimentID);	//create SQL query	string_sql = "select " + label + " from " + capture_table			+ " where  FlowID=/"" + strFlowId + "/" and experimentID=/""			+ strExperimentId + "/";";	sql = new char[string_sql.length() + 1];	strcpy(sql, string_sql.c_str());	//create SQL statement definition	rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);	if (rc != SQLITE_OK)	{		errno = ENOENT;		fprintf(stderr, "Failed to fetch data: %s/n", sqlite3_errmsg(db));		sqlite3_close(db);		databaseInterface_error = 2;		return (1);	}	//capture values until the table finishes	while (true)	{		rc = sqlite3_step(res);		if (rc != SQLITE_ROW)		{			break;		}		value = stod((const char*) sqlite3_column_text(res, 0), NULL);		value_list.push_back(value);	}	//free allocated memory	delete[] sql;	sqlite3_finalize(res);	return (0);}
开发者ID:AndersonPaschoalon,项目名称:CompactTraceDescriptor,代码行数:53,


示例3: trainingFile

std::vector< std::vector< std::vector<double> > > NeuralNetwork::readDataFromFile(std::string fpath){    std::vector< std::vector<double> > inputMatrix;    std::vector< std::vector<double> > outputMatrix;    std::ifstream trainingFile(fpath);    std::string line;    while(getline(trainingFile, line)){        //structure is x_1,...,x_n y_1,y_2,...,y_m (comma and space separated)        int spacePosition = (int)line.find(" ");        int lastCommaPosition = -1;        int nextCommaPosition = (int)line.find(",",lastCommaPosition+1);        //get inputs        std::vector<double> input;        while(nextCommaPosition != std::string::npos && nextCommaPosition < spacePosition){            input.push_back(stod(line.substr(lastCommaPosition+1,nextCommaPosition)));            lastCommaPosition = nextCommaPosition;            nextCommaPosition = (int)line.find(",",nextCommaPosition+1);        }        input.push_back(stod(line.substr(lastCommaPosition+1,spacePosition)));        //get outputs        std::vector<double> output;        lastCommaPosition = spacePosition;        nextCommaPosition = (int)line.find(",",lastCommaPosition+1);        while(nextCommaPosition != std::string::npos && nextCommaPosition < line.length()){            output.push_back(stod(line.substr(lastCommaPosition+1,nextCommaPosition)));            lastCommaPosition = nextCommaPosition;            nextCommaPosition = (int)line.find(",",lastCommaPosition+1);        }        output.push_back(stod(line.substr(lastCommaPosition+1)));        //add these training data points to the training matrices        inputMatrix.push_back(input);        outputMatrix.push_back(output);    }    trainingFile.close();    std::vector< std::vector< std::vector<double> > > dataFromFile;    dataFromFile.push_back(inputMatrix);    dataFromFile.push_back(outputMatrix);    return dataFromFile;}
开发者ID:pontusahlqvist,项目名称:NeuralNetwork,代码行数:41,


示例4: CreatePoint

void CreatePoint(const std::vector<std::string>& command, std::vector<std::shared_ptr<CShape>>& figures, std::vector<std::shared_ptr<sf::Shape>>& drawableFigures){	if (command.size() != 4)	{		throw std::exception("/tError: Invalid parameters count to create point");	}	try	{		double x = stod(command[1]);		double y = stod(command[2]);		figures.push_back(std::make_shared<CPoint>(x, y, command[3]));		std::shared_ptr<sf::Shape> point = std::make_shared<sf::CircleShape>(2.f);		point->setPosition(float(x), float(y));		point->setFillColor(HexToRgb(command[3]));		drawableFigures.push_back(point);	}	catch (const std::exception&)	{		throw std::exception("/tError: Invalid parameters to create point");	}}
开发者ID:JokerSSmile,项目名称:OOP,代码行数:21,


示例5: read

void SimplePhraseTable::read(string filename, bool reverse){    ifstream is(filename.c_str());    for(string line; getline(is,line);){        trim(line);        if(line=="")continue;        vector<string> content;        split_regex(content,line,regex(" => | //|//|//| "));        if(content.size()<3)continue;        vector<string> features;        split_regex(features,content[2],regex(" "));        if(features.size()==1){            double fraccount=(double)stod(features[0]);            (*this)[content[0]][content[1]]=            SimplePhraseInfo(fraccount,fraccount);        }        else if(features.size()==2){            //double count=(double)stod(features[1]);            double fraccount=(double)stod(features[0]);            (*this)[content[0]][content[1]]=            SimplePhraseInfo(fraccount,fraccount);        }        else if(features.size()>=4){            if(reverse){                (*this)[content[1]][content[0]]=                SimplePhraseInfo(stod(features[3]),stod(features[3]));            }            else{                (*this)[content[0]][content[1]]=                SimplePhraseInfo(stod(features[1]),stod(features[1]));            }        }    }    is.close();}
开发者ID:hznlp,项目名称:pbmt,代码行数:35,


示例6: CreateTriangle

void CreateTriangle(const std::vector<std::string>& command, std::vector<std::shared_ptr<CShape>>& figures, std::vector<std::shared_ptr<sf::Shape>>& drawableFigures){	if (command.size() != 9)	{		throw std::exception("/tError: Invalid parameters count to create triangle");	}	try	{		double x1 = stod(command[1]);		double y1 = stod(command[2]);		double x2 = stod(command[3]);		double y2 = stod(command[4]);		double x3 = stod(command[5]);		double y3 = stod(command[6]);		figures.push_back(std::make_shared<CTriangle>(x1, y1, x2, y2, x3,			y3, command[7], command[8]));		std::shared_ptr<sf::ConvexShape> triangle = std::make_shared<sf::ConvexShape>(3);		triangle->setPoint(0, (sf::Vector2f(float(x1), float(y1))));		triangle->setPoint(1, (sf::Vector2f(float(x2), float(y2))));		triangle->setPoint(2, (sf::Vector2f(float(x3), float(y3))));		triangle->setOutlineThickness(3);		triangle->setOutlineColor(HexToRgb(command[7]));		triangle->setFillColor(HexToRgb(command[8]));		drawableFigures.push_back(triangle);	}	catch (const std::exception&)	{		throw std::exception("/tError: Invalid parameters to create triangle");	}}
开发者ID:JokerSSmile,项目名称:OOP,代码行数:30,


示例7: countStuff

Matrix DataCollector::readFromText(string filename, vector<string> &assetNames){	//filename = "Stocks.txt";	unsigned int numAssets, numDates;	countStuff(filename, numAssets, numDates);	//cout << numAssets << "/t" << numDates << endl;	Matrix priceMatrix(numDates, numAssets);	ifstream infile; //input file stream object	infile.open(filename);	if (!infile) {		cerr << "Bad input! Can't open " << filename << endl;		exit(1);	}	unsigned int i = 0;	unsigned int j = 0;	string line;	string token;	double price;	getline(infile, line, '/n');	stringstream ss(line);	while (getline(ss, token, ' '))	{		//cout << token << "/t";		assetNames.push_back(token);	}	//cout << endl;	while (!infile.eof())	{		getline(infile, line, '/n');		stringstream ss(line);		j = 0;		while (getline(ss, token, ','))		{			price = stod(token);			priceMatrix(i, j) = price;			j++;			//cout << price << "/t";		}		//cout << endl;		i++;	}	//cout << priceMatrix << endl;	return priceMatrix;}
开发者ID:myellen,项目名称:Projects,代码行数:52,


示例8: parseShovel

Aris::Core::MSG parseShovel(const std::string &cmd, const map<std::string, std::string> &params){    SHOVEL_PARAM  param;    param.radius=2;    param.periodNum = 7;    for(int i = 0; i < param.periodNum; i++)    {        param.periodCount[i]=3000;    }    for(auto &i:params)    {        if(i.first=="height")        {            param.height=stod(i.second);        }        else if(i.first=="length")        {            param.length=stod(i.second);        }        else if(i.first=="degree")        {            param.rad=stod(i.second)/180*PI;        }        else        {            std::cout<<"parse failed"<<std::endl;            return MSG{};        }    }    Aris::Core::MSG msg;    msg.CopyStruct(param);    std::cout<<"finished parse"<<std::endl;    return msg;}
开发者ID:liujimu,项目名称:RobotIII_Move,代码行数:39,


示例9: Handle_Pressure_Vessel

void Handle_Pressure_Vessel(Initial_Data& InitialParameters, vector<string> Input){	PressureVessel Pressure_Vessel;	int i;	for(i=0;i<(int)Input.size();i++)	{		vector< string > line_content;		if(Test_If_Word_Found(Input[i],"Liquid Volume"))		{			line_content = Tokenise_String_To_String(Input[i]," /t");			// it is mL -> make into m^3			Pressure_Vessel.Liquid_Sample_Volume = stod(line_content[3],NULL)*1e-6;			cout << "Sample Size: " << InitialParameters.PetroOxy.SampleSize << "/n";			line_content.clear();		}		if(Test_If_Word_Found(Input[i],"Gas Volume"))		{			line_content = Tokenise_String_To_String(Input[i]," /t");			// it is mL -> make into m^3			Pressure_Vessel.Gas_Sample_Volume = stod(line_content[3],NULL)*1e-6;			cout << "Sample Size: " << InitialParameters.PetroOxy.SampleSize << "/n";			line_content.clear();		}	}	// Need to think about useful additional information	// Maybe Gas Phase pressure so that we can calculate a concentration in case we do not know it?	// how do I handle a "gap" between expected and actual pressure - mainly from the PetroOxy calculation where I had	// an initial pressure and a max pressure which wasn't fully covered by the oxygen component...	// assume fuel filled the rest? ...	InitialParameters.Pressure_Vessel = Pressure_Vessel;}
开发者ID:DetlevCM,项目名称:chemical-kinetics-solver,代码行数:39,


示例10: plus

void plus(int n){	int len;	char a[100][100] = {0,};	a[n][100] = fir[n][100];	a[n+1][100] = fir[n+1][100];	if( strlen(a[n]) > strlen(a[n+1]) )		len = strlen(a[n]);	else len = strlen(a[n+1]);	reverse(a[n], strlen(a[n]));	reverse(a[n+1], strlen(a[n+1]));	char an[100][100];	int i, up = 0;	for(i=0; i<len; i++){		an[n][i] = (stod(a[n][i]) + stod(a[n+1][i])+up)%10+'0';		if((stod(a[n][i]) + stod(a[n+1][i]) + up) > 9)			up=1;		else up=0;	}}
开发者ID:KiyaLee,项目名称:calculater1,代码行数:22,


示例11: main

int main(int argc, char *argv[]) {    const double def_max_time = {1000.0};    const size_t def_nr_particles {5};    const size_t def_grid_size {10};    double max_time {def_max_time};    size_t nr_particles {def_nr_particles};    size_t grid_size {def_grid_size};    bool is_verbose = false;    char opt {'/0'};    while ((opt = getopt(argc, argv, "t:p:g:vh")) != -1) {        try {            switch (opt) {                case 't':                    max_time = stod(optarg);                    break;                case 'p':                    nr_particles = stoi(optarg);                    break;                case 'g':                    grid_size = stoi(optarg);                    break;                case 'h':                    print_help(std::cout);                    return 0;                case 'v':                    is_verbose = true;                    break;                default:                    print_help(std::cerr);                    return 1;            }        } catch (invalid_argument& e) {            std::cerr << "# error: invalid argument for option -"                      << opt << endl;            print_help(std::cerr);            return 1;        }    }    double time {0.0};    System system(nr_particles, grid_size);    system.print_grid();    while (time < max_time) {        if (is_verbose)            cout << "time = " << time << endl;        if (is_verbose)            system.print_queue();        time += system.update();    }    system.print_grid();    return 0;}
开发者ID:gjbex,项目名称:training-material,代码行数:51,


示例12: Twitter

void ofApp::populate_tw(){	tw_users.clear();	for (int i = 0; i < num_tw_draw ; i++)	{		Twitter *t = new Twitter();		t->set_twitter(twitter_csv.data[rand2[i]][0]);		t->set_user_name(twitter_csv.data[rand2[i]][1]);		t->set_length((t->get_twitter()).length());		t->set_rad_limit(t->get_length() / 2.5);		t->set_rad(1.0 / 100);		t->set_rad_grow(true);		t->set_x(stod(twitter_csv.data[rand2[i]][3]));		t->set_y(stod(twitter_csv.data[rand2[i]][2]));		t->w_div_t = w_div;		t->h_div_t = h_div;		t->w_mult_t = w_mult;		t->h_mult_t = h_mult;		t->w_glob_t = w_glob_add;		t->h_glob_t = h_glob_add;		tw_users.push_back(*t);	}}
开发者ID:sandblasted7,项目名称:resilient21Demo,代码行数:23,


示例13: string

int DataPreprocessor::addIndicators(string fileName){	ifstream inputStream;	inputStream.open(fileName);	ofstream outputStream;	outputStream.open(fileName + string("_preprocessed.csv"));	if (inputStream.is_open() && outputStream.is_open())	{		int closePriceIndex = 4;		int volumeIndex = 5;		int storedPricesCount = 200;		closePrices = list<double>();		string token;		string line;		istringstream ss;		int i;		getline(inputStream, line);		addHeaders(line, indicators, outputStream);		while (getline(inputStream, line))		{			ss = istringstream(line);			i = 0;			outputStream << line;			while (getline(ss, token, ','))			{				if (i == closePriceIndex)				{					if (closePrices.size() == storedPricesCount)					{						closePrices.pop_front();					}					closePrices.push_back(stod(token));				}				i++;			}			addIndicatorValues(outputStream);		}		return 0;	}	else	{		return -1;	}}
开发者ID:qzmp,项目名称:GeneticTrading,代码行数:50,


示例14: stod

exparser::return_type exparser::parse_constant(const std::string& s) {    try {        std::size_t pos = 0;        auto c = stod(s, &pos);        if (pos == s.length())            return return_type(make_constant(c));        else            return return_false;    } catch (std::invalid_argument e) {        return return_false;    } catch (std::out_of_range e) {        throw e;    }}
开发者ID:tomas789,项目名称:dx,代码行数:14,


示例15: split_string

/******************************************************************************Function:	 Split StringsAuthor: 	 Stephanie AthowDescription: 	Parses a csv file, it will break up a comma sperated lineParameters:	in: line		line to break up	in: delim		character to delineate a breakReturns:	data_values		a vector of doubles that contains the year, burned acres					and 12 months of PDSI values******************************************************************************/vector<double> split_string( string line, char delim ){	vector<double> data_values;				// holds data values to be returned	stringstream line_stream( line );		// turn into stream to use getline	string tok;								// holds return from getline	double val;								// holds double val converted from getline	while( getline( line_stream, tok, delim ) )	{		val = stod( tok );		data_values.push_back( val );	}	return data_values;}
开发者ID:stormbreaker,项目名称:WildFireNeuron,代码行数:27,


示例16: ScaleFilterModel

void ScaleFilter::ParseArgument(CommandLineArgModel* arg){	ScaleFilterModel* model = new ScaleFilterModel();	model->Scale = -1;	for (unsigned int index = 0; index < arg->Parameters->size(); index++)	{		if (model->Scale < 0)		{			model->Scale = stod(trim(arg->Parameters->at(index)));		}	} 	arg->ParsedModel = model;}
开发者ID:CyAScott,项目名称:ImageProcessor,代码行数:15,


示例17: Facebook

void ofApp::populate_fb(){	fb_users.clear();	for(int i = 0; i < num_fb_draw ; i++)	{		Facebook *f = new Facebook();		f->set_name(facebook_csv.data[rand[i]][0]);		f->set_category(facebook_csv.data[rand[i]][1]);		f->set_checkins(stod(facebook_csv.data[rand[i]][2]));		f->set_rad_limit(-1.0*stod(facebook_csv.data[rand[i]][2])/10000);		f->set_rad(1.0/100);		f->set_rad_grow(true);		f->set_x(stod(facebook_csv.data[rand[i]][4]));		f->set_y(stod(facebook_csv.data[rand[i]][3]));		f->w_div_f = w_div;		f->h_div_f = h_div;		f->w_mult_f = w_mult;		f->h_mult_f = h_mult;		f->w_glob_f = w_glob_add;		f->h_glob_f = h_glob_add;		fb_users.push_back(*f);			}}
开发者ID:sandblasted7,项目名称:resilient21Demo,代码行数:24,


示例18: CreateLine

void CreateLine(const std::vector<std::string>& command, std::vector<std::shared_ptr<CShape>>& figures, std::vector<std::shared_ptr<sf::Shape>>& drawableFigures){	if (command.size() != 6)	{		throw std::exception("/tError: Invalid parameters count to create line");	}	try	{		double x1 = stod(command[1]);		double y1 = stod(command[2]);		double x2 = stod(command[3]);		double y2 = stod(command[4]);		figures.push_back(std::make_shared<CLineSegment>(x1, y1, x2, y2, command[5]));		std::shared_ptr<sf::Shape> line = std::make_shared<sf::RectangleShape>(sf::Vector2f(float(figures.back()->GetPerimeter()), 3.f));		x2 < x1 ? line->setPosition(float(x2), float(y2)) : line->setPosition(float(x1), float(y1));		line->setRotation(float(std::atan((y2 - y1) / (x2 - x1)) * 180 / C_PI));		line->setFillColor(HexToRgb(command[5]));		drawableFigures.push_back(line);	}	catch (const std::exception&)	{		throw std::exception("/tError: Invalid parameters to create line");	}}
开发者ID:JokerSSmile,项目名称:OOP,代码行数:24,


示例19: solveWithPlaku

void solveWithPlaku(const VREPInterface *interface, const InstanceFileMap *args, const VREPInterface::State &start, const VREPInterface::State &goal) {	dfpair(stdout, "planner", "%s", "Plaku IROS 2014");	typedef PRMLite<VREPInterface, VREPInterface> PRMLite;	typedef PlakuTreeInterface<VREPInterface, VREPInterface, PRMLite> PlakuTreeInterface;	typedef RRT<VREPInterface, VREPInterface, PlakuTreeInterface> Plaku;	unsigned int numberOfPRMVertices = stol(args->value("Number Of PRM Vertices"));	unsigned int numberOfNearestNeighborEdgeConsiderations = stol(args->value("Nearest Neighbors To Consider In PRM Edge Construction"));	double prmCollisionCheckDT = stod(args->value("PRM Collision Check DT"));	PRMLite prmLite(*interface, *interface, start, numberOfPRMVertices, numberOfNearestNeighborEdgeConsiderations, prmCollisionCheckDT);	double alpha = stod(args->value("Plaku Alpha Value"));	double b = stod(args->value("Plaku b Value"));	double stateRadius = stod(args->value("Plaku PRM State Selection Radius"));	PlakuTreeInterface plakuTreeInterface(*interface, *interface, prmLite, start, goal, alpha, b, stateRadius);	// plakuTreeInterface.draw();	Plaku plaku(*interface, *interface, plakuTreeInterface, *args);	plaku.query(start, goal);}
开发者ID:skiesel,项目名称:motionplanningtoolkit,代码行数:24,


示例20: getInitialState

void DescentOptimizer::initialize() {  cout << "Duplex initialization started. It make take a while to analyze the "          "root."       << endl;  double *init = getInitialState();  max = new double[objectiveDimension];  min = new double[objectiveDimension];  vector<string> objectiveMinStringVector =      settings->listValues("objective", "uid-objective.min");  vector<string> objectiveMaxStringVector =      settings->listValues("objective", "uid-objective.max");  for (int i = 0; i < objectiveDimension; i++) {    min[i] = stod(objectiveMinStringVector[i]);    max[i] = stod(objectiveMaxStringVector[i]);  }  stat = new Stat(settings, max, min, opt);  // Setting up the root node  State *root = new State(parameterDimension, objectiveDimension);  root->setParameter(init);  root->setID(0);  root->setParentID(-1);  system->eval(root);  insert(0, root, root);}
开发者ID:ahmadyan,项目名称:Duplex,代码行数:24,


示例21: parse

OptionValue parse(option_type t, std::string s) {	switch(t) {	case options::option_type::bool_type:		return options::OptionValue(s == "true");	case option_type::int_type:		return options::OptionValue(stoi(s));	case option_type::double_type:		return options::OptionValue(stod(s));	case option_type::string_type:		return options::OptionValue(s);	case option_type::list_type:		// TODO:		return options::OptionValue(false);	}	return options::OptionValue(false);}
开发者ID:Arroon,项目名称:openage,代码行数:16,


示例22: split

bool Dynamics::from_log_string(Dynamics & d, string &s) {  auto fields = split(s,',');  if(fields.size() <2) {    return false;  }  if(fields[1] != "TD")    return false;  if(fields.size() != 41) {    cerr << "field size was " << fields.size() << endl;    //usb_error_count++;    return false;  }//    self.datetime = dateutil.parser.parse(fields[0])  try {    d.datetime = time_from_string(fields[0]);    d.str = stoi(fields[3]);    d.esc = stoi(fields[5]);    d.ax = stod(fields[7]);    d.ay = stod(fields[8]);    d.az = stod(fields[9]);    d.spur_delta_us = stoul(fields[11]);    d.spur_last_us = stoul(fields[12]);    d.spur_odo = stoi(fields[14]);    d.ping_millimeters = stoi(fields[16]);    d.odometer_front_left =  stoi(fields[18]);    d.odometer_front_left_last_us =  stoul(fields[19]);    d.odometer_front_right = stoi(fields[21]);    d.odometer_front_right_last_us = stoul(fields[22]);    d.odometer_back_left = stoi(fields[24]);    d.odometer_back_left_last_us = stoul(fields[25]);    d.odometer_back_right = stoi(fields[27]);    d.odometer_back_right_last_us = stoul(fields[28]);    d.ms = stoul(fields[30]);    d.us = stoul(fields[32]);    d.yaw = Angle::degrees(stod(fields[34]));    d.pitch = Angle::degrees(stod(fields[35]));    d.roll = Angle::degrees(stod(fields[36]));    d.battery_voltage = stod(fields[38]);    d.calibration_status = stoi(fields[40]);  } catch (...)  {    return false;  }  return true;}
开发者ID:berickson,项目名称:car,代码行数:50,


示例23: get_poses

/** * @brief get_poses * @param dir_root * @param rotations      - Vector of rotation matrix(3,3) * @param pts            - Vector of translation vector * @return 1: file found, 0: file not found */bool get_poses(string dir_root,string sequence,vector<Eigen::Matrix3d> &rotations,vector<geometry_msgs::Point> &pts) {    string poseFile=sequence+".txt";    string infile =(fs::path(dir_root) / fs::path("poses") /poseFile).string();    fstream input(infile.c_str());    string line;    if(!input.good())    {        ROS_ERROR_STREAM ( "Could not read file: " << infile );        return false;    }    //Transform each Isometric matrix stored in the file into a rotation Matrix and a translation vector    while (getline (input,line))    {        stringstream ss(line);        Eigen::Matrix3d rotation;        geometry_msgs::Point pt;        string entry;        int i=0;        while (ss >> entry) {            double value=stod(entry);            switch(i) {            case 3:                pt.x=value;                break;            case 7:                pt.y=value;                break;            case 11:                pt.z=value;                break;            default:                rotation(i/4,i%4)= value;                break;            }            i++;        }        rotations.push_back(rotation);        pts.push_back(pt);    }    input.close();    return true;}
开发者ID:Ellon,项目名称:kitti_player,代码行数:54,


示例24: readString

bool Parser::readDouble(double& val, std::string& del){    std::string str;    readString(str, del);    try    {        val = stod(str);    }    catch (std::invalid_argument ex)    {        return 0;    }    return 1;}
开发者ID:gitter-badger,项目名称:MA-Engine,代码行数:17,


示例25: in

    void SyntaxModel::ReadFromText(const string& file)    {        wifstream in(file);        wstring str;        getline(in, str);        int size = stoi(str);        parameters.resize(size);        vector<wstring> splitted;        for (int it = 0; it < size; ++it)        {            getline(in, str);            splitted = Tools::Split(str, L"/t");            alphabet->LookUpIndex_Adding(splitted[0]);            parameters[it] = stod(splitted[1]);        }        in.close();    }
开发者ID:Samsung,项目名称:veles.nlp,代码行数:18,


示例26: while

// the function only expects a line of doubles separated with whitespaces, has no argument validation vector<double> inputHandler::parseLineOfDoubles (string line) {	vector<double> result;	int pos = 0;	int spacePosition = line.find(" ", pos);	double tmp;	while(spacePosition!=-1)	{		tmp = stod(line.substr(pos, spacePosition));		inputHandler::furthestPoint = max(tmp, inputHandler::furthestPoint);		inputHandler::closestPoint = min(tmp, inputHandler::closestPoint);		result.push_back(tmp);		pos = spacePosition+1;				spacePosition = line.find(" ", pos);	}		return result;}
开发者ID:DarknessSwitch,项目名称:depth_map_parsing,代码行数:19,


示例27: mapFile

	Map* MapLoader::loadMap(const string& mapFileName, const string& constrFileName) {		ifstream mapFile(mapFileName);		LoadableLocationSet locations;		LoadableReaderSet readers;		NameIdMap locationsMap;		string line;		if (mapFile.is_open()) {			unsigned int lId = 0, rId = 0;			while (getline(mapFile, line)) {				Util::trim(line);				// Jump if blank line or comment (starts with '#')				if (line.length() == 0 || line[0] == '#') continue;				vector<string> v = Util::split(line, SEP);				if (v.size() == 5) { // Location line					string name = v[0];					double x = stod(v[1]), y = stod(v[2]),					       w = stod(v[3]), h = stod(v[4]);					locationsMap.insert(NameIdPair(name, lId));					locations.push_back(Location(lId++, name, x, y, w, h));				} else if (v.size() == 3) { // Reader line					string name = v[0];					double x = stod(v[1]), y = stod(v[2]);					readers.push_back(Reader(rId++, name, x, y));				} else throw BadInput();			}		} else throw BadInput();		Map* map = Map::createMap<LoadableLocationSet,LoadableReaderSet>(locations, readers);		ifstream constrFile(constrFileName);		if (constrFile.is_open()) {			while (getline(constrFile, line)) {				Util::trim(line);				// Jump if blank line or comment (starts with '#')				if (line.length() == 0 || line[0] == '#') continue;				vector<string> v = Util::split(line, CSEP);				if (v[0] == "DR") { // Direct Reachability Constraint					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]);					map->setDR(id1, id2);				} else if (v[0] == "DU") { // Direct Unreachability Constraint					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]);					map->setDU(id1, id2);				} else if (v[0] == "LT") { // Latency Constraint					unsigned int id = locationsMap.at(v[1]), latency = stoi(v[2]);					map->setLT(id, latency);				} else if (v[0] == "TT") { // Traveling Time Constraint					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]),						     travelingTime = stoi(v[3]);					map->setTT(id1, id2, travelingTime);				} else throw BadInput();			}		}		return map;	}
开发者ID:Andrey92,项目名称:MHCTrajectorySampler,代码行数:52,


示例28: countLines

Matrix DataCollector::readQMatrixFromText(string filename){	unsigned int rows, columns;	countLines(filename, rows, columns);	ifstream infile; //input file stream object	infile.open(filename);	if (!infile) {		cerr << "Bad input! Can't open " << filename << endl;		exit(1);	}	Matrix Q(rows, 1);	unsigned int i = 0;	string line;	while (getline(infile, line, '/n'))	{		Q(i++, 0) = stod(line);	}	return Q;}
开发者ID:myellen,项目名称:Projects,代码行数:19,


示例29: getString

/*    getDouble        Gets double value from key.    Throws an error if appropriate.    If an error occurs, value is set to zero.*/void KeyValueReader::getDouble(const std::string &key, double &value) const{    string valueString;        // Default value    value = 0.0;        // Get value as string    getString(key, valueString);        // Convert to double    try {        value = stod(valueString);    }    catch (...) {        c_data->printMessage("Error converting value to double");        throw ExceptionStringConversionError;    }}
开发者ID:ckrisgarrett,项目名称:KeyValueReader,代码行数:26,



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


C++ stof函数代码示例
C++ stm32_gpiowrite函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。