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


C++ MatrixXd::rows方法代码示例

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


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

示例1: Newmark

Eigen::MatrixXd TimeIntegrator::Newmark(Eigen::MatrixXd &K, Eigen::MatrixXd &M, double &del, double &gam)
{
    Eigen::MatrixXd U,V,A;
    U.setZero(K.rows(),_nstep+1);
    V.setZero(K.rows(),_nstep+1); A.setZero(K.rows(),_nstep+1);
    Eigen::VectorXd F = Eigen::VectorXd::Zero(K.rows());
    // Loop over time steps
    for (int istep=0; istep<_nstep; ++istep)
    {
        for (int i=0; i<_napp.rows(); ++i)
        {
            F(_napp(i)) = F1(istep);
        }

        U.col(istep+1) = (1.0/(_dt*_dt*gam)*M+K).llt().solve(F+1.0/(_dt*_dt*gam)*M*U.col(istep)+1/(_dt*gam)*M*V.col(istep)+(1.0/(2*gam)-1.0)*M*A.col(istep));
        A.col(istep+1) = 1.0/(_dt*_dt*gam)*(U.col(istep+1)-U.col(istep))-1.0/(_dt*gam)*V.col(istep)+(1.0-1.0/(2.0*gam))*A.col(istep);
        V.col(istep+1) = V.col(istep)+_dt*(del*A.col(istep+1)+(1-del)*A.col(istep));
    }
    return U;
}
开发者ID:koecher,项目名称:FEAPB,代码行数:20,代码来源:TimeIntegration.cpp

示例2: relabelFaces

void relabelFaces(Eigen::MatrixXi& aggregated,
                  const Eigen::MatrixXd& vertices,
                  const Eigen::MatrixXi& faces,
                  Eigen::Vector3i& vertexOffset,
                  int& offset) {
  for (int i = 0; i < faces.rows(); i++) {
    aggregated.row(offset++) = vertexOffset + Eigen::Vector3i(faces.row(i));
  }
  int numVerts = vertices.rows();
  vertexOffset += Eigen::Vector3i(numVerts, numVerts, numVerts);
}
开发者ID:evouga,项目名称:tiling,代码行数:11,代码来源:SliceStack.cpp

示例3: setNullForceTorque

void ATIForceTorqueSensorTWE::setNullForceTorque(Eigen::MatrixXd ft_null)
{
	if( (ft_null.rows() != 6) || (ft_null.cols() != 1) ){
		ROS_ERROR("Invalid ft null size");
		return;
	}

	ft_scale_param_mutex_.lock();
	ft_null_ = ft_null;
	ft_scale_param_mutex_.unlock();
}
开发者ID:ROBOTIS-GIT,项目名称:ROBOTIS-THORMANG-MPC,代码行数:11,代码来源:ati_force_torque_sensor_twe.cpp

示例4: SwapCols

void lpengine::SwapCols(Eigen::MatrixXd& matn, int index_matn,
                        Eigen::MatrixXd& matb, int index_matb) {
  Eigen::VectorXd tmp(matb.rows());
  tmp = matb.col(index_matb);
  matb.col(index_matb) = matn.col(index_matn);
  matn.col(index_matn) = tmp;
  int tmp_index;
  tmp_index = p_.basic_set_[index_matb];
  p_.basic_set_[index_matb] = p_.nonbasic_set_[index_matn];
  p_.nonbasic_set_[index_matn] = tmp_index;
}
开发者ID:sinaaghli,项目名称:lp-engine,代码行数:11,代码来源:lpengine.cpp

示例5:

IGL_INLINE void igl::ViewerData::add_points(const Eigen::MatrixXd& P,  const Eigen::MatrixXd& C)
{
  Eigen::MatrixXd P_temp;

  // If P only has two columns, pad with a column of zeros
  if (P.cols() == 2)
  {
    P_temp = Eigen::MatrixXd::Zero(P.rows(),3);
    P_temp.block(0,0,P.rows(),2) = P;
  }
  else
    P_temp = P;

  int lastid = points.rows();
  points.conservativeResize(points.rows() + P_temp.rows(),6);
  for (unsigned i=0; i<P_temp.rows(); ++i)
    points.row(lastid+i) << P_temp.row(i), i<C.rows() ? C.row(i) : C.row(C.rows()-1);

  dirty |= DIRTY_OVERLAY_POINTS;
}
开发者ID:daniel-perry,项目名称:libigl,代码行数:20,代码来源:ViewerData.cpp

示例6: BuildConnectivity

bool FastMarchingData::BuildConnectivity(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
{
	if (V.rows() == 0 || F.rows() == 0) return false;
	//V_border = igl::is_border_vertex(V, F);
	vertex_vertex_adjacency(F, VV);
	vertex_triangle_adjacency(F, VF);
	triangle_triangle_adjacency(F, TT, TTi);
	// igl::edge_topology(V, F, E, F2E, E2F);
	
	return true;
}
开发者ID:hwdong,项目名称:deformation_graph,代码行数:11,代码来源:fast_marching.cpp

示例7: Yhat

void MacauOnePrior<FType>::sample_latents(
    Eigen::MatrixXd &U,
    const Eigen::SparseMatrix<double> &Ymat,
    double mean_value,
    const Eigen::MatrixXd &V,
    double alpha,
    const int num_latent)
{
  const int N = U.cols();
  const int D = U.rows();

#pragma omp parallel for schedule(dynamic, 4)
  for (int i = 0; i < N; i++) {

    const int nnz = Ymat.outerIndexPtr()[i + 1] - Ymat.outerIndexPtr()[i];
    VectorXd Yhat(nnz);

    // precalculating Yhat and Qi
    int idx = 0;
    VectorXd Qi = lambda;
    for (SparseMatrix<double>::InnerIterator it(Ymat, i); it; ++it, idx++) {
      Qi.noalias() += alpha * V.col(it.row()).cwiseAbs2();
      Yhat(idx)     = mean_value + U.col(i).dot( V.col(it.row()) );
    }
    VectorXd rnorms(num_latent);
    bmrandn_single(rnorms);

    for (int d = 0; d < D; d++) {
      // computing Lid
      const double uid = U(d, i);
      double Lid = lambda(d) * (mu(d) + Uhat(d, i));

      idx = 0;
      for ( SparseMatrix<double>::InnerIterator it(Ymat, i); it; ++it, idx++) {
        const double vjd = V(d, it.row());
        // L_id += alpha * (Y_ij - k_ijd) * v_jd
        Lid += alpha * (it.value() - (Yhat(idx) - uid*vjd)) * vjd;
      }
      // Now use Lid and Qid to update uid
      double uid_old = U(d, i);
      double uid_var = 1.0 / Qi(d);

      // sampling new u_id ~ Norm(Lid / Qid, 1/Qid)
      U(d, i) = Lid * uid_var + sqrt(uid_var) * rnorms(d);

      // updating Yhat
      double uid_delta = U(d, i) - uid_old;
      idx = 0;
      for (SparseMatrix<double>::InnerIterator it(Ymat, i); it; ++it, idx++) {
        Yhat(idx) += uid_delta * V(d, it.row());
      }
    }
  }
}
开发者ID:jaak-s,项目名称:macau,代码行数:54,代码来源:macauoneprior.cpp

示例8: load

void load( Archive & ar,
           Eigen::MatrixXd & t,
           const unsigned int file_version )
{
    int n0;
    ar >> BOOST_SERIALIZATION_NVP( n0 );
    int n1;
    ar >> BOOST_SERIALIZATION_NVP( n1 );
    t.resize( n0, n1 );
    ar >> make_array( t.data(), t.rows()*t.cols() );
}
开发者ID:feelpp,项目名称:feelpp,代码行数:11,代码来源:serialization.hpp

示例9: compare_force_constant_matrix

void compare_force_constant_matrix(
        Eigen::MatrixXd & low_carb_result,
        const std::string & filename_reach_results,
        double precision,
        bool is_hex,
        bool toggle_row_and_col) {

    if (!exists(boost::filesystem::path(filename_reach_results))) {
        throw std::runtime_error("file does not exist: " + filename_reach_results);
    }

    std::ifstream file_reach_results;
    file_reach_results.open(filename_reach_results);

    size_t rows=0;
    size_t cols=0;

    std::string row;

    while (std::getline(file_reach_results,row)) {
        cols=0;
        size_t begin=0;
        size_t delimiter_pos;
        std::string entry;


        do {
            delimiter_pos = row.find(',',begin);
            entry = row.substr(begin, delimiter_pos-begin);
            double low_carb_result_entry;
            if(toggle_row_and_col) {
                low_carb_result_entry = low_carb_result(cols,rows);
            } else {
                low_carb_result_entry = low_carb_result(rows, cols);
            }
            if (is_hex)
            {
                BOOST_REQUIRE_CLOSE_FRACTION(cast_hex_to_double(entry), low_carb_result_entry, precision);
            }
            else
                BOOST_REQUIRE_CLOSE_FRACTION(std::atof(entry.c_str()), low_carb_result_entry, precision);

            begin=delimiter_pos+1;
            cols++;
        } while (delimiter_pos != std::string::npos);

        rows++;
    }

    BOOST_CHECK_EQUAL(rows, cols);
    BOOST_CHECK_EQUAL(rows, low_carb_result.rows());
    BOOST_CHECK_EQUAL(cols, low_carb_result.cols());
    //std::cout << "average difference :" << diff_sum/(cols*rows) << std::endl;
}
开发者ID:AFriemann,项目名称:LowCarb,代码行数:54,代码来源:test.cpp

示例10: set_misc

void Trajectory::set_misc(const Eigen::MatrixXd& misc)
{
    if (misc.rows()==ts_.size())
    {
        // misc is of size n_time_steps X n_dims_misc
        misc_ = misc;
    }
    else if (misc.rows()==1)
    {
        // misc is of size 1 X n_dim_misc
        // then replicate it so that it becomes of size n_time_steps X n_dims_misc
        misc_ = misc.replicate(ts_.size(),1);
    }
    else
    {
        cerr << __FILE__ << ":" << __LINE__ << ":";
        cerr << "misc must have 1 or " << ts_.size() << " rows, but it has " << misc.rows() << endl;
    }

}
开发者ID:humm,项目名称:dovecot,代码行数:20,代码来源:Trajectory.cpp

示例11: PostProcessFrames

void cMotion::PostProcessFrames(Eigen::MatrixXd& frames) const
{
	int num_frames = static_cast<int>(frames.rows());
	double curr_time = gMinTime;
	for (int f = 0; f < num_frames; ++f)
	{
		double duration = frames.row(f)(0, eFrameTime);
		frames.row(f)(0, eFrameTime) = curr_time;
		curr_time += duration;
	}
}
开发者ID:saadmahboob,项目名称:DeepLoco,代码行数:11,代码来源:Motion.cpp

示例12: fprintfMat

/**
 * @brief fprintf
 * @param mat
 */
void fprintfMat(Eigen::MatrixXd &mat, std::string name)
{
    FILE *file = fopen(name.c_str(), "w");
    for(int i = 0; i < mat.rows(); i++){
        for(int j = 0; j < mat.cols(); j++){
            fprintf(file, "%f ", mat(i, j));
        }
        fprintf(file, "\n");
    }
    fclose(file);
}
开发者ID:andyTsing,项目名称:piccante,代码行数:15,代码来源:eigen_util.hpp

示例13: normProbMatrix

Eigen::MatrixXd normProbMatrix(Eigen::MatrixXd P)
{
	// each column is a probability simplex
	Eigen::MatrixXd P_norm(P.rows(), P.cols());
	for (int col = 0; col < P.cols(); col++)
	{
		Eigen::VectorXd P_vec = P.col(col);
		P_norm.col(col) = normProbVector(P_vec);
	}
	return P_norm;
}
开发者ID:FurongHuang,项目名称:OnlineTensorCommunity,代码行数:11,代码来源:Probability.cpp

示例14: eigen2mat

void eigen2mat(Eigen::MatrixXd &grayscale, cv::Mat &dst)
{
    int width = grayscale.cols();
    int height = grayscale.rows();
    dst = cv::Mat(height, width, CV_8UC1);
    uint8_t* image_ptr = (uint8_t*)dst.data;

    for (int i = 0; i < height; i++)
        for (int j = 0; j < width; j++)
            image_ptr[i*dst.cols + j] = grayscale(i, j);
}
开发者ID:roboticslab-uc3m,项目名称:textiles,代码行数:11,代码来源:ImageUtils.cpp

示例15: updateCenters

void KMeans::updateCenters(const Eigen::MatrixXd& X)
{
  const int N = X.rows();
  for(int n = 0; n < N; ++n)
  {
    const int cluster = clusterIndices[n];
    v(cluster)++;
    const double eta = 1.0 / (double) v(cluster);
    C.row(cluster) += eta * (X.row(n) - C.row(cluster));
  }
}
开发者ID:AlexanderFabisch,项目名称:OpenANN,代码行数:11,代码来源:KMeans.cpp


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