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


C++ table::size方法代码示例

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


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

示例1: contains

bool contains(const table& tbl, int val)
  { // return true if tbl contains val
  int hash_val = hash(val) % tbl.size();
  bucket::const_iterator first = tbl[hash_val].begin();
  bucket::const_iterator last = tbl[hash_val].end();
  return find(first, last, val) != last;
  }
开发者ID:abo321,项目名称:books-code,代码行数:7,代码来源:hashtable.cpp

示例2: add_gradient

 /**
  * Adds the gradient of the expected log-likelihood of the specified
  * data point to the gradient table g.
  *
  * \param phead the distribution over a leading set of indices of f
  * \param tail a fixed assignment to the remaining indices of f
  * \param w the weight of the data point
  */
 void add_gradient(const table<T>& phead, const uint_vector& tail, T w,
                   table<T>& g) const {
   assert(phead.arity() + tail.size() == g.arity());
   std::size_t index = g.offset().linear(tail, phead.arity());
   for (std::size_t i = 0; i < phead.size(); ++i) {
     g[index + i] += phead[i] * w;
   }
 }
开发者ID:chongbingbao,项目名称:libgm,代码行数:16,代码来源:canonical_table_ll.hpp

示例3: add_hessian_diag

 /**
  * Adds the diagonal of the Hessia of the expected log-likelihoood of
  * the specified data point to the Hessian diagonal h.
  */
 void add_hessian_diag(const table<T>& phead, const uint_vector& tail, T w,
                       table<T>& h) const {
   assert(phead.arity() + tail.size() == h.arity());
   std::size_t index = h.offset().linear(tail, phead.arity());
   for (std::size_t i = 0; i < phead.size(); ++i) {
     h[index + i] -= phead[i] * w / (f[index + i] * f[index + i]);
   }
 }
开发者ID:chongbingbao,项目名称:libgm,代码行数:12,代码来源:probability_table_ll.hpp

示例4: show

void show(const table& tbl)
  { // show contents of buckets in table
  for (int i = 0; i < tbl.size(); ++i)
    { // show contents of bucket i
    cout << "bucket " << setw(2) << i << ": ";
    copy(tbl[i].begin(), tbl[i].end(),
      ostream_iterator<int>(cout, " "));
    cout << '\n';
    }
  }
开发者ID:abo321,项目名称:books-code,代码行数:10,代码来源:hashtable.cpp

示例5: insert

void insert(table& tbl, int val)
  { // insert val into table
  size_t hash_val = hash(val) % tbl.size();
  tbl[hash_val].push_back(val);
  }
开发者ID:abo321,项目名称:books-code,代码行数:5,代码来源:hashtable.cpp

示例6: restrict

 /**
  * Restricts the given table to an assignment to all the dimensions
  * >= n, where n is the arity of this table. The parameter x_start is
  * the linear index of the first element in the input table that should
  * be copied. This table must be preallocated, and its first n
  * dimensions must match the first n dimensions of the input table.
  */
 void restrict(const table& x, std::size_t x_start) {
   assert(arity() <= x.arity());
   assert(std::equal(shape_.begin(), shape_.end(), x.shape_.begin()));
   assert(x_start + size() <= x.size());
   std::copy(x.data() + x_start, x.data() + x_start + size(), data());
 }
开发者ID:chongbingbao,项目名称:libgm,代码行数:13,代码来源:table.hpp


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