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


C++ Eval函数代码示例

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


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

示例1: Pair

Value* Pair(Value* h, Value* t, EnvironmentFrame* env, Allocator* a)
{
    gcguard<Value> head = Eval(h, env);
    gcguard<Value> tail = Eval(t, env);

    return a->allocate<ConsPair>(head.ptr(), tail.ptr());
}
开发者ID:kthielen,项目名称:scm,代码行数:7,代码来源:Lists.cpp

示例2: main

int main(int argc, char *argv[]) {

    printf("\n");

    if (argc < 2) {
        printf("not enough arguments\n\n");
        return 1;
    }

    printf("STARTING MATLAB ENGINE\n\n");
    Engine *ep = engOpen("");
    if (ep == NULL) {
        printf("unable to start MATLAB engine\n\n");
        return 1;
    }
    engSetVisible(ep, false);
    char out[BUFSIZE];
    engOutputBuffer(ep, out, BUFSIZE);

    printf("SETTING PATH TO CNS\n\n");
    Eval(ep, out, "run(fullfile('%s', 'cns_path'));", argv[1]);

    bool ok = RunDemo(ep, out);

    printf("PRESS RETURN TO CONTINUE: ");
    fgets(out, BUFSIZE, stdin);
    printf("\n");

    printf("CLOSING MATLAB ENGINE\n\n");
    Eval(ep, out, "close all;");
    engClose(ep);

    return ok ? 0 : 1;

}
开发者ID:haishanwu,项目名称:cnpkg,代码行数:35,代码来源:demoeng.cpp

示例3: destroyPoints

void CEvaluatingFunction::generatePoints(COUNTER FitCaseNum){

		F<double> IntervalSize = (RangeMax-RangeMin)/(double)FitCaseNum;
		destroyPoints();
		try{
			FunctionX1.push_back(RangeMin);
			FunctionY.push_back(Eval(RangeMin));
			for(COUNTER i=1; i<FitCaseNum-1; i++){
			
				F<double> x = RangeMin + ((F<double>)i*IntervalSize);	//Pick a point 
				int somewhere = rand()%100;		//in the interval,
				if (somewhere) x+= ((F<double>)1.0f/(F<double>)(somewhere))*IntervalSize;	//somewhere in the interval.
			
				FunctionX1.push_back(x);
				FunctionY.push_back(Eval(x));
			}
			FunctionX1.push_back(RangeMax);
			FunctionY.push_back(Eval(RangeMax));
		}
		catch(CString Exc){

			throw Exc;

		}
}
开发者ID:0ctoDragon,项目名称:cpp-symbolic-regression,代码行数:25,代码来源:EvaluatingFunction.cpp

示例4: NumericalProjectParam

double ExplicitCurve2d :: NumericalProjectParam (const Point<2> & p, double lb, double ub) const
  {
  double t(-1);
  Vec<2> tan;
  Vec<2> curv;
  Point<2> cp;
  double f, fl, fu;
  int cnt;
  
  tan = EvalPrime (lb);
  cp = Eval (lb);
  fl = tan * (cp - p);
  if (fl > 0)			// changed by wmf, originally fl >= 0
    {
      //      cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl;
      //      cerr << "ExplicitCurve2d::NumericalProject: lb wrong" << endl;
      return 0;
    }
  
  tan = EvalPrime (ub);
  cp = Eval (ub);
  fu = tan * (cp - p);
  if (fu < 0)			// changed by wmf, originally fu <= 0
    {
      //    cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl;
      //    cerr << "ExplicitCurve2d::NumericalProject: ub wrong" << endl;
    return 0;
    }
    
  cnt = 0;
  while (ub - lb > 1e-12 && fu - fl > 1e-12)
    {
    cnt++;
    if (cnt > 50)
      {
      (*testout) << "Num Proj, cnt = " << cnt << endl;
      }
     
    t = (lb * fu - ub * fl) / (fu - fl);
    if (t > 0.9 * ub + 0.1 * lb) t = 0.9 * ub + 0.1 * lb;
    if (t < 0.1 * ub + 0.9 * lb) t = 0.1 * ub + 0.9 * lb;
    
    tan = EvalPrime (t);
    cp = Eval (t);
    f = tan * (cp - p);
    
    if (f >= 0)
      {
      ub = t;
      fu = f;
      }
    else
      {
      lb = t;
      fl = f;
      }
    }
    
  return t;
  }
开发者ID:11235813,项目名称:netgen-csg2d,代码行数:60,代码来源:explicitcurve2d.cpp

示例5: controlExpression

static bool controlExpression(char relOp, expADT expL, expADT expR, environmentADT env){

	valueADT leftV, rightV;

	leftV = Eval(expL, env);
	rightV = Eval(expR, env);

	if(ValueType(leftV) == IntValue && ValueType(rightV) == IntValue ){

		switch(relOp){

		case '<':
		return (GetIntValue(leftV) < GetIntValue(rightV));

		case '>':
			return (GetIntValue(leftV) > GetIntValue(rightV));

		case '=':
			return (GetIntValue(leftV) == GetIntValue(rightV));

		default:
			Error("Reloperator %c is not valid.\n", relOp);
			break;
		}
	}
	else
		Error("\nCompared expressions is not Integers\n");

}
开发者ID:tobiasanhed,项目名称:DoP-labb-3,代码行数:29,代码来源:eval.c

示例6: Unset

void Unset(Var x)
{
	if(SymQ(x))
	{
		OwnValues.erase(x);
		return;
	}
	if(VecQ(x))
	{
		size_t n = Size(x);
		for(size_t i = 0; i < n; ++i)
			Unset(At(x,i));
		return;
	}
	if(ExQ(x))
	{
		var h = Eval(Head(x));
		if(SymQ(h))
		{
			var b = Body(x);
			if(h == TAG(Property))
			{
				if(SymQ(At(b,0)) && SymQ(At(b,1)))
				{
					std::map<Var,map_t>::iterator
						iter = Properties.find(At(b,0));
					if(iter != Properties.end())
						iter->second.erase(At(b,1));
				}
				return;
			}
			b = Eval(b);
			if(FixQ(b))
			{
				std::map<Var,dict_t>::iterator
					iter = FactValues.find(h);
				if(iter != FactValues.end())
					iter->second.erase(b);
			}
			else
			{
				std::map<Var,def_t>::iterator
					iter = DownValues.find(h);
				if(iter != DownValues.end())
					iter->second.erase(b);
			}
			return;
		}
		else if(ExQ(h) && SymQ(Head(h)))
		{
			var b = Eval(Body(x));
			var t = Vec(Body(h),b);
			std::map<Var,def_t>::iterator
				iter = SubValues.find(Head(h));
			if(iter != SubValues.end())
					iter->second.erase(t);
			return;
		}
	}
}
开发者ID:hyln9,项目名称:nV,代码行数:60,代码来源:set.cpp

示例7: Eval

int Minimax::Quiescence(Board *board, GameInfo *gameInfo, int depth, int alpha, int beta) {
	// Evaluate the node in its current state. If it causes a beta-cutoff, assume that there will be no move further down the
	//game tree that will result in a better evaluation. Otherwise, set it as the lower bound, alpha.
	int nodeEvaluation = Eval(board, gameInfo);
	if (nodeEvaluation >= beta) return beta;
	if (nodeEvaluation > alpha) alpha = nodeEvaluation;
	MoveList moveList;
	// If the node is in check, consider every move. Otherwise, just consider captures/promotions.
	moveList.generate(gameInfo->turn, board, gameInfo, !MoveList::InCheck(gameInfo->turn, board));
	moveList.prune((Piece::Color)!gameInfo->turn, board);
	for (MoveList::iterator moveItr = moveList.begin(); moveItr != moveList.end(); moveItr++) {
		Move move = *moveItr;
		board->executeMove(move);
		// Save any irreversible game info before making a move.
		GameInfo::Irreversible irreversible(gameInfo);
		gameInfo->executeMove(move);
		int childEval = 0;
		// If we are at depth 0, just get the score of the board (The score is negated as it is measured relative to the opposite color).
		if (depth == 0) childEval = -Eval(board, gameInfo);
		else childEval = -Quiescence(board, gameInfo, depth - 1, -beta, -alpha);
		board->reverseMove(move);
		gameInfo->reverseMove(irreversible);
		if (childEval >= beta) return beta;
		if (childEval > alpha) alpha = childEval;
	}
	return alpha;
}
开发者ID:lukehesluke,项目名称:Third-Year-Chess-Project,代码行数:27,代码来源:minimax.cpp

示例8: Eval

double MyParser::EvalRemoveSingularity(double *xvar)
{
	try {
		double result = Eval();
		if ( gsl_isinf(result) || gsl_isnan(result) )
			throw Singularity();
		return result;
	} catch (Singularity) {
		try {
			if (isinf(Eval()))
				throw Pole();

			int n;
			frexp (*xvar, &n);
			double xp = *xvar + ldexp(DBL_EPSILON,n);
			double xm = *xvar - ldexp(DBL_EPSILON,n);
			*xvar = xp;
			double yp = Eval();
			if (gsl_isinf(yp) || gsl_isnan(yp))
				throw Pole();
			*xvar = xm;
			double ym = Eval();
			if (gsl_isinf(ym) || gsl_isnan(ym))
				throw Pole();
			return (yp + ym)/2;
		} catch (Pole) {
			SingularityErrorMessage(*xvar);
			return GSL_ESING;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:31,代码来源:MyParser.cpp

示例9: GetX

double TrPdf::Integral(double xlow, double xhig) {	
  if (xlow<GetX(0)) {
    if (VERBOSE) printf("TrPdf::Integral-V xlow out of bounds, using low edge.\n");
    xlow = GetX(0);
  }
  if (xhig>GetX(GetN()-1)) {
    if (VERBOSE) printf("TrPdf::Integral-V xhigh out of bounds, using upper edge.\n");
    xhig = GetX(GetN()-1);
  }
  if (xlow>=xhig) {
    if (VERBOSE) printf("TrPdf::Integral-V xlow greater-equal than xhig, returning 0.\n");
    return 0.;
  }
  double sum = 0.;
  double y1,y0,x1,x0;
  for (int i=0; i<GetN()-1; i++) {
    if      (xlow<=GetX(i))   { x0 = GetX(i);   y0 = GetY(i);    }
    else if (xlow>=GetX(i+1)) { x0 = GetX(i+1); y0 = GetY(i+1);  } 
    else                      { x0 = xlow;      y0 = Eval(xlow); }
    if      (xhig<=GetX(i))   { x1 = GetX(i);   y1 = GetY(i);    }
    else if (xhig>=GetX(i+1)) { x1 = GetX(i+1); y1 = GetY(i+1);  }
    else                      { x1 = xhig;      y1 = Eval(xhig); }
    sum  += (y1+y0)*(x1-x0)/2.;
  }
  return sum;
}
开发者ID:krafczyk,项目名称:AMS,代码行数:26,代码来源:TrPdf.C

示例10: Eval

void CParametricSurface::Vertex(Vec2 domain)
{
    Vec3 p0, p1, p2, p3;
    Vec3 normal;
    float u = domain.x;
    float v = domain.y;
	
    Eval(domain, p0);
    Vec2 z1(u + du/2, v);
    Eval(z1, p1);
    Vec2 z2(u + du/2 + du, v);
    Eval(z2, p3);
	
    if (flipped) {
        Vec2 z3(u + du/2, v - dv);
        Eval(z3, p2);
    } else {
        Vec2 z4(u + du/2, v + dv);
        Eval(z4, p2);
    }
	
    const float epsilon = 0.00001f;
	
    Vec3 tangent = p3 - p1;
    Vec3 binormal = p2 - p1;
    MatrixVec3CrossProduct(normal, tangent, binormal);
    if (normal.length() < epsilon)
        normal = p0;
    normal.normalize();
	if (tangent.length() < epsilon)
		MatrixVec3CrossProduct(tangent, binormal, normal);
	tangent.normalize();
	binormal.normalize();
	binormal = binormal * -1.0f;
	 
	/*
    if (CustomAttributeLocation() != -1)
        glVertexAttrib1f(CustomAttributeLocation(), CustomAttributeValue(domain));
	 */
	
    //glNormal(normal);
    //glTexCoord(domain);
    //glVertex(p0);
	int vertexIndex = totalVertex * 14;
	vertexBuffer[vertexIndex++] = p0.x;
	vertexBuffer[vertexIndex++] = p0.y;
	vertexBuffer[vertexIndex++] = p0.z;
	vertexBuffer[vertexIndex++] = domain.x;
	vertexBuffer[vertexIndex++] = domain.y;
	vertexBuffer[vertexIndex++] = normal.x;
	vertexBuffer[vertexIndex++] = normal.y;
	vertexBuffer[vertexIndex++] = normal.z;
	vertexBuffer[vertexIndex++] = tangent.x;
	vertexBuffer[vertexIndex++] = tangent.y;
	vertexBuffer[vertexIndex++] = tangent.z;
	vertexBuffer[vertexIndex++] = binormal.x;
	vertexBuffer[vertexIndex++] = binormal.y;
	vertexBuffer[vertexIndex++] = binormal.z;
}
开发者ID:astojilj,项目名称:astoj_oolongengine,代码行数:59,代码来源:Surface.cpp

示例11: scope_run

int scope_run(SuperScopePrivate *priv, ScopeRunnable runnable)
{

    RESULT result;

    SetVariableNumeric("n", priv->n);
    SetVariableNumeric("b", priv->b);
    SetVariableNumeric("x", priv->x);
    SetVariableNumeric("y", priv->y);
    SetVariableNumeric("i", priv->i);
    SetVariableNumeric("v", priv->v);
    SetVariableNumeric("w", priv->w);
    SetVariableNumeric("h", priv->h);
    SetVariableNumeric("red", priv->red);
    SetVariableNumeric("green", priv->green);
    SetVariableNumeric("blue", priv->blue);
    SetVariableNumeric("linesize", priv->linesize);
    SetVariableNumeric("skip", priv->skip);
    SetVariableNumeric("drawmode", priv->drawmode);
    SetVariableNumeric("t", priv->t);
    SetVariableNumeric("d", priv->d);

    switch(runnable) {
        case SCOPE_RUNNABLE_INIT:
		Eval(priv->init, &result);
	break;
	case SCOPE_RUNNABLE_BEAT:
		Eval(priv->beat, &result);
	break;
	case SCOPE_RUNNABLE_FRAME:
		Eval(priv->frame, &result);
	break;
	case SCOPE_RUNNABLE_POINT:
		Eval(priv->point, &result);
	break;
    }

    //(FindVariable("n"))->value = NULL;
    VARIABLE var;
    var.value = NULL;
    priv->n = R2N(FindVariable("n")->value);
    priv->b = R2N(FindVariable("b")->value);
    priv->x = R2N(FindVariable("x")->value);
    priv->y = R2N(FindVariable("y")->value);
    priv->i = R2N(FindVariable("i")->value);
    priv->v = R2N(FindVariable("v")->value);
    priv->w = R2N(FindVariable("w")->value);
    priv->h = R2N(FindVariable("h")->value);
    priv->red = R2N(FindVariable("red")->value);
    priv->green = R2N(FindVariable("green")->value);
    priv->blue = R2N(FindVariable("blue")->value);
    priv->linesize = R2N(FindVariable("linesize")->value);
    priv->skip = R2N(FindVariable("skip")->value);
    priv->drawmode = R2N(FindVariable("drawmode")->value);
    priv->t = R2N(FindVariable("t")->value);
    priv->d = R2N(FindVariable("d")->value);

    return 0;
}
开发者ID:Starlon,项目名称:StarVisuals-And,代码行数:59,代码来源:plasma.c

示例12: Eval

sint32 SlicFrame::IsEqual(SS_TYPE type1, SlicStackValue value1,
						  SS_TYPE type2, SlicStackValue value2)
{
	SlicSymbolData *sym1, *sym2;
	if(type1 == SS_TYPE_INT || type2 == SS_TYPE_INT) {
		return Eval(type1, value1) == Eval(type2, value2);
	}

	switch(type1) {
		case SS_TYPE_SYM:
		case SS_TYPE_VAR:
		{
			if(type1 == SS_TYPE_SYM) {
				sym1 = value1.m_sym;
			} else {
				sym1 = g_slicEngine->GetSymbol(value1.m_int);
			}

			if(type2 == SS_TYPE_SYM) {
				sym2 = value2.m_sym;
			} else if(type2 == SS_TYPE_VAR) {
				sym2 = g_slicEngine->GetSymbol(value2.m_int);
			} else {
				Assert(FALSE);
				return 0;
			}

			MapPoint pos1, pos2;
			Unit u1, u2;
			if(sym1->GetPos(pos1)) {
				if(sym2->GetPos(pos2)) {
					return pos1 == pos2;
				}
			} 
			if(sym1->GetUnit(u1)) {
				if(sym2->GetUnit(u2)) {
					return u1 == u2;
				}
			} 
			if(sym1->GetCity(u1)) {
				if(sym2->GetCity(u2)) {
					return u1 == u2;
				}
			}
			
			if(sym1->GetType() != SLIC_SYM_IVAR)
				return 0;

			if(sym2->GetType() != SLIC_SYM_IVAR)
				return 0;

			return Eval(type1, value1) == Eval(type2, value2);
		}
		default:
			Assert(FALSE);
			return 0;
	}
}
开发者ID:talentlesshack,项目名称:C2P2,代码行数:58,代码来源:SlicFrame.cpp

示例13: EvalEx

var EvalEx(Var expression)
{
	var head = Eval(Head(expression));
	var body;
	var result;
	if(SymQ(head))
	{
		std::map<Var,attr_t>::const_iterator
			iter = Attributes.find(head);
		if(iter != Attributes.end())
		{
			if (HandleAttributes(result, expression, iter->second, head, body))
			{
				return result;
			}
		}
		else
		{
			body = Eval(Body(expression));
		}

		if (SearchFactValues(result, head, body))
		{
			return result;
		}

		if (SearchDownValues(result, head, body))
		{
			return result;
		}

		if (SearchCProcs(result, head, body))
		{
			return result;
		}
	}
	else
	{
		body = Eval(Body(expression));

		if(ExQ(head) && SymQ(Head(head)))
		{
			if (SearchSubValues(result, head, body))
			{
				return result;
			}

			if (SearchCOpers(result, head, body))
			{
				return result;
			}
		}
	}
	return Ex(head,body);
}
开发者ID:hyln9,项目名称:nV,代码行数:55,代码来源:eval.cpp

示例14: ConcatExpand

bool CAG_RegEx::CreateNFA(string strRegEx)
{
	// Parse regular expresion using similar 
	// method to evaluate arithmetic expressions
	// But first we will detect concatenation and
	// insert char(8) at the position where 
	// concatenation needs to occur
	strRegEx = ConcatExpand(strRegEx);
	cout<<strRegEx<<" : length "<<strRegEx.size()<<endl;

	for(int i=0; i<strRegEx.size(); ++i)
	{
		// get the charcter
		char c = strRegEx[i];
		
		if(IsInput(c))
			Push(c);
		else if(m_OperatorStack.empty())
			m_OperatorStack.push(c);
		else if(IsLeftParanthesis(c))
			m_OperatorStack.push(c);
		else if(IsRightParanthesis(c))
		{
			// Evaluate everyting in paranthesis
			while(!IsLeftParanthesis(m_OperatorStack.top()))
				if(!Eval())
					return false;
			// Remove left paranthesis after the evaluation
			m_OperatorStack.pop(); 
		}
		else
		{
			while(!m_OperatorStack.empty() && Presedence(c, m_OperatorStack.top()))
				if(!Eval())
					return false;
			m_OperatorStack.push(c);
		}
	}

	// Evaluate the rest of operators
	while(!m_OperatorStack.empty())
		if(!Eval())
			return false;

	// Pop the result from the stack
	if(!Pop(m_NFATable))
		return false;

	// Last NFA state is always accepting state
	m_NFATable[m_NFATable.size()-1]->m_bAcceptingState = true;

	return true;
}
开发者ID:burner,项目名称:dex,代码行数:53,代码来源:AG_RegEx.cpp

示例15: EvalProbL

double EvalProbL(int j,int x,int layers)  {
	int i=0;
	DModel *m= (DModel*)&(models[j]);
	double error=0;
	double y=0;
	int length=m->len;
	if  (m->len < x) {
//	elog(WARNING," Future %d %d",x,m->len);
}
//	double y= Eval(j,x,&error);// no need to compute the value
	//elog(WARNING, "Model error%f requested error %f",error,err);
	//btw, compute the next values and add them to the cache
	//	return y;

	if ((layers==0)||(m->nc <= 0)) {
		//elog(WARNING," matches the error %p",cache);
		if((cache != NULL) && (m_cache>0)) {
			//    elog(WARNING, "Filling from %d len: %d",x+1+i,m_cache);	
       			cache_start=x+1;
			for(i=0;i<m->len;i++) {
			   if(i>=m_cache)break;
			   cache[i]=Eval(j,x+1+i,&error);
			 }
			 for(i=x+m->len;i<m_cache;i++) {
			    cache[i]=-1;
			 }
		}	
	y= Eval(j,x,&error);	
//	elog(WARNING,"EvalProbL layers:%d val %lf",layers,y);
	return y; // found result within the error
	}
	//elog(WARNING,"here");
	DModel *mm;

	int l=0;
	l=m->children[0];
	mm= (DModel*)&(models[l]);
        int llen = mm->len;
        int li = x / llen;
	
        if (li >= m->nc) {
          li =m-> nc - 1;
	  l=m->children[li];
	  mm= (DModel*)&(models[l]);
          llen = mm->len;
            }
	l=m->children[li];
//	printf("l %d li %d\n",l,li);
        double yy= EvalProbL(l,x % llen, layers-1);
//	elog(WARNING, "Eval Prop L layers %d %lf",layers,yy);
	return yy;
}
开发者ID:SmarterSoftware,项目名称:VLDB12,代码行数:52,代码来源:model.c


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