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


C++ PolyRing::one方法代码示例

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


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

示例1: poly

void L::initNiederreiter
(GeneratorMatrixGen<typename A::type> &gm, A a, int d,
 const typename PolynomialRing<A>::type &irred)
{
    typedef typename A::type T;
    typedef PolynomialRing<A> PolyRing;
    typedef typename PolyRing::type Poly;

    const int degree = irred.degree ();

    const int vSize
        = std::max (gm.getM() + degree - 1,   // these elements are copied to gm
                    (gm.getPrec() + degree + 1));  // used in the loop

    Array<T> v (vSize);
    PolyRing poly (a);

    // cout << "Using " << irred << " for d=" << d << endl;

    Poly newPoly = poly.one();

    int u = 0;

    for (int j = 0; j < gm.getPrec(); j++)
    {
        // cout << "  j=" << j << endl;
        // Do we need a new v?

        if (u == 0)
        {
            Poly oldPoly = newPoly;
            int oldDegree = oldPoly.degree ();

            // calculate polyK+1 from polyK

            poly.mulBy (newPoly, irred);
            int newDegree = newPoly.degree ();
            // cout << "    newPolynomial: " << newPoly << endl;

            // kj can be set to any value between 0 <= kj < newDegree

            const int kj = oldDegree   // proposed by BFN
                           // newDegree - 1    // standard, bad???
                           // 0
                           // (newDegree > 3) ? 3 : oldDegree
                           ;

            std::fill (&v[0], &v[kj], T());  // Set leading v's to 0

            v[kj] = a.one();                     // the next one is 1

            if (kj < oldDegree)
            {
                T term = oldPoly [kj];

                for (int r = kj + 1; r < oldDegree; ++r)
                {
                    v [r] = a.one (); // 1 is arbitrary. Could be 0, too

                    a.addTo (term, a.mul (oldPoly [r], v [r]));
                }

                // set v[] not equal to -term

                v [oldDegree] = a.sub (a.one(), term);

                for (int r = oldDegree + 1; r < newDegree; ++r) v [r] = a.one(); //or 0
            }
            else
            {
                for (int r = kj + 1; r < newDegree; ++r) v [r] = a.one(); // or 0..
            }

            // All other elements are calculated by a recursion parameterized
            // by polyK

            for (int r = 0; r < vSize - newDegree; ++r)
            {
                T term = T();

                for (int i = 0; i < newDegree; ++i)
                {
                    a.addTo (term, a.mul (newPoly [i], v [r+i]));
                }
                v [newDegree + r] = a.neg (term);
            }
        }

        // Set data in ci

        for (int r = 0; r < gm.getM(); ++r)  gm.setd (d,r,j, v[r+u]);

        if (++u == degree) u = 0;
    }
}
开发者ID:JohannesBuchner,项目名称:HIntLib,代码行数:95,代码来源:niederreitermatrixgen.cpp


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