本文整理汇总了C++中MatrixXf::topLeftCorner方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXf::topLeftCorner方法的具体用法?C++ MatrixXf::topLeftCorner怎么用?C++ MatrixXf::topLeftCorner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixXf
的用法示例。
在下文中一共展示了MatrixXf::topLeftCorner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eig
float OptSO3::linesearch(Matrix3f& R, Matrix3f& M_t_min, const Matrix3f& H,
float N, float t_max, float dt)
{
Matrix3f A = R.transpose() * H;
EigenSolver<MatrixXf> eig(A);
MatrixXcf U = eig.eigenvectors();
MatrixXcf invU = U.inverse();
VectorXcf d = eig.eigenvalues();
#ifndef NDEBUG
cout<<"A"<<endl<<A<<endl;
cout<<"U"<<endl<<U<<endl;
cout<<"d"<<endl<<d<<endl;
#endif
Matrix3f R_t_min=R;
float f_t_min = 999999.0f;
float t_min = 0.0f;
//for(int i_t =0; i_t<10; i_t++)
for(float t =0.0f; t<t_max; t+=dt)
{
//float t= ts[i_t];
VectorXcf expD = ((d*t).array().exp());
MatrixXf MN = (U*expD.asDiagonal()*invU).real();
Matrix3f R_t = R*MN.topLeftCorner(3,3);
float detR = R_t.determinant();
float maxDeviationFromI = ((R_t*R_t.transpose()
- Matrix3f::Identity()).cwiseAbs()).maxCoeff();
if ((R_t(0,0)==R_t(0,0))
&& (abs(detR-1.0f)< 1e-2)
&& (maxDeviationFromI <1e-1))
{
float f_t = evalCostFunction(R_t)/float(N);
#ifndef NDEBUG
cout<< " f_t = "<<f_t<<endl;
#endif
if (f_t_min > f_t && f_t != 0.0f)
{
R_t_min = R_t;
M_t_min = MN.topLeftCorner(3,3);
f_t_min = f_t;
t_min = t;
}
}else{
cout<<"R_t is corruputed detR="<<detR
<<"; max deviation from I="<<maxDeviationFromI
<<"; nans? "<<R_t(0,0)<<" f_t_min="<<f_t_min<<endl;
}
}
if(f_t_min == 999999.0f) return f_t_min;
// case where the MN is nans
R = R_t_min;
#ifndef NDEBUG
#endif
cout<<"R: det(R) = "<<R.determinant()<<endl<<R<<endl;
cout<< "t_min="<<t_min<<" f_t_min="<<f_t_min<<endl;
return f_t_min;
}
示例2: findMinQ
void NeighbourJoining::findMinQ(const MatrixXf& Q, const MatrixXi& rowsID, Pair& p) {
Q.topLeftCorner(numCurrentNodes, numCurrentNodes).minCoeff(&pair.i,
&pair.j);
pair.iID = rowsID(pair.i);
pair.jID = rowsID(pair.j);
//cout << " closestPair: " << pair.i << ", " << pair.j << endl;
//cout << " closestPairID: " << pair.iID << ", " << pair.jID << endl;
}
示例3: calcQ
void NeighbourJoining::calcQ(const MatrixXf& currentD, MatrixXf& Q) {
//calculates sum of the rows of the distance matrix
Matrix<float, latentNodes, 1> sumRows;
//MatrixXf sumRows (numObservableNodes+1,1) ;
sumRows.head(numCurrentNodes) = currentD.topLeftCorner(numCurrentNodes,
numCurrentNodes).colwise().sum();
//cout << sumRows.head(numCurrentNodes); cout << endl;
//Q = (n-2) * currentD
Q.topLeftCorner(numCurrentNodes, numCurrentNodes) = (numCurrentNodes - 2)
* currentD.topLeftCorner(numCurrentNodes, numCurrentNodes);
//each row in Q - sumRows and each column in Q - sumRows
Q.topLeftCorner(numCurrentNodes, numCurrentNodes).colwise() -= sumRows.head(
numCurrentNodes);
Q.topLeftCorner(numCurrentNodes, numCurrentNodes).rowwise() -= sumRows.head(
numCurrentNodes).transpose();
Q.diagonal().setZero();
//cout << "Q Matrix:" << endl; printMatrix(Q);
}
示例4: printMatrix
void NeighbourJoining::printMatrix(const MatrixXf& M) {
cout << M.topLeftCorner(numCurrentNodes, numCurrentNodes);
cout << endl;
}