本文整理汇总了C++中Evaluate函数的典型用法代码示例。如果您正苦于以下问题:C++ Evaluate函数的具体用法?C++ Evaluate怎么用?C++ Evaluate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Evaluate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClearScreen
//----------------------------------------------------------------------------
void QuadraticFreeForm2D::OnDisplay ()
{
ClearScreen();
int dim0 = mTexture->GetDimension(0, 0);
int dim1 = mTexture->GetDimension(1, 0);
unsigned char* data = (unsigned char*)mTexture->GetData(0);
const int numSamples = 2*mSize;
const float invNumSamples = 1.0f/(float)numSamples;
Vector2f param;
for (int s = 0; s < numSamples; ++s)
{
int u = s*dim0/numSamples;
param.X() = invNumSamples*s;
for (int t = 0; t < numSamples; ++t)
{
int v = t*dim1/numSamples;
param.Y() = invNumSamples*t;
Vector2f result = Evaluate(param);
int x = ControlToScreen(result.X());
int y = ControlToScreen(result.Y());
int index = 4*(u + dim0*v);
unsigned char b = data[index++];
unsigned char g = data[index++];
unsigned char r = data[index++];
++index;
SetPixel(x, y, ColorRGB(r, g, b));
}
}
// Draw the control points.
ColorRGB green(0, 255, 0);
for (int row = 0; row <= 2; ++row)
{
for (int col = 0; col <= 2; ++col)
{
SetThickPixel(mCtrlX[row][col], mCtrlY[row][col], 2, green);
}
}
WindowApplication2::OnDisplay();
}
示例2: AlphaBeta
int AlphaBeta(board state, int depth, int alpha, int beta, int player, int *
bestX, int * bestY) //AlphaBeta
{
int X,Y, numacts, i, value;
int Xacts[64], Yacts[64]; //maximum of 64 (actually 60) possible moves
board child;
if (timelimit1){
currenttime = clock();
if (deadline < currenttime) return 0;
}
if (CutoffTest(state, depth)) return Evaluate(state);
numacts = Actions(state, player, Xacts, Yacts);
if (player == 1){//the MAX player (us)
for (i=0; i<numacts; i++) {
Result(state, child, player, Xacts[i], Yacts[i]);
value = AlphaBeta(child, depth-1, alpha, beta, -player, &X, &Y);
if (timelimit1 && deadline < currenttime) return 0;
//checking if we've reached the timelimit if applicable
if (value > alpha) {
alpha = value;
*bestX = Xacts[i]; *bestY = Yacts[i];
}
if (beta <= alpha)//beta cut-off
break;
}
return alpha;
} else {
for (i=0; i<numacts; i++) {
Result(state, child, player, Xacts[i], Yacts[i]);
value = AlphaBeta(child, depth-1, alpha, beta, -player, &X, &Y);
if (timelimit1 && deadline < currenttime) return 0;
//checking if we've reached the time limit if applicable
if (value < beta) {
beta = value;
*bestX = Xacts[i]; *bestY = Yacts[i];
}
if (beta <= alpha)//alpha cutoff
break;
}
return beta;
}
}
示例3: Evaluate
bool DistanceEstimator::DoesIntersect(const Ray &r, float *tHit) const {
Ray ray;
(*WorldToObject)(r, &ray);
float t = ray.mint;
bool intersected = false;
for (int itr = 0; ray.mint <= t && t <= ray.maxt && itr < DE_params.maxIters; itr++) {
float dist = Evaluate(ray(t));
if (fabs(dist) < DE_params.hitEpsilon) {
intersected = true;
break;
}
t += dist;
}
if (!intersected || t < ray.mint || t > ray.maxt)
return false;
if (tHit) *tHit = t;
return true;
}
示例4: msgBox
void MainWindow::ReportJackpotFileDownloaded()
{
if (!UpdateJackpots()) {
QMessageBox msgBox(this);
msgBox.setText("That does not appear to be a valid table. Jackpots file is invalid.");
msgBox.exec();
ui->tableName->setEnabled(true);
ui->table_instructions->show();
return;
}
if (m_gamestate == Login) {
SetupMoney();
}
else if (m_gamestate == WaitingForPayout) {
// let's try once more to make a payout, but with the new jackpot amounts
Evaluate();
}
}
示例5: SetTypeGV
size_w SetTypeGV(HWND hwndGridView, HGRIDITEM hItem, TypeDecl *typeDecl, size_w dwOffset)
{
if(typeDecl->typeAlias == true)
return dwOffset;
if(typeDecl->declList.size() > 0)
{
Type *type = typeDecl->declList[0];
ExprNode *offsetExpr;
if(FindTag(typeDecl->tagList, TOK_OFFSET, &offsetExpr))
dwOffset = Evaluate(offsetExpr);
dwOffset += RecurseType(hwndGridView, hItem, type, dwOffset, typeDecl);
}
return dwOffset;
}
示例6: StdoutFn
Value *
StdoutFn (const char *name, State * state, int argc, Expr * argv[])
{
int i;
for (i = 0; i < argc; ++i)
{
char *v = Evaluate (state, argv[i]);
if (v == NULL)
{
return NULL;
}
fputs (v, stdout);
free (v);
}
return StringValue (strdup (""));
}
示例7: strtod
int ParameterScalar::SetValue(const string value, bool Eval)
{
if (value.empty()) return -1;
//check if string is only a plain double
char *pEnd;
double val = strtod(value.c_str(),&pEnd);
if (*pEnd == 0)
SetValue(val);
ParameterMode=true;
bModified=true;
sValue=value;
if (Eval) return Evaluate();
return 0;
}
示例8: EvalSubStatement
double EvalSubStatement (char *status, char *look, struct Variable *Vars) {
#ifdef DEBUG
printf ("EvalSubStatement in; status: %i, look: %c;\n", *status, *look);
#endif
char oldstatus = *status;
*status = -1; // pass on substatement status
struct TokenStruct tmp;
// tmp.Token = malloc (sizeof (char) * 2);
tmp.Token = "+";
tmp.type = TokenType ('+');
tmp.priority = OpPriority ('+');
double ret = Evaluate (0, tmp, status, look, Vars);
if (!*status) { *status = oldstatus; } // if no error occured during substatement evaluation, reset status
return ret;
}
示例9: Evaluate
/*MATH_EXPRESSION FUNCTION Evaluate: EVALUATES EVERY OCCURANCE OF THE OPERATION*/
void MATH_EXPRESSION::Evaluate(int op1, int op2) {
if( (op1==op)||(op2==op) ) {
//Evaluate mathematical operation
if(op=='^') {number = pow(number, next->number);} else
if(op=='*') {number = number * next->number;} else
if(op=='/') {number = number / next->number;} else
if(op=='+') {number = number + next->number;} else
if(op=='-') {number = number - next->number;} else
{Log <<"Operation: "<<op<<" is undefined."<<endl;}
//Reduce linked list by copying numbers and operators down one
op = next->op;
if(next->next==NULL) {
delete next;
next=NULL;
return;
}
next->Copy();
Evaluate(op1, op2);
}
if(next!=NULL) {next->Evaluate(op1, op2);}
return;
/*if(_op==op) {
//Evaluate mathematical operation
if(op=='^') {number = pow(number, next->number);} else
if(op=='*') {number = number * next->number;} else
if(op=='/') {number = number / next->number;} else
if(op=='+') {number = number + next->number;} else
if(op=='-') {number = number - next->number;} else
{Log <<"Operation: "<<op<<" is undefined."<<endl;}
//Reduce linked list by copying numbers and operators down one
op = next->op;
if(next->next==NULL) {
delete next;
next=NULL;
return;
}
next->Copy();
Evaluate(_op);
}
if(next!=NULL) {next->Evaluate(_op);}
return;*/
}
示例10: expect
int expect(const char* expr_str, const char* expected, int* errors) {
Expr* e;
char* result;
printf(".");
int error_count = parse_string(expr_str, &e, &error_count);
if (error_count > 0) {
fprintf(stderr, "error parsing \"%s\" (%d errors)\n",
expr_str, error_count);
++*errors;
return 0;
}
State state;
state.cookie = NULL;
state.script = strdup(expr_str);
state.errmsg = NULL;
result = Evaluate(&state, e);
free(state.errmsg);
free(state.script);
if (result == NULL && expected != NULL) {
fprintf(stderr, "error evaluating \"%s\"\n", expr_str);
++*errors;
return 0;
}
if (result == NULL && expected == NULL) {
return 1;
}
if (strcmp(result, expected) != 0) {
fprintf(stderr, "evaluating \"%s\": expected \"%s\", got \"%s\"\n",
expr_str, expected, result);
++*errors;
free(result);
return 0;
}
free(result);
return 1;
}
示例11: Initialize
int PhaseFit::LevMarFit(int max_iter, int nParam, float *params) {
unsigned int nRead = signal.size();
int nData = nRead * nFlow;
// Call LevMarFitter::Initialize() - the 3rd arg is null as we don't need access to
// the LevMarFitter's internal x array in the calls to Evaluate
Initialize(nParam,nData,NULL);
// Update LevMarFitter::residualWeight array if we are using flow-specific weighting or
// if we are ignoring homopolymers of size > 1
if( (!ignoreHPs) || (flowWeight.size() > 0) || (hpWeight.size() > 0) )
updateResidualWeight(ignoreHPs, flowWeight, hpWeight);
// Gather the observed data into an array of floats
float *y = new float[nData];
unsigned int iY=0;
for(unsigned int iRead=0; iRead<nRead; iRead++)
for(unsigned int iFlow=0; iFlow<nFlow; iFlow++)
y[iY++] = (float) signal[iRead][iFlow];
err.resize(nData);
int nIter = LevMarFitter::Fit(max_iter, y, params);
// Store the (possibly weighted) residuals
float *fval = new float[len];
Evaluate(fval,params);
residual_raw_vec.resize(nRead);
residual_weighted_vec.resize(nRead);
for(unsigned int iRead=0,iY=0; iRead<nRead; iRead++) {
residual_raw_vec[iRead].resize(nFlow);
residual_weighted_vec[iRead].resize(nFlow);
for(unsigned int iFlow=0; iFlow<nFlow; iFlow++, iY++) {
weight_t res = y[iY] - fval[iY];
residual_raw_vec[iRead][iFlow] = res;
residual_weighted_vec[iRead][iFlow] = residualWeight[iY] * res;
}
}
delete [] fval;
delete [] y;
return(nIter);
}
示例12: AnimatedTranslateTransform2Impl
AnimatedTranslateTransform2Impl(
Number* ptime,
RectValue* prect,
int side,
const Point& vecStart,
const Point& vecEnd,
float dtimeAnimation
) :
AnimatedTranslateTransform2(ptime, prect),
m_side(side),
m_pointStart(vecStart),
m_pointEnd(vecEnd),
m_dtimeAnimation(dtimeAnimation),
m_bGotoStart(true),
m_bStationary(true),
m_timeStart(ptime->GetValue() - dtimeAnimation)
{
Evaluate();
}
示例13: SymlinkFn
// symlink target src1 src2 ...
// unlinks any previously existing src1, src2, etc before creating symlinks.
Value* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) {
if (argc == 0) {
return ErrorAbort(state, "%s() expects 1+ args, got %d", name, argc);
}
char* target;
target = Evaluate(state, argv[0]);
if (target == NULL) return NULL;
char** srcs = ReadVarArgs(state, argc-1, argv+1);
if (srcs == NULL) {
free(target);
return NULL;
}
int bad = 0;
int i;
for (i = 0; i < argc-1; ++i) {
if (unlink(srcs[i]) < 0) {
if (errno != ENOENT) {
fprintf(stderr, "%s: failed to remove %s: %s\n",
name, srcs[i], strerror(errno));
++bad;
}
}
if (make_parents(srcs[i])) {
fprintf(stderr, "%s: failed to symlink %s to %s: making parents failed\n",
name, srcs[i], target);
++bad;
}
if (symlink(target, srcs[i]) < 0) {
fprintf(stderr, "%s: failed to symlink %s to %s: %s\n",
name, srcs[i], target, strerror(errno));
++bad;
}
free(srcs[i]);
}
free(srcs);
if (bad) {
return ErrorAbort(state, "%s: some symlinks failed", name);
}
return StringValue(strdup(""));
}
示例14: CalculateExpression
static void CalculateExpression(
const std::shared_ptr<SyntaxNode>& expression_node,
const std::shared_ptr<CalculateResult>& result,
std::int64_t& integer_value) {
auto evaluator = CreateValueEvaluator(expression_node);
if (evaluator == nullptr) {
result->error = CalculateResult::Error::SemanticsError;
return;
}
std::shared_ptr<Value> value;
auto evaluate_status = evaluator->Evaluate(value);
if (evaluate_status != EvaluateStatus::Ok) {
result->error = CalculateResult::Error::SemanticsError;
return;
}
integer_value = value->integer_value;
}
示例15: AbortFn
Value *
AbortFn (const char *name, State * state, int argc, Expr * argv[])
{
char *msg = NULL;
if (argc > 0)
{
msg = Evaluate (state, argv[0]);
}
free (state->errmsg);
if (msg)
{
state->errmsg = msg;
}
else
{
state->errmsg = strdup ("called abort()");
}
return NULL;
}