本文整理汇总了C++中SpdMatrix::diag方法的典型用法代码示例。如果您正苦于以下问题:C++ SpdMatrix::diag方法的具体用法?C++ SpdMatrix::diag怎么用?C++ SpdMatrix::diag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpdMatrix
的用法示例。
在下文中一共展示了SpdMatrix::diag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forecast_precision
//---------------------------------------------------------------------------
SpdMatrix Marginal::forecast_precision() const {
const Selector &observed(model_->observed_status(time_index()));
DiagonalMatrix observation_precision =
model_->observation_variance(time_index()).inv();
const SparseKalmanMatrix *observation_coefficients(
model_->observation_coefficients(time_index(), observed));
SpdMatrix variance;
if (previous()) {
variance = previous()->state_variance();
} else {
variance = model_->initial_state_variance();
}
// 'inner' is I + P * Z' Hinv Z
Matrix inner = variance * observation_coefficients->inner(
observation_precision.diag());
inner.diag() += 1.0;
SpdMatrix outer = inner.solve(variance);
SpdMatrix ans = observation_precision.sandwich(
observation_coefficients->sandwich(outer));
ans *= -1;
ans.diag() += observation_precision.diag();
return ans;
}
示例2: direct_forecast_precision
//---------------------------------------------------------------------------
SpdMatrix Marginal::direct_forecast_precision() const {
SpdMatrix variance;
if (previous()) {
variance = previous()->state_variance();
} else {
variance = model_->initial_state_variance();
}
const Selector &observed(model_->observed_status(time_index()));
SpdMatrix ans = model_->observation_coefficients(
time_index(), observed)->sandwich(variance);
ans.diag() += model_->observation_variance(time_index()).diag();
return ans.inv();
}