• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ bipartite_graph_descriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DistSlicedMat

 DistSlicedMat(int _start_offset, int _end_offset, bool _transpose, const bipartite_graph_descriptor &_info, std::string _name){
   //assert(_start_offset < _end_offset);
   assert(_start_offset >= 0);
   assert(_info.total() > 0);
   transpose = _transpose;
   info = _info;
   init();
   start_offset = _start_offset;
   end_offset = _end_offset;
   name = _name;
 }
开发者ID:bmabey,项目名称:graphchi,代码行数:11,代码来源:math.hpp


示例2: diag

vec diag(DistMat & mat){
  assert(info.is_square());
  vec ret = zeros(info.total());
  for (int i=0; i< info.total(); i++){
    ret[i] = latent_factors_inmem[i].A_ii;
  }
  return ret;
}
开发者ID:bmabey,项目名称:graphchi,代码行数:8,代码来源:math.hpp


示例3: diag

vec diag(DistMat & mat){
  assert(info.is_square());
  vec ret = zeros(info.total());
  for (int i=0; i< info.total(); i++){
    //TODO ret[i] = pgraph->vertex_data(i).A_ii;
    assert(false);
  }
  return ret;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:9,代码来源:math.hpp


示例4: update

  /**
   *  Vertex update function.
   */
  void update(graphchi_vertex<VertexDataType, EdgeDataType> &vertex, graphchi_context &gcontext) {

    if (vertex.id() < (uint)mi.start || vertex.id() >= (uint)mi.end)
      return;

    vertex_data& user = latent_factors_inmem[vertex.id()];
    bool rows = vertex.id() < (uint)info.get_start_node(false);
    if (info.is_square()) 
      rows = mi.A_transpose;
    (void) rows; // unused
    assert(mi.r_offset >=0);
    //store previous value for convergence detection
    if (mi.prev_offset >= 0)
      user.pvec[mi.prev_offset ] = user.pvec[mi.r_offset];

    double val = 0;
    assert(mi.x_offset >=0 || mi.y_offset>=0);

    /*** COMPUTE r = c*A*x  ********/
    if (mi.A_offset  && mi.x_offset >= 0){
      for(int e=0; e < vertex.num_edges(); e++) {
        const edge_data & edge = vertex.edge(e)->get_data();
        const vertex_data  & movie = latent_factors_inmem[vertex.edge(e)->vertex_id()];
        val += (edge.weight * movie.pvec[mi.x_offset]);
      }

      if  (info.is_square() && mi.use_diag)// add the diagonal term
        val += (/*mi.c**/ (user.A_ii+ regularization) * user.pvec[mi.x_offset]);

      val *= mi.c;
    }
    /***** COMPUTE r = c*I*x  *****/
    else if (!mi.A_offset && mi.x_offset >= 0){
      val = mi.c*user.pvec[mi.x_offset];
    }

    /**** COMPUTE r+= d*y (optional) ***/
    if (mi.y_offset>= 0){
      val += mi.d*user.pvec[mi.y_offset]; 
    }

    /***** compute r = (... ) / div */
    if (mi.div_offset >= 0){
      val /= user.pvec[mi.div_offset];
    }
    assert(mi.r_offset>=0 && mi.r_offset < user.pvec.size());
    user.pvec[mi.r_offset] = val;
  } //end update
开发者ID:Alienfeel,项目名称:graphchi-cpp,代码行数:51,代码来源:math.hpp


示例5: assert

DistVec& DistVec::operator=(DistMat &mat){
  mi.r_offset = offset;
  assert(prev_offset < data_size);
  mi.prev_offset = prev_offset;
  transpose = mat.transpose;
  mi.start = info.get_start_node(!transpose);
  mi.end = info.get_end_node(!transpose);
  //graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); 
  //set_engine_flags(engine);
  //Axb program;
  pengine->run(program, 1);
  debug_print(name);
  mi.reset_offsets();
  mat.transpose = false;
  return *this;
}
开发者ID:Alienfeel,项目名称:graphchi-cpp,代码行数:16,代码来源:math.hpp


示例6: assert

 DistVec& operator=(const DistVec & vec){
   assert(offset < (info.is_square() ? 2*data_size: data_size));
   if (mi.x_offset == -1 && mi.y_offset == -1){
     mi.y_offset = vec.offset;
   }  
   mi.r_offset = offset;
   assert(prev_offset < data_size);
   mi.prev_offset = prev_offset;
   if (mi.d == 0.0)
     mi.d=1.0;
   transpose = vec.transpose;
   end = vec.end; 
   start = vec.start;
   mi.start = start;
   mi.end = end;
   graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); 
   engine.set_disable_vertexdata_storage();  
   engine.set_modifies_inedges(false);
   engine.set_modifies_outedges(false);
   Axb program;
   engine.run(program, 1);
   debug_print(name);
   mi.reset_offsets();
   return *this;
 }
开发者ID:bmabey,项目名称:graphchi,代码行数:25,代码来源:math.hpp


示例7: gather

    /* Gather the weighted rank of the adjacent page   */
    double gather(icontext_type& context, const vertex_type& vertex,
        edge_type& edge) const {

      if (edge.data().role == edge_data::PREDICT)
         return 0;

      bool brows = vertex.id() < (uint)info.get_start_node(false);
      if (info.is_square()) 
        brows = !mi.A_transpose;
      if (mi.A_offset  && mi.x_offset >= 0){
        double val = edge.data().obs * (brows ? edge.target().data().pvec[mi.x_offset] :
            edge.source().data().pvec[mi.x_offset]);
        //printf("gather edge on vertex %d val %lg obs %lg\n", vertex.id(), val, edge.data().obs);
        return val;
      }
      //printf("edge on vertex %d val %lg\n", vertex.id(), 0.0);
      return 0;
    }
开发者ID:Alienfeel,项目名称:graphlab,代码行数:19,代码来源:math.hpp


示例8: assert

DistVec& DistVec::operator=(DistMat &mat){
  mi.r_offset = offset;
  assert(prev_offset < data_size);
  mi.prev_offset = prev_offset;
  transpose = mat.transpose;
  mi.start = info.get_start_node(!transpose);
  mi.end = info.get_end_node(!transpose);
  INITIALIZE_TRACER(Axbtrace, "Axb update function");
  BEGIN_TRACEPOINT(Axbtrace);
  pcurrent = this;
  int old_start = start; int old_end = end;
  start = mi.start; end = mi.end;
  start_engine();
  start = old_start; end = old_end;
  END_TRACEPOINT(Axbtrace);
  debug_print(name);
  mi.reset_offsets();
  mat.transpose = false;
  return *this;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:20,代码来源:math.hpp


示例9: multiply

void multiply(DistSlicedMat & mat, int curoffset, double a){

  assert(a>0);
  DistVec current = mat[curoffset];
  assert(mat.start_offset <= current.offset); 
  vec result = zeros(curoffset);

  if (curoffset > 0){

#pragma omp parallel for
    for (int i=mat.start_offset; i< current.offset; i++){
      for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
        result[i-mat.start_offset] += latent_factors_inmem[k].pvec[i] * latent_factors_inmem[k].pvec[current.offset];
      }
    }
#pragma omp parallel for
    for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
      latent_factors_inmem[k].pvec[curoffset] /= a;
    }

    for (int i=mat.start_offset; i< current.offset; i++){
#pragma omp parallel for
      for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
        latent_factors_inmem[k].pvec[current.offset] -= result[i-mat.start_offset]/a  * latent_factors_inmem[k].pvec[i];
      }
    }
  }

  current.debug_print(current.name);
}
开发者ID:bmabey,项目名称:graphchi,代码行数:30,代码来源:math.hpp


示例10: orthogonalize_vs_all

void orthogonalize_vs_all(DistSlicedMat & mat, int curoffset, double &alpha){
  assert(mi.ortho_repeats >=1 && mi.ortho_repeats <= 3);
  bool old_debug = debug;
  debug = false;
  DistVec current = mat[curoffset];
  assert(mat.start_offset <= current.offset); 
  double * alphas = new double[curoffset];
  //DistDouble * alphas = new DistDouble[curoffset];
  //cout<<current.to_vec().transpose() << endl;
  if (curoffset > 0){
    for (int j=0; j < mi.ortho_repeats; j++){
      memset(alphas, 0, sizeof(double)*curoffset);
#pragma omp parallel for
      for (int i=mat.start_offset; i< current.offset; i++){
        for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
          assert(i-mat.start_offset>=0 && i-mat.start_offset < curoffset);
          assert(i < latent_factors_inmem[k].pvec.size());
          assert(k < (int)latent_factors_inmem.size());
          assert(current.offset < latent_factors_inmem[k].pvec.size());
          alphas[i-mat.start_offset] += latent_factors_inmem[k].pvec[i] * latent_factors_inmem[k].pvec[current.offset];
        }
      }
      for (int i=mat.start_offset; i< current.offset; i++){
#pragma omp parallel for
        for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
          latent_factors_inmem[k].pvec[current.offset] -= alphas[i-mat.start_offset]  * latent_factors_inmem[k].pvec[i];
        }
      }
    } //for ortho_repeast 
  }

  delete [] alphas; 
  debug = old_debug;
  current.debug_print(current.name);
  //    alpha = 0;
  double sum = 0;
  int k;
  //#pragma omp parallel for private(k) reduction(+: sum)
  for (k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
    sum = sum + pow(latent_factors_inmem[k].pvec[current.offset],2);
  }    
  alpha = sqrt(sum);
  if (alpha >= 1e-10 ){
#pragma omp parallel for
    for (int k=info.get_start_node(!current.transpose); k< info.get_end_node(!current.transpose); k++){
      latent_factors_inmem[k].pvec[current.offset]/=alpha;
    }    
  }
}
开发者ID:Alienfeel,项目名称:graphchi-cpp,代码行数:49,代码来源:math.hpp


示例11: apply

    /* Use the total rank of adjacent pages to update this page */
    void apply(icontext_type& context, vertex_type& vertex,
        const double& total) {

      //printf("Entered apply on node %d value %lg\n", vertex.id(), total);
      vertex_data & user = vertex.data();
      assert(mi.x_offset >=0 || mi.y_offset >= 0);
      assert(mi.r_offset >=0);

      /* perform orthogonalization of current vector */
      if (mi.orthogonalization){
         for (int i=mi.mat_offset; i< mi.vec_offset; i++){
            vertex.data().pvec[mi.vec_offset] -= alphas.pvec[i-mi.mat_offset] * vertex.data().pvec[i]; 
         }
         return;
      }

      double val = total;
      //assert(total != 0 || mi.y_offset >= 0);

      //store previous value for convergence detection
      if (mi.prev_offset >= 0)
        user.pvec[mi.prev_offset ] = user.pvec[mi.r_offset];

      assert(mi.x_offset >=0 || mi.y_offset>=0);
      if (mi.A_offset  && mi.x_offset >= 0){
        if  (info.is_square() && mi.use_diag)// add the diagonal term
          val += (/*mi.c**/ (user.A_ii+ regularization) * user.pvec[mi.x_offset]);
        //printf("node %d added diag term: %lg\n", vertex.id(), user.A_ii);
        val *= mi.c;
      }
      /***** COMPUTE r = c*I*x  *****/
      else if (!mi.A_offset && mi.x_offset >= 0){
        val = mi.c*user.pvec[mi.x_offset];
      }

      /**** COMPUTE r+= d*y (optional) ***/
      if (mi.y_offset>= 0){
        val += mi.d*user.pvec[mi.y_offset]; 
      }

      /***** compute r = (... ) / div */
      if (mi.div_offset >= 0){
        val /= user.pvec[mi.div_offset];
      }

      user.pvec[mi.r_offset] = val;
      //printf("Exit apply on node %d value %lg\n", vertex.id(), val);
    }
开发者ID:Alienfeel,项目名称:graphlab,代码行数:49,代码来源:math.hpp


示例12: assign_vec

void assign_vec(graph_type::vertex_type & vertex){
  if (!info.is_square())
    assert(vertex.id() - pcurrent->start >= 0 && vertex.id() - pcurrent->start < curvec.size());
  vertex.data().pvec[pcurrent->offset] = curvec[vertex.id() - pcurrent->start];
}  
开发者ID:Alienfeel,项目名称:graphlab,代码行数:5,代码来源:math.hpp


示例13: init

 void init(){
   start = info.get_start_node(!transpose);
   end = info.get_end_node(!transpose);
   assert(start < end && start >= 0 && end >= 1);
   //debug_print(name);
 };
开发者ID:bmabey,项目名称:graphchi,代码行数:6,代码来源:math.hpp


示例14: selected_node

 bool selected_node(const graph_type::vertex_type& vertex){
   if (info.is_square())
     return true;
   else return ((vertex.id() >= (uint)info.get_start_node(!pcurrent->transpose)) &&
       (vertex.id() < (uint)info.get_end_node(!pcurrent->transpose)));
 }
开发者ID:Alienfeel,项目名称:graphlab,代码行数:6,代码来源:math.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ bit_vector类代码示例发布时间:2022-05-31
下一篇:
C++ bigint类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap