本文整理汇总了C++中MatrixX::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixX::transpose方法的具体用法?C++ MatrixX::transpose怎么用?C++ MatrixX::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixX
的用法示例。
在下文中一共展示了MatrixX::transpose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
const typename
Type<Scalar>::MatrixX& HumanoidLipComJerkMinimizationObjective<Scalar>::getHessian()
{
assert(feetSupervisor_.getNbSamples() == lipModel_.getNbSamples());;
int N = lipModel_.getNbSamples();
int M = feetSupervisor_.getNbPreviewedSteps();
int nb = feetSupervisor_.getNbOfCallsBeforeNextSample() - 1;
const LinearDynamic<Scalar>& dynCopX = lipModel_.getCopXLinearDynamic(nb);
const LinearDynamic<Scalar>& dynCopY = lipModel_.getCopYLinearDynamic(nb);
MatrixX tmp = MatrixX::Zero(2*N, 2*N + 2*M);
tmp.block(0, 0, 2*N, 2*N) = feetSupervisor_.getRotationMatrixT();
tmp.block(0, 2*N, N, M) = feetSupervisor_.getFeetPosLinearDynamic().U;
tmp.block(N, 2*N + M, N, M) = feetSupervisor_.getFeetPosLinearDynamic().U;
MatrixX tmp2 = MatrixX::Zero(2*N, 2*N);
const MatrixX& weight = feetSupervisor_.getSampleWeightMatrix();
tmp2.block(0, 0, N, N) = dynCopX.UTinv*weight*dynCopX.Uinv;
tmp2.block(N, N, N, N) = dynCopY.UTinv*weight*dynCopY.Uinv;
hessian_.noalias() = tmp.transpose()*tmp2*tmp;
return hessian_;
}
示例2: execute
GMMExpectationMaximization::uint GMMExpectationMaximization::execute(const MatrixX & dataset)
{
const uint data_count = dataset.rows();
const uint num_gaussians = m_means.size();
const uint dim = dataset.cols();
MatrixX pxi(data_count,num_gaussians);
MatrixX pix(data_count,num_gaussians);
VectorX pxidatatot(data_count);
VectorX weights(num_gaussians);
VectorX ex(data_count);
MatrixX ts(dim,dim);
VectorX dif(dim);
Real prev_log_likelyhood = 1.0;
uint it_num;
for (it_num = 0; it_num < m_max_iterations; it_num++)
{
for (uint g = 0; g < num_gaussians; g++)
weights[g] = m_weights[g];
for (uint d = 0; d < data_count; d++)
for (uint g = 0; g < num_gaussians; g++)
pxi(d,g) = gauss(m_means[g],m_covs[g],dataset.row(d).transpose());
pxidatatot = pxi * weights;
Real log_likelyhood = pxidatatot.array().log().sum() / Real(data_count);
if (it_num != 0 && (std::abs(log_likelyhood / prev_log_likelyhood - 1.0) < m_termination_threshold))
break;
prev_log_likelyhood = log_likelyhood;
for (uint d = 0; d < data_count; d++)
pix.row(d) = (pxi.row(d).transpose().array() * weights.array()).transpose() / pxidatatot[d];
ex = pix.colwise().sum();
for(uint g = 0; g < num_gaussians; g++)
{
m_weights[g] = ex[g] / Real(data_count);
m_means[g] = (dataset.transpose() * pix.col(g)) / ex[g];
ts = MatrixX::Zero(dim,dim);
for (uint d = 0; d < data_count; d++)
{
dif = dataset.row(d).transpose() - m_means[g];
ts.noalias() += (dif * dif.transpose()) * pix(d,g);
}
m_covs[g] = (ts / ex[g]) + MatrixX::Identity(dim,dim) * m_epsilon;
}
// interruption point here
if (m_termination_handler && m_termination_handler->isTerminated())
return it_num;
}
return it_num;
}