本文整理汇总了C++中Epetra_Vector::SumIntoMyValues方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_Vector::SumIntoMyValues方法的具体用法?C++ Epetra_Vector::SumIntoMyValues怎么用?C++ Epetra_Vector::SumIntoMyValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_Vector
的用法示例。
在下文中一共展示了Epetra_Vector::SumIntoMyValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MultiVectorTests
//.........这里部分代码省略.........
if (Map.MyGID(testGID)) {
LIDOfGID = Map.LID(testGID);
FirstEntryOfGID = Map.FirstPointInElement(LIDOfGID);
if ((*x)[FirstEntryOfGID]!=(VecValues[i]+VecValues[i])) err++;
if (verbose) cout << "x["<<FirstEntryOfGID<<"] = "
<< (*x)[FirstEntryOfGID]
<< " should = " << (VecValues[i]+VecValues[i]) << endl;
}
else
if (locerr!=1) err++; // Test for GID out of range error (=1)
}
// ========================================================================
// Test int ReplaceGlobalValues (int NumEntries, int BlockOffset, double *Values, int *Indices)
// ========================================================================
VecValues[0] = 1.0; VecValues[1] = 2.0;
locerr = x->ReplaceGlobalValues(NumEntries, GIDSize-1, VecValues, VecGIDs);
locerr = x->SumIntoGlobalValues(NumEntries, GIDSize-1, VecValues, VecGIDs);
for (i=0; i<NumEntries; i++) {
testGID = VecGIDs[i];
if (Map.MyGID(testGID)) {
LIDOfGID = Map.LID(testGID);
FirstEntryOfGID = Map.FirstPointInElement(LIDOfGID);
if ((*x)[FirstEntryOfGID+GIDSize-1]!=(VecValues[i]+VecValues[i])) err++;
if (verbose) cout << "x["<<FirstEntryOfGID+GIDSize-1<<"] = "
<< (*x)[FirstEntryOfGID+GIDSize-1]
<< " should = " << (VecValues[i]+VecValues[i]) << endl;
}
else
if (locerr!=1) err++; // Test for GID out of range error (=1)
}
// ========================================================================
// Test Local "My" versions of same routine (less complicated)
// ========================================================================
int * VecLIDs = new int[NumEntries];
VecLIDs[0] = testLID;
VecLIDs[1] = testLID+1; // Some pathological chance that these LIDs are not valid
VecValues[0] = 2.0; VecValues[1] = 4.0;
locerr = x->ReplaceMyValues(NumEntries, VecValues, VecLIDs);
for (i=0; i<NumEntries; i++) {
testLID = VecLIDs[i];
LIDSize = EPETRA_MIN(LIDSize,Map.ElementSize(testLID)); // Need this value below
FirstEntryOfLID = Map.FirstPointInElement(testLID);
if ((*x)[FirstEntryOfLID]!=VecValues[i]) err++;
if (verbose) cout << "x["<<FirstEntryOfLID<<"] = "
<< (*x)[FirstEntryOfLID]
<< " should = " << VecValues[i] << endl;
}
VecValues[0] = 4.0; VecValues[1] = 8.0;
locerr = x->ReplaceMyValues(NumEntries, LIDSize-1, VecValues, VecLIDs);
for (i=0; i<NumEntries; i++) {
testLID = VecLIDs[i];
LIDSize = EPETRA_MIN(LIDSize,Map.ElementSize(testLID)); // Need this value below
FirstEntryOfLID = Map.FirstPointInElement(testLID);
if ((*x)[FirstEntryOfLID+LIDSize-1]!=VecValues[i]) err++;
if (verbose) cout << "x["<<FirstEntryOfLID+LIDSize-1<<"] = "
<< (*x)[FirstEntryOfLID+LIDSize-1]
<< " should = " << VecValues[i] << endl;
}
VecValues[0] = 1.0; VecValues[1] = 1.0;
locerr = x->ReplaceMyValues(NumEntries, VecValues, VecLIDs);
locerr = x->SumIntoMyValues(NumEntries, VecValues, VecLIDs);
for (i=0; i<NumEntries; i++) {
testLID = VecLIDs[i];
LIDSize = EPETRA_MIN(LIDSize,Map.ElementSize(testLID)); // Need this value below
FirstEntryOfLID = Map.FirstPointInElement(testLID);
if ((*x)[FirstEntryOfLID]!=(VecValues[i]+VecValues[i])) err++;
if (verbose) cout << "x["<<FirstEntryOfLID<<"] = "
<< (*x)[FirstEntryOfLID]
<< " should = " << (VecValues[i]+VecValues[i]) << endl;
}
VecValues[0] = 2.0; VecValues[1] = 4.0;
locerr = x->ReplaceMyValues(NumEntries, LIDSize-1, VecValues, VecLIDs);
locerr = x->SumIntoMyValues(NumEntries, LIDSize-1, VecValues, VecLIDs);
for (i=0; i<NumEntries; i++) {
testLID = VecLIDs[i];
LIDSize = EPETRA_MIN(LIDSize,Map.ElementSize(testLID)); // Need this value below
FirstEntryOfLID = Map.FirstPointInElement(testLID);
if ((*x)[FirstEntryOfLID+LIDSize-1]!=(VecValues[i]+VecValues[i])) err++;
if (verbose) cout << "x["<<FirstEntryOfLID+LIDSize-1<<"] = "
<< (*x)[FirstEntryOfLID+LIDSize-1]
<< " should = " << (VecValues[i]+VecValues[i]) << endl;
}
delete [] VecValues;
delete [] VecGIDs;
delete [] VecLIDs;
return(ierr);
}