本文整理汇总了C++中eigen::VectorXf::cwiseProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorXf::cwiseProduct方法的具体用法?C++ VectorXf::cwiseProduct怎么用?C++ VectorXf::cwiseProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::VectorXf
的用法示例。
在下文中一共展示了VectorXf::cwiseProduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildManifoldAndPerformFiltering
//.........这里部分代码省略.........
//std::cout << "min_pixel_dist_to_manifold_squared=\n" << min_pixel_dist_to_manifold_squared_.head(10) << "\n";
// for debug
// for (int i=0; i<inputSize; i++)
// {
// if (!g_isInfinite(wkiPsiBlur(i,0)))
// std::cout << "(" << i << "," << 0 << ")\n";
// if (!g_isInfinite(wkiPsiBlur(i,1)))
// std::cout << "(" << i << "," << 1 << ")\n";
// //if (!g_isInfinite(wkiPsiBlur(i,2)))
// // std::cout << "(" << i << "," << 2 << ")\n";
// }
//std::cout << wkiPsiBlur.norm() << "\n";
Eigen::VectorXf rangeDiff(inputSize);
for (int i=0; i<inputSize; i++)
{
Eigen::VectorXf n0 = wkiPsiBlur.row(i);
Eigen::VectorXf n1 = input.row(i).tail(rangeDim_);
n0.normalize();
n1.normalize();
rangeDiff(i) = 1.f-n0.dot(n1);
}
static bool bSaved = false;
if (!bSaved)
{
ZFileHelper::saveEigenVectorToFile("rangeDiff.txt", rangeDiff);
ZFileHelper::saveEigenVectorToFile("gaussian.txt", gaussianDistWeight);
ZFileHelper::saveEigenMatrixToFile("splat.txt", psiSplat);
ZFileHelper::saveEigenMatrixToFile("blur.txt", wkiPsiBlur);
bSaved = true;
}
// Slicing
Eigen::VectorXf wki = gaussianDistWeight;
for (int i=0; i<inputSize; i++)
{
if (!clusterK[i]) continue;
sum_w_ki_Psi_blur_.row(i) += wkiPsiBlur.row(i)*wki(i);
sum_w_ki_Psi_blur_0_(i) += wkiPsiBlur0(i)*wki(i);
}
//////////////////////////////////////////////////////////////////////////
// for debug
wki_Psi_blurs_.push_back(Eigen::MatrixXf(inputSize, rangeDim_));
wki_Psi_blur_0s_.push_back(Eigen::VectorXf(inputSize));
Eigen::MatrixXf& lastM = wki_Psi_blurs_[wki_Psi_blurs_.size()-1];
lastM.fill(0);
Eigen::VectorXf& lastV = wki_Psi_blur_0s_[wki_Psi_blur_0s_.size()-1];
lastV.fill(0);
for (int i=0; i<inputSize; i++)
{
if (!clusterK[i]) continue;
lastM.row(i) = wkiPsiBlur.row(i)*wki(i);
lastV(i) = wkiPsiBlur0(i)*wki(i);
}
std::cout << sum_w_ki_Psi_blur_.norm() << "\n";
//////////////////////////////////////////////////////////////////////////
// compute two new manifolds eta_minus and eta_plus
// test stopping criterion
if (currentTreeLevel<filterPara_.tree_height)
{
// algorithm 1, Step 2: compute the eigenvector v1
Eigen::VectorXf v1 = computeMaxEigenVector(diffX, clusterK);
// algorithm 1, Step 3: Segment vertices into two clusters
std::vector<bool> clusterMinus(inputSize, false);
std::vector<bool> clusterPlus(inputSize, false);
int countMinus=0;
int countPlus =0;
for (int i=0; i<inputSize; i++)
{
float dot = diffX.row(i).dot(v1);
if (dot<0 && clusterK[i]) {countMinus++; verticeClusterIds[i] =etaI+0.5; clusterMinus[i] = true;}
if (dot>=0 && clusterK[i]) {countPlus++; verticeClusterIds[i] =etaI-0.5; clusterPlus[i] = true;}
}
std::cout << "Minus manifold: " << countMinus << "\n";
std::cout << "Plus manifold: " << countPlus << "\n";
// Eigen::MatrixXf diffXManifold(inputSize, spatialDim_+rangeDim_);
// diffXManifold.block(0, 0, inputSize, spatialDim_) = input.block(0, 0, inputSize, spatialDim_);
// diffXManifold.block(0, spatialDim_, inputSize, rangeDim_) = diffX;
// algorithm 1, Step 4: Compute new manifolds by weighted low-pass filtering -- Eq. (7)(8)
Eigen::VectorXf theta(inputSize);
theta.fill(1);
theta = theta - wki.cwiseProduct(wki);
pGaussianFilter_->setKernelFunc(NULL);
CHECK_FALSE_AND_RETURN(pGaussianFilter_->apply(input, spatialDim_, rangeDim_, theta, clusterMinus));
Eigen::MatrixXf etaMinus = pGaussianFilter_->getResult();
CHECK_FALSE_AND_RETURN(pGaussianFilter_->apply(input, spatialDim_, rangeDim_, theta, clusterPlus));
Eigen::MatrixXf etaPlus = pGaussianFilter_->getResult();
// algorithm 1, Step 5: recursively build more manifolds
CHECK_FALSE_AND_RETURN(buildManifoldAndPerformFiltering(input, etaMinus, clusterMinus, sigma_s, sigma_r, currentTreeLevel+1));
CHECK_FALSE_AND_RETURN(buildManifoldAndPerformFiltering(input, etaPlus, clusterPlus, sigma_s, sigma_r, currentTreeLevel+1));
}
return true;
}