本文整理汇总了C++中Epetra_CrsGraph::NumGlobalRows方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_CrsGraph::NumGlobalRows方法的具体用法?C++ Epetra_CrsGraph::NumGlobalRows怎么用?C++ Epetra_CrsGraph::NumGlobalRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_CrsGraph
的用法示例。
在下文中一共展示了Epetra_CrsGraph::NumGlobalRows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: show_matrix
void show_matrix(const char *txt, const Epetra_CrsGraph &graph, const Epetra_Comm &comm)
{
int me = comm.MyPID();
if (comm.NumProc() > 10){
if (me == 0){
std::cerr << txt << std::endl;
std::cerr << "Printed matrix format only works for 10 or fewer processes" << std::endl;
}
return;
}
const Epetra_BlockMap &rowmap = graph.RowMap();
const Epetra_BlockMap &colmap = graph.ColMap();
int myRows = rowmap.NumMyElements();
int numRows = graph.NumGlobalRows();
int numCols = graph.NumGlobalCols();
int base = rowmap.IndexBase();
if ((numRows > 200) || (numCols > 500)){
if (me == 0){
std::cerr << txt << std::endl;
std::cerr << "show_matrix: problem is too large to display" << std::endl;
}
return;
}
int *myA = new int [numRows * numCols];
memset(myA, 0, sizeof(int) * numRows * numCols);
int *myIndices;
int *myRowGIDs = rowmap.MyGlobalElements();
for (int i=0; i< myRows; i++){
int myRowLID = rowmap.LID(myRowGIDs[i]);
int numEntries = graph.NumMyIndices(myRowLID);
if (numEntries > 0){
int rc = graph.ExtractMyRowView(myRowLID, numEntries, myIndices);
if (rc){
std::cerr << txt << std::endl;
std::cerr << "extract graph error" << std::endl;
return;
}
int *row = myA + (numCols * (myRowGIDs[i] - base));
for (int j=0; j < numEntries; j++){
int gid = colmap.GID(myIndices[j]);
row[gid-base] = me+1;
}
}
}
printMatrix(txt, myA, NULL, NULL, numRows, numCols, comm);
delete [] myA;
}