InfinityNorm( const DistMatrix<F,U,V>& A ) { #ifndef RELEASE CallStackEntry entry("InfinityNorm"); #endif // Compute the partial row sums defined by our local matrix, A[U,V] typedef BASE(F) R; const Int localHeight = A.LocalHeight(); const Int localWidth = A.LocalWidth(); std::vector<R> myPartialRowSums( localHeight ); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { myPartialRowSums[iLoc] = 0; for( Int jLoc=0; jLoc<localWidth; ++jLoc ) myPartialRowSums[iLoc] += Abs(A.GetLocal(iLoc,jLoc)); } // Sum our partial row sums to get the row sums over A[U,* ] std::vector<R> myRowSums( localHeight ); mpi::Comm rowComm = ReduceRowComm<U,V>( A.Grid() ); mpi::AllReduce( &myPartialRowSums[0], &myRowSums[0], localHeight, rowComm ); // Find the maximum out of the row sums R myMaxRowSum = 0; for( Int iLoc=0; iLoc<localHeight; ++iLoc ) myMaxRowSum = std::max( myMaxRowSum, myRowSums[iLoc] ); // Find the global maximum row sum by searching over the U team mpi::Comm colComm = ReduceColComm<U,V>( A.Grid() ); return mpi::AllReduce( myMaxRowSum, mpi::MAX, colComm ); }
inline typename Base<F>::type internal::InfinityNorm( const DistMatrix<F,MC,MR>& A ) { #ifndef RELEASE PushCallStack("internal::InfinityNorm"); #endif typedef typename Base<F>::type R; // Compute the partial row sums defined by our local matrix, A[MC,MR] std::vector<R> myPartialRowSums(A.LocalHeight()); for( int iLocal=0; iLocal<A.LocalHeight(); ++iLocal ) { myPartialRowSums[iLocal] = 0; for( int jLocal=0; jLocal<A.LocalWidth(); ++jLocal ) myPartialRowSums[iLocal] += Abs(A.GetLocalEntry(iLocal,jLocal)); } // Sum our partial row sums to get the row sums over A[MC,* ] std::vector<R> myRowSums(A.LocalHeight()); mpi::AllReduce ( &myPartialRowSums[0], &myRowSums[0], A.LocalHeight(), mpi::SUM, A.Grid().RowComm() ); // Find the maximum out of the row sums R myMaxRowSum = 0; for( int iLocal=0; iLocal<A.LocalHeight(); ++iLocal ) myMaxRowSum = std::max( myMaxRowSum, myRowSums[iLocal] ); // Find the global maximum row sum by searching over the MC team R maxRowSum = 0; mpi::AllReduce( &myMaxRowSum, &maxRowSum, 1, mpi::MAX, A.Grid().ColComm() ); #ifndef RELEASE PopCallStack(); #endif return maxRowSum; }