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


C++ Grid::ColComm方法代码示例

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


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

示例1: TestColumnMaxNorms

void TestColumnMaxNorms(Int m, Int n, const Grid& g, bool print)
{
  // Generate random matrix to test.
  DistMatrix<T, MC, MR, W> A(g);
  Uniform(A, m, n);
  if (print)
    Print(A, "A");
  DistMatrix<T, MR, STAR, W> norms(g);
  ColumnMaxNorms(A, norms);
  if (print)
    Print(norms, "norms");
  for (Int j = 0; j < A.LocalWidth(); ++j)
  {
    T got = norms.GetLocal(j, 0);
    T expected = 0;
    for (Int i = 0; i < A.LocalHeight(); ++i)
      expected = Max(expected, Abs(A.GetLocal(i, j)));
    T r;
    mpi::AllReduce(&expected, &r, 1, mpi::MAX, g.ColComm());
    expected = r;
    if (got != expected)
    {
      Output("Results do not match, norms(", j, ")=", got,
             " instead of ", expected);
      RuntimeError("got != expected");
    }
  }
}
开发者ID:elemental,项目名称:Elemental,代码行数:28,代码来源:ColumnNorms.cpp

示例2: TestColumnTwoNorms

void TestColumnTwoNorms(Int m, Int n, const Grid& g, bool print)
{
  // Generate random matrix to test.
  DistMatrix<T, MC, MR, W> A(g);
  Uniform(A, m, n);
  if (print)
    Print(A, "A");
  DistMatrix<T, MR, STAR, W> norms(g);
  ColumnTwoNorms(A, norms);
  if (print)
    Print(norms, "norms");
  for (Int j = 0; j < A.LocalWidth(); ++j)
  {
    T got = norms.GetLocal(j, 0);
    T expected = 0;
    for (Int i = 0; i < A.LocalHeight(); ++i)
    {
      T val = A.GetLocal(i, j);
      expected += val * val;
    }
    expected = mpi::AllReduce(expected, g.ColComm());
    expected = Sqrt(expected);
    // Compute max(expected, 1) to use relative bound.
    // (std::max and El::Max don't support BigFloat.
    T div = expected > 1 ? expected : 1;
    if (Abs(got - expected) / div > m * n * 10 * limits::Epsilon<El::Base<T>>())
    {
      Output("Results do not match, norms(", j, ")=", got,
             " instead of ", expected);
      RuntimeError("got != expected");
    }
  }
}
开发者ID:elemental,项目名称:Elemental,代码行数:33,代码来源:ColumnNorms.cpp


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