本文整理汇总了C++中Epetra_Comm::SumAll方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_Comm::SumAll方法的具体用法?C++ Epetra_Comm::SumAll怎么用?C++ Epetra_Comm::SumAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_Comm
的用法示例。
在下文中一共展示了Epetra_Comm::SumAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allGatherCompact
void MPIWrapper::allGatherCompact(const Epetra_Comm &Comm, FieldContainer<Scalar> &gatheredValues,
FieldContainer<Scalar> &myValues, FieldContainer<int> &offsets)
{
int mySize = myValues.size();
int totalSize;
Comm.SumAll(&mySize, &totalSize, 1);
int myOffset = 0;
Comm.ScanSum(&mySize,&myOffset,1);
myOffset -= mySize;
gatheredValues.resize(totalSize);
for (int i=0; i<mySize; i++)
{
gatheredValues[myOffset+i] = myValues[i];
}
MPIWrapper::entryWiseSum(Comm, gatheredValues);
offsets.resize(Comm.NumProc());
offsets[Comm.MyPID()] = myOffset;
MPIWrapper::entryWiseSum(Comm, offsets);
}
示例2: printMatrix
static void printMatrix(const char *txt, int *myA, int *myX, int *myB,
int numRows, int numCols, const Epetra_Comm &comm)
{
int me = comm.MyPID();
int *A = new int [numRows * numCols];
int *x = NULL;
int *b = NULL;
comm.SumAll(myA, A, numRows * numCols);
if (myX){
x = new int [numCols];
comm.SumAll(myX, x, numCols);
}
if (myB){
b = new int [numRows];
comm.SumAll(myB, b, numRows);
}
if (me == 0){
std::cout << txt << std::endl;
std::cout << " ";
for (int j=0; j<numCols; j++){
std::cout << j%10 ;
}
if (x)
std::cout << " LHS";
if (b)
std::cout << " RHS";
std::cout << std::endl;
int *row = A;
for (int i=0; i < numRows; i++, row += numCols){
std::cout << i%10 << " ";
for (int j=0; j < numCols; j++){
if (row[j] > 0){
std::cout << row[j]-1;
}
else{
std::cout << " ";
}
}
std::cout << " " << i%10 ;
if (x && (i < numCols)){
std::cout << " " << x[i]-1;
}
if ((i == 0) && b){
std::cout << " = [";
for (int j=0; j<numRows; j++){
std::cout << b[j]-1;
}
std::cout << "]";
}
std::cout << std::endl;
}
std::cout << " ";
for (int j=0; j<numCols; j++){
std::cout << j%10 ;
}
int columnsRemaining = numCols - numRows;
int next_x = numRows;
if ((columnsRemaining > 0) && x){
std::cout << " " << x[next_x++] - 1 << std::endl;
columnsRemaining--;
int pad = numCols + 7;
while(columnsRemaining){
for( int i=0; i < pad; i++){
std::cout << " ";
}
std::cout << x[next_x++] - 1 << std::endl;
columnsRemaining--;
}
}
std::cout << std::endl;
}
delete [] A;
if (x) delete [] x;
if (b) delete [] b;
}