当前位置: 首页>>代码示例>>C++>>正文


C++ MessageBox::begin方法代码示例

本文整理汇总了C++中MessageBox::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageBox::begin方法的具体用法?C++ MessageBox::begin怎么用?C++ MessageBox::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageBox的用法示例。


在下文中一共展示了MessageBox::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: functionPrecision

GaussianMessage EqualityNode::functionPrecision(int to, const MessageBox &msgs)
{
    size_t size = msgs.begin()->second.size();

    GaussianMessage result(size, GaussianMessage::GAUSSIAN_PRECISION);

    Matrix &mean = result.mean();
    Matrix &prec = result.precision();

    for (MessageBox::const_iterator it = msgs.begin(); it != msgs.end(); ++it)
    {
        const int from = it->first;
        const GaussianMessage &msg = it->second;

        if (from == to)
            continue;

        const Matrix &msgMean = msg.mean();
        const Matrix &msgPrec = msg.precision();

        prec += msgPrec;
        mean += msgPrec * msgMean;
    }


    // TODO: mult(in1, in2, out)
    mean = pinv(prec) * mean;

    return result;
}
开发者ID:bertdv,项目名称:factor-graph,代码行数:30,代码来源:equalitynode.cpp

示例2: functionVariance

GaussianMessage EqualityNode::functionVariance(int to, const MessageBox &msgs)
{
    if (msgs.empty())
        throw std::runtime_error("EqualityNode::functionVariance(): no messages");

    // TODO: assert on various sizes of messages
    size_t size = msgs.begin()->second.size();

    GaussianMessage result(size);

    Matrix &mean = result.mean();
    Matrix &variance = result.variance();

    Matrix sum(size, 1);
    for (MessageBox::const_iterator it = msgs.begin(); it != msgs.end(); ++it)
    {
        const int from = it->first;
        const GaussianMessage &msg = it->second;

        // skipping the message itself
        if (from == to)
            continue;

        const Matrix &msgMean = msg.mean();
        const Matrix &msgVar = msg.variance();

        // W_i = V^-1 = tmp^-1
        Matrix msgPrec = inv(msgVar);
        // W_j += W_i
        variance += msgPrec;
        // tmp_sum += W_i m_i
        sum += msgPrec * msgMean;
    }

    // V_j = W_j^-1
    variance.inv();

    // TODO: mult(variance, sum, out)
    mean = variance * sum;

    return result;
}
开发者ID:bertdv,项目名称:factor-graph,代码行数:42,代码来源:equalitynode.cpp

示例3: function

GaussianMessage EqualityNode::function(int to, const MessageBox &msgs)
{
    GaussianMessage::Type msgType = msgs.begin()->second.type();
    return (msgType == GaussianMessage::GAUSSIAN_VARIANCE) ? functionVariance(to, msgs)
                                                           : functionPrecision(to, msgs);
}
开发者ID:bertdv,项目名称:factor-graph,代码行数:6,代码来源:equalitynode.cpp


注:本文中的MessageBox::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。