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


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

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


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

示例1: getCovariance

void LegOdoCommon::getCovariance(LegOdoCommonMode mode_current, bool delta_certain,
  Eigen::MatrixXd &cov_legodo, Eigen::VectorXi &z_indices){
  
  // Determine which velocity variance to use
  double R_legodo_vxyz_current = R_legodo_vxyz_;
  double R_legodo_vang_current = R_legodo_vang_;
  if (!delta_certain){
    R_legodo_vxyz_current = R_legodo_vxyz_uncertain_;
    R_legodo_vang_current = R_legodo_vang_uncertain_;
  }
  
  Eigen::VectorXd R_legodo;
  if (mode_current == MODE_LIN_AND_ROT_RATE) {
    z_indices.resize(6);
    R_legodo.resize(6);
  }else if (mode_current == MODE_LIN_RATE){
    z_indices.resize(3);
    R_legodo.resize(3);
  }else if (mode_current == MODE_POSITION_AND_LIN_RATE){
    z_indices.resize(6);
    R_legodo.resize(6);
  }

  // Initialize covariance matrix based on mode.
  if (mode_current == MODE_LIN_AND_ROT_RATE) {
    R_legodo(0) = bot_sq(R_legodo_vxyz_current);
    R_legodo(1) = bot_sq(R_legodo_vxyz_current);
    R_legodo(2) = bot_sq(R_legodo_vxyz_current);
    R_legodo(3) = bot_sq(R_legodo_vang_current);
    R_legodo(4) = bot_sq(R_legodo_vang_current);
    R_legodo(5) = bot_sq(R_legodo_vang_current);
    
    z_indices.head<3>() = eigen_utils::RigidBodyState::velocityInds();
    z_indices.tail<3>() = eigen_utils::RigidBodyState::angularVelocityInds();
  }else if (mode_current == MODE_LIN_RATE){
    R_legodo(0) = bot_sq(R_legodo_vxyz_current);
    R_legodo(1) = bot_sq(R_legodo_vxyz_current);
    R_legodo(2) = bot_sq(R_legodo_vxyz_current);
    
    z_indices.head<3>() = eigen_utils::RigidBodyState::velocityInds();
  }else if (mode_current == MODE_POSITION_AND_LIN_RATE){
    R_legodo(0) = bot_sq(R_legodo_xyz_);
    R_legodo(1) = bot_sq(R_legodo_xyz_);
    R_legodo(2) = bot_sq(R_legodo_xyz_);
    R_legodo(3) = bot_sq(R_legodo_vxyz_current);
    R_legodo(4) = bot_sq(R_legodo_vxyz_current);
    R_legodo(5) = bot_sq(R_legodo_vxyz_current);
    
    z_indices.head<3>() = eigen_utils::RigidBodyState::positionInds();
    z_indices.tail<3>() = eigen_utils::RigidBodyState::velocityInds();    
  }
  
  cov_legodo = R_legodo.asDiagonal();

}
开发者ID:openhumanoids,项目名称:pronto,代码行数:55,代码来源:rbis_legodo_common.cpp

示例2: getParameterVectorMask

void FunctionApproximator::getParameterVectorMask(const std::set<std::string> selected_values_labels, Eigen::VectorXi& selected_mask) const {
  if (checkModelParametersInitialized())
    model_parameters_->getParameterVectorMask(selected_values_labels,selected_mask);
  else
    selected_mask.resize(0);
  
};
开发者ID:rlober,项目名称:dmpbbo,代码行数:7,代码来源:FunctionApproximator.cpp

示例3: runtime_error

Eigen::VectorXi
readLabelFromFile(const std::string &file, int padding)
{

    // check if file exists
    boost::filesystem::path path = file;
    if ( ! (boost::filesystem::exists ( path ) && boost::filesystem::is_regular_file(path)) )
        throw std::runtime_error ("Given file path to read Matrix does not exist!");

    std::ifstream in (file.c_str (), std::ifstream::in);

    char linebuf[819200];



    Eigen::VectorXi Vector;

    in.getline (linebuf, 819200);
        std::string line (linebuf);
        std::vector < std::string > strs_2;
        boost::split (strs_2, line, boost::is_any_of (" "));
        Vector.resize(strs_2.size()-1);
        for (int i = 0; i < strs_2.size()-1; i++)
            Vector ( i) = static_cast<int> (atof (strs_2[i].c_str ()));

    return Vector;
}
开发者ID:Cerarus,项目名称:v4r,代码行数:27,代码来源:eigen.cpp

示例4: main

int main(int argc, char *argv[])
{
  using namespace std;
  using namespace Eigen;

  // Load a mesh in OFF format
  igl::readOFF("../shared/bumpy.off", V, F);

  // Threshold faces with high anisotropy
  b.resize(1);
  b << 0;
  bc.resize(1,3);
  bc << 1,1,1;

  igl::Viewer viewer;

  // Interpolate the field and plot
  key_down(viewer, '4', 0);

  // Plot the mesh
  viewer.data.set_mesh(V, F);
  viewer.callback_key_down = &key_down;

  // Disable wireframe
  viewer.core.show_lines = false;

  // Launch the viewer
  viewer.launch();
}
开发者ID:JiaranZhou,项目名称:libigl,代码行数:29,代码来源:main.cpp

示例5: findMatchedIndex

void EigsGen::findMatchedIndex(const Eigen::VectorXcd &target,
                               const Eigen::VectorXcd &collection,
                               Eigen::VectorXi &result)
{
    int nfound = 0;
    int maxn = target.size();
    if(result.size() < maxn)
        result.resize(maxn);
    for(int i = 0; i < collection.size(); i++)
    {
        int j;
        for(j = 0; j < maxn; j++)
        {
            if(abs(collection[i] - target[j]) < 1e-8 * abs(target[j]))
                break;
        }
        if(j < maxn)
        {
            result[nfound] = i;
            nfound++;
            if(collection[i].imag() != 0)
            {
                i++;
                result[nfound] = i;
                nfound++;
            }
        }
        if(nfound >= maxn)  break;
    }
    if(result.size() > nfound)
        result.conservativeResize(nfound);
}
开发者ID:cran,项目名称:rARPACK,代码行数:32,代码来源:EigsGen.cpp

示例6: parse_rhs

void parse_rhs(
  const int nrhs, 
  const mxArray *prhs[], 
  Eigen::MatrixXd & V,
  Eigen::MatrixXi & Ele,
  Eigen::MatrixXd & Q,
  Eigen::MatrixXd & bb_mins,
  Eigen::MatrixXd & bb_maxs,
  Eigen::VectorXi & elements)
{
  using namespace std;
  using namespace igl;
  using namespace igl::matlab;
  mexErrMsgTxt(nrhs >= 3, "The number of input arguments must be >=3.");

  const int dim = mxGetN(prhs[0]);
  mexErrMsgTxt(dim == 3 || dim == 2,
    "Mesh vertex list must be #V by 2 or 3 list of vertex positions");

  mexErrMsgTxt(dim+1 == mxGetN(prhs[1]),
    "Mesh \"face\" simplex size must equal dimension+1");

  parse_rhs_double(prhs,V);
  parse_rhs_index(prhs+1,Ele);
  parse_rhs_double(prhs+2,Q);
  mexErrMsgTxt(Q.cols() == dim,"Dimension of Q should match V");
  if(nrhs > 3)
  {
    mexErrMsgTxt(nrhs >= 6, "The number of input arguments must be 3 or >=6.");
    parse_rhs_double(prhs+3,bb_mins);
    if(bb_mins.size()>0)
    {
      mexErrMsgTxt(bb_mins.cols() == dim,"Dimension of bb_mins should match V");
      mexErrMsgTxt(bb_mins.rows() >= Ele.rows(),"|bb_mins| should be > |Ele|");
    }
    parse_rhs_double(prhs+4,bb_maxs);
    mexErrMsgTxt(bb_maxs.cols() == bb_mins.cols(),
      "|bb_maxs| should match |bb_mins|");
    mexErrMsgTxt(bb_mins.rows() == bb_maxs.rows(),
      "|bb_mins| should match |bb_maxs|");
    parse_rhs_index(prhs+5,elements);
    mexErrMsgTxt(elements.cols() == 1,"Elements should be column vector");
    mexErrMsgTxt(bb_mins.rows() == elements.rows(),
      "|bb_mins| should match |elements|");
  }else
  {
    // Defaults
    bb_mins.resize(0,dim);
    bb_maxs.resize(0,dim);
    elements.resize(0,1);
  }
}
开发者ID:WoodMath,项目名称:gptoolbox,代码行数:52,代码来源:in_element_aabb.cpp

示例7: vectorToIntEigenVector

    template<typename T> Eigen::VectorXi vectorToIntEigenVector( T &array )
    {
        Eigen::VectorXi eigenVector;

        size_t N_elements = array.size();

        eigenVector.resize( N_elements );

        for ( size_t i = 0; i < N_elements; i++ )
            eigenVector( i ) = array[i];

        return eigenVector;
    }
开发者ID:jotaraul,项目名称:upgmpp,代码行数:13,代码来源:base_utils.hpp

示例8: signed_distance_pseudonormal

IGL_INLINE void igl::signed_distance_pseudonormal(
  const Eigen::MatrixXd & P,
  const Eigen::MatrixXd & V,
  const Eigen::MatrixXi & F,
  const AABB<Eigen::MatrixXd,3> & tree,
  const Eigen::MatrixXd & FN,
  const Eigen::MatrixXd & VN,
  const Eigen::MatrixXd & EN,
  const Eigen::VectorXi & EMAP,
  Eigen::VectorXd & S,
  Eigen::VectorXi & I,
  Eigen::MatrixXd & C,
  Eigen::MatrixXd & N)
{
  using namespace Eigen;
  const size_t np = P.rows();
  S.resize(np,1);
  I.resize(np,1);
  N.resize(np,3);
  C.resize(np,3);
# pragma omp parallel for if(np>1000)
  for(size_t p = 0;p<np;p++)
  {
    double s,sqrd;
    RowVector3d n,c;
    int i = -1;
    RowVector3d q = P.row(p);
    signed_distance_pseudonormal(tree,V,F,FN,VN,EN,EMAP,q,s,sqrd,i,c,n);
    S(p) = s*sqrt(sqrd);
    I(p) = i;
    N.row(p) = n;
    C.row(p) = c;
  }
//  igl::AABB<MatrixXd,3> tree_P;
//  MatrixXi J = VectorXi::LinSpaced(P.rows(),0,P.rows()-1);
//  tree_P.init(P,J);
//  tree.squared_distance(V,F,tree_P,P,J,S,I,C);
//# pragma omp parallel for if(np>1000)
//  for(size_t p = 0;p<np;p++)
//  {
//    RowVector3d c = C.row(p);
//    RowVector3d q = P.row(p);
//    const int f = I(p);
//    double s;
//    RowVector3d n;
//    pseudonormal_test(V,F,FN,VN,EN,EMAP,q,f,c,s,n);
//    N.row(p) = n;
//    S(p) = s*sqrt(S(p));
//  }

}
开发者ID:JianpingCAI,项目名称:libigl,代码行数:51,代码来源:signed_distance.cpp

示例9: readSamples

void readSamples(const std::string &fname, Eigen::VectorXi &samples)
{
  int numSamples;
  FILE *fp = fopen(fname.c_str(),"r");
  if (fscanf(fp, "%d", &numSamples)!=1)
  {
    fclose(fp);
    return;
  }
  samples.resize(numSamples,1);
  int vali;
  for (int i =0; i<numSamples; ++i)
  {
    if (fscanf(fp, "%d", &vali)!=1 || vali<0)
    {
      fclose(fp);
      samples.resize(0,1);
      return;
    }
    samples[i]=vali;
  }
  fclose(fp);
  
}
开发者ID:danielepanozzo,项目名称:libigl,代码行数:24,代码来源:main.cpp

示例10: main

int main(int argc, char *argv[])
{
  using namespace Eigen;
  using namespace std;
  MatrixXd V;
  MatrixXi F;
  igl::readOFF(TUTORIAL_SHARED_PATH "/cheburashka.off",V,F);

  // Plot the mesh
  igl::opengl::glfw::Viewer viewer;
  viewer.data().set_mesh(V, F);
  viewer.data().show_lines = false;
  viewer.callback_key_down = &key_down;

  // One fixed point
  b.resize(1,1);
  // point on belly.
  b<<2556;
  bc.resize(1,1);
  bc<<1;

  // Construct Laplacian and mass matrix
  SparseMatrix<double> L,M,Minv;
  igl::cotmatrix(V,F,L);
  igl::massmatrix(V,F,igl::MASSMATRIX_TYPE_VORONOI,M);
  //M = (M/M.diagonal().maxCoeff()).eval();
  igl::invert_diag(M,Minv);
  // Bi-Laplacian
  Q = L.transpose() * (Minv * L);
  // Zero linear term
  B = VectorXd::Zero(V.rows(),1);

  // Lower and upper bound
  lx = VectorXd::Zero(V.rows(),1);
  ux = VectorXd::Ones(V.rows(),1);

  // Equality constraint constrain solution to sum to 1
  Beq.resize(1,1);
  Beq(0) = 0.08;
  Aeq = M.diagonal().sparseView().transpose();
  // (Empty inequality constraints)
  solve(viewer);
  cout<<
    "Press '.' to increase scale and resolve."<<endl<<
    "Press ',' to decrease scale and resolve."<<endl;

  viewer.launch();
}
开发者ID:bbrrck,项目名称:libigl,代码行数:48,代码来源:main.cpp

示例11: getParameterVectorMask

void Dmp::getParameterVectorMask(const std::set<std::string> selected_values_labels, Eigen::VectorXi& selected_mask) const
{
  cout << __FILE__ << ":" << __LINE__ << ":Here" << endl;

  selected_mask.resize(getParameterVectorAllSize());
  selected_mask.fill(0);
  
  int offset = 0;
  VectorXi cur_mask;
  for (int dd=0; dd<dim_orig(); dd++)
  {
    function_approximators_[dd]->getParameterVectorMask(selected_values_labels,cur_mask);
    selected_mask.segment(offset,cur_mask.size()) = cur_mask;
    offset += cur_mask.size();
  }
  //nnn Check for multi-dim dmps

  assert(offset == getParameterVectorAllSize());   
}
开发者ID:humm,项目名称:dovecot,代码行数:19,代码来源:Dmp.cpp

示例12: runtime_error

void calin::iact_data::instrument_layout::map_channels_using_from_coordinates(
  Eigen::VectorXi& map,
  const std::vector<double>& from_x, const std::vector<double>& from_y,
  const calin::ix::iact_data::instrument_layout::CameraLayout& to,
  double tolerance)
{
  tolerance *= tolerance;
  if(from_x.size() != from_y.size())
    throw std::runtime_error("X and Y coordinate vectors must be same size.");
  map.resize(to.channel_size());
  for(int ichan=0; ichan<to.channel_size(); ichan++) {
    const auto& chan = to.channel(ichan);
    map[ichan] = -1;
    for(unsigned jchan=0; jchan<from_x.size(); jchan++) {
      double d2 = SQR(chan.x()-from_x[jchan])+SQR(chan.y()-from_y[jchan]);
      if(d2 < tolerance) {
        map[ichan] = jchan;
        break;
      }
    }
  }
}
开发者ID:sfegan,项目名称:calin,代码行数:22,代码来源:instrument_layout.cpp

示例13: query

IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance(
  const Eigen::MatrixXd & P,
  const CGAL::AABB_tree<
    CGAL::AABB_traits<Kernel, 
      CGAL::AABB_triangle_primitive<Kernel, 
        typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
      >
    >
  > & tree,
  const std::vector<CGAL::Triangle_3<Kernel> > & T,
  Eigen::VectorXd & sqrD,
  Eigen::VectorXi & I,
  Eigen::MatrixXd & C)
{
  typedef CGAL::Triangle_3<Kernel> Triangle_3; 
  typedef typename std::vector<Triangle_3>::iterator Iterator;
  typedef CGAL::AABB_triangle_primitive<Kernel, Iterator> Primitive;
  typedef CGAL::AABB_traits<Kernel, Primitive> AABB_triangle_traits;
  typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
  typedef typename Tree::Point_and_primitive_id Point_and_primitive_id;
  typedef CGAL::Point_3<Kernel>    Point_3;
  assert(P.cols() == 3);
  const int n = P.rows();
  sqrD.resize(n,1);
  I.resize(n,1);
  C.resize(n,P.cols());
  for(int p = 0;p < n;p++)
  {
    Point_3 query(P(p,0),P(p,1),P(p,2));
    // Find closest point and primitive id
    Point_and_primitive_id pp = tree.closest_point_and_primitive(query);
    Point_3 closest_point = pp.first;
    C(p,0) = CGAL::to_double(closest_point[0]);
    C(p,1) = CGAL::to_double(closest_point[1]);
    C(p,2) = CGAL::to_double(closest_point[2]);
    sqrD(p) = CGAL::to_double((closest_point-query).squared_length());
    I(p) = pp.second - T.begin();
  }
}
开发者ID:AurelGruber,项目名称:Scalable-Locally-Injective-Mappings,代码行数:39,代码来源:point_mesh_squared_distance.cpp

示例14: if

void calin::iact_data::instrument_layout::map_channels_using_grid(
  Eigen::VectorXi& map,
  const calin::ix::iact_data::instrument_layout::CameraLayout& from,
  const calin::ix::iact_data::instrument_layout::CameraLayout& to)
{
  std::map<unsigned, int> grid_map;
  for(int ichan=0; ichan<from.channel_size(); ichan++) {
    const auto& chan = from.channel(ichan);
    if(chan.pixel_grid_index() >= 0)
      grid_map[chan.pixel_grid_index()] = chan.channel_index();
  }
  map.resize(to.channel_size());
  for(int ichan=0; ichan<to.channel_size(); ichan++) {
    const auto& chan = to.channel(ichan);
    if(chan.pixel_grid_index() < 0)
      map[ichan] = -1;
    else if(grid_map.find(chan.pixel_grid_index()) == grid_map.end())
      map[ichan] = -1;
    else
      map[ichan] = grid_map[chan.pixel_grid_index()];
  }
}
开发者ID:sfegan,项目名称:calin,代码行数:22,代码来源:instrument_layout.cpp

示例15: polyvector_field_one_ring_matchings

void igl::polyvector_field_one_ring_matchings(const Eigen::PlainObjectBase<DerivedV> &V,
                                              const Eigen::PlainObjectBase<DerivedF> &F,
                                              const std::vector<std::vector<VFType> >& VF,
                                              const Eigen::MatrixXi& E2F,
                                              const Eigen::MatrixXi& F2E,
                                              const Eigen::PlainObjectBase<DerivedTT>& TT,
                                              const Eigen::PlainObjectBase<DerivedM> &match_ab,
                                              const Eigen::PlainObjectBase<DerivedM> &match_ba,
                                              const int vi,
                                              Eigen::MatrixXi &mvi,
                                              Eigen::VectorXi &fi)
{
  int half_degree = match_ab.cols();
  mvi.resize(VF[vi].size()+1,half_degree);
  fi.resize(VF[vi].size()+1,1);
  //start from one face
  //first, check if the vertex is on a boundary
  //then there must be two faces that are on the boundary
  //(other cases not supported)

  int fstart = -1;
  int ind = 0;
  for (int i =0; i<VF[vi].size(); ++i)
  {
    int fi = VF[vi][i];
    for (int  j=0; j<3; ++j)
      if (F(fi,j)==vi && TT(fi,j) == -1)
      {
        ind ++;
        fstart = fi;
        //        break;
      }
  }
  if (ind >1 )
  {
    std::cerr<<"igl::polyvector_field_one_ring_matchings -- vertex "<<vi<< " is on an unusual boundary"<<std::endl;
    exit(1);
  }
  if (fstart == -1)
    fstart = VF[vi][0];
  int current_face = fstart;
  int i =0;
  fi[i] = current_face;
  for (int j=0; j<half_degree; ++j)
    mvi(i,j) = j;

  int next_face = -1;
  while (next_face != fstart && current_face!=-1)
  {
    // look for the vertex
    int j=-1;
    for (unsigned z=0; z<3; ++z)
      if (F(current_face,(z+1)%3) == vi)
      {
        j=z;
        break;
      }
    assert(j!=-1);

    next_face = TT(current_face, j);
    ++i;

    if (next_face == -1)
      mvi.row(i).setConstant(-1);
    else
    {
      // look at the edge between the two faces
      const int &current_edge = F2E(current_face,j);

      for (int k=0; k<half_degree; ++k)
      {
        // check its orientation to determine whether match_ab or match_ba should be used
        if ((E2F(current_edge,0) == current_face) &&
            (E2F(current_edge,1) == next_face) )
        {
          //look at match_ab
          mvi(i,k) = match_ab(current_edge,(mvi(i-1,k))%half_degree);
        }
        else
        {
          assert((E2F(current_edge,1) == current_face) &&
                 (E2F(current_edge,0) == next_face));
          //look at match_ba
          mvi(i,k) = match_ba(current_edge,(mvi(i-1,k))%half_degree);
        }
        if (mvi(i-1,k)>=half_degree)
          mvi(i,k) = (mvi(i,k)+half_degree)%(2*half_degree);
      }
    }
    current_face = next_face;
    fi[i] = current_face;
  }
}
开发者ID:heartnheart,项目名称:libigl,代码行数:93,代码来源:polyvector_field_singularities_from_matchings.cpp


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