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


C++ Tuple::resize方法代码示例

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


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

示例1: projection

Paving Paving::projection(const Names &names) {

  Paving result;
  NamedBox varbox;   // varbox for result, varbox_ for this paving
  Tuple varlist;   // list of variables to be retained
  varlist.resize(names.size());
  result.set_type(type_);

  // push the relevant names and intervals
  for (nat i = 0; i < names.size(); ++i) {
    nat v = varbox_.var(names[i]);
    if (v < varbox_.size()) {
      varbox.push(names[i], varbox_.val(v));
      varlist[i] = v;
    } else {
      std::ostringstream os;
      os << "Kodiak (projection): name \"" << names[i] << "\" doesn't exist in the paving.";
      throw Growl(os.str());
    }
  }
  result.set_varbox(varbox);

  // add boxes
  Box x;
  x.resize(names.size());
  if (boxes_.size() == 0) return result;
  for (nat i = 0; i < boxes_.size(); ++i) { // iterate over types
    if (boxes_[i].size() == 0) continue;
    // add the first box
    for (nat k = 0; k < names.size(); ++k) x[k] = boxes_[i][0][varlist[k]];
    result.push_box(i, x);
    if (boxes_[i].size() == 1) continue;
    // add remaining boxes where necessary
    for (nat j = 1; j < boxes_[i].size(); ++j) {
      for (nat k = 0; k < names.size(); ++k) x[k] = boxes_[i][j][varlist[k]];
      nat subset = 0;   // is the jth box a subset of any box already
      // pushed into the result paving?
      for (nat jj = 0; jj < result.boxes(i).size(); ++jj) {
        if (box_subset(result.boxes(i)[jj], x)) {
          subset = 1;
          break;
        }
      }
      if (subset == 0) result.push_box(i, x);
    }
  }

  for (nat i = 0; i < boxes_.size(); ++i) { // iterate over types
    encluster(result.boxes(i));
  }

  result.set_type(type_);
  return result;

}
开发者ID:E-LLP,项目名称:Kodiak,代码行数:55,代码来源:Paver.cpp

示例2: join

bool join(Tuple &t1, const Tuple &t2, Tuple &r) {
  if (t1.size() < t2.size()) {
    t1.resize(t2.size());
  }
  Tuple temp(t1.size());
  int i;
  for (i = 0; i < t1.size(); ++i) {
    if (i >= t2.size() || t2[i] == 0) {
      temp[i] = t1[i];
    } else if (t1[i] == 0 || t1[i] == t2[i]) {
      temp[i] = t2[i];
    } else {
      return false;
    }
  }
  r.swap(temp);
  return true;
}
开发者ID:jrweave,项目名称:phd,代码行数:18,代码来源:infer-rules.cpp

示例3: save

void Paving::save(const std::string filename, const Names &titles, const Names &names) const {
  if (empty()) return;
  Tuple vs;
  for (nat v = 0; v < names.size(); ++v) {
    nat n = varbox_.var(names[v]);
    if (n < nvars())
      vs.push_back(n);
  }
  std::ostringstream os;
  os << filename;
  for (nat i = 0; i < vs.size(); ++i)
    os << "_" << varbox_.name(vs[i]);
  os << ".dat";
  if (vs.empty()) {
    vs.resize(varbox_.size());
    for (nat v = 0; v < varbox_.size(); ++v)
      vs[v] = v;
  }
  std::ofstream f;
  f.open(os.str().c_str(), std::ofstream::out);
  f << "## File: " << os.str() << std::endl;
  f << "## Type: " << type_ << std::endl;
  f << "## Vars:" << std::endl;
  nat width = 2 * Kodiak::precision();
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.name(vs[i]);
  f << std::endl;
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.box()[vs[i]].inf();
  f << std::endl;
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.box()[vs[i]].sup();
  f << std::endl;
  f << std::endl;
  for (nat i = 0; i < titles.size(); ++i) {
    f << "## " << titles[i] << ": " << size(i) << " boxes " << std::endl;
    if (i < boxes_.size() && boxes_[i].size() > 0)
      save_boxes(f, boxes_[i], vs, width);
    else
      f << std::endl;
  }
  f.close();
  std::cout << "Kodiak (save): Boxes were saved in file " << os.str() << std::endl;
}
开发者ID:E-LLP,项目名称:Kodiak,代码行数:44,代码来源:Paver.cpp


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