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


C++ bipartite_graph_descriptor::is_square方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: init_lanczos

void init_lanczos(bipartite_graph_descriptor & info){
  srand48(time(NULL));
  latent_factors_inmem.resize(info.total());
  data_size = nsv + nv+1 + max_iter;
  if (info.is_square())
    data_size *= 2;
  actual_vector_len = data_size;
#pragma omp parallel for
  for (int i=0; i< info.total(); i++){
      latent_factors_inmem[i].pvec = zeros(actual_vector_len);
  } 
  logstream(LOG_INFO)<<"Allocated a total of: " << ((double)actual_vector_len * info.total() * sizeof(double)/ 1e6) << " MB for storing vectors." << std::endl;
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:13,代码来源:svd.cpp

示例6: 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

示例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& 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); 
   //set_engine_flags(engine);
   //Axb program;
   pengine->run(program, 1);
   debug_print(name);
   mi.reset_offsets();
   return *this;
 }
开发者ID:Alienfeel,项目名称:graphchi-cpp,代码行数:23,代码来源:math.hpp

示例9: assert

DistVec& 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;
      INITIALIZE_TRACER(Axbtrace2, "Update function Axb");
      BEGIN_TRACEPOINT(Axbtrace2);
      pcurrent = (DistVec*)&vec;
      start_engine();
      debug_print(name);
      mi.reset_offsets();
      return *this;
    }
开发者ID:Alienfeel,项目名称:graphlab,代码行数:23,代码来源:math.hpp

示例10: 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

示例11: 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


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