本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
}
示例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() );
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
}