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


C++ Index::constant方法代码示例

本文整理汇总了C++中Index::constant方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::constant方法的具体用法?C++ Index::constant怎么用?C++ Index::constant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Index的用法示例。


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

示例1: if

void
MMO_Expression_::_addAlgebriacDeps (Index algIndex, MMO_Equation equation,
				    Index equationIndex, Index derivativeIndex,
				    Dependencies derivativeDeps,
				    map<Index, Index> *states,
				    map<Index, Index> *discretes,
				    Index variableChange, int value)
{
  stringstream buffer;
  string indent;
  string variableString = equation->lhs ().variable (algIndex, "i");
  Dependencies deps = equation->exp ()->deps ();
  map<Index, Index> &stateVariables = *states;
  Index eqIndex = equationIndex;
  for (Index *idx = deps->begin (DEP_STATE); !deps->end (DEP_STATE);
      idx = deps->next (DEP_STATE))
    {
      if (stateVariables.find (*idx) == stateVariables.end ()
	  || equation->lhs ().variableChange (algIndex))
	{
	  Index stateIndex = Index (
	      idx->applyVariableChange (
		  equation->lhs ().variableIndex (algIndex)));
	  stateVariables[*idx] = *idx;
	  eqIndex.setOffset (_equationIndex++);
	  if (idx->hasRange () && eqIndex.hasRange ())
	    {
	      // X[i] = B[i];
	      derivativeDeps->insert (stateIndex, eqIndex, DEP_ALGEBRAIC_STATE);
	    }
	  else if (!idx->hasRange () && eqIndex.hasRange ())
	    {
	      // X[i] = B[N];
	      derivativeDeps->insert (stateIndex, eqIndex, DEP_ALGEBRAIC_STATE);
	    }
	  else if (idx->hasRange () && !eqIndex.hasRange ())
	    {
	      // X[N] = B[i];
	      if (derivativeIndex.hasRange ())
		{
		  Index newEqIndex = eqIndex;
		  newEqIndex.setRange ();
		  newEqIndex.setLow (derivativeIndex.low ());
		  newEqIndex.setHi (derivativeIndex.hi ());
		  derivativeDeps->insert (
		      stateIndex.indexValue (
			  stateIndex.value (algIndex.constant ())),
		      newEqIndex, DEP_ALGEBRAIC_STATE);
		}
	      else
		{
		  derivativeDeps->insert (
		      stateIndex.indexValue (
			  stateIndex.value (algIndex.constant ())),
		      eqIndex, DEP_ALGEBRAIC_STATE);
		}
	    }
	  else if (!idx->hasRange () && !eqIndex.hasRange ())
	    {
	      // X[N] = B[N];
	      if (derivativeIndex.hasRange () && !algIndex.isArray())
	     	{
	     	  Index newEqIndex = eqIndex;
	     	  newEqIndex.setRange ();
	     	  newEqIndex.setLow (derivativeIndex.low ());
	     	  newEqIndex.setHi (derivativeIndex.hi ());
	     	  derivativeDeps->insert (stateIndex,
	     	      newEqIndex, DEP_ALGEBRAIC_STATE);
	     	}
	      else
	     	{
	          derivativeDeps->insert (stateIndex, eqIndex, DEP_ALGEBRAIC_STATE);
	     	}

	    }
	}
    }
  map<Index, Index> &discreteVariables = *discretes;
  for (Index *idx = deps->begin (DEP_DISCRETE); !deps->end (DEP_DISCRETE); idx =
      deps->next (DEP_DISCRETE))
    {
      if (discreteVariables.find (*idx) == discreteVariables.end ()
	  || equation->lhs ().variableChange (algIndex))
	{
	  Index discreteIndex = Index (
	      idx->applyVariableChange (
		  equation->lhs ().variableIndex (algIndex)));
	  discreteVariables[*idx] = *idx;
	  eqIndex.setOffset (_equationIndex++);
	  if (idx->hasRange () && eqIndex.hasRange ())
	    {
	      // X[i] = B[i];
	      derivativeDeps->insert (discreteIndex, eqIndex,
				      DEP_ALGEBRAIC_DISCRETE);
	    }
	  else if (!idx->hasRange () && eqIndex.hasRange ())
	    {
	      // X[i] = B[N];
	      derivativeDeps->insert (discreteIndex, eqIndex,
				      DEP_ALGEBRAIC_DISCRETE);
//.........这里部分代码省略.........
开发者ID:RexFuzzle,项目名称:qss-solver,代码行数:101,代码来源:expression.cpp


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