本文整理汇总了C#中PositiveDefiniteMatrix.SetToProduct方法的典型用法代码示例。如果您正苦于以下问题:C# PositiveDefiniteMatrix.SetToProduct方法的具体用法?C# PositiveDefiniteMatrix.SetToProduct怎么用?C# PositiveDefiniteMatrix.SetToProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PositiveDefiniteMatrix
的用法示例。
在下文中一共展示了PositiveDefiniteMatrix.SetToProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Combine
public static VectorGaussianWishart Combine(VectorGaussian position, Wishart orientation, VectorGaussianWishart result)
{
if (orientation.IsUniform())
{
result.SetToUniform();
}
else if (position.IsUniform())
{
result.SetTo(orientation.Shape, orientation.Rate, Vector.Zero(2), 0);
}
else
{
PositiveDefiniteMatrix rateTimesPrecision = new PositiveDefiniteMatrix(2, 2);
rateTimesPrecision.SetToProduct(orientation.Rate, position.Precision);
double trace = MathHelpers.Invert(rateTimesPrecision).Trace();
Vector positionMean = position.MeanTimesPrecision * MathHelpers.Invert(position.Precision);
result.SetTo(orientation.Shape, orientation.Rate, positionMean, orientation.Dimension / (orientation.Shape * trace));
}
return result;
}
示例2: ProductAverageConditional
/// <summary>
/// EP message to 'product'
/// </summary>
/// <param name="A">Constant value for 'a'.</param>
/// <param name="BMean">Buffer 'BMean'.</param>
/// <param name="BVariance">Buffer 'BVariance'.</param>
/// <param name="result">Modified to contain the outgoing message</param>
/// <returns><paramref name="result"/></returns>
/// <remarks><para>
/// The outgoing message is the factor viewed as a function of 'product' conditioned on the given values.
/// </para></remarks>
public static VectorGaussian ProductAverageConditional(Matrix A, [Fresh] Vector BMean, [Fresh] PositiveDefiniteMatrix BVariance, VectorGaussian result)
{
// P.mean = A*B.mean
// P.var = A*B.var*A'
// if A is invertible, then
// P.prec = inv(A)'*inv(B.var)*inv(A)
// P.precTimesMean = inv(A)'*B.precTimesMean
Vector rmean = A * BMean;
PositiveDefiniteMatrix rvariance = new PositiveDefiniteMatrix(result.Dimension, result.Dimension);
Matrix temp = (A*BVariance).Transpose();
rvariance.SetToProduct(A, temp);
result.SetMeanAndVariance(rmean, rvariance);
return result;
}