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


C++ Permutation::MakeArbitrary方法代码示例

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


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

示例1: Mod


//.........这里部分代码省略.........
    const Real sqrtTwo = Sqrt( Real(2) );
    z(0) = betaSgn*Q0(lastRowOfQ0,n0-1) / sqrtTwo;
    columnTypes(0) = DENSE_COLUMN;
    for( Int j=0; j<n0-1; ++j )
    {
        z(j+1) = betaSgn*Q0(lastRowOfQ0,j) / sqrtTwo;
        columnTypes(j+1) = COLUMN_NONZERO_IN_FIRST_BLOCK;
    }
    for( Int j=0; j<n1; ++j )
    {
        z(j+n0) = Q1(0,j) / sqrtTwo;
        columnTypes(j+n0) = COLUMN_NONZERO_IN_SECOND_BLOCK;
    }

    Permutation combineSortPerm;
    SortingPermutation( d, combineSortPerm, ASCENDING );
    combineSortPerm.PermuteRows( d );
    combineSortPerm.PermuteRows( z );
    combineSortPerm.PermuteRows( columnTypes );

    auto combinedToOrig = [&]( const Int& combinedIndex )
      {
          const Int preCombined = combineSortPerm.Preimage( combinedIndex );
          if( preCombined < n0 )
              // Undo the cyclic shift [0,n0) |-> [1,n0+1) mod n0 which
              // pushed the removed row into the first position.
              return Mod( preCombined-1, n0 );
          else
              return preCombined;
      };

    Permutation deflationPerm;
    deflationPerm.MakeIdentity( n );
    deflationPerm.MakeArbitrary();
    // Since we do not yet know how many undeflated entries there will be, we
    // must use the no-deflation case as our storage upper bound.
    Matrix<Real> dUndeflated(n,1), zUndeflated(n,1);
    dUndeflated(0) = 0;
    zUndeflated(0) = z(0);

    // Deflate all (off-diagonal) update entries sufficiently close to zero
    Int numDeflated = 0;
    Int numUndeflated = 0;
    // We will keep track of the last column that we encountered that was not
    // initially deflatable (but that could be deflated later due to close
    // diagonal entries if another undeflatable column is not encountered
    // first).
    Int revivalCandidate = n;
    for( Int j=0; j<n; ++j )
    {
        if( Abs(2*beta*z(j)) <= deflationTol )
        {
            // We can deflate due to the r component being sufficiently small
            const Int deflationDest = (n-1) - numDeflated;
            deflationPerm.SetImage( j, deflationDest );
            if( ctrl.progress )
                Output
                ("Deflating via p(",j,")=",deflationDest,
                 " because |2*beta*z(",j,")|=|",2*beta*z(j),"| <= ",
                 deflationTol);
            columnTypes(j) = DEFLATED_COLUMN;
            ++numDeflated;
            ++secularInfo.numDeflations;
            ++secularInfo.numSmallUpdateDeflations;
        }
        else
开发者ID:YingzhouLi,项目名称:Elemental,代码行数:67,代码来源:DivideAndConquer.hpp


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