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


C++ Expression::SetDepth方法代码示例

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


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

示例1: if

Expression Expression::operator-() const {
  // checkWellFormed();
  if (kindIs("constant")) {
    return -value;
  } else if (kindIs("*/") && name == "*" && arg1->kindIs("constant")) {
    return (-arg1->value) * *arg2;
  } else if (kindIs("*/") && name == "/" && arg1->kindIs("constant")) {
    return (-arg1->value) / *arg2;
  } else if (kindIs("*/") && name == "*" && arg2->kindIs("constant")) {
    return *arg1 * (-arg2->value);
  } else if (kindIs("*/") && name == "/" && arg2->kindIs("constant")) {
    return *arg1 / (-arg2->value);
  //} else if (kindIs("+-") && name == "+") {
  //  return (-*arg1) + (-*arg2);
  } else if (kindIs("unary") && name == "-") {
    return *arg1;
  }
  Expression out;
  out.name = "-";
  out.kind = "unary";
  out.type = type;
  out.arg1 = new Expression(*this);
  out.SetDepth();
  // out.checkWellFormed();
  return out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:26,代码来源:Expression.cpp

示例2: method

Expression Expression::method(const std::string n) const {
  Expression out;
  out.kind = "method";
  out.name = "." + n + "(";
  out.arg1 = new Expression(*this);
  out.type = type; // default to methods not changing types
  out.SetDepth();
  return out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:9,代码来源:Expression.cpp

示例3: operator

Expression Expression::operator()(const Expression &e) const {
  Expression out;
  out.name = "(";
  out.kind = "method";
  out.arg1 = new Expression(*this);
  out.arg2 = new Expression(e);
  out.SetDepth();
  return out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:9,代码来源:Expression.cpp

示例4: linearfunexprgd

Expression linearfunexprgd(const char *n, const char *type, const Expression &arg) {
  if (arg.kindIs("constant") && arg.value == 0)
    return Expression(0); // Nice optimization!  :)
  Expression newarg(arg);
  Expression prefactor = newarg.ScalarFactor();

  Expression out = funexpr(n, newarg);
  out.kind = "linear function";
  out.name = std::string(n) + "(gd, ";
  out.unlazy = true;
  out.type = type;
  out.SetDepth();
  return prefactor*out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:14,代码来源:Expression.cpp

示例5: Expression

Expression Expression::operator+(const Expression &e) const {
  if (kindIs("constant") && value == 0) {
    return e;
  } else if (e.kindIs("constant") && e.value == 0) {
    return *this;
  } else if (e.kindIs("constant") && kindIs("constant")) {
    return Expression(value+e.value);
  }
  Expression thispost(*this), epost(e);
  Expression thispre = thispost.ScalarFactor(), epre = epost.ScalarFactor();
  if (thispost.kindIs("linear function") && epost.kindIs("linear function") &&
      thispost.name == epost.name) {
    if (thispre == epre) {
      Expression out = linearfunexprgd("oops", thispost.type, *thispost.arg1 + *epost.arg1);
      out.name = thispost.name;
      return epre*out;
    }
    if (thispre == -epre && thispre != Expression(1)) {
      Expression out = linearfunexprgd("oops", thispost.type, *thispost.arg1 - *epost.arg1);
      out.name = thispost.name;
      return thispre*out;
    }
    Expression out = linearfunexprgd("oops", thispost.type,
                                     thispre * *thispost.arg1 + epre * *epost.arg1);
    out.name = thispost.name;
    return out;
  }
  Expression out;
  if (typeIs("ReciprocalGrid")) {
    assert(!e.typeIs("Grid"));
    out.type = "ReciprocalGrid";
  } else if (typeIs("Grid")) {
    assert(!e.typeIs("ReciprocalGrid"));
  } else if (e.typeIs("double")) {
    out.type = "double";
  } else if (e.typeIs("ReciprocalGrid")) {
    out.type = "ReciprocalGrid";
  }
  out.name = "+";
  out.kind = "+-";
  out.arg1 = new Expression(*this);
  out.arg2 = new Expression(e);
  out.SetDepth();
  return out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:45,代码来源:Expression.cpp

示例6: funexpr

Expression funexpr(const char *n, const Expression &arg, const Expression &a2, const Expression &a3) {
  Expression out = funexpr(n, arg, a2);
  out.arg3 = new Expression(a3);
  out.SetDepth();
  return out;
}
开发者ID:Chris-Haglund,项目名称:deft,代码行数:6,代码来源:Expression.cpp


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