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


C++ dep函数代码示例

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


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

示例1: generate

  void BinaryMX<ScX, ScY>::
  generate(CodeGenerator& g, const std::string& mem,
           const std::vector<int>& arg, const std::vector<int>& res) const {
    // Quick return if nothing to do
    if (nnz()==0) return;

    // Check if inplace
    bool inplace;
    switch (op_) {
    case OP_ADD:
    case OP_SUB:
    case OP_MUL:
    case OP_DIV:
      inplace = res[0]==arg[0];
      break;
    default:
      inplace = false;
      break;
    }

    // Scalar names of arguments (start assuming all scalars)
    string r = g.workel(res[0]);
    string x = g.workel(arg[0]);
    string y = g.workel(arg[1]);

    // Codegen loop, if needed
    if (nnz()>1) {
      // Iterate over result
      g.local("rr", "real_t", "*");
      g.local("i", "int");
      g << "for (i=0, " << "rr=" << g.work(res[0], nnz());
      r = "(*rr++)";

      // Iterate over first argument?
      if (!ScX && !inplace) {
        g.local("cr", "const real_t", "*");
        g << ", cr=" << g.work(arg[0], dep(0).nnz());
        x = "(*cr++)";
      }

      // Iterate over second argument?
      if (!ScY) {
        g.local("cs", "const real_t", "*");
        g << ", cs=" << g.work(arg[1], dep(1).nnz());
        y = "(*cs++)";
      }

      // Close loop
      g << "; i<" << nnz() << "; ++i) ";
    }

    // Perform operation
    g << r << " ";
    if (inplace) {
      g << casadi_math<double>::sep(op_) << "= " << y;
    } else {
      g << " = " << casadi_math<double>::print(op_, x, y);
    }
    g << ";\n";
  }
开发者ID:andrescodas,项目名称:casadi,代码行数:60,代码来源:binary_mx_impl.hpp

示例2: interval

 interval interval_relation_plugin::meet(interval const& src1, interval const& src2, bool& isempty) {
     isempty = false;
     if (is_empty(0, src1) || is_infinite(src2)) {
         return src1;
     }
     if (is_empty(0, src2) || is_infinite(src1)) {
         return src2;
     }
     bool l_open = src1.is_lower_open();
     bool r_open = src1.is_upper_open();
     ext_numeral low = src1.inf();
     ext_numeral high = src1.sup();
     if (src2.inf() > low || (src2.inf() == low && !l_open)) {
         low = src2.inf();
         l_open = src2.is_lower_open();
     }
     if (src2.sup() < high || (src2.sup() == high && !r_open)) {
         high = src2.sup();
         r_open = src2.is_upper_open();
     }
     if (low > high || (low == high && (l_open || r_open))) {
         isempty = true;
         return interval(dep());
     }
     else {
         return interval(dep(), low, l_open, nullptr, high, r_open, nullptr);
     }
 }
开发者ID:NikolajBjorner,项目名称:z3,代码行数:28,代码来源:dl_interval_relation.cpp

示例3: nout

 void Split::generate(CodeGenerator& g, const std::string& mem,
                      const std::vector<int>& arg, const std::vector<int>& res) const {
   int nx = nout();
   for (int i=0; i<nx; ++i) {
     int nz_first = offset_[i];
     int nz_last = offset_[i+1];
     int nz = nz_last-nz_first;
     if (res[i]>=0 && nz>0) { // if anything to assign
       if (nz==1) { // assign scalar
         g.body << "  " << g.workel(res[i]) << " = ";
         if (dep(0).nnz()==1) {
           // rhs is also scalar
           casadi_assert(nz_first==0);
           g.body << g.workel(arg[0]) << ";" << endl;
         } else {
           // rhs is an element in a vector
           g.body << g.work(arg[0], dep(0).nnz()) << "[" << nz_first << "];" << endl;
         }
       } else {
         // assign vector
         std::string r = g.work(arg[0], dep(0).nnz());
         if (nz_first!=0) r = r + "+" + g.to_string(nz_first);
         g.body << "  " << g.copy(r, nz, g.work(res[i], nnz(i))) << endl;
       }
     }
   }
 }
开发者ID:RobotXiaoFeng,项目名称:casadi,代码行数:27,代码来源:split.cpp

示例4: dep

 void InnerProd::evalFwd(const std::vector<std::vector<MX> >& fseed,
                         std::vector<std::vector<MX> >& fsens) {
   for (int d=0; d<fsens.size(); ++d) {
     fsens[d][0] = dep(0)->getInnerProd(fseed[d][1])
       + fseed[d][0]->getInnerProd(dep(1));
   }
 }
开发者ID:BrechtBa,项目名称:casadi,代码行数:7,代码来源:inner_prod.cpp

示例5: for

 void DenseTranspose::generate(const std::vector<int>& arg, const std::vector<int>& res,
                               CodeGenerator& g) const {
   g.body << "  for (i=0, rr=" << g.work(res[0], nnz()) << ", "
          << "cs=" << g.work(arg[0], nnz()) << "; i<" << dep().size2() << "; ++i) "
          << "for (j=0; j<" << dep().size1() << "; ++j) "
          << "rr[i+j*" << dep().size2() << "] = *cs++;" << endl;
 }
开发者ID:BrechtBa,项目名称:casadi,代码行数:7,代码来源:transpose.cpp

示例6: neg_lits

void goal::elim_redundancies() {
    if (inconsistent())
        return;
    expr_ref_fast_mark1 neg_lits(m());
    expr_ref_fast_mark2 pos_lits(m());
    unsigned sz = size();
    unsigned j  = 0;
    for (unsigned i = 0; i < sz; i++) {
        expr * f = form(i);
        if (m().is_true(f))
            continue;
        if (m().is_not(f)) {
            expr * atom = to_app(f)->get_arg(0);
            if (neg_lits.is_marked(atom))
                continue;
            if (pos_lits.is_marked(atom)) {
                proof * p = 0;
                if (proofs_enabled()) {
                    proof * prs[2] = { pr(get_idx(atom)), pr(i) };
                    p = m().mk_unit_resolution(2, prs);
                }
                expr_dependency_ref d(m());
                if (unsat_core_enabled())
                    d = m().mk_join(dep(get_idx(atom)), dep(i));
                push_back(m().mk_false(), p, d);                    
                return;
            }
            neg_lits.mark(atom);
        }
        else {
            if (pos_lits.is_marked(f))
                continue;
            if (neg_lits.is_marked(f)) {
                proof * p = 0;
                if (proofs_enabled()) {
                    proof * prs[2] = { pr(get_not_idx(f)), pr(i) };
                    p = m().mk_unit_resolution(2, prs);
                }
                expr_dependency_ref d(m());
                if (unsat_core_enabled())
                    d = m().mk_join(dep(get_not_idx(f)), dep(i));
                push_back(m().mk_false(), p, d);
                return;
            }
            pos_lits.mark(f);
        }
        if (i == j) {
            j++;
            continue;
        }
        m().set(m_forms, j, f);
        if (proofs_enabled())
            m().set(m_proofs, j, pr(i));
        if (unsat_core_enabled())
            m().set(m_dependencies, j, dep(i));
        j++;
    }
    shrink(j);
}
开发者ID:CharudattaSChitale,项目名称:sygus-comp14,代码行数:59,代码来源:goal.cpp

示例7: dep

 void HorzRepmat::generate(CodeGenerator& g, const std::string& mem,
                           const std::vector<int>& arg, const std::vector<int>& res) const {
   int nnz = dep(0).nnz();
   g.body << "  for (i=0;i<" << n_ << ";++i) {" << endl;
   g.body << "    " << g.copy(g.work(arg[0], dep(0).nnz()), nnz,
                              g.work(res[0], sparsity().nnz()) + "+ i*" + g.to_string(nnz))
          << endl
   << "  }" << endl;
 }
开发者ID:RobotXiaoFeng,项目名称:casadi,代码行数:9,代码来源:repmat.cpp

示例8: dep

  void BinaryMX<ScX, ScY>::evalFwd(const std::vector<std::vector<MX> >& fseed,
                                   std::vector<std::vector<MX> >& fsens) {
    // Get partial derivatives
    MX pd[2];
    casadi_math<MX>::der(op_, dep(0), dep(1), shared_from_this<MX>(), pd);

    // Propagate forward seeds
    for (int d=0; d<fsens.size(); ++d) {
      fsens[d][0] = pd[0]*fseed[d][0] + pd[1]*fseed[d][1];
    }
  }
开发者ID:BrechtBa,项目名称:casadi,代码行数:11,代码来源:binary_mx_impl.hpp

示例9: dep

 void Solve<Tr>::print(std::ostream &stream, long& remaining_calls) const{
   if(remaining_calls>0){
     remaining_calls--;
     stream << "(";
     dep(1)->print(stream,remaining_calls);
     if(Tr) stream << "'";
     stream << "\\";
     dep(0)->print(stream,remaining_calls);
     stream << ")";
   } else {
     stream << "...";
   }
 }
开发者ID:zhenglei-gao,项目名称:casadi,代码行数:13,代码来源:solve_impl.hpp

示例10: build23

three_cells_t build23(reduce_t f, cell_t *x, cell_t *y) {
  three_cells_t r;
  r.a = closure_alloc(4);
  r.b = dep(r.a);
  r.c = dep(r.a);
  r.a->func = f;
  r.a->arg[0] = x;
  r.a->arg[1] = y;
  r.a->arg[2] = r.b;
  r.a->arg[3] = r.c;
  r.a->out = 2;
  return r;
}
开发者ID:bruce2008github,项目名称:poprc,代码行数:13,代码来源:primitive.c

示例11: dep

  void DenseTranspose::evalGen(const T* const* arg, T* const* res,
                               int* iw, T* w) {
    // Get sparsity patterns
    int x_nrow = dep().size1();
    int x_ncol = dep().size2();

    const T* x = arg[0];
    T* xT = res[0];
    for (int i=0; i<x_ncol; ++i) {
      for (int j=0; j<x_nrow; ++j) {
        xT[i+j*x_ncol] = x[j+i*x_nrow];
      }
    }
  }
开发者ID:BrechtBa,项目名称:casadi,代码行数:14,代码来源:transpose.cpp

示例12: zz_isEqual

 /** \brief Check if two nodes are equivalent up to a given depth */
 virtual bool zz_isEqual(const MXNode* node, int depth) const {
   if (op_==node->getOp()) {
     if (isEqual(dep(0), node->dep(0), depth-1) && isEqual(dep(1), node->dep(1), depth-1)) {
       // If arguments are equal
       return true;
     } else {
       // If arguments are flipped
       return operation_checker<CommChecker>(op_) && isEqual(dep(1), node->dep(0), depth-1) &&
         isEqual(dep(0), node->dep(1), depth-1);
     }
   } else {
     return false;
   }
 }
开发者ID:BrechtBa,项目名称:casadi,代码行数:15,代码来源:binary_mx.hpp

示例13: carrier

// policy: callback whenever i~k but not j~k
void BinaryRelation::unsafe_merge (Ob i)
{
    Ob j = carrier().find(i);
    POMAGMA_ASSERT4(j < i, "BinaryRelation tried to merge item with self");

    DenseSet diff(item_dim());
    DenseSet rep(item_dim(), nullptr);
    DenseSet dep(item_dim(), nullptr);

    // merge rows (i, _) into (j, _)
    dep.init(m_lines.Lx(i));
    _remove_Rx(i, dep);
    rep.init(m_lines.Lx(j));
    if (rep.merge(dep, diff)) {
        for (auto k = diff.iter(); k.ok(); k.next()) {
            _insert_Rx(j, *k);
        }
    }

    // merge cols (_, i) into (_, j)
    dep.init(m_lines.Rx(i));
    _remove_Lx(dep, i);
    rep.init(m_lines.Rx(j));
    if (rep.merge(dep, diff)) {
        for (auto k = diff.iter(); k.ok(); k.next()) {
            _insert_Lx(*k, j);
        }
    }
}
开发者ID:imclab,项目名称:pomagma,代码行数:30,代码来源:binary_relation.cpp

示例14: Vector2df

bool CTrackball::DoTracking(int x, int y)
{
  if (!m_tracking)
    return false;

  Vector2df delta = m_start - Vector2df((float)x, (float)y);
  delta /= 2;

  Vector3df mouse(delta.x, -delta.y, 0.0f);
  Vector3df dep(0.0f, 0.0f, 1.0f);
  Vector3df axis(0.0f, 0.0f, 0.0f);

	// axis will be perpendicular to mouse and dep vectors
	// this is our rotation axis
  axis = mouse ^ dep;
	axis.Normalize();

	// every 100 pixels is 360 degress or rotation
  //GLfloat len = axis.Magnitude() / 100.0f;
  GLfloat len = fabs(delta.Magnitude());
  
	while (len > 360.0f)
		len -= 360.0f;

  ATLTRACE("delta_x : %f, delta_y: %f\n", mouse.x, mouse.y);
  ATLTRACE("axis: x:%f  y:%f  z:%f\n", axis.x, axis.y, axis.z, len);
  ATLTRACE("angle: %f\n", len);
  
  m_rotation_delta.CreateFromAxisAngle(axis.x, axis.y, axis.z, len);
  
  m_quat = m_rotation_delta * m_rotation;
  return true; // still tracking
}
开发者ID:ebutusov,项目名称:MRender,代码行数:33,代码来源:Trackball.cpp

示例15: project

 void Project::evalAdj(const std::vector<std::vector<MX> >& aseed,
                         std::vector<std::vector<MX> >& asens) {
   int nadj = aseed.size();
   for (int d=0; d<nadj; ++d) {
     asens[d][0] += project(aseed[d][0], dep().sparsity(), true);
   }
 }
开发者ID:BrechtBa,项目名称:casadi,代码行数:7,代码来源:project.cpp


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