58 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 68 const int* numIndicesPerRow,
bool staticProfile)
72 Allocate(numIndicesPerRow, 1, staticProfile);
78 int numIndicesPerRow,
bool staticProfile)
82 Allocate(&numIndicesPerRow, 0, staticProfile);
89 const int* numIndicesPerRow,
bool staticProfile)
94 throw ReportError(
"Epetra_CrsGraph::Epetra_CrsGraph: cannot be called with different indices types for rowMap and colMap", -1);
96 Allocate(numIndicesPerRow, 1, staticProfile);
103 int numIndicesPerRow,
bool staticProfile)
108 throw ReportError(
"Epetra_CrsGraph::Epetra_CrsGraph: cannot be called with different indices types for rowMap and colMap", -1);
110 Allocate(&numIndicesPerRow, 0, staticProfile);
116 CrsGraphData_(Graph.CrsGraphData_)
122 template<
typename int_type>
135 throw ReportError(
"Error with NumIndicesPerRow_ allocation.", -99);
139 throw ReportError(
"Error with NumAllocatedIndicesPerRow_ allocation.", -99);
143 if (numIndicesPerRow != 0) {
144 for(i = 0; i < numMyBlockRows; i++) {
145 int nnzr = numIndicesPerRow[i*Inc];
159 if (staticProfile) Data.All_Indices_.Size(nnz);
160 int_type * all_indices = Data.All_Indices_.Values();
161 for(i = 0; i < numMyBlockRows; i++) {
162 const int NumIndices = numIndicesPerRow==0 ? 0 :numIndicesPerRow[i*Inc];
163 const int_type indexBaseMinusOne = (int_type)
IndexBase64() - 1;
167 Data.Indices_[i] = all_indices;
168 all_indices += NumIndices;
169 int_type* ColIndices = Data.Indices_[i];
170 for(
int j = 0; j < NumIndices; j++)
171 ColIndices[j] = indexBaseMinusOne;
177 Data.SortedEntries_[i].entries_.resize(NumIndices,
180 Data.SortedEntries_[i].entries_.resize(0);
184 Data.Indices_[i] = NULL;
189 if (staticProfile) assert(Data.All_Indices_.Values()+nnz==all_indices);
192 for(i = 0; i < numMyBlockRows; i++) {
193 Data.Indices_[i] = 0;
204 if(
RowMap().GlobalIndicesInt()) {
205 return TAllocate<int>(numIndicesPerRow, Inc, staticProfile);
209 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 210 TAllocate<int>(numIndicesPerRow, Inc, staticProfile);
211 TAllocate<long long>(numIndicesPerRow, Inc, staticProfile);
214 throw ReportError(
"Epetra_CrsGraph::Allocate: ERROR, GlobalIndicesLongLong but no API for it.",-1);
218 throw ReportError(
"Epetra_CrsGraph::Allocate: Internal error.", -1);
253 template<
typename int_type>
260 int locRow =
LRID(Row);
271 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 274 if(
RowMap().GlobalIndicesInt())
275 return InsertGlobalIndices<int>(Row, NumIndices, indices);
277 throw ReportError(
"Epetra_CrsGraph::InsertGlobalIndices int version called for a graph that is not int.", -1);
281 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 284 if(
RowMap().GlobalIndicesLongLong())
285 return InsertGlobalIndices<long long>(Row, NumIndices, indices);
287 throw ReportError(
"Epetra_CrsGraph::InsertGlobalIndices long long version called for a graph that is not long long.", -1);
308 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 311 throw ReportError(
"Epetra_CrsGraph::InsertIndicesIntoSorted: Failure because neither 32 bit nor 64 bit indices insertable.", -1);
321 template<
typename int_type>
324 int_type* UserIndices)
344 if(Data.Indices_[Row] != 0)
346 Data.Indices_[Row] = UserIndices;
347 current_numAllocIndices = NumIndices;
348 current_numIndices = NumIndices;
358 delete [] Data.TempColIndices_;
359 Data.TempColIndices_ =
new int_type[NumIndices];
362 int_type * tempIndices = Data.TempColIndices_;
365 for(j = 0; j < NumIndices; ++j)
367 tempIndices[loc++] = UserIndices[j];
370 for(j = 0; j < NumIndices; ++j) {
373 tempIndices[loc++] = UserIndices[j];
377 if(loc != NumIndices)
380 UserIndices = tempIndices;
383 int start = current_numIndices;
384 int stop = start + NumIndices;
386 if(stop > current_numAllocIndices)
390 if (current_numAllocIndices > 0 && stop > current_numAllocIndices)
392 Data.SortedEntries_[Row].entries_.resize(stop,
IndexBase64() - 1);
393 Data.Indices_[Row] = stop>0 ? &Data.SortedEntries_[Row].entries_[0] : NULL;
395 current_numAllocIndices = (int) Data.SortedEntries_[Row].entries_.capacity();
398 current_numIndices = stop;
399 int_type* RowIndices = Data.Indices_[Row]+start;
400 for(j = 0; j < NumIndices; j++) {
401 RowIndices[j] = UserIndices[j];
418 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 423 if(
RowMap().GlobalIndicesTypeValid())
424 return InsertIndices<int>(Row, NumIndices, UserIndices);
426 throw ReportError(
"Epetra_CrsGraph::InsertIndices global index type unknown.", -1);
430 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 433 long long* UserIndices)
435 if(
RowMap().GlobalIndicesLongLong())
436 return InsertIndices<long long>(Row, NumIndices, UserIndices);
438 throw ReportError(
"Epetra_CrsGraph::InsertIndices long long version called for a graph that is not long long.", -1);
443 template<
typename int_type>
446 int_type* UserIndices)
475 delete [] Data.TempColIndices_;
476 Data.TempColIndices_ =
new int_type[NumIndices];
479 int_type * tempIndices = Data.TempColIndices_;
482 for(
int j = 0; j < NumIndices; ++j)
484 tempIndices[loc++] = UserIndices[j];
487 for(
int j = 0; j < NumIndices; ++j) {
489 tempIndices[loc++] = UserIndices[j];
493 if(loc != NumIndices)
496 UserIndices = tempIndices;
501 Data.SortedEntries_[Row].AddEntries(NumIndices, UserIndices);
502 current_numIndices = (int) Data.SortedEntries_[Row].entries_.size();
503 current_numAllocIndices = (int) Data.SortedEntries_[Row].entries_.capacity();
505 Data.Indices_[Row] = current_numIndices > 0 ? &Data.SortedEntries_[Row].entries_[0] : NULL;
519 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 524 if(
RowMap().GlobalIndicesTypeValid())
525 return InsertIndicesIntoSorted<int>(Row, NumIndices, UserIndices);
527 throw ReportError(
"Epetra_CrsGraph::InsertIndicesIntoSorted global index type unknown.", -1);
531 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 534 long long* UserIndices)
536 if(
RowMap().GlobalIndicesLongLong())
537 return InsertIndicesIntoSorted<long long>(Row, NumIndices, UserIndices);
539 throw ReportError(
"Epetra_CrsGraph::InsertIndicesIntoSorted long long version called for a graph that is not long long.", -1);
543 template<
typename int_type>
559 int locRow =
LRID(Row);
568 for(j = 0; j < NumIndices; j++) {
569 int_type Index = indices[j];
571 for(k = Loc+1; k < NumCurrentIndices; k++)
572 Data.Indices_[locRow][k-1] = Data.Indices_[locRow][k];
576 Data.SortedEntries_[locRow].entries_.pop_back();
578 Data.Indices_[locRow][NumCurrentIndices-1] =
IndexBase64() - 1;
592 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 595 if(
RowMap().GlobalIndicesInt())
596 return RemoveGlobalIndices<int>(Row, NumIndices, indices);
598 throw ReportError(
"Epetra_CrsGraph::RemoveGlobalIndices int version called for a graph that is not int.", -1);
602 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 605 if(
RowMap().GlobalIndicesLongLong())
606 return RemoveGlobalIndices<long long>(Row, NumIndices, indices);
608 throw ReportError(
"Epetra_CrsGraph::RemoveGlobalIndices long long version called for a graph that is not long long.", -1);
635 for(j = 0; j < NumIndices; j++) {
636 int Index = indices[j];
638 for(k = Loc + 1; k < NumCurrentIndices; k++)
659 template<
typename int_type>
673 #ifdef EPETRA_NO_64BIT_GLOBAL_INDICES 674 int locRow =
LRID((
int) Row);
676 int locRow =
LRID(Row);
687 const int_type indexBaseMinusOne = (int_type)
IndexBase64() - 1;
688 for(j = 0; j < NumIndices; j++)
689 Data.Indices_[locRow][j] = indexBaseMinusOne;
692 Data.SortedEntries_[locRow].entries_.resize(0);
708 if(
RowMap().GlobalIndicesLongLong())
709 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 710 return TRemoveGlobalIndices<long long>(Row);
712 throw ReportError(
"Epetra_CrsGraph::RemoveGlobalIndices: ERROR, GlobalIndicesLongLong but no API for it.",-1);
715 if(
RowMap().GlobalIndicesInt())
716 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 717 return TRemoveGlobalIndices<int>(Row);
719 throw ReportError(
"Epetra_CrsGraph::RemoveGlobalIndices: ERROR, GlobalIndicesInt but no API for it.",-1);
722 throw ReportError(
"Epetra_CrsGraph::RemoveGlobalIndices: Internal error.", -1);
746 for(
int j = 0; j < NumIndices; j++)
764 template<
typename int_type>
774 int* locIndices =
Indices(LocalRow);
775 int locIndex =
LCID(Index);
783 for(j = 0; j < NumIndices; j++) {
786 if(locIndices[j0] == locIndex) {
795 int_type* locIndices = TIndices<int_type>(LocalRow);
803 for(j = 0; j < NumIndices; j++) {
806 if(locIndices[j0] == Index) {
818 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 824 if(
RowMap().GlobalIndicesInt())
825 return FindGlobalIndexLoc<int>(LocalRow, Index, Start, Loc);
827 throw ReportError(
"Epetra_CrsGraph::FindGlobalIndexLoc int version called for a graph that is not int.", -1);
830 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 836 if(
RowMap().GlobalIndicesLongLong())
837 return FindGlobalIndexLoc<long long>(LocalRow, Index, Start, Loc);
839 throw ReportError(
"Epetra_CrsGraph::FindGlobalIndexLoc long long version called for a graph that is not long long.", -1);
844 template<
typename int_type>
846 const int_type* indices,
863 for(j = 0; j < NumIndices; j++) {
866 if(indices[j0] == Index) {
876 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 883 if(
RowMap().GlobalIndicesInt())
884 return FindGlobalIndexLoc<int>(NumIndices, indices, Index, Start, Loc);
886 throw ReportError(
"Epetra_CrsGraph::FindGlobalIndexLoc int version called for a graph that is not int.", -1);
889 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 891 const long long* indices,
896 if(
RowMap().GlobalIndicesLongLong())
897 return FindGlobalIndexLoc<long long>(NumIndices, indices, Index, Start, Loc);
899 throw ReportError(
"Epetra_CrsGraph::FindGlobalIndexLoc long long version called for a graph that is not long long.", -1);
910 int* locIndices =
Indices(LocalRow);
913 throw ReportError(
"Epetra_CrsGraph::FindMyIndexLoc", -1);
923 for(j = 0; j < NumIndices; j++) {
926 if(locIndices[j0] == Index) {
944 throw ReportError(
"Epetra_CrsGraph::FindMyIndexLoc", -1);
954 for(j = 0; j < NumIndices; j++) {
957 if(indices[j0] == Index) {
976 throw ReportError(
"Epetra_CrsGraph::FillComplete: cannot be called with different indices types for domainMap and rangeMap", -1);
979 throw ReportError(
"Epetra_CrsGraph::FillComplete: cannot be called with different indices types for row map and incoming rangeMap", -1);
1014 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 1025 {
for(
int i = 0; i < numMyBlockRows; i++) {
1031 if(
RowMap().ConstantElementSize() &&
ColMap().ConstantElementSize() &&
RowMap().ElementSize() ==
ColMap().ElementSize()) {
1048 int ColElementSize = RowElementSize;
1061 int* ColElementSizeList = RowElementSizeList;
1064 for(
int i = 0; i < numMyBlockRows; i++){
1066 int* indices = intData.
Indices_[i];
1067 if(NumEntries > 0) {
1068 int CurNumNonzeros = 0;
1069 int RowDim = RowElementSizeList[i];
1070 for(
int j = 0; j < NumEntries; j++) {
1071 int ColDim = ColElementSizeList[indices[j]];
1072 CurNumNonzeros += RowDim*ColDim;
1113 int i, j, j2, temp, istep;
1119 for (i=step; i < length; i++)
1125 if (list[j2] > temp) {
1126 while ((j >= istep) && (list[j2] > temp))
1139 step = (int) (step / 2.2);
1155 for(
int i = 0; i < numMyBlockRows; i++){
1157 int*
const list = intData.
Indices_[i];
1205 if (len < 2)
return;
1207 int* ptr0 = &list[0];
1208 int* ptr1 = &list[1];
1210 int* ptr_end = &list[len-1];
1212 while(*ptr0 != *ptr1 && ptr1 < ptr_end) {
1217 if (ptr1 < ptr_end) {
1223 while(*ptr0 == *ptr1 && ptr1 < ptr_end) ++ptr1;
1225 while(ptr1 < ptr_end) {
1229 while(val == *ptr1 && ptr1 < ptr_end) {
1236 if (*(ptr0-1) != *ptr1) *ptr0++ = *ptr1;
1238 int num_removed = (int)(ptr_end - ptr0 + 1);
1239 newlen = len - num_removed;
1242 if (*ptr0 == *ptr1) newlen = len - 1;
1259 bool found_redundancies =
false;
1264 for(
int i=0; i<numMyBlockRows; ++i) {
1265 int NumIndices = numIndicesPerRow[i];
1266 int* col_indices = this->
Indices(i);
1268 if(NumIndices > 1) {
1270 numIndicesPerRow[i]);
1272 if (NumIndices != numIndicesPerRow[i]) {
1273 found_redundancies =
true;
1278 for(
int i=0; i<numMyBlockRows; ++i) {
1279 int* col_indices = this->
Indices(i);
1282 intData.
SortedEntries_[i].entries_.assign(col_indices, col_indices+numIndicesPerRow[i]);
1283 if (numIndicesPerRow[i] > 0) {
1315 for(
int i = 0; i < numMyBlockRows; i++) {
1317 if(NumIndices > 0) {
1318 #if defined(EPETRA_NO_64BIT_GLOBAL_INDICES) && !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) 1319 int ig = rowMap.
GID(i);
1321 long long ig = rowMap.
GID64(i);
1323 int* col_indices = this->
Indices(i);
1325 int jl_0 = col_indices[0];
1326 int jl_n = col_indices[NumIndices-1];
1333 int jl = colMap.
LID(ig);
1335 int insertPoint = -1;
1352 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 1371 bool * LocalGIDs = 0;
1372 if (numDomainElements>0) LocalGIDs =
new bool[numDomainElements];
1373 for (i=0; i<numDomainElements; i++) LocalGIDs[i] =
false;
1379 int hashsize = numMyBlockRows;
if (hashsize < 100) hashsize = 100;
1384 int NumLocalColGIDs = 0;
1385 int NumRemoteColGIDs = 0;
1387 for(i = 0; i < numMyBlockRows; i++) {
1389 int* ColIndices = intData.
Indices_[i];
1390 for(j = 0; j < NumIndices; j++) {
1391 int GID = ColIndices[j];
1393 int LID = domainMap.
LID(GID);
1395 bool alreadyFound = LocalGIDs[LID];
1396 if (!alreadyFound) {
1397 LocalGIDs[LID] =
true;
1402 if(RemoteGIDs.
Get(GID) == -1) {
1403 RemoteGIDs.
Add(GID, NumRemoteColGIDs);
1404 RemoteGIDList.
Add(NumRemoteColGIDs++, GID);
1413 if (NumRemoteColGIDs!=0) {
1414 throw ReportError(
"Some column IDs are not in domainMap. If matrix is rectangular, you must pass in domainMap to FillComplete",-1);
1416 if (NumLocalColGIDs==numDomainElements) {
1419 if (LocalGIDs!=0)
delete [] LocalGIDs;
1426 int numMyBlockCols = NumLocalColGIDs + NumRemoteColGIDs;
1428 if(numMyBlockCols > 0)
1429 ColIndices.
Size(numMyBlockCols);
1431 int* RemoteColIndices = ColIndices.
Values() + NumLocalColGIDs;
1433 for(i = 0; i < NumRemoteColGIDs; i++)
1434 RemoteColIndices[i] = RemoteGIDList.
Get(i);
1439 int* RemoteSizeList = 0;
1442 if(NumRemoteColGIDs > 0)
1443 PIDList.
Size(NumRemoteColGIDs);
1446 if(numMyBlockCols > 0)
1447 SizeList.
Size(numMyBlockCols);
1448 RemoteSizeList = SizeList.
Values() + NumLocalColGIDs;
1457 SortLists[0] = RemoteColIndices;
1458 SortLists[1] = RemoteSizeList;
1459 Util.
Sort(
true, NumRemoteColGIDs, PIDList.
Values(), 0, 0, NLists, SortLists, 0, 0);
1466 int StartCurrent, StartNext;
1467 StartCurrent = 0; StartNext = 1;
1468 while ( StartNext < NumRemoteColGIDs ) {
1469 if ((PIDList.
Values())[StartNext]==(PIDList.
Values())[StartNext-1]) StartNext++;
1471 if(DoSizes) SortLists[0] = &(RemoteSizeList[StartCurrent]);
1472 Util.
Sort(
true,StartNext-StartCurrent, &(RemoteColIndices[StartCurrent]),0,0,NLists,SortLists, 0, 0);
1473 StartCurrent = StartNext; StartNext++;
1476 if(DoSizes) SortLists[0] = &(RemoteSizeList[StartCurrent]);
1477 Util.
Sort(
true, StartNext-StartCurrent, &(RemoteColIndices[StartCurrent]), 0, 0, NLists, SortLists, 0, 0);
1494 int* ElementSizeList = 0;
1497 int NumLocalAgain = 0;
1498 for(i = 0; i < NumMyElements; i++) {
1501 SizeList[NumLocalAgain] = ElementSizeList[i];
1502 ColIndices[NumLocalAgain++] = MyGlobalElements[i];
1505 assert(NumLocalAgain==NumLocalColGIDs);
1509 if (LocalGIDs!=0)
delete [] LocalGIDs;
1532 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 1551 bool * LocalGIDs = 0;
1552 if (numDomainElements>0) LocalGIDs =
new bool[numDomainElements];
1553 for (i=0; i<numDomainElements; i++) LocalGIDs[i] =
false;
1559 int hashsize = numMyBlockRows;
if (hashsize < 100) hashsize = 100;
1564 int NumLocalColGIDs = 0;
1565 int NumRemoteColGIDs = 0;
1571 for(i = 0; i < numMyBlockRows; i++) {
1573 int* ColIndices = intData.
Indices_[i];
1574 for(j = 0; j < NumIndices; j++) {
1575 int GID = ColIndices[j];
1577 int LID = domainMap.
LID(GID);
1579 bool alreadyFound = LocalGIDs[LID];
1580 if (!alreadyFound) {
1581 LocalGIDs[LID] =
true;
1586 if(RemoteGIDs.
Get(GID) == -1) {
1587 RemoteGIDs.
Add(GID, NumRemoteColGIDs);
1588 RemoteGIDList.
Add(NumRemoteColGIDs++, GID);
1598 for(i = 0; i < numMyBlockRows; i++) {
1600 long long* ColIndices = LLData.
Indices_[i];
1601 for(j = 0; j < NumIndices; j++) {
1602 long long GID = ColIndices[j];
1604 int LID = domainMap.
LID(GID);
1606 bool alreadyFound = LocalGIDs[LID];
1607 if (!alreadyFound) {
1608 LocalGIDs[LID] =
true;
1613 if(RemoteGIDs.
Get(GID) == -1) {
1614 RemoteGIDs.
Add(GID, NumRemoteColGIDs);
1615 RemoteGIDList.
Add(NumRemoteColGIDs++, GID);
1625 if (NumRemoteColGIDs!=0) {
1626 throw ReportError(
"Some column IDs are not in domainMap. If matrix is rectangular, you must pass in domainMap to FillComplete",-1);
1628 if (NumLocalColGIDs==numDomainElements) {
1631 if (LocalGIDs!=0)
delete [] LocalGIDs;
1638 int numMyBlockCols = NumLocalColGIDs + NumRemoteColGIDs;
1640 if(numMyBlockCols > 0)
1641 ColIndices.
Size(numMyBlockCols);
1643 long long* RemoteColIndices = ColIndices.
Values() + NumLocalColGIDs;
1645 for(i = 0; i < NumRemoteColGIDs; i++)
1646 RemoteColIndices[i] = RemoteGIDList.
Get(i);
1651 int* RemoteSizeList = 0;
1654 if(NumRemoteColGIDs > 0)
1655 PIDList.
Size(NumRemoteColGIDs);
1658 if(numMyBlockCols > 0)
1659 SizeList.
Size(numMyBlockCols);
1660 RemoteSizeList = SizeList.
Values() + NumLocalColGIDs;
1671 Util.
Sort(
true, NumRemoteColGIDs, PIDList.
Values(), 0, 0, NLists, &RemoteSizeList, 1, &RemoteColIndices);
1677 int* SortLists[1] = {0};
1679 int StartCurrent, StartNext;
1680 StartCurrent = 0; StartNext = 1;
1681 while ( StartNext < NumRemoteColGIDs ) {
1682 if ((PIDList.
Values())[StartNext]==(PIDList.
Values())[StartNext-1]) StartNext++;
1684 if(DoSizes) SortLists[0] = &(RemoteSizeList[StartCurrent]);
1685 Util.
Sort(
true,StartNext-StartCurrent, &(RemoteColIndices[StartCurrent]),0,0,NLists,SortLists, 0, 0);
1686 StartCurrent = StartNext; StartNext++;
1689 if(DoSizes) SortLists[0] = &(RemoteSizeList[StartCurrent]);
1690 Util.
Sort(
true, StartNext-StartCurrent, &(RemoteColIndices[StartCurrent]), 0, 0, NLists, SortLists, 0, 0);
1707 int* ElementSizeList = 0;
1710 int NumLocalAgain = 0;
1711 for(i = 0; i < NumMyElements; i++) {
1714 SizeList[NumLocalAgain] = ElementSizeList[i];
1715 ColIndices[NumLocalAgain++] = MyGlobalElements[i];
1718 assert(NumLocalAgain==NumLocalColGIDs);
1722 if (LocalGIDs!=0)
delete [] LocalGIDs;
1749 throw ReportError(
"Epetra_CrsGraph::MakeColMap: cannot be called with different indices types for domainMap and rangeMap", -1);
1752 throw ReportError(
"Epetra_CrsGraph::MakeColMap: cannot be called with different indices types for row map and incoming rangeMap", -1);
1755 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1758 throw ReportError(
"Epetra_CrsGraph::MakeColMap: ERROR, GlobalIndicesInt but no API for it.",-1);
1761 if(
RowMap().GlobalIndicesLongLong())
1762 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 1765 throw ReportError(
"Epetra_CrsGraph::MakeColMap: ERROR, GlobalIndicesLongLong but no API for it.",-1);
1768 throw ReportError(
"Epetra_CrsGraph::MakeColMap: Internal error, unable to determine global index type of maps", -1);
1774 throw ReportError(
"Epetra_CrsGraph::MakeIndicesLocal: cannot be called with different indices types for domainMap and rangeMap", -1);
1777 throw ReportError(
"Epetra_CrsGraph::MakeIndicesLocal: cannot be called with different indices types for row map and incoming rangeMap", -1);
1795 bool mapMonotone =
true;
1797 long long oldGID = colmap.
GID64(0);
1799 if (oldGID > colmap.
GID64(i)) {
1800 mapMonotone =
false;
1803 oldGID = colmap.
GID64(i);
1819 for(
int i = 0; i < numMyBlockRows; i++) {
1821 int* ColIndices = intData.
Indices_[i];
1822 for(
int j = 0; j < NumIndices; j++) {
1823 int GID = ColIndices[j];
1824 int LID = colmap.
LID(GID);
1826 ColIndices[j] = LID;
1828 throw ReportError(
"Internal error in FillComplete ",-1);
1832 else if(
RowMap().GlobalIndicesLongLong())
1834 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 1839 const long long indexBaseMinusOne =
IndexBase64() - 1;
1840 for(
int i = 0; i < numMyBlockRows; i++) {
1842 intData.
SortedEntries_[i].entries_.resize(NumIndices, indexBaseMinusOne);
1849 for(
int i = 0; i < numMyBlockRows; i++) {
1851 long long* ColIndices = LL_Data.
Indices_[i];
1852 int* intColIndices = intData.
Indices_[i];
1853 for(
int j = 0; j < NumIndices; j++) {
1854 long long GID = ColIndices[j];
1855 int LID = colmap.
LID(GID);
1857 intColIndices[j] = LID;
1859 throw ReportError(
"Internal error in FillComplete ",-1);
1865 throw ReportError(
"Epetra_CrsGraph::MakeIndicesLocal: GlobalIndicesLongLong but no long long API", -1);
1891 bool Contiguous =
true;
1892 for(
int i = 1; i < numMyBlockRows; i++) {
1898 if((NumIndices != NumAllocateIndices) ||
1920 int curNumIndices = numIndicesPerRow[0];
1921 numIndicesPerRow[0] = 0;
1922 for (
int i=0; i<numMyBlockRows; ++i) {
1923 int nextNumIndices = numIndicesPerRow[i+1];
1924 numIndicesPerRow[i+1] = numIndicesPerRow[i]+curNumIndices;
1925 curNumIndices = nextNumIndices;
1936 if(errorcode != 0)
throw ReportError(
"Error with All_Indices_ allocation.", -99);
1945 #ifdef EPETRA_HAVE_OMP 1946 #pragma omp parallel for default(none) shared(indexOffset,all_indices,indices) 1948 for(
int i = 0; i < numMyBlockRows; i++) {
1949 int numColIndices = indexOffset[i+1] - indexOffset[i];
1950 int* ColIndices = indices[i];
1951 int *newColIndices = all_indices+indexOffset[i];
1952 for(
int j = 0; j < numColIndices; j++) newColIndices[j] = ColIndices[j];
1954 for(
int i = 0; i < numMyBlockRows; i++) {
1955 if (indices[i]!=0) {
1963 for(
int i = 0; i < numMyBlockRows; i++) {
1964 int numColIndices = indexOffset[i+1] - indexOffset[i];
1965 int* ColIndices = indices[i];
1966 int *newColIndices = all_indices+indexOffset[i];
1967 if (ColIndices!=newColIndices)
1968 for(
int j = 0; j < numColIndices; j++) newColIndices[j] = ColIndices[j];
1980 if(errorcode != 0)
throw ReportError(
"Error with All_Indices_ allocation.", -99);
1982 int* old_all_indices = Data.
Indices_[0];
1985 #ifdef EPETRA_HAVE_OMP 1986 #pragma omp parallel for default(none) shared(indexOffset,old_all_indices,new_all_indices) 1988 for(
int i = 0; i < numMyBlockRows; i++) {
1989 int numColIndices = indexOffset[i+1] - indexOffset[i];
1990 int *oldColIndices = old_all_indices+indexOffset[i];
1991 int *newColIndices = new_all_indices+indexOffset[i];
1992 for(
int j = 0; j < numColIndices; j++) newColIndices[j] = oldColIndices[j];
2022 template<
typename int_type>
2027 int locRow =
LRID(Row);
2033 if(LenOfIndices < NumIndices)
2038 int * srcIndices = TIndices<int>(locRow);
2040 for(j = 0; j < NumIndices; j++)
2041 targIndices[j] = static_cast<int_type>(
GCID64(srcIndices[j]));
2045 int_type * srcIndices = TIndices<int_type>(locRow);
2046 for(j = 0; j < NumIndices; j++)
2047 targIndices[j] = srcIndices[j];
2053 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 2056 if(
RowMap().GlobalIndicesInt())
2057 return ExtractGlobalRowCopy<int>(Row, LenOfIndices, NumIndices, targIndices);
2059 throw ReportError(
"Epetra_CrsGraph::ExtractGlobalRowCopy int version called for a graph that is not int.", -1);
2063 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2066 if(
RowMap().GlobalIndicesLongLong())
2067 return ExtractGlobalRowCopy<long long>(Row, LenOfIndices, NumIndices, targIndices);
2069 throw ReportError(
"Epetra_CrsGraph::ExtractGlobalRowCopy long long version called for a graph that is not long long.", -1);
2074 template<
typename int_type>
2083 if(LenOfIndices < NumIndices)
2089 int * srcIndices = TIndices<int>(Row);
2090 for(j = 0; j < NumIndices; j++)
2091 targIndices[j] = srcIndices[j];
2098 if(
RowMap().GlobalIndicesTypeValid())
2099 return ExtractMyRowCopy<int>(Row, LenOfIndices, NumIndices, targIndices);
2101 throw ReportError(
"Epetra_CrsGraph::ExtractMyRowCopy graph global index type unknown.", -1);
2105 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 2108 if(!
RowMap().GlobalIndicesInt())
2109 throw ReportError(
"Epetra_CrsGraph::ExtractGlobalRowView int version called for a graph that is not int.", -1);
2111 int locRow =
LRID(Row);
2121 targIndices = TIndices<int>(locRow);
2127 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2130 if(!
RowMap().GlobalIndicesLongLong())
2131 throw ReportError(
"Epetra_CrsGraph::ExtractGlobalRowView long long version called for a graph that is not long long.", -1);
2133 int locRow =
LRID(Row);
2143 targIndices = TIndices<long long>(locRow);
2159 targIndices = TIndices<int>(Row);
2166 #ifdef EPETRA_NO_64BIT_GLOBAL_INDICES 2167 int locRow =
LRID((
int) Row);
2169 int locRow =
LRID(Row);
2179 #ifdef EPETRA_NO_64BIT_GLOBAL_INDICES 2180 int locRow =
LRID((
int) Row);
2182 int locRow =
LRID(Row);
2193 if (
RowMap().PointSameAs(newmap)) {
2218 if(
ColMap().PointSameAs(newmap)) {
2231 if( !NewImporter &&
ColMap().SameAs(NewDomainMap)) {
2259 newDomainMap = newMap;
2269 newRangeMap = newMap;
2290 throw ReportError(
"Epetra_CrsGraph::RemoveEmptyProcessesInPlace does not work for shared CrsGraphData_",-2);
2293 #if defined(EPETRA_NO_32BIT_GLOBAL_INDICES) && defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 2318 if(newColMap != newMap)
delete newColMap;
2319 if(newDomainMap != newMap)
delete newDomainMap;
2320 if(newRangeMap != newMap)
delete newRangeMap;
2329 if(!
A.GlobalConstantsComputed())
2343 int* PermuteFromLIDs,
2348 throw ReportError(
"Epetra_CrsGraph::CopyAndPermute: Incoming global index type does not match the one for *this",-1);
2353 PermuteFromLIDs,Indexor,CombineMode));
2359 PermuteFromLIDs,Indexor,CombineMode));
2370 template<
typename int_type>
2375 int* PermuteFromLIDs,
2386 int maxNumIndices =
A.MaxNumEntries();
2388 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2393 int* local_indices = 0;
2394 int_type* global_indices = 0;
2396 if(maxNumIndices > 0) {
2397 local_indices_vec.
Size(maxNumIndices);
2398 local_indices = local_indices_vec.
Values();
2400 if(
A.RowMatrixRowMap().GlobalIndicesLongLong())
2402 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2403 global_indices_vec.
Size(maxNumIndices);
2404 global_indices =
reinterpret_cast<int_type*
>(global_indices_vec.
Values());
2406 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteRowMatrix: GlobalIndicesLongLong but no API for long long",-1);
2411 global_indices =
reinterpret_cast<int_type*
>(local_indices);
2414 Values.
Size(maxNumIndices);
2421 for(i = 0; i < NumSameIDs; i++) {
2422 ToRow = (int) rowMap.
GID64(i);
2424 for(j = 0; j < NumIndices; j++)
2425 global_indices[j] = (int_type) colMap.
GID64(local_indices[j]);
2432 for(i = 0; i < NumPermuteIDs; i++) {
2433 FromRow = PermuteFromLIDs[i];
2434 ToRow = (int_type)
GRID64(PermuteToLIDs[i]);
2435 EPETRA_CHK_ERR(
A.ExtractMyRowCopy(FromRow, maxNumIndices, NumIndices, Values.
Values(), local_indices));
2436 for(j = 0; j < NumIndices; j++)
2437 global_indices[j] = (int_type) colMap.
GID64(local_indices[j]);
2449 int* PermuteFromLIDs,
2453 if(!
A.RowMatrixRowMap().GlobalIndicesTypeMatch(
RowMap()))
2454 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteRowMatrix: Incoming global index type does not match the one for *this",-1);
2456 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 2457 if(
A.RowMatrixRowMap().GlobalIndicesInt())
2458 return CopyAndPermuteRowMatrix<int>(
A, NumSameIDs, NumPermuteIDs, PermuteToLIDs, PermuteFromLIDs, Indexor,CombineMode);
2461 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2462 if(
A.RowMatrixRowMap().GlobalIndicesLongLong())
2463 return CopyAndPermuteRowMatrix<long long>(
A, NumSameIDs, NumPermuteIDs, PermuteToLIDs, PermuteFromLIDs, Indexor,CombineMode);
2466 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteRowMatrix: Unable to determine global index type of map", -1);
2470 template<
typename int_type>
2475 int* PermuteFromLIDs,
2484 int_type* indices = 0;
2485 int_type FromRow, ToRow;
2486 int maxNumIndices =
A.MaxNumIndices();
2488 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2492 if(maxNumIndices > 0 &&
A.IndicesAreLocal()) {
2493 if(
A.RowMap().GlobalIndicesInt())
2495 int_IndicesVector.
Size(maxNumIndices);
2496 indices =
reinterpret_cast<int_type*
>(int_IndicesVector.
Values());
2498 else if(
A.RowMap().GlobalIndicesLongLong())
2500 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2501 LL_IndicesVector.
Size(maxNumIndices);
2502 indices =
reinterpret_cast<int_type*
>(LL_IndicesVector.
Values());
2504 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteCrsGraph: ERROR, GlobalIndicesLongLong but no API for it.",-1);
2510 if(NumSameIDs > 0) {
2511 if(
A.IndicesAreLocal()) {
2512 for(i = 0; i < NumSameIDs; i++) {
2513 Row = (int_type)
GRID64(i);
2514 EPETRA_CHK_ERR(
A.ExtractGlobalRowCopy(Row, maxNumIndices, NumIndices, indices));
2521 for(i = 0; i < NumSameIDs; i++) {
2522 Row = (int_type)
GRID64(i);
2532 if(NumPermuteIDs > 0) {
2533 if(
A.IndicesAreLocal()) {
2534 for(i = 0; i < NumPermuteIDs; i++) {
2535 FromRow = (int_type)
A.GRID64(PermuteFromLIDs[i]);
2536 ToRow = (int_type)
GRID64(PermuteToLIDs[i]);
2537 EPETRA_CHK_ERR(
A.ExtractGlobalRowCopy(FromRow, maxNumIndices, NumIndices, indices));
2544 for(i = 0; i < NumPermuteIDs; i++) {
2545 FromRow = (int_type)
A.GRID64(PermuteFromLIDs[i]);
2546 ToRow = (int_type)
GRID64(PermuteToLIDs[i]);
2562 int* PermuteFromLIDs,
2566 if(!
A.RowMap().GlobalIndicesTypeMatch(
RowMap()))
2567 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteCrsGraph: Incoming global index type does not match the one for *this",-1);
2569 if(
A.RowMap().GlobalIndicesInt())
2570 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
2571 return CopyAndPermuteCrsGraph<int>(
A, NumSameIDs, NumPermuteIDs, PermuteToLIDs, PermuteFromLIDs, Indexor, CombineMode);
2573 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteCrsGraph: ERROR, GlobalIndicesInt but no API for it.",-1);
2576 if(
A.RowMap().GlobalIndicesLongLong())
2577 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
2578 return CopyAndPermuteCrsGraph<long long>(
A, NumSameIDs, NumPermuteIDs, PermuteToLIDs, PermuteFromLIDs, Indexor, CombineMode);
2580 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteCrsGraph: ERROR, GlobalIndicesLongLong but no API for it.",-1);
2583 throw ReportError(
"Epetra_CrsGraph::CopyAndPermuteCrsGraph: Unable to determine global index type of map", -1);
2598 throw ReportError(
"Epetra_CrsGraph::PackAndPrepare: Incoming global index type does not match the one for *this",-1);
2600 int globalMaxNumIndices = 0;
2601 int TotalSendSize = 0;
2606 SizeOfPacket = (
int)
sizeof(int);
2608 SizeOfPacket = (
int)
sizeof(
long long);
2610 throw ReportError(
"Epetra_CrsGraph::PackAndPrepare: Unable to determine source global index type",-1);
2612 if(NumExportIDs <= 0)
return(0);
2616 globalMaxNumIndices =
A.GlobalMaxNumIndices();
2617 for(
int i = 0; i < NumExportIDs; ++i )
2619 Sizes[i] = (
A.NumMyIndices( ExportLIDs[i] ) + 2);
2620 TotalSendSize += Sizes[i];
2626 int maxNumIndices =
A.MaxNumEntries();
2627 A.Comm().MaxAll(&maxNumIndices, &globalMaxNumIndices, 1);
2628 for(
int i = 0; i < NumExportIDs; ++i )
2631 A.NumMyRowEntries( ExportLIDs[i], NumEntries );
2632 Sizes[i] = (NumEntries + 2);
2633 TotalSendSize += Sizes[i];
2646 SizeOfPacket, Sizes, VarSizes, Distor));
2651 SizeOfPacket, Sizes, VarSizes, Distor));
2667 if(!
A.RowMap().GlobalIndicesTypeMatch(
RowMap()))
2668 throw ReportError(
"Epetra_CrsGraph::PackAndPrepareCrsGraph: Incoming global index type does not match the one for *this",-1);
2684 int maxNumIndices =
A.MaxNumIndices();
2687 if(
A.RowMap().GlobalIndicesInt()) {
2689 int* intptr = (
int*) Exports;
2691 for(i = 0; i < NumExportIDs; i++) {
2692 FromRow = (int)
A.GRID64(ExportLIDs[i]);
2694 indices = intptr + 2;
2695 EPETRA_CHK_ERR(
A.ExtractGlobalRowCopy(FromRow, maxNumIndices, NumIndices, indices));
2696 intptr[1] = NumIndices;
2697 intptr += (NumIndices+2);
2700 else if(
A.RowMap().GlobalIndicesLongLong()) {
2701 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2702 long long* indices = 0;
2703 long long* LLptr = (
long long*) Exports;
2705 for(i = 0; i < NumExportIDs; i++) {
2706 FromRow =
A.GRID64(ExportLIDs[i]);
2708 indices = LLptr + 2;
2709 EPETRA_CHK_ERR(
A.ExtractGlobalRowCopy(FromRow, maxNumIndices, NumIndices, indices));
2710 LLptr[1] = NumIndices;
2711 LLptr += (NumIndices+2);
2714 throw ReportError(
"Epetra_CrsGraph::PackAndPrepareCrsGraph: ERROR, GlobalIndicesLongLong but no API for it.",-1);
2718 throw ReportError(
"Epetra_CrsGraph::PackAndPrepareCrsGraph: Unable to determine source global index type",-1);
2736 if(!
A.Map().GlobalIndicesTypeMatch(
RowMap()))
2737 throw ReportError(
"Epetra_CrsGraph::PackAndPrepareRowMatrix: Incoming global index type does not match the one for *this",-1);
2755 int maxNumIndices =
A.MaxNumEntries();
2756 if(maxNumIndices > 0) {
2757 Values.
Size(maxNumIndices);
2766 int* intptr = (
int*) Exports;
2767 for(i = 0; i < NumExportIDs; i++) {
2768 FromRow = (int) rowMap.
GID64(ExportLIDs[i]);
2770 indices = intptr + 2;
2771 EPETRA_CHK_ERR(
A.ExtractMyRowCopy(ExportLIDs[i], maxNumIndices, NumIndices, Values.
Values(), indices));
2772 for(j = 0; j < NumIndices; j++) indices[j] = (
int) colMap.
GID64(indices[j]);
2773 intptr[1] = NumIndices;
2774 intptr += (NumIndices+2);
2783 long long* LL_indices = 0;
2785 long long* LLptr = (
long long*) Exports;
2786 for(i = 0; i < NumExportIDs; i++) {
2787 FromRow = rowMap.
GID64(ExportLIDs[i]);
2789 LL_indices = LLptr + 2;
2790 int* int_indices =
reinterpret_cast<int*
>(LL_indices);
2791 EPETRA_CHK_ERR(
A.ExtractMyRowCopy(ExportLIDs[i], maxNumIndices, NumIndices, Values.
Values(), int_indices));
2794 for(j = NumIndices; j > 0;) {
2796 LL_indices[j] = colMap.
GID64(int_indices[j]);
2799 LLptr[1] = NumIndices;
2800 LLptr += (NumIndices+2);
2804 throw ReportError(
"Epetra_CrsGraph::PackAndPrepareRowMatrix: Unable to determine source global index type",-1);
2824 throw ReportError(
"Epetra_CrsGraph::UnpackAndCombine: Incoming global index type does not match the one for *this",-1);
2832 if(NumImportIDs <= 0)
2842 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 2848 int* intptr = (
int*) Imports;
2849 for(i = 0; i < NumImportIDs; i++) {
2850 ToRow = (int)
GRID64(ImportLIDs[i]);
2851 assert((intptr[0])==ToRow);
2852 NumIndices = intptr[1];
2853 indices = intptr + 2;
2858 intptr += (NumIndices+2);
2863 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 2869 long long* LLptr = (
long long*) Imports;
2870 for(i = 0; i < NumImportIDs; i++) {
2871 ToRow =
GRID64(ImportLIDs[i]);
2872 assert((LLptr[0])==ToRow);
2873 NumIndices = (int) LLptr[1];
2874 indices = LLptr + 2;
2879 LLptr += (NumIndices+2);
2884 throw ReportError(
"Epetra_CrsGraph::UnpackAndCombine: Unable to determine source global index type",-1);
2903 int mineComputed = 0;
2909 return(allComputed==1);
2914 int myIndicesAreLocal = 0;
2915 int myIndicesAreGlobal = 0;
2917 myIndicesAreLocal = 1;
2919 myIndicesAreGlobal = 1;
2920 int allIndicesAreLocal;
2921 int allIndicesAreGlobal;
2929 #if defined(Epetra_ENABLE_MKL_SPARSE) && !defined(Epetra_DISABLE_MKL_SPARSE_MM) 2930 int *Epetra_CrsGraph::All_IndicesPlus1()
const {
2939 throw ReportError(
"Epetra_CrsGraph: int *All_IndicesPlus1() cannot be called when StorageOptimized()==false", -1);
2949 ptr[i] = indices[i] + 1;
2957 #endif // defined(Epetra_ENABLE_MKL_SPARSE) && !defined(Epetra_DISABLE_MKL_SPARSE_MM) 2964 for(
int iproc = 0; iproc < NumProc; iproc++) {
2965 if(MyPID == iproc) {
2975 os <<
"\nGlobal Maximum Block Row Dim = " <<
GlobalMaxRowDim() << std::endl;
2976 os <<
"Global Maximum Block Col Dim = " <<
GlobalMaxColDim() << std::endl;
2978 if(
LowerTriangular()) os <<
" ** Matrix is Lower Triangular **" << std::endl;
2979 if(
UpperTriangular()) os <<
" ** Matrix is Upper Triangular **" << std::endl;
2980 if(
NoDiagonal()) os <<
" ** Matrix has no diagonal **" << std::endl << std::endl;
2982 os <<
"\nNumber of My Block Rows = " <<
NumMyBlockRows() << std::endl;
2983 os <<
"Number of My Block Cols = " <<
NumMyBlockCols() << std::endl;
2985 os <<
"Number of My Entries = " <<
NumMyEntries() << std::endl;
2986 os <<
"\nNumber of My Rows = " <<
NumMyRows() << std::endl;
2987 os <<
"Number of My Cols = " <<
NumMyCols() << std::endl;
2988 os <<
"Number of My Diagonals = " <<
NumMyDiagonals() << std::endl;
2989 os <<
"Number of My Nonzeros = " <<
NumMyNonzeros() << std::endl;
2990 os <<
"\nMy Maximum Block Row Dim = " <<
MaxRowDim() << std::endl;
2991 os <<
"My Maximum Block Col Dim = " <<
MaxColDim() << std::endl;
2992 os <<
"My Maximum Num Indices = " <<
MaxNumIndices() << std::endl << std::endl;
2997 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 3001 if(
RowMap().GlobalIndicesInt()) {
3002 Indices1_int.
Resize(MaxNumIndices1);
3004 else if(
RowMap().GlobalIndicesLongLong()) {
3005 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 3006 Indices1_LL.
Resize(MaxNumIndices1);
3008 throw ReportError(
"Epetra_CrsGraph::Print: GlobalIndicesLongLong but no long long API",-1);
3012 throw ReportError(
"Epetra_CrsGraph::Print: Unable to determine source global index type",-1);
3019 os <<
" Row Index "; os <<
" ";
3022 os <<
"Col Index"; os <<
" ";
3025 for(i = 0; i < NumMyBlockRows1; i++) {
3026 if(
RowMap().GlobalIndicesInt()) {
3027 int Row = (int)
GRID64(i);
3030 os << Row ; os <<
" ";
3031 for(j = 0; j < NumIndices1 ; j++) {
3033 os << Indices1_int[j]; os <<
" ";
3037 else if(
RowMap().GlobalIndicesLongLong()) {
3038 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 3039 long long Row =
GRID64(i);
3042 os << Row ; os <<
" ";
3043 for(j = 0; j < NumIndices1 ; j++) {
3045 os << Indices1_LL[j]; os <<
" ";
3049 throw ReportError(
"Epetra_CrsGraph::Print: Unable to determine source global index type",-1);
bool GlobalConstantsComputed_
void SetFilled(bool Flag)
int MakeViewOf(const Epetra_IntSerialDenseVector &Source)
Reset an existing IntSerialDenseVector to point to another Vector.
int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
Perform any packing or preparation required for call to DoTransfer().
const Epetra_Export * Exporter_
const Epetra_Import * Importer() const
Returns the Importer associated with this graph.
long long NumGlobalEntries64() const
bool FindMyIndexLoc(int LocalRow, int Index, int Start, int &Loc) const
bool HaveColMap() const
Returns true if we have a well-defined ColMap, and returns false otherwise.
int MakeImportExport()
called by FillComplete (and TransformToLocal)
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_Map: A class for partitioning vectors and matrices.
bool MyLID(int lid) const
Returns true if the LID passed in belongs to the calling processor in this map, otherwise returns fal...
virtual ~Epetra_CrsGraph()
Epetra_CrsGraph Destructor.
int Size(int Length_in)
Set length of a Epetra_SerialDenseVector object; init values to zero.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
Epetra_BlockMap RangeMap_
long long NumGlobalBlockCols64() const
long long NumGlobalBlockCols_
int ComputeGlobalConstants()
Epetra_IntSerialDenseVector NumIndicesPerRow_
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
int DetermineTriangular()
int GlobalMaxNumNonzeros_
int SortIndices()
Sort column indices, row-by-row, in ascending order.
int Allocate(const int *NumIndicesPerRow, int Inc, bool StaticProfile)
int Resize(int Length_in)
Resize a Epetra_IntSerialDenseVector object.
int ReferenceCount() const
Get reference count.
bool FindGlobalIndexLoc(int LocalRow, int Index, int Start, int &Loc) const
Epetra_CrsGraph & operator=(const Epetra_CrsGraph &Source)
Assignment operator.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
bool ConstantElementSize() const
Returns true if map has constant element size.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
long long * Values()
Returns pointer to the values in vector.
int TRemoveGlobalIndices(long long Row)
void DecrementReferenceCount()
Decrement reference count.
bool SameAs(const Epetra_BlockMap &Map) const
Returns true if this and Map are identical maps.
long long NumGlobalEntries_
int ReAllocateAndCast(char *&UserPtr, int &Length, const int IntPacketSizeTimesNumTrans)
called by PackAndPrepare
int PackAndPrepareCrsGraph(const Epetra_CrsGraph &A, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
int NumMyDiagonals() const
Returns the number of diagonal entries in the local graph, based on global row/column index compariso...
int NumAllocatedGlobalIndices(long long Row) const
Returns the allocated number of nonzero entries in specified global row on this processor.
long long NumGlobalNonzeros_
value_type Get(const long long key)
int NumMyNonzeros() const
Returns the number of indices in the local graph.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this graph.
int Size(int Length_in)
Set length of a Epetra_IntSerialDenseVector object; init values to zero.
const Epetra_BlockMap & SourceMap() const
Returns the SourceMap used to construct this importer.
int InsertMyIndices(int LocalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified local row of the graph.
int NumAllocatedMyIndices(int Row) const
Returns the allocated number of nonzero entries in specified local row on this processor.
const Epetra_CrsGraphData * DataPtr() const
Returns a pointer to the CrsGraphData instance this CrsGraph uses.
bool SortGhostsAssociatedWithEachProcessor_
double * Values() const
Returns pointer to the values in vector.
long long IndexBase64() const
T * Epetra_Util_data_ptr(std::vector< T > &vec)
Function that returns either a pointer to the first entry in the vector or, if the vector is empty...
Epetra_BlockMap DomainMap_
#define EPETRA_CHK_ERR(a)
int GlobalMaxColDim() const
Returns the max column dimension of block entries across all processors.
int MakeColMap_LL(const Epetra_BlockMap &DomainMap, const Epetra_BlockMap &RangeMap)
const Epetra_BlockMap & TargetMap() const
Returns the TargetMap used to construct this importer.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
int MakeIndicesLocal(const Epetra_BlockMap &DomainMap, const Epetra_BlockMap &RangeMap)
int ReplaceRowMap(const Epetra_BlockMap &newmap)
Replaces the current RowMap with the user-specified map object, but only if currentmap->PointSameAs(n...
void SetAllocated(bool Flag)
long long NumGlobalBlockDiagonals64() const
int RemoveEmptyProcessesInPlace(const Epetra_BlockMap *NewMap)
Remove processes owning zero rows from the Maps and their communicator.
bool NoRedundancies() const
If RemoveRedundantIndices() has been called, this query returns true, otherwise it returns false...
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
long long NumGlobalElements64() const
int ExtractGlobalRowView(int GlobalRow, int &NumIndices, int *&Indices) const
Get a view of the elements in a specified global row of the graph.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
virtual void Barrier() const =0
Epetra_Comm Barrier function.
const Epetra_BlockMap & RowMap() const
Returns the RowMap associated with this graph.
int ReplaceDomainMapAndImporter(const Epetra_BlockMap &NewDomainMap, const Epetra_Import *NewImporter)
Replaces the current DomainMap & Importer with the user-specified map object.
int Length() const
Returns length of vector.
long long * MyGlobalElements64() const
Epetra_CrsGraphData * CrsGraphData_
virtual int MyPID() const =0
Return my process ID.
int RemoveRedundantIndices()
Removes any redundant column indices in the rows of the graph.
int * ElementSizeList() const
List of the element sizes corresponding to the array MyGlobalElements().
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
int Size(int Length_in)
Set length of a Epetra_LongLongSerialDenseVector object; init values to zero.
Epetra_CrsGraphData: The Epetra CrsGraph Data Class.
int NumMyBlockDiagonals() const
Returns the number of Block diagonal entries in the local graph, based on global row/column index com...
int RemoveGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Remove a list of elements from a specified global row of the graph.
int NumMyRows() const
Returns the number of matrix rows on this processor.
IndexData< int_type > & Data()
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
const Epetra_BlockMap & ColMap() const
Returns the Column Map associated with this graph.
bool LowerTriangular() const
If graph is lower triangular in local index space, this query returns true, otherwise it returns fals...
Epetra_Util: The Epetra Util Wrapper Class.
Epetra_SerialDenseVector: A class for constructing and using dense vectors.
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
Epetra_Comm Global Sum function.
bool StorageOptimized() const
If OptimizeStorage() has been called, this query returns true, otherwise it returns false...
int NumMyBlockRows() const
Returns the number of block matrix rows on this processor.
long long NumGlobalPoints64() const
std::vector< EntriesInOneRow< int > > SortedEntries_
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
int InsertIndices(int Row, int NumIndices, int *Indices)
Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap &RowMap, const int *NumIndicesPerRow, bool StaticProfile=false)
Epetra_CrsGraph constuctor with variable number of indices per row.
int CheckSizes(const Epetra_SrcDistObject &A)
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
Epetra_Comm: The Epetra Communication Abstract Base Class.
long long GID64(int LID) const
void SetIndicesAreGlobal(bool Flag)
Epetra_IntSerialDenseVector NumAllocatedIndicesPerRow_
int NumMyBlockCols() const
Returns the number of Block matrix columns on this processor.
void SetIndicesAreLocal(bool Flag)
const Epetra_BlockMap & RangeMap() const
Returns the RangeMap associated with this graph.
bool IndicesAreContiguous() const
void SetNoRedundancies(bool Flag)
const Epetra_Comm * Comm_
int MaxRowDim() const
Returns the max row dimension of block entries on the processor.
int CopyAndPermuteCrsGraph(const Epetra_CrsGraph &A, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode)
int * All_Indices() const
int MakeColMap(const Epetra_BlockMap &DomainMap, const Epetra_BlockMap &RangeMap)
void SetIndicesAreContiguous(bool Flag)
int MaxColDim() const
Returns the max column dimension of block entries on the processor.
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
virtual const Epetra_BlockMap & Map() const =0
Returns a reference to the Epetra_BlockMap for this object.
int NumMyElements() const
Number of elements on the calling processor.
void epetra_shellsort(int *list, int length)
int PackAndPrepareRowMatrix(const Epetra_RowMatrix &A, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
int TransformToLocal()
Use FillComplete() instead.
int ElementSize() const
Returns the size of elements in the map; only valid if map has constant element size.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
bool UpperTriangular() const
If graph is upper triangular in local index space, this query returns true, otherwise it returns fals...
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
bool IndicesAreLocal() const
If column indices are in local range, this query returns true, otherwise it returns false...
int GlobalMaxNumIndices() const
Returns the maximun number of nonzero entries across all rows across all processors.
void SetGlobalConstantsComputed(bool Flag)
bool NoDiagonal() const
If graph has no diagonal entries in global index space, this query returns true, otherwise it returns...
int RemoteIDList(int NumIDs, const int *GIDList, int *PIDList, int *LIDList) const
Returns the processor IDs and corresponding local index value for a given list of global indices...
int NumGlobalIndices(long long Row) const
Returns the current number of nonzero entries in specified global row on this processor.
int Epetra_Util_binary_search(T item, const T *list, int len, int &insertPoint)
Utility function to perform a binary-search on a list of data.
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified global row of the graph.
void IncrementReferenceCount()
Increment reference count.
Epetra_IntSerialDenseVector All_Indices_
Epetra_SerialComm: The Epetra Serial Communication Class.
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
Epetra_IntSerialDenseVector All_IndicesPlus1_
long long IndexBase64() const
void SetSorted(bool Flag)
int ReplaceColMap(const Epetra_BlockMap &newmap)
Replaces the current ColMap with the user-specified map object, but only if no entries have been inse...
long long NumGlobalNonzeros64() const
virtual int NumProc() const =0
Returns total number of processes.
int RemoveMyIndices(int LocalRow, int NumIndices, int *Indices)
Remove a list of elements from a specified local row of the graph.
const Epetra_BlockMap & DomainMap() const
Returns the DomainMap associated with this graph.
Epetra_IntSerialDenseVector IndexOffset_
bool GlobalIndicesTypeMatch(const Epetra_BlockMap &other) const
bool StaticProfile() const
long long NumGlobalBlockDiagonals_
int ExtractMyRowCopy(int LocalRow, int LenOfIndices, int &NumIndices, int *Indices) const
Extract a list of elements in a specified local row of the graph. Put into storage allocated by calli...
long long GCID64(int LCID_in) const
int NumMyIndices(int Row) const
Returns the current number of nonzero entries in specified local row on this processor.
int MaxNumIndices() const
Returns the maximum number of nonzero entries across all rows on this processor.
int MaxElementSize() const
Maximum element size across all processors.
long long GRID64(int LRID_in) const
int CopyAndPermuteRowMatrix(const Epetra_RowMatrix &A, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode)
int NumMyEntries() const
Returns the number of entries on this processor.
int ExtractMyRowView(int LocalRow, int &NumIndices, int *&Indices) const
Get a view of the elements in a specified local row of the graph.
int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)
Perform ID copies and permutations that are on processor.
static void Sort(bool SortAscending, int NumKeys, T *Keys, int NumDoubleCompanions, double **DoubleCompanions, int NumIntCompanions, int **IntCompanions, int NumLongLongCompanions, long long **LongLongCompanions)
Epetra_Util Sort Routine (Shell sort)
int ExtractGlobalRowCopy(int GlobalRow, int LenOfIndices, int &NumIndices, int *Indices) const
Extract a list of elements in a specified global row of the graph. Put into storage allocated by call...
const Epetra_Import * Importer_
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
int NumMyPoints() const
Number of local points for this map; equals the sum of all element sizes on the calling processor...
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices...
long long NumGlobalBlockRows64() const
int * Values()
Returns pointer to the values in vector.
int NumMyCols() const
Returns the number of entries in the set of column-indices that appear on this processor.
long long NumGlobalCols64() const
int InsertIndicesIntoSorted(int Row, int NumIndices, int *Indices)
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
long long NumGlobalDiagonals64() const
int MakeColMap_int(const Epetra_BlockMap &DomainMap, const Epetra_BlockMap &RangeMap)
int TAllocate(const int *numIndicesPerRow, int Inc, bool staticProfile)
int Resize(int Length_in)
Resize a Epetra_LongLongSerialDenseVector object.
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this processor. ...
virtual void Print(std::ostream &os) const
Print method.
void Add(const long long key, const value_type value)
int UnpackAndCombine(const Epetra_SrcDistObject &Source, int NumImportIDs, int *ImportLIDs, int LenImports, char *Imports, int &SizeOfPacket, Epetra_Distributor &Distor, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor)
Perform any unpacking and combining after call to DoTransfer().
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
bool GlobalConstantsComputed() const
void epetra_crsgraph_compress_out_duplicates(int len, int *list, int &newlen)
int LRID(int GRID_in) const
Returns the local row index for given global row index, returns -1 if no local row for this global ro...
long long NumGlobalDiagonals_
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
Epetra_BlockMap * ReplaceCommWithSubset(const Epetra_Comm *Comm) const
Replace this BlockMap's communicator with a subset communicator.
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
bool IndicesAreGlobal() const
If column indices are in global range, this query returns true, otherwise it returns false...
long long NumGlobalRows64() const
int GlobalMaxRowDim() const
Returns the max row dimension of block entries across all processors.
bool Sorted() const
If SortIndices() has been called, this query returns true, otherwise it returns false.