本文整理汇总了C++中Epetra_MultiVector::DistributedGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_MultiVector::DistributedGlobal方法的具体用法?C++ Epetra_MultiVector::DistributedGlobal怎么用?C++ Epetra_MultiVector::DistributedGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_MultiVector
的用法示例。
在下文中一共展示了Epetra_MultiVector::DistributedGlobal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildMatrixTests
int BuildMatrixTests (Epetra_MultiVector & C,
const char TransA, const char TransB,
const double alpha,
Epetra_MultiVector& A,
Epetra_MultiVector& B,
const double beta,
Epetra_MultiVector& C_GEMM ) {
// For given values of TransA, TransB, alpha and beta, a (possibly
// zero) filled Epetra_MultiVector C, and allocated
// Epetra_MultiVectors A, B and C_GEMM this routine will generate values for
// Epetra_MultiVectors A, B and C_GEMM such that, if A, B and (this) are
// used with GEMM in this class, the results should match the results
// generated by this routine.
// Test for Strided multivectors (required for GEMM ops)
if (!A.ConstantStride() ||
!B.ConstantStride() ||
!C_GEMM.ConstantStride() ||
!C.ConstantStride()) return(-1); // Error
int i, j;
double fi, fj; // Used for casting loop variables to floats
// Get a view of the MultiVectors
double *Ap = 0;
double *Bp = 0;
double *Cp = 0;
double *C_GEMMp = 0;
int A_nrows = A.MyLength();
int A_ncols = A.NumVectors();
int B_nrows = B.MyLength();
int B_ncols = B.NumVectors();
int C_nrows = C.MyLength();
int C_ncols = C.NumVectors();
int A_Stride = 0;
int B_Stride = 0;
int C_Stride = 0;
int C_GEMM_Stride = 0;
A.ExtractView(&Ap, &A_Stride);
B.ExtractView(&Bp, &B_Stride);
C.ExtractView(&Cp, &C_Stride);
C_GEMM.ExtractView(&C_GEMMp, &C_GEMM_Stride);
// Define some useful constants
int opA_ncols = (TransA=='N') ? A.NumVectors() : A.MyLength();
int opB_nrows = (TransB=='N') ? B.MyLength() : B.NumVectors();
int C_global_inner_dim = (TransA=='N') ? A.NumVectors() : A.GlobalLength();
bool A_is_local = (!A.DistributedGlobal());
bool B_is_local = (!B.DistributedGlobal());
bool C_is_local = (!C.DistributedGlobal());
int A_IndexBase = A.Map().IndexBase();
int B_IndexBase = B.Map().IndexBase();
// Build two new maps that we can use for defining global equation indices below
Epetra_Map * A_Map = new Epetra_Map(-1, A_nrows, A_IndexBase, A.Map().Comm());
Epetra_Map * B_Map = new Epetra_Map(-1, B_nrows, B_IndexBase, B.Map().Comm());
int* A_MyGlobalElements = new int[A_nrows];
A_Map->MyGlobalElements(A_MyGlobalElements);
int* B_MyGlobalElements = new int[B_nrows];
B_Map->MyGlobalElements(B_MyGlobalElements);
// Check for compatible dimensions
if (C.MyLength() != C_nrows ||
opA_ncols != opB_nrows ||
C.NumVectors() != C_ncols ||
C.MyLength() != C_GEMM.MyLength() ||
C.NumVectors() != C_GEMM.NumVectors() ) {
delete A_Map;
delete B_Map;
delete [] A_MyGlobalElements;
delete [] B_MyGlobalElements;
return(-2); // Return error
}
bool Case1 = ( A_is_local && B_is_local && C_is_local); // Case 1 above
bool Case2 = (!A_is_local && !B_is_local && C_is_local && TransA=='T' );// Case 2
bool Case3 = (!A_is_local && B_is_local && !C_is_local && TransA=='N');// Case 3
// Test for meaningful cases
if (!(Case1 || Case2 || Case3)) {
delete A_Map;
delete B_Map;
delete [] A_MyGlobalElements;
delete [] B_MyGlobalElements;
return(-3); // Meaningless case
}
//.........这里部分代码省略.........