本文整理汇总了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");
}
}
}
示例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");
}
}
}