本文整理汇总了C++中MatrixT::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixT::transpose方法的具体用法?C++ MatrixT::transpose怎么用?C++ MatrixT::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixT
的用法示例。
在下文中一共展示了MatrixT::transpose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: T
void
test_transpose_readonly(MatrixT view)
{
typedef typename MatrixT::value_type T;
// Check that view is initialized
check_matrix(view, 0);
length_type const size1 = view.size(1);
typename MatrixT::const_transpose_type trans = view.transpose();
test_assert(trans.size(0) == view.size(1));
test_assert(trans.size(1) == view.size(0));
for (index_type idx0=0; idx0<trans.size(0); ++idx0)
for (index_type idx1=0; idx1<trans.size(1); ++idx1)
{
T expected = T(idx1 * size1 + idx0 + 0);
test_assert(equal(trans.get(idx0, idx1), expected));
test_assert(equal(trans.get(idx0, idx1),
view. get(idx1, idx0)));
}
// Check that view is unchanged
check_matrix(view, 0);
}
示例2: computeInverseOperation
bool WHeadPositionCorrection::computeInverseOperation( MatrixT* const g, const MatrixT& lf ) const
{
WLTimeProfiler profiler( CLASS, __func__, true );
const float snr = 25;
const MatrixT noiseCov = MatrixT::Identity( lf.rows(), lf.rows() );
// Leafield transpose matrix
const MatrixT LT = lf.transpose();
// WinvLT = W^-1 * LT
SpMatrixT w = SpMatrixT( lf.cols(), lf.cols() );
w.setIdentity();
w.makeCompressed();
SparseLU< SpMatrixT > spSolver;
spSolver.compute( w );
if( spSolver.info() != Eigen::Success )
{
wlog::error( CLASS ) << "spSolver.compute( weighting ) not succeeded: " << spSolver.info();
return false;
}
const MatrixT WinvLT = spSolver.solve( LT ); // needs dense matrix, returns dense matrix
if( spSolver.info() != Eigen::Success )
{
wlog::error( CLASS ) << "spSolver.solve( LT ) not succeeded: " << spSolver.info();
return false;
}
wlog::debug( CLASS ) << "WinvLT " << WinvLT.rows() << " x " << WinvLT.cols();
// LWL = L * W^-1 * LT
const MatrixT LWL = lf * WinvLT;
wlog::debug( CLASS ) << "LWL " << LWL.rows() << " x " << LWL.cols();
// alpha = sqrt(trace(LWL)/(snr * num_sensors));
double alpha = sqrt( LWL.trace() / ( snr * lf.rows() ) );
// G = W^-1 * LT * inv( (L W^-1 * LT) + alpha^2 * Cn )
const MatrixT toInv = LWL + pow( alpha, 2 ) * noiseCov;
const MatrixT inv = toInv.inverse();
*g = WinvLT * inv;
WAssertDebug( g->rows() == lf.cols() && g->cols() == lf.rows(), "Dimension of G and L does not match." );
return true;
}