本文整理汇总了C++中eigen::Matrix::cwiseAbs方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::cwiseAbs方法的具体用法?C++ Matrix::cwiseAbs怎么用?C++ Matrix::cwiseAbs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix
的用法示例。
在下文中一共展示了Matrix::cwiseAbs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assembleP
inline void igl::PlanarizerShapeUp<DerivedV, DerivedF>::planarize(Eigen::PlainObjectBase<DerivedV> &Vout)
{
Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> planarity;
Vout = Vin;
for (int iter =0; iter<maxIter; ++iter)
{
igl::quad_planarity(Vout, Fin, planarity);
typename DerivedV::Scalar nonPlanarity = planarity.cwiseAbs().maxCoeff();
//std::cerr<<"iter #"<<iter<<": max non-planarity: "<<nonPlanarity<<std::endl;
if (nonPlanarity<threshold)
break;
assembleP();
Vv = solver.solve(Q.transpose()*P);
if(solver.info()!=Eigen::Success)
{
std::cerr << "Linear solve failed - PlanarizerShapeUp.cpp" << std::endl;
assert(0);
}
for (int i =0;i<numV;++i)
Vout.row(i) << Vv.segment(3*i,3).transpose();
}
// set the mean of Vout to the mean of Vin
Eigen::Matrix<typename DerivedV::Scalar, 1, 3> oldMean, newMean;
oldMean = Vin.colwise().mean();
newMean = Vout.colwise().mean();
Vout.rowwise() += (oldMean - newMean);
};
示例2: assembleSelector
inline void igl::PlanarizerShapeUp<DerivedV, DerivedF>::assembleP()
{
P.setZero(3*ni*numF);
for (int fi = 0; fi< numF; fi++)
{
// todo: this can be made faster by omitting the selector matrix
Eigen::SparseMatrix<typename DerivedV::Scalar > Sfi;
assembleSelector(fi, Sfi);
Eigen::SparseMatrix<typename DerivedV::Scalar > NSi = Ni*Sfi;
Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> Vi = NSi*Vv;
Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic> CC(3,ni);
for (int i = 0; i <ni; ++i)
CC.col(i) = Vi.segment(3*i, 3);
Eigen::Matrix<typename DerivedV::Scalar, 3, 3> C = CC*CC.transpose();
// Alec: Doesn't compile
Eigen::EigenSolver<Eigen::Matrix<typename DerivedV::Scalar, 3, 3>> es(C);
// the real() is for compilation purposes
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> lambda = es.eigenvalues().real();
Eigen::Matrix<typename DerivedV::Scalar, 3, 3> U = es.eigenvectors().real();
int min_i;
lambda.cwiseAbs().minCoeff(&min_i);
U.col(min_i).setZero();
Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic> PP = U*U.transpose()*CC;
for (int i = 0; i <ni; ++i)
P.segment(3*ni*fi+3*i, 3) = weightsSqrt[fi]*PP.col(i);
}
}