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

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

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

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

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

示例1: formatBalance

std::string formatBalance(bigint const& _b){    ostringstream ret;    u256 b;    if (_b < 0)    {        ret << "-";        b = (u256)-_b;    }    else        b = (u256)_b;    if (b > units()[0].first * 10000)    {        ret << (b / units()[0].first) << " " << units()[0].second;        return ret.str();    }    ret << setprecision(5);    for (auto const& i: units())        if (i.first != 1 && b >= i.first * 100)        {            ret << (double(b / (i.first / 1000)) / 1000.0) << " " << i.second;            return ret.str();        }    ret << b << " wei";    return ret.str();}
开发者ID:daukantas,项目名称:cpp-ethereum,代码行数:27,


示例2: find_frame

bool Block::flag (const symbol key) const{   const Frame& frame = find_frame (key);  if (frame.is_reference (key))    return flag (expand_reference (key));  //Handle primitive flags.  Attribute::type type = lookup (key);  if (type != Attribute::Model)    return frame.flag (key);   // Handle boolean objects.  daisy_assert (type == Attribute::Model);  daisy_assert (frame.component (key) == Boolean::component);  daisy_assert (frame.check (*this));  std::unique_ptr<Boolean> boolean (Librarian::build_frame<Boolean>                                 (*this, frame.model (key), key));  daisy_assert (boolean.get ());  daisy_assert (boolean->initialize (units (), *this, msg ()));  daisy_assert (boolean->check (units (), *this, msg ()));  boolean->tick (units (), *this, msg ());  daisy_assert (!boolean->missing (*this));  return boolean->value (*this);}
开发者ID:perabrahamsen,项目名称:daisy-model,代码行数:25,


示例3: LOG_AND_THROW

OSQuantityVector& OSQuantityVector::operator+=(OSQuantityVector rVector) {  if (this == &rVector) {    (*this) *= 2.0;    return *this;  }  if (units() != rVector.units()) {    LOG_AND_THROW("Cannot add OSQuantityVectors with different units (" << units()                  << " and " << rVector.units() << ").");  }  unsigned n = size();  if (rVector.size() != n) {    LOG_AND_THROW("Cannot add vectors of different sizes.");  }  if (scale() != rVector.scale()) {    rVector.setScale(scale().exponent);  }  DoubleVector rValues = rVector.values();  for (unsigned i = 0; i < n; ++i) {    m_values[i] += rValues[i];  }  if (isTemperature() && rVector.isTemperature()) {    if (!isAbsolute() && rVector.isAbsolute()) {      setAsAbsolute();    }  }  return *this;}
开发者ID:jamiebull1,项目名称:OpenStudio,代码行数:33,


示例4: main

intmain(int argc, char **argv){	register int i;	register char *file;	struct unit u1, u2;	double f;	if(argc>1 && *argv[1]=='-') {		argc--;		argv++;		dumpflg++;	}	file = dfile;	if(argc > 1)		file = argv[1];	if ((inp = fopen(file, "r")) == NULL) {		printf("no table/n");		exit(1);	}	sigset(SIGFPE, fperr);	init();loop:	fperrc = 0;	printf("you have: ");	if(convr(&u1))		goto loop;	if(fperrc)		goto fp;loop1:	printf("you want: ");	if(convr(&u2))		goto loop1;	for(i=0; i<NDIM; i++)		if(u1.dim[i] != u2.dim[i])			goto conform;	f = u1.factor/u2.factor;	if(fperrc)		goto fp;	printf("/t* %e/n", f);	printf("/t/ %e/n", 1./f);	goto loop;conform:	if(fperrc)		goto fp;	printf("conformability/n");	units(&u1);	units(&u2);	goto loop;fp:	printf("underflow or overflow/n");	goto loop;}
开发者ID:Sunshine-OS,项目名称:svr4-userland,代码行数:56,


示例5: LOG_AND_THROW

void OSQuantityVector::push_back(Quantity q) {  if (!(q.units() == units())) {    LOG_AND_THROW("Quantity " << q << " is incompatible with this OSQuantityVector, which has "                  "units " << units() << ".");  }  else if (q.scale() != scale()) {    q.setScale(scale().exponent);  }  m_values.push_back(q.value());}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:10,


示例6:

std::vector<Quantity> OSQuantityVector::quantities() const {  QuantityVector result;  for (double value : values()) {    result.push_back(Quantity(value,units()));  }  return result;}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:7,


示例7: units

void LogicAnalyzerDisplay::updateHeaders(void){    const size_t numElems = _tableView->columnCount();    double factor = 1.0;    QString units("s");    double timeSpan = numElems/_sampleRate;    if (timeSpan <= 100e-9)    {        factor = 1e9;        units = "ns";    }    else if (timeSpan <= 100e-6)    {        factor = 1e6;        units = "us";    }    else if (timeSpan <= 100e-3)    {        factor = 1e3;        units = "ms";    }    if (_xAxisMode == "INDEX") for (size_t i = 0; i < numElems; i++)    {        _tableView->setHorizontalHeaderItem(i, new QTableWidgetItem(QString::number(i)));    }    if (_xAxisMode == "TIME") for (size_t i = 0; i < numElems; i++)    {        double t = i*_sampleRate/factor;        _tableView->setHorizontalHeaderItem(i, new QTableWidgetItem(QString::number(t)+units));    }}
开发者ID:m0x72,项目名称:pothos,代码行数:34,


示例8: assert

OSQuantityVector& OSQuantityVector::operator-=(Quantity rQuantity) {  if (isTemperature() && rQuantity.isTemperature()) {    if (isAbsolute() && rQuantity.isAbsolute()) {      // units must be the same, check that exponent on this is 1      std::vector<std::string> bus = m_units.baseUnits();      assert(bus.size() == 1);      if (m_units.baseUnitExponent(bus[0]) == 1) {        setAsRelative();        rQuantity.setAsRelative();      }    } else if (!isAbsolute() && rQuantity.isAbsolute()) {      setAsAbsolute();    } else if (isAbsolute() && !rQuantity.isAbsolute()) {      rQuantity.setAsAbsolute();    }  }  if (units() != rQuantity.units()) {    LOG_AND_THROW("Cannot subtract OSQuantityVector and Quantity with different units (" << units()                  << " and " << rQuantity.units() << ").");  }  if (scale() != rQuantity.scale()) {    rQuantity.setScale(scale().exponent);  }  double value = rQuantity.value();  for (unsigned i = 0, n = size(); i < n; ++i) {    m_values[i] -= value;  }  return *this;}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:34,


示例9: setAsAbsolute

OSQuantityVector& OSQuantityVector::operator+=(Quantity rQuantity) {  if (isTemperature() && rQuantity.isTemperature()) {    if (!isAbsolute() && rQuantity.isAbsolute()) {      setAsAbsolute();    } else if (isAbsolute() && !rQuantity.isAbsolute()) {      rQuantity.setAsAbsolute();    }  }  if (units() != rQuantity.units()) {    LOG_AND_THROW("Cannot add OSQuantityVector and Quantity with different units (" << units()                  << " and " << rQuantity.units() << ").");  }  if (scale() != rQuantity.scale()) {    rQuantity.setScale(scale().exponent);  }  double value = rQuantity.value();  for (unsigned i = 0, n = size(); i < n; ++i) {    m_values[i] += value;  }  return *this;}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:26,


示例10: get_adjacent_tiles

bool display_context::would_be_discovered(const map_location & loc, int side_num, bool see_all){	map_location adjs[6];	get_adjacent_tiles(loc,adjs);	for (const map_location &u_loc : adjs)	{		unit_map::const_iterator u_it = units().find(u_loc);		if (!u_it.valid()) {			continue;		}		const unit & u = *u_it;		if (get_team(side_num).is_enemy(u.side()) && !u.incapacitated()) {			// Enemy spotted in adjacent tiles, check if we can see him.			// Watch out to call invisible with see_all=true to avoid infinite recursive calls!			if(see_all) {				return true;			} else if (!get_team(side_num).fogged(u_loc)			&& !u.invisible(u_loc, *this, true)) {				return true;			}		}	}	return false;}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:25,


示例11: sqlite3_mprintf

ModelEntry DataStore::findModelEntryByName(std::string name) {  const char *q = sqlite3_mprintf("select name, data, units from model where name = '%q'", name.c_str());  sqlite3_stmt *stmt = query(q);  int rc;  while((rc = sqlite3_step(stmt)) != SQLITE_DONE) {    switch(rc) {      case SQLITE_ROW:        std::string name(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 0)));        int len = sqlite3_column_bytes(stmt, 1);        void *data = std::malloc(len);        std::memcpy(data, sqlite3_column_blob(stmt, 1), len);        std::string units(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 2)));        ModelEntry entry(name, data, len, units);        sqlite3_free((void *) q);        sqlite3_finalize(stmt);        return entry;    }  }  throw std::runtime_error("No model for given id");}
开发者ID:RemchoResearchGroup,项目名称:OccuChrome-GitHub,代码行数:25,


示例12: storeFieldData

void telemetryDataPoint::storeFieldData(int field, double value, int unitType){  long double cuVal=units(value,unitType,fieldUnit(field));  if (field==fieldIndex("Time"))              time=cuVal;  if (field==fieldIndex("Frequency"))         frequency=cuVal;  if (field==fieldIndex("Acceleration (X)"))  accX=cuVal;  if (field==fieldIndex("Acceleration (Y)"))  accY=cuVal;  if (field==fieldIndex("Acceleration (Z)"))  accZ=cuVal;  if (field==fieldIndex("Gyroscope (X)"))     gyrX=cuVal;  if (field==fieldIndex("Gyroscope (Y)"))     gyrY=cuVal;  if (field==fieldIndex("Gyroscope (Z)"))     gyrZ=cuVal;  if (field==fieldIndex("Magnetometer (X)"))  magX=cuVal;  if (field==fieldIndex("Magnetometer (Y)"))  magY=cuVal;  if (field==fieldIndex("Magnetometer (Z)"))  magZ=cuVal;  if (field==fieldIndex("Roll"))              roll=cuVal;  if (field==fieldIndex("Pitch"))             pitch=cuVal;  if (field==fieldIndex("Yaw"))               yaw=cuVal;  if (field==fieldIndex("Latitude"))          latitude=cuVal;  if (field==fieldIndex("Longitude"))         longitude=cuVal;  if (field==fieldIndex("Altitude"))          altitude=cuVal;  if (field==fieldIndex("Track"))             track=cuVal;  if (field==fieldIndex("Speed"))             speed=cuVal;  if (field==fieldIndex("hDOP"))              hDOP=cuVal;  if (field==fieldIndex("vDOP"))              vDOP=cuVal;  if (field==fieldIndex("mDOP"))              mDOP=cuVal;  if (field==fieldIndex("Temperature"))       temperature=cuVal;  if (field==fieldIndex("Voltage"))           voltage=cuVal;}
开发者ID:TimB-QNA,项目名称:AeroTelemetry,代码行数:27,


示例13: get_team

bool display_context::unit_can_move(const unit &u) const{	if(!u.attacks_left() && u.movement_left()==0)		return false;	// Units with goto commands that have already done their gotos this turn	// (i.e. don't have full movement left) should have red globes.	if(u.has_moved() && u.has_goto()) {		return false;	}	const team &current_team = get_team(u.side());	map_location locs[6];	get_adjacent_tiles(u.get_location(), locs);	for(int n = 0; n != 6; ++n) {		if (map().on_board(locs[n])) {			const unit_map::const_iterator i = units().find(locs[n]);			if (i.valid() && !i->incapacitated() &&			    current_team.is_enemy(i->side())) {				return true;			}			if (u.movement_cost(map()[locs[n]]) <= u.movement_left()) {				return true;			}		}	}	return false;}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:31,


示例14: addDisplacementAboutAxisParams

void addDisplacementAboutAxisParams(InputParameters& params){  MooseEnum units("degrees radians");  params.addRequiredParam<FunctionName>("function", "The function providing the angle of rotation.");  params.addRequiredParam<MooseEnum>("angle_units",units,"The units of the angle of rotation. Choices are:" + units.getRawNames());  params.addRequiredParam<RealVectorValue>("axis_origin","Origin of the axis of rotation");  params.addRequiredParam<RealVectorValue>("axis_direction","Direction of the axis of rotation");}
开发者ID:Biyss,项目名称:moose,代码行数:8,


示例15: modes_init

// ---------------------------------------------------------------------------/// Initializes spectrum using tag_photoDF_parameters(int param, void *pntr) to get parameter of the photo-DF.// ---------------------------------------------------------------------------// XXX staticvoidmodes_init (int m1, int m2, double gamma_cutOff, double phase){  int    mz;  double V0, omega2_pe; 												// Parameters of the photo-DF.  char name[50];  tag_photoDF_parameters (mc_photoDF_V0, &V0);										// Takes photo-DF parameters from creator.  tag_photoDF_parameters (mc_photoDF_omega2_pe, &omega2_pe);  modeN = m2 - m1 + 1;  modeM1 = m1;  modePhase = (double*) calloc (modeN, sizeof (double));  modeGamma = (double*) calloc (modeN, sizeof (double));  const double unit_alpha = units (mc_r0)/(units (mc_t0)*units (mc_v0));						// [omega/kV] with k = 2/pi//lambda.  const double omega_pe = sqrt (omega2_pe);  for (mz = m1 ; mz <= m2 ; mz++)  {    double kz, gammaDivOmegaPE;												// Parameters of the mode.    kz = 2.0*mc_pi*mz/Lz;    gammaDivOmegaPE = kz*V0/(unit_alpha*omega_pe)*dispFunc_s (unit_alpha*omega_pe/(kz*V0));    if (gammaDivOmegaPE < gamma_cutOff)      continue;    modeGamma[mz-modeM1] = gammaDivOmegaPE;    modePhase[mz-modeM1] = (phase < 0) ? 2.0*mc_pi*rand ()/(double) RAND_MAX : phase;  }  MPI_Bcast (modePhase, modeN, MPI_DOUBLE, 0, MPI_COMM_WORLD);								// Syncronizes global random parameters.  sprintf (name, "output/tag_seed_PITS(%03d).dat", cpu_here);  FILE *fp = cfg_open (name, "wt", "tag_seed2Stream_singleMode");  fprintf (fp, "variables = mode, E<sub>0</sub>, <greek>f/p</greek>, <greek>g/w</greek><sub>pe</sub>, ");  fprintf (fp, "<greek>g</greek><sub>WE</sub>, k<sub>z</sub>, /"2.0/(h3*kz)*sin (kz*h3/2.0) - 1.0/"/n");  fprintf (fp, "zone t = /"L_z = %e, `w_p_e = %e/", f = point/n", Lz, sqrt (omega2_pe));  for (mz = m1 ; mz <= m2 ; mz++)											// Prints spectrum of initial seed.  {    double kz, gamma;													// Parameters of the mode.    kz = 2*mc_pi*mz/Lz;    gamma = modeGamma[mz-modeM1];    fprintf (fp, "%d %e %e %e %e %e %e/n", mz, dEz, modePhase[mz-modeM1]/mc_pi, gamma, 2.0*gamma*omega_pe, kz, 2.0/(h3*kz)*sin (kz*h3/2.0) - 1.0);  }  fclose (fp);}
开发者ID:binarycode,项目名称:mandor3,代码行数:50,


示例16: side_units

int display_context::side_units(int side) const{	int res = 0;	for (const unit &u : units()) {		if (u.side() == side) ++res;	}	return res;}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:8,


示例17: side_upkeep

int display_context::side_upkeep(int side) const{	int res = 0;	for (const unit &u : units()) {		if (u.side() == side) res += u.upkeep();	}	return res;}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:8,


示例18: units

void HudSettingsPage::LoadSettings(){    ConVarRef units("mom_speedometer_units"), sync_type("mom_strafesync_type"),        sync_color("mom_strafesync_colorize");    m_pSpeedometerUnits->ActivateItemByRow(units.GetInt() - 1);    m_pSyncType->ActivateItemByRow(sync_type.GetInt() - 1);    m_pSyncColorize->ActivateItemByRow(sync_color.GetInt());}
开发者ID:Asunaya,项目名称:game,代码行数:8,


示例19: while

void MXPImporter::loadIngredients( QTextStream &stream, Recipe &recipe ){	//============ingredients=================//	stream.skipWhiteSpace();	( void ) stream.readLine();	QString current = stream.readLine();	if ( !current.contains( "NONE" ) && !current.isEmpty() ) {		while ( !current.isEmpty() && !stream.atEnd() ) {			Ingredient new_ingredient;			//amount			QString amount_str = current.mid( 0, 9 ).simplified();			if ( !amount_str.isEmpty() )  // case of amount_str.isEmpty() correctly handled by class default			{				MixedNumber amount;				QValidator::State state;				state = MixedNumber::fromString( amount_str, amount, false );				if ( state != QValidator::Acceptable )				{					addWarningMsg( i18n( "While loading recipe /"%1/" Invalid amount /"%2/" in the line /"%3/"" , recipe.title, amount_str , current.trimmed() ) );					current = stream.readLine();					continue;				}				new_ingredient.amount = amount.toDouble();			}			//units			QString units( current.mid( 9, 13 ) );			new_ingredient.units = Unit( units.simplified(), new_ingredient.amount );			//name			int dash_index = current.indexOf( "--" );			int length;			if ( dash_index == -1 || dash_index == 24 )  //ignore a dash in the first position (index 24)				length = current.length();			else				length = dash_index - 22;			QString ingredient_name( current.mid( 22, length ) );			new_ingredient.name = ingredient_name.trimmed();			//prep method			if ( dash_index != -1 && dash_index != 24 )  //ignore a dash in the first position (index 24)				new_ingredient.prepMethodList.append( Element(current.mid( dash_index + 2, current.length() ).trimmed()) );			recipe.ingList.append( new_ingredient );			//kDebug()<<"Found ingredient: amount="<<new_ingredient.amount			//  <<", unit:"<<new_ingredient.units			//  <<", name:"<<new_ingredient.name			//  <<", prep_method:"<<prep_method;			current = stream.readLine();		}	}	//else	//	kDebug()<<"No ingredients found.";}
开发者ID:netrunner-debian-kde-extras,项目名称:krecipes,代码行数:58,


示例20: size

OSQuantityVector& OSQuantityVector::operator-=(OSQuantityVector rVector) {  unsigned n = size();  if (this == &rVector) {    clear();    resize(n,0.0);    return *this;  }  if (isTemperature() && rVector.isTemperature()) {    if (isAbsolute() && rVector.isAbsolute()) {      // units must be the same, check that exponent on this is 1      std::vector<std::string> bus = m_units.baseUnits();      assert(bus.size() == 1);      if (m_units.baseUnitExponent(bus[0]) == 1) {        setAsRelative();        rVector.setAsRelative();      }    } else if (!isAbsolute() && rVector.isAbsolute()) {      setAsAbsolute();    } else if (isAbsolute() && !rVector.isAbsolute()) {      rVector.setAsAbsolute();    }  }  if (units() != rVector.units()) {    LOG_AND_THROW("Cannot subtract OSQuantityVectors with different units (" << units()                  << " and " << rVector.units() << ").");  }  if (rVector.size() != n) {    LOG_AND_THROW("Cannot subtract vectors of different sizes.");  }  if (scale() != rVector.scale()) {    rVector.setScale(scale().exponent);  }  DoubleVector rValues = rVector.values();  for (unsigned i = 0; i < n; ++i) {    m_values[i] -= rValues[i];  }  return *this;}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:45,


示例21: units

const unit * display_context::get_visible_unit(const map_location & loc, const team &current_team, bool see_all) const{	if (!map().on_board(loc)) return nullptr;	const unit_map::const_iterator u = units().find(loc);	if (!u.valid() || !u->is_visible_to_team(current_team, *this, see_all)) {		return nullptr;	}	return &*u;}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:9,


示例22: units

bool MERefValue<DimValue>::setValue(QVariant value,QString unit){    int iUnit = units().indexOf(unit);    if(iUnit==-1)        return false;    else        setValue(value,iUnit);    return true;}
开发者ID:SemiSQ,项目名称:OpenModelica,代码行数:9,


示例23: AMMeasurementInfo

AMDetector::operator AMMeasurementInfo() {    return AMMeasurementInfo(name(), description(), units(), axes());    // This is code included from the previous AMDetector(Info) system. This may be important for the transition. [DKC January 14th, 2013]    /*    if(!description().isEmpty())    	return AMMeasurementInfo(description().remove(" "), description(), units(), axes());    else    	return AMMeasurementInfo(name(), name(), units(), axes());    */}
开发者ID:anukat2015,项目名称:acquaman,代码行数:10,



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


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