Epetra Package Browser (Single Doxygen Collection) Development
Epetra_CrsGraph.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2011 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_CRSGRAPH_H
00045 #define EPETRA_CRSGRAPH_H
00046 
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_DistObject.h" 
00049 #include "Epetra_CrsGraphData.h"
00050 class Epetra_BlockMap;
00051 class Epetra_Util;
00052 class Epetra_Time;
00053 class Epetra_Import;
00054 class Epetra_Export;
00055 class Epetra_Distributor;
00056 class Epetra_RowMatrix;
00057 
00059 
00213 class EPETRA_LIB_DLL_EXPORT Epetra_CrsGraph: public Epetra_DistObject {
00214       
00215  public:
00216 
00218 
00219 
00220 
00232   Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const int* NumIndicesPerRow, bool StaticProfile = false);
00233   
00235 
00248   Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int NumIndicesPerRow, bool StaticProfile = false);
00249   
00251 
00265   Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, 
00266       const Epetra_BlockMap& ColMap, const int* NumIndicesPerRow, bool StaticProfile = false);
00267   
00269 
00285   Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, 
00286       const Epetra_BlockMap& ColMap, int NumIndicesPerRow, bool StaticProfile = false);
00287   
00289 
00292   Epetra_CrsGraph(const Epetra_CrsGraph& Graph);
00293 
00295   virtual ~Epetra_CrsGraph();
00297   
00299 
00300 
00301 
00315 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00316   int InsertGlobalIndices(int GlobalRow, int NumIndices, int* Indices);
00317 #endif
00318 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00319   int InsertGlobalIndices(long long GlobalRow, int NumIndices, long long* Indices);
00320 #endif
00321 
00323 
00332 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00333   int RemoveGlobalIndices(int GlobalRow, int NumIndices, int* Indices);
00334 #endif
00335 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00336   int RemoveGlobalIndices(long long GlobalRow, int NumIndices, long long* Indices);
00337 #endif
00338   
00340 
00347   int RemoveGlobalIndices(long long Row);
00348 
00349   
00351 
00366   int InsertMyIndices(int LocalRow, int NumIndices, int* Indices);
00367   
00369 
00378   int RemoveMyIndices(int LocalRow, int NumIndices, int* Indices);
00379   
00381 
00388   int RemoveMyIndices(int Row);
00390 
00392 
00393   
00395 
00402   int FillComplete();
00403 
00405 
00417   int FillComplete(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
00418 
00420 
00434   int OptimizeStorage();
00435 
00437 
00439 
00440 
00442 
00450 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00451   int ExtractGlobalRowCopy(int GlobalRow, int LenOfIndices, int& NumIndices, int* Indices) const;
00452 #endif
00453 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00454   int ExtractGlobalRowCopy(long long GlobalRow, int LenOfIndices, int& NumIndices, long long* Indices) const;
00455 #endif
00456 
00458 
00468   int ExtractMyRowCopy(int LocalRow, int LenOfIndices, int& NumIndices, int* Indices) const;
00469 
00471 
00481 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00482   int ExtractGlobalRowView(int GlobalRow, int& NumIndices, int*& Indices) const;
00483 #endif
00484 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00485   int ExtractGlobalRowView(long long GlobalRow, int& NumIndices, long long*& Indices) const;
00486 #endif
00487 
00489 
00499   int ExtractMyRowView(int LocalRow, int& NumIndices, int*& Indices) const;
00501 
00503 
00504 
00505   bool Filled() const {return(CrsGraphData_->Filled_);}
00506   
00508   bool StorageOptimized() const {return(CrsGraphData_->StorageOptimized_);}
00509   
00511   bool IndicesAreGlobal() const {return(CrsGraphData_->IndicesAreGlobal_);}
00512   
00514   bool IndicesAreLocal() const {return(CrsGraphData_->IndicesAreLocal_);}
00515   
00517 
00520   bool LowerTriangular() const {return(CrsGraphData_->LowerTriangular_);}
00521   
00523 
00526   bool UpperTriangular() const {return(CrsGraphData_->UpperTriangular_);}
00527   
00529 
00532   bool NoDiagonal() const {return(CrsGraphData_->NoDiagonal_);}
00533   
00535 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00536   bool MyGlobalRow(int GID) const {return(RowMap().MyGID(GID));}
00537 #endif
00538 
00539 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00540   bool MyGlobalRow(long long GID) const {return(RowMap().MyGID(GID));}
00541 #endif
00542 
00544 
00548   bool HaveColMap() const {return(CrsGraphData_->HaveColMap_);}
00550   
00552 
00553     
00555   int NumMyRows() const {return(CrsGraphData_->NumMyRows_);}
00556   
00558 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00559     int  NumGlobalRows() const {
00560       if(RowMap().GlobalIndicesInt())
00561         return (int) NumGlobalRows64();
00562       throw "Epetra_CrsGraph::NumGlobalRows: GlobalIndices not int.";
00563     }
00564 #endif
00565   long long NumGlobalRows64() const {return(CrsGraphData_->NumGlobalRows_);}
00566   
00568 
00572   int NumMyCols() const {return(CrsGraphData_->NumMyCols_);}
00573   
00575 
00578 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00579     int  NumGlobalCols() const {
00580       if(RowMap().GlobalIndicesInt())
00581         return (int) NumGlobalCols64();
00582       throw "Epetra_CrsGraph::NumGlobalCols: GlobalIndices not int.";
00583     }
00584 #endif
00585   long long NumGlobalCols64() const {return(CrsGraphData_->NumGlobalCols_);}
00586   
00588 
00594 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00595     int  NumGlobalNonzeros() const {
00596       if(RowMap().GlobalIndicesInt())
00597         return (int) NumGlobalNonzeros64();
00598       throw "Epetra_CrsGraph::NumGlobalNonzeros: GlobalIndices not int.";
00599     }
00600 #endif
00601   long long NumGlobalNonzeros64() const {return(CrsGraphData_->NumGlobalNonzeros_);}
00602   
00604 
00607 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00608     int  NumGlobalDiagonals() const {
00609       if(RowMap().GlobalIndicesInt())
00610         return (int) NumGlobalDiagonals64();
00611       throw "Epetra_CrsGraph::NumGlobalDiagonals: GlobalIndices not int.";
00612     }
00613 #endif
00614   long long NumGlobalDiagonals64() const {return(CrsGraphData_->NumGlobalDiagonals_);}
00615   
00617 
00620   int NumMyDiagonals() const {return(CrsGraphData_->NumMyDiagonals_);}
00621   
00623   int NumMyBlockRows() const {return(CrsGraphData_->NumMyBlockRows_);}
00624   
00626 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00627     int  NumGlobalBlockRows() const {
00628       if(RowMap().GlobalIndicesInt())
00629         return (int) NumGlobalBlockRows64();
00630       throw "Epetra_CrsGraph::NumGlobalBlockRows: GlobalIndices not int.";
00631     }
00632 #endif
00633   long long NumGlobalBlockRows64() const {return(CrsGraphData_->NumGlobalBlockRows_);}
00634   
00636 
00639   int NumMyBlockCols() const {return(CrsGraphData_->NumMyBlockCols_);}
00640   
00642 
00645 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00646     int  NumGlobalBlockCols() const {
00647       if(RowMap().GlobalIndicesInt())
00648         return (int) NumGlobalBlockCols64();
00649       throw "Epetra_CrsGraph::NumGlobalBlockCols: GlobalIndices not int.";
00650     }
00651 #endif
00652   long long NumGlobalBlockCols64() const {return(CrsGraphData_->NumGlobalBlockCols_);}
00653   
00655 
00658   int NumMyBlockDiagonals() const {return(CrsGraphData_->NumMyBlockDiagonals_);}
00659   
00661 
00664 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00665     int  NumGlobalBlockDiagonals() const {
00666       if(RowMap().GlobalIndicesInt())
00667         return (int) NumGlobalBlockDiagonals64();
00668       throw "Epetra_CrsGraph::NumGlobalBlockDiagonals: GlobalIndices not int.";
00669     }
00670 #endif
00671   long long NumGlobalBlockDiagonals64() const {return(CrsGraphData_->NumGlobalBlockDiagonals_);}
00672   
00674 
00677 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00678     int  NumGlobalEntries() const {
00679       if(RowMap().GlobalIndicesInt())
00680         return (int) NumGlobalEntries64();
00681       throw "Epetra_CrsGraph::NumGlobalEntries: GlobalIndices not int.";
00682     }
00683 #endif
00684   long long NumGlobalEntries64() const {return(CrsGraphData_->NumGlobalEntries_);}
00685   
00687 
00690   int NumMyEntries() const {return(CrsGraphData_->NumMyEntries_);}
00692 
00695   int MaxRowDim() const {return(CrsGraphData_->MaxRowDim_);}
00696   
00698 
00701   int GlobalMaxRowDim() const {return(CrsGraphData_->GlobalMaxRowDim_);}
00702   
00704 
00707   int MaxColDim() const {return(CrsGraphData_->MaxColDim_);}
00708   
00710 
00713   int GlobalMaxColDim() const {return(CrsGraphData_->GlobalMaxColDim_);}
00714   
00716 
00719   int NumMyNonzeros() const {return(CrsGraphData_->NumMyNonzeros_);}
00720   
00722   int NumGlobalIndices(long long Row) const;
00723   
00725   int NumAllocatedGlobalIndices(long long Row) const;
00726   
00728 
00731   int MaxNumIndices() const {return(CrsGraphData_->MaxNumIndices_);}
00732   
00734 
00737   int GlobalMaxNumIndices() const {return(CrsGraphData_->GlobalMaxNumIndices_);}
00738   
00740 
00749   int MaxNumNonzeros() const {return(CrsGraphData_->MaxNumNonzeros_);}
00750   
00752 
00756   int GlobalMaxNumNonzeros() const {return(CrsGraphData_->GlobalMaxNumNonzeros_);}
00757   
00759   int NumMyIndices(int Row) const {if (Row<0 || Row >= NumMyRows()) return(0);
00760     if (StorageOptimized()) return(CrsGraphData_->IndexOffset_[Row+1] - CrsGraphData_->IndexOffset_[Row]); 
00761     else return(CrsGraphData_->NumIndicesPerRow_[Row]);}
00762   
00764   int NumAllocatedMyIndices(int Row) const {if (Row<0 || Row >= NumMyRows()) return(0);
00765     if (StorageOptimized()) return(CrsGraphData_->IndexOffset_[Row+1] - CrsGraphData_->IndexOffset_[Row]); 
00766     else return(CrsGraphData_->NumAllocatedIndicesPerRow_[Row]);}
00767   
00769 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00770 
00771   int  IndexBase() const {
00772     if(RowMap().GlobalIndicesInt())
00773       return (int) IndexBase64();
00774     throw "Epetra_CrsGraph::IndexBase: GlobalIndices not int.";
00775   }
00776 #endif
00777   long long  IndexBase64() const {return(CrsGraphData_->IndexBase_);};
00778   
00780   const Epetra_BlockMap& RowMap() const {return(Epetra_DistObject::Map());}
00781     
00788   int ReplaceRowMap(const Epetra_BlockMap& newmap);
00789 
00798   int ReplaceColMap(const Epetra_BlockMap& newmap);
00799 
00801 
00809   int ReplaceDomainMapAndImporter(const Epetra_BlockMap& NewDomainMap, const Epetra_Import * NewImporter);
00810 
00812 
00823   int RemoveEmptyProcessesInPlace(const Epetra_BlockMap * NewMap);
00824 
00825 
00827 
00830   const Epetra_BlockMap& ColMap() const {return(CrsGraphData_->ColMap_);}
00831   
00833 
00836   const Epetra_BlockMap& DomainMap() const {return(CrsGraphData_->DomainMap_);}
00837   
00839 
00842   const Epetra_BlockMap& RangeMap() const {return(CrsGraphData_->RangeMap_);}
00843   
00845   const Epetra_Import* Importer() const {return(CrsGraphData_->Importer_);}
00846   
00848   const Epetra_Export* Exporter() const {return(CrsGraphData_->Exporter_);}
00849   
00851   const Epetra_Comm& Comm() const {return(Epetra_DistObject::Comm());}
00853   
00855 
00856 
00858 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00859   int LRID(int GRID_in) const {return(RowMap().LID(GRID_in));}
00860 #endif
00861 
00862 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00863   int LRID(long long GRID_in) const {return(RowMap().LID(GRID_in));}
00864 #endif
00865 
00866 #if defined(EPETRA_NO_32BIT_GLOBAL_INDICES) && defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
00867   // default implementation so that no compiler/linker error in case neither 32 nor 64
00868   // bit indices present.
00869   int LRID(long long GRID_in) const {return(RowMap().LID(GRID_in));}
00870 #endif
00871 
00873 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00874     int  GRID(int LRID_in) const {
00875       if(RowMap().GlobalIndicesInt())
00876         return (int) GRID64(LRID_in);
00877       throw "Epetra_CrsGraph::GRID: GlobalIndices not int.";
00878     }
00879 #endif
00880   long long GRID64(int LRID_in) const {return(RowMap().GID64(LRID_in));}
00881   
00883 
00886 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00887   int LCID(int GCID_in) const
00888     {
00889       return( CrsGraphData_->HaveColMap_ ? ColMap().LID(GCID_in) : -1 );
00890     }
00891 #endif
00892 
00893 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00894   int LCID(long long GCID_in) const
00895     {
00896       return( CrsGraphData_->HaveColMap_ ? ColMap().LID(GCID_in) : -1 );
00897     }
00898 #endif
00899   
00901 
00904 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00905     int  GCID(int LCID_in) const {
00906       if(RowMap().GlobalIndicesInt())
00907         return (int) GCID64(LCID_in);
00908       throw "Epetra_CrsGraph::GCID: GlobalIndices not int.";
00909     }
00910 #endif
00911   long long GCID64(int LCID_in) const
00912     {
00913       return( CrsGraphData_->HaveColMap_ ? ColMap().GID64(LCID_in) : -1 );
00914     }
00915   
00917 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00918   bool MyGRID(int GRID_in) const {return(LRID(GRID_in) != -1);}
00919 #endif
00920 
00921 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00922   bool MyGRID(long long GRID_in) const {return(LRID(GRID_in) != -1);}
00923 #endif
00924   
00926   bool MyLRID(int LRID_in) const {return(GRID64(LRID_in) != IndexBase64() - 1);}
00927   
00929 
00932 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00933   bool MyGCID(int GCID_in) const {return(LCID(GCID_in) != -1);}
00934 #endif
00935 
00936 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00937   bool MyGCID(long long GCID_in) const {return(LCID(GCID_in) != -1);}
00938 #endif
00939 
00941 
00944   bool MyLCID(int LCID_in) const {return(GCID64(LCID_in) != IndexBase64() - 1);}
00946   
00948 
00949   
00951 
00957   inline int*  operator[]( int Loc ) { 
00958     if (StorageOptimized()){ return(CrsGraphData_->data->All_Indices_.Values() + CrsGraphData_->IndexOffset_[Loc]);}
00959     else return(CrsGraphData_->data->Indices_[Loc]); }
00960 
00961   inline int* operator[]( int Loc ) const { 
00962     if (StorageOptimized()) { return(CrsGraphData_->data->All_Indices_.Values() +CrsGraphData_->IndexOffset_[Loc]);}
00963     else return(CrsGraphData_->data->Indices_[Loc]); }
00964 
00966 
00968 
00971   Epetra_CrsGraph& operator = (const Epetra_CrsGraph& Source);
00972 
00974 
00975 
00977   virtual void Print(std::ostream& os) const;
00978 
00979   void PrintGraphData(std::ostream& os) const {CrsGraphData_->Print(os);}
00980   void PrintGraphData(std::ostream& os, int level) const {CrsGraphData_->Print(os, level);}
00982 
00984 
00985 
00987   const Epetra_BlockMap& ImportMap() const {return(CrsGraphData_->ColMap_);}
00988   
00990   int TransformToLocal();
00991   
00993   int TransformToLocal(const Epetra_BlockMap* DomainMap, const Epetra_BlockMap* RangeMap);
00994   
00996 
00998 
00999 
01001 
01002   int ReferenceCount() const {return(CrsGraphData_->ReferenceCount());}
01003 
01005 
01006   const Epetra_CrsGraphData* DataPtr() const {return(CrsGraphData_);}
01007 
01009 
01018         void SortGhostsAssociatedWithEachProcessor(bool Flag) {CrsGraphData_->SortGhostsAssociatedWithEachProcessor_ = Flag;}
01019 
01021 
01022   // functions listed in protected are the ones used by CrsMatrix and VbrMatrix.
01023   // functions listed in private are the ones that are really private.
01024   // (just pretend CrsMatrix and VbrMatrix derive from CrsGraph to understand the distinction.)
01025   friend class Epetra_CrsMatrix;
01026   friend class Epetra_VbrMatrix;
01027   friend class Epetra_FECrsGraph;
01028   friend class Epetra_FECrsMatrix;
01029   friend class Epetra_FEVbrMatrix;
01030   friend class Epetra_OffsetIndex;
01031 
01032  protected:
01033   int *All_Indices() const {
01034     if (!StorageOptimized()) throw ReportError("This method: int *All_Indices() cannot be called when StorageOptimized()==false", -1);
01035     else return(CrsGraphData_->data->All_Indices_.Values());}
01036 #if defined(Epetra_ENABLE_MKL_SPARSE) && !defined(Epetra_DISABLE_MKL_SPARSE_MM)
01037   int *All_IndicesPlus1() const;
01038 #endif
01039   int *IndexOffset() const {
01040     if (!StorageOptimized()) throw ReportError("This method: int *IndexOffset()  cannot be called when StorageOptimized()==false", -1);
01041     else return(CrsGraphData_->IndexOffset_.Values());}
01042   int* NumIndicesPerRow() const {
01043     if (StorageOptimized()) throw ReportError("This method: int* NumIndicesPerRow() cannot be called when StorageOptimized()==true", -1);
01044     else return(CrsGraphData_->NumIndicesPerRow_.Values());}
01045   int* NumAllocatedIndicesPerRow() const {
01046     if (StorageOptimized()) throw ReportError("This method: int* NumAllocatedIndicesPerRow() cannot be called when StorageOptimized()==true", -1);
01047     else return(CrsGraphData_->NumAllocatedIndicesPerRow_.Values());}
01048   int** Indices() const {
01049     if (StorageOptimized()) throw ReportError("This method: int** Indices() cannot be called when StorageOptimized()==true", -1);
01050     else return(CrsGraphData_->data->Indices_);}
01051   int* Indices(int LocalRow) const {
01052     if (StorageOptimized()) return(CrsGraphData_->data->All_Indices_.Values()+CrsGraphData_->IndexOffset_[LocalRow]);
01053     else return(CrsGraphData_->data->Indices_[LocalRow]);}
01054 
01055   template<typename int_type>
01056   int_type** TIndices() const {
01057     if (StorageOptimized()) throw ReportError("This method: int_type** TIndices() cannot be called when StorageOptimized()==true", -1);
01058     else return(CrsGraphData_->Data<int_type>().Indices_);}
01059 
01060   template<typename int_type>
01061   int_type* TIndices(int LocalRow) const {
01062     if (StorageOptimized()) return(CrsGraphData_->Data<int_type>().All_Indices_.Values()+CrsGraphData_->IndexOffset_[LocalRow]);
01063     else return(CrsGraphData_->Data<int_type>().Indices_[LocalRow]);}
01064 
01065   // If column indices are stored in one long array (via a call to OptimizeStorage), 
01066   // IndicesAreContiguous returns true, otherwise it returns false.
01067   bool IndicesAreContiguous() const {return(CrsGraphData_->IndicesAreContiguous_);}
01068   bool StaticProfile() const {return(CrsGraphData_->StaticProfile_);}
01069   bool GlobalConstantsComputed() const;
01070 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01071   bool FindGlobalIndexLoc(int LocalRow, int Index, int Start, int& Loc) const;
01072   bool FindGlobalIndexLoc(int NumIndices, const int* Indices, int Index, int Start, int& Loc) const;
01073 #endif
01074 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01075   bool FindGlobalIndexLoc(int LocalRow, long long Index, int Start, int& Loc) const;
01076   bool FindGlobalIndexLoc(int NumIndices, const long long* Indices, long long Index, int Start, int& Loc) const;
01077 #endif
01078 
01079   bool FindMyIndexLoc(int LocalRow, int Index, int Start, int& Loc) const;
01080   bool FindMyIndexLoc(int NumIndices, const int* Indices, int Index, int Start, int& Loc) const;
01081 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01082   int InsertIndices(int Row, int NumIndices, int* Indices);
01083     int InsertIndicesIntoSorted(int Row, int NumIndices, int* Indices);
01084 #endif
01085 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01086   int InsertIndices(int Row, int NumIndices, long long* Indices);
01087   int InsertIndicesIntoSorted(int Row, int NumIndices, long long* Indices);
01088 #endif
01089 
01090   int MakeIndicesLocal(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
01091   void SetIndicesAreLocal(bool Flag) {CrsGraphData_->IndicesAreLocal_ = Flag;}
01092   void SetIndicesAreGlobal(bool Flag) {CrsGraphData_->IndicesAreGlobal_ = Flag;}
01093   void SetSorted(bool Flag) {CrsGraphData_->Sorted_ = Flag;}
01094 
01095 
01097 
01100   int SortIndices();
01101 
01103   bool Sorted() const {return(CrsGraphData_->Sorted_);}
01104   
01106 
01109   int RemoveRedundantIndices();
01110   int DetermineTriangular();
01111 
01113   bool NoRedundancies() const {return(CrsGraphData_->NoRedundancies_);}
01114 
01115  private:
01116   void SetGlobalConstantsComputed(bool Flag) {CrsGraphData_->GlobalConstantsComputed_ = Flag;}
01117   void SetIndicesAreContiguous(bool Flag) {CrsGraphData_->IndicesAreContiguous_ = Flag;}
01118   void SetNoRedundancies(bool Flag) {CrsGraphData_->NoRedundancies_ = Flag;}
01119   void ComputeIndexState();
01120   int MakeColMap(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
01121 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01122   int MakeColMap_int(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
01123 #endif
01124 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01125   int MakeColMap_LL (const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
01126 #endif
01127   int Allocate(const int* NumIndicesPerRow, int Inc, bool StaticProfile);
01128   //int ReAllocate();
01129   int ComputeGlobalConstants();
01130   void SetFilled(bool Flag) {CrsGraphData_->Filled_ = Flag;}
01131   bool Allocated() const {return(CrsGraphData_->Allocated_);}
01132   void SetAllocated(bool Flag) {CrsGraphData_->Allocated_ = Flag;}
01133   
01134   int CheckSizes(const Epetra_SrcDistObject& A);
01135 
01136   int CopyAndPermute(const Epetra_SrcDistObject& Source,
01137                            int NumSameIDs, 
01138                            int NumPermuteIDs,
01139                            int* PermuteToLIDs,
01140                            int* PermuteFromLIDs,
01141                            const Epetra_OffsetIndex * Indexor);
01142   int CopyAndPermuteRowMatrix(const Epetra_RowMatrix& A,
01143                                     int NumSameIDs, 
01144                                     int NumPermuteIDs,
01145                                     int* PermuteToLIDs,
01146                                     int* PermuteFromLIDs,
01147                                     const Epetra_OffsetIndex * Indexor);
01148 
01149   template<typename int_type>
01150   int CopyAndPermuteRowMatrix(const Epetra_RowMatrix& A,
01151                                     int NumSameIDs, 
01152                                     int NumPermuteIDs,
01153                                     int* PermuteToLIDs,
01154                                     int* PermuteFromLIDs,
01155                                     const Epetra_OffsetIndex * Indexor);
01156 
01157   int CopyAndPermuteCrsGraph(const Epetra_CrsGraph& A,
01158                                    int NumSameIDs, 
01159                                    int NumPermuteIDs,
01160                                    int* PermuteToLIDs,
01161                                    int* PermuteFromLIDs,
01162                                    const Epetra_OffsetIndex * Indexor);
01163   
01164   template<typename int_type>
01165   int CopyAndPermuteCrsGraph(const Epetra_CrsGraph& A,
01166                                    int NumSameIDs, 
01167                                    int NumPermuteIDs,
01168                                    int* PermuteToLIDs,
01169                                    int* PermuteFromLIDs,
01170                                    const Epetra_OffsetIndex * Indexor);
01171 
01172         int PackAndPrepare(const Epetra_SrcDistObject& Source,
01173                            int NumExportIDs,
01174                            int* ExportLIDs,
01175                            int& LenExports,
01176                            char*& Exports,
01177                            int& SizeOfPacket,
01178                            int * Sizes,
01179                            bool & VarSizes,
01180                            Epetra_Distributor& Distor);
01181         int PackAndPrepareCrsGraph(const Epetra_CrsGraph& A,
01182                                    int NumExportIDs,
01183                                    int* ExportLIDs,
01184                                    int& LenExports,
01185                                    char*& Exports,
01186                                    int& SizeOfPacket,
01187                                    int* Sizes,
01188                                    bool& VarSizes,
01189                                    Epetra_Distributor& Distor);
01190         int PackAndPrepareRowMatrix(const Epetra_RowMatrix& A,
01191                                     int NumExportIDs,
01192                                     int* ExportLIDs,
01193                                     int& LenExports,
01194                                     char*& Exports,
01195                                     int& SizeOfPacket,
01196                                     int* Sizes,
01197                                     bool& VarSizes,
01198                                     Epetra_Distributor& Distor);
01199 
01200         int UnpackAndCombine(const Epetra_SrcDistObject& Source,
01201                              int NumImportIDs,
01202                              int* ImportLIDs, 
01203                              int LenImports, 
01204                              char* Imports,
01205                              int& SizeOfPacket, 
01206                              Epetra_Distributor& Distor,
01207                              Epetra_CombineMode CombineMode,
01208                              const Epetra_OffsetIndex * Indexor);
01209 
01210   void CleanupData();
01211 
01212   Epetra_CrsGraphData* CrsGraphData_;  
01213 
01214 private:
01215 
01216   template<typename int_type>
01217   int TAllocate(const int* numIndicesPerRow, int Inc, bool staticProfile);
01218 
01219   template<typename int_type>
01220   int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type* Indices);
01221 
01222   template<typename int_type>
01223   int InsertIndices(int Row, int NumIndices, int_type* Indices);
01224 
01225   template<typename int_type>
01226   int InsertIndicesIntoSorted(int Row, int NumIndices, int_type* Indices);
01227 
01228   template<typename int_type>
01229   int RemoveGlobalIndices(int_type GlobalRow, int NumIndices, int_type* Indices);
01230 
01231   template<typename int_type>
01232   int TRemoveGlobalIndices(long long Row);
01233 
01234   template<typename int_type>
01235   bool FindGlobalIndexLoc(int LocalRow, int_type Index, int Start, int& Loc) const;
01236 
01237   template<typename int_type>
01238   bool FindGlobalIndexLoc(int NumIndices, const int_type* Indices, int_type Index, int Start, int& Loc) const;
01239 
01240   template<typename int_type>
01241   int ExtractGlobalRowCopy(int_type Row, int LenOfIndices, int& NumIndices, int_type* Indices) const;
01242 
01243   template<typename int_type>
01244   int ExtractMyRowCopy(int Row, int LenOfIndices, int& NumIndices, int_type* targIndices) const;
01245 };
01246 #endif /* EPETRA_CRSGRAPH_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines