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


C++ Variable类代码示例

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


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

示例1: addVariable

void Programme::addVariable(Variable& var) {
	if(hasVar(variables, var.getNom())) {
		throw "La variable \""+var.getNom()+"\" a déjà été instanciée dans le programme \""+nom+"\".";
	}
	else if(hasVar(arguments, var.getNom())) {
		throw "La variable \""+var.getNom()+"\" a déjà été instanciée dans le programme \""+nom+"\" en tant qu'argument.";
	}
	else {
		variables.push_back(var);
	}
}
开发者ID:lumiru,项目名称:algo-analyser,代码行数:11,代码来源:programme.cpp

示例2: ZFUNCTRACE_DEVELOP

ZCsl::Variable* ZCsl::Block::findVar(const ZString& aVarName, ZBoolean aFail)
{
   ZFUNCTRACE_DEVELOP("ZCsl::Block::findVar(const ZString& aVarName, ZBoolean aFail)");
   Variable* v = iVars;
   while (v) {
      if (v->match(aVarName)) return v;
      v = v->iPrev;
   } // while
   if (aFail) iParent->throwExcept(msgVarNotFound, aVarName);
   return v;
} // findVar
开发者ID:OS2World,项目名称:DEV-CSL-UTIL-GNU-C_Scripting_Language,代码行数:11,代码来源:BLOCK.CPP

示例3: getOrCreate

void Variables::removeGlobal(const Symbol& _key, int _iLevel)
{
    Variable* pVar = getOrCreate(_key);
    if (pVar->isGlobal())
    {
        pVar->setGlobal(false);
        pVar->setGlobalValue(NULL);
    }

    remove(pVar, _iLevel);
}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:11,代码来源:variables.cpp

示例4: put

void MmaSink::put(const Variable& x) {
#ifdef DEBUG_MMASINK
  GBStream << "sink:variable " << this << x.cstring() << '\n';
#endif
  MLPutFunction(d_mlink,"ToExpression",1L);
  MLPutString(d_mlink,x.cstring());
#ifdef DEBUG_MMASINK
  checkforerror();
#endif
  ++d_count;
};
开发者ID:lolmid,项目名称:2015-2016,代码行数:11,代码来源:MmaSink.cpp

示例5: process_impl

      std::string process_impl(Variable const & e, bool /*use_parenthesis*/, rt_latex_translator<InterfaceType> const & /*translator*/) const
      {
        std::stringstream ss;

        std::map<id_type, std::string>::const_iterator it = variable_strings_.find(e.id());
        if (it != variable_strings_.end())
          ss << it->second;
        else
          ss << " x_{" << e.id() << "} ";

        return ss.str();
      }
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:12,代码来源:latex.hpp

示例6: Variable

Variable Array::getMember(const Variable &id) {
	if (id.isNumber()) {
		std::list<Variable>::iterator iter = _values.begin();
		std::advance(iter, static_cast<size_t>(id.asNumber()));
		return *iter;
	}

	if (id.isString() && id.asString() == "length")
		return Variable((unsigned long)_values.size());

	return Object::getMember(id);
}
开发者ID:ccawley2011,项目名称:xoreos,代码行数:12,代码来源:array.cpp

示例7: isRecordTypeWithoutSideEffects

static bool isRecordTypeWithoutSideEffects(const Variable& var)
{
    // a type that has no side effects (no constructors and no members with constructors)
    /** @todo false negative: check base class for side effects */
    /** @todo false negative: check constructors for side effects */
    if (var.type() && var.type()->numConstructors == 0 &&
        (var.type()->varlist.empty() || var.type()->needInitialization == Scope::True) &&
        var.type()->derivedFrom.empty())
        return true;

    return false;
}
开发者ID:Drahakar,项目名称:cppcheck,代码行数:12,代码来源:checkunusedvar.cpp

示例8: EvaluateCombinedOutputs

/// <summary>
/// The example shows
/// - how to load a pretrained model and evaluate several nodes by combining their outputs
/// Note: The example uses the model trained by <CNTK>/Examples/Image/Classification/ResNet/Python/TrainResNet_CIFAR10.py
/// Please see README.md in <CNTK>/Examples/Image/Classification/ResNet about how to train the model.
/// The parameter 'modelFilePath' specifies the path to the model.
/// </summary>
void EvaluateCombinedOutputs(const wchar_t* modelFilePath, const DeviceDescriptor& device)
{
    printf("\n===== Evaluate combined outputs =====\n");

    // Load the model.
    FunctionPtr modelFunc = Function::Load(modelFilePath, device);

    // Get node of interest
    std::wstring intermediateLayerName = L"final_avg_pooling";
    FunctionPtr interLayerPrimitiveFunc = modelFunc->FindByName(intermediateLayerName);

    Variable poolingOutput = interLayerPrimitiveFunc->Output();

    // Create a function which combine outputs from the node "final_avg_polling" and the final layer of the model.
    FunctionPtr evalFunc = Combine( { modelFunc->Output(), poolingOutput });
    Variable inputVar = evalFunc->Arguments()[0];

    // Prepare input data.
    // For evaluating an image, you first need to perform some image preprocessing to make sure that the input image has the correct size and layout
    // that match the model inputs.
    // Please note that the model used by this example expects the CHW image layout.
    // inputVar.Shape[0] is image width, inputVar.Shape[1] is image height, and inputVar.Shape[2] is channels.
    // For simplicity and avoiding external dependencies, we skip the preprocessing step here, and just use some artificially created data as input.
    std::vector<float> inputData(inputVar.Shape().TotalSize());
    for (size_t i = 0; i < inputData.size(); ++i)
    {
        inputData[i] = static_cast<float>(i % 255);
    }

    // Create input value and input data map
    ValuePtr inputVal = Value::CreateBatch(inputVar.Shape(), inputData, device);
    std::unordered_map<Variable, ValuePtr> inputDataMap = { { inputVar, inputVal } };

    // Create output data map. Using null as Value to indicate using system allocated memory.
    // Alternatively, create a Value object and add it to the data map.
    Variable modelOutput = evalFunc->Outputs()[0];
    Variable interLayerOutput = evalFunc->Outputs()[1];

    std::unordered_map<Variable, ValuePtr> outputDataMap = { { modelOutput, nullptr }, { interLayerOutput, nullptr } };

    // Start evaluation on the device
    evalFunc->Evaluate(inputDataMap, outputDataMap, device);

    // Get evaluate result as dense outputs
    for(auto & outputVariableValuePair : outputDataMap)
    {
        auto variable = outputVariableValuePair.first;
        auto value = outputVariableValuePair.second;
        std::vector<std::vector<float>> outputData;
        value->CopyVariableValueTo(variable, outputData);
        PrintOutput<float>(variable.Shape().TotalSize(), outputData);
    }
}
开发者ID:AllanYiin,项目名称:CNTK,代码行数:60,代码来源:CNTKLibraryCPPEvalExamples.cpp

示例9: switch

Variable * VariableScript::_build_value(LR_Node *node) {
    Variable *ret = 0;
    switch (node->productionId()) {
        case internal::PROD_value_0:
            ret = Variable_null::instance();
            ret->grab();
            break;
            
        case internal::PROD_value_1:
            ret = vnnew Variable_bool(true);
            break;
            
        case internal::PROD_value_2:
            ret = vnnew Variable_bool(false);
            break;
            
        case internal::PROD_value_3:
            ret = vnnew Variable_int32(node->child(0)->token()->int32);
            break;
            
        case internal::PROD_value_4:
            ret = vnnew Variable_int64(node->child(0)->token()->int64);
            break;
            
        case internal::PROD_value_5:
            ret = vnnew Variable_float32(node->child(0)->token()->float32);
            break;
            
        case internal::PROD_value_6:
            ret = vnnew Variable_float64(node->child(0)->token()->float64);
            break;
            
        case internal::PROD_value_7:
            ret = vnnew Variable_string(node->child(0)->token()->text);
            break;
            
        case internal::PROD_value_8:
            ret = _build_reference(node->child(0));
            break;
            
        case internal::PROD_value_9:
            ret = _build_array(node->child(0));
            break;
            
        case internal::PROD_value_10: {
            Variable_object *object = vnnew Variable_object();
            _build_object(node->child(0), object);
            ret = object;
            break;
        }
    }
    return ret;
}
开发者ID:signorinotang,项目名称:tools,代码行数:53,代码来源:vnVariableScript.cpp

示例10: SetVarValue

bool VariablesInfo::SetVarValue(string varName, float varValue) {
	Variable* var = NULL;
	unsigned i;
	for (i = 0; i < mVariables.size() && var == NULL; i++) {
		if (mVariables[i]->GetVarName() == varName) var = mVariables[i];
	}
	if (var != NULL) {
		var->SetVarValue(varValue);
		return true;
	}
	return false;
}
开发者ID:edecote,项目名称:VI,代码行数:12,代码来源:VariablesInfo.cpp

示例11: CompareWithFloat

Variable::commandPrompResults Variable::CompareWith(const Variable &aVariable) const {
	Variable::Type type = aVariable.getType();
	if (type == FLOAT || type == FLOAT) {
		return CompareWithFloat(aVariable.getFloat());
	} else if (type == INT && type == INT) {
		return CompareWithInt(aVariable.getInteger());
	} else if (type == STRING || type == STRING) {
		return CompareWithString(aVariable.getString());
	}

	return UNDEFCMP;
}
开发者ID:freakypain,项目名称:Aiki,代码行数:12,代码来源:Variable.cpp

示例12: while

//-----------------------------------------------------------------------------
// Returns colour data from the named variable.
//-----------------------------------------------------------------------------
D3DCOLORVALUE *Script::GetColourData( char *variable )
{
	m_variables->Iterate( true );
	while( m_variables->Iterate() != NULL )
	{
		Variable* pVar = m_variables->GetCurrent();
		if( strcmp( pVar->GetName(), variable ) == 0 )
			return (D3DCOLORVALUE*)m_variables->GetCurrent()->GetData();
	}

	return NULL;
}
开发者ID:BornHunter,项目名称:CGSF,代码行数:15,代码来源:Scripting.cpp

示例13: CurrentModule

bool Registry::AddVariableToCurrentImportList(Variable* import_var)
{
  Module* submod = CurrentModule()->GetVariable(m_currentImportedModule)->GetModule();
  Variable* var = submod->GetNextExportVariable();
  if (var == NULL) {
    string error = "Unable to add variable '" + import_var->GetNameDelimitedBy(GetCC()) + "' when creating an instance of the module '" + submod->GetModuleName() + "' because this module is defined to have only " + SizeTToString(submod->GetNumExportVariables()) + " variable(s) definable by default in its construction.";
    SetError(error);
    return true;
  }
  var->Synchronize(import_var);
  return false;
}
开发者ID:dchandran,项目名称:evolvenetworks,代码行数:12,代码来源:registry.cpp

示例14: get

void IISource::get(Variable& x) {
  int type = getType();
  if(type==GBInputNumbers::s_IOSYMBOL) {
    symbolGB y;
    ((ISource *)this)->get(y);
    x.assign(y.value().chars());
  } else if(type==GBInputNumbers::s_IOFUNCTION) {
    StringAccumulator acc; 
    getAnything(acc);
    x.assign(acc.chars());
  } else DBG();
};
开发者ID:mcdeoliveira,项目名称:NC,代码行数:12,代码来源:IISource.cpp

示例15: assert

bool ReactantList::SetComponentFormulasTo(Formula form)
{
  for (size_t component=0; component<m_components.size(); component++) {
    Module* module = g_registry.GetModule(m_module);
    assert(module != NULL);
    Variable* var = module->GetVariable(m_components[component].second);
    if (var != NULL) {
      if (var->SetFormula(&form)) return true;
    }
  }
  return false;
}
开发者ID:dchandran,项目名称:evolvenetworks,代码行数:12,代码来源:reactantlist.cpp


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