41#ifndef EpetraExt_PERMUTATION_IMPL_H 
   42#define EpetraExt_PERMUTATION_IMPL_H 
   44#if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS) 
   46#warning "The EpetraExt package is deprecated" 
   54#include <Epetra_Export.h> 
   55#include <Epetra_Map.h> 
   56#include <Epetra_Comm.h> 
   57#include <Epetra_MultiVector.h> 
   58#include <Epetra_CrsGraph.h> 
   59#include <Epetra_CrsMatrix.h> 
   60#include <Epetra_GIDTypeVector.h> 
   86  { 
static const char name[] = 
"unknown"; 
return( name ); }
 
 
  105  { std::cerr << 
"not implemented for unknown type"<<std::endl; }
 
 
  108  template<
typename int_type>
 
  112  { std::cerr << 
"not implemented for unknown type"<<std::endl; }
 
 
 
  126  { 
static const char name[] = 
"Epetra_CrsMatrix"; 
return( name ); }
 
 
  143    if (pointmap == NULL) {
 
  144      std::cerr << 
"dynamic_cast<const Epetra_Map*> failed."<<std::endl;
 
  157  template<
typename int_type>
 
  171    colperm->PutValue(0);
 
  174    colperm->Export(*perm, p_exporter, 
Add);
 
  178    int_type* myGlobalRows = 0;
 
  179    origRowMap.MyGlobalElementsPtr(myGlobalRows);
 
  185    for(
int i=0; i<numMyRows; ++i) {
 
  186      int_type globalRow = myGlobalRows[i];
 
  190      double* src_values = 
new double[len];
 
  191      int_type* src_indices = 
new int_type[len];
 
  193               src_values, src_indices);
 
  194      if (err < 0 || numIndices != len) {
 
  195  std::cerr<<
"Perm_traits<CrsMatrix>::produceColumnPermutation err("<<err<<
") row " 
  196      <<globalRow<<
", len "<<len<<
", numIndices "<<numIndices<<std::endl;
 
  199      int_type* pindices = 
new int_type[len];
 
  202      int_type* p = colperm->Values();
 
  204      for(
int j=0; j<len; ++j) {
 
  205  int_type old_col = src_indices[j];
 
  207  int lid = pmap.
LID(old_col);
 
  209    std::cerr << 
"Perm_traits<CrsMatrix>::permuteColumnIndices GID("<<old_col
 
  210         <<
") not found"<<std::endl;
 
  214  pindices[j] = p[lid];
 
  219  std::cerr << 
"Perm_traits<CrsMatrix>::permuteColumnIndices err("<<err
 
  220       <<
") row "<<globalRow<<std::endl;
 
  224      delete [] src_indices;
 
  225      delete [] src_values;
 
 
  235#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  241    return TproduceColumnPermutation<int>(perm, srcObj);
 
 
  245#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  251    return TproduceColumnPermutation<long long>(perm, srcObj);
 
 
  266  { 
static const char name[] = 
"Epetra_CrsGraph"; 
return( name ); }
 
 
  287  template<
typename int_type>
 
  301    colperm->PutValue(0);
 
  304    colperm->Export(*perm, p_exporter, 
Add);
 
  308    int_type* myGlobalRows = 0;
 
  309    origRowMap.MyGlobalElementsPtr(myGlobalRows);
 
  315    for(
int i=0; i<numMyRows; ++i) {
 
  316      int_type globalRow = myGlobalRows[i];
 
  320      int_type* src_indices = 
new int_type[len];
 
  322      if (err < 0 || numIndices != len) {
 
  323  std::cerr<<
"Perm_traits<CrsGraph>::produceColumnPermutation err("<<err<<
") row " 
  324    <<globalRow<<
", len "<<len<<
", numIndices "<<numIndices<<std::endl;
 
  327      int_type* pindices = 
new int_type[len];
 
  330      int_type* p = colperm->Values();
 
  332      for(
int j=0; j<len; ++j) {
 
  333  int_type old_col = src_indices[j];
 
  335  int lid = pmap.
LID(old_col);
 
  337    std::cerr << 
"Perm_traits<CrsGraph>::permuteColumnIndices GID("<<old_col
 
  338         <<
") not found"<<std::endl;
 
  342  pindices[j] = p[lid];
 
  347  std::cerr << 
"Perm_traits<CrsGraph>::produceColumnPermutation err("<<err
 
  348       <<
") row "<<globalRow<<std::endl;
 
  352      delete [] src_indices;
 
 
  362#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  368    return TproduceColumnPermutation<int>(perm, srcObj);
 
 
  372#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  378    return TproduceColumnPermutation<long long>(perm, srcObj);
 
 
 
  392  { 
static const char name[] = 
"Epetra_MultiVector"; 
return( name ); }
 
 
  409#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  415    std::cerr << 
"col-permutation not implemented for Epetra_MultiVector"<<std::endl;
 
 
  419#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  425    std::cerr << 
"col-permutation not implemented for Epetra_MultiVector"<<std::endl;
 
 
 
  436template<
typename T, 
typename int_type>
 
  439                         int_type* permutation)
 
  444  if (!isTypeSupported()) {
 
  445    std::cerr << 
"unsupported type for permutation, aborting" << std::endl;
 
 
  450template<
typename T, 
typename int_type>
 
  456  if (!isTypeSupported()) {
 
  457    std::cerr << 
"unsupported type for permutation, aborting" << std::endl;
 
 
  462template<
typename T, 
typename int_type>
 
  468  if (!isTypeSupported()) {
 
  469    std::cerr << 
"unsupported type for permutation, aborting" << std::endl;
 
 
 
  474template<
typename T, 
typename int_type>
 
  477  if (newObj_ != NULL) 
delete newObj_;
 
 
  480template<
typename T, 
typename int_type>
 
  484  if (!strcmp(type_name, 
"unknown")) {
 
  491template<
typename T, 
typename int_type>
 
  527  TPermutation* p = 
this;
 
  534    TPermutation* newp = 
new TPermutation(origMap);
 
  535    newp->Export(*p, p_exporter, Add);
 
  539    pmap = 
new Epetra_Map((int_type) p->Map().NumGlobalPoints64(),
 
  540        p->Map().NumMyPoints(),
 
  542        (int_type) p->Map().IndexBase64(),
 
  558  newObj_->Export(orig, exporter, Add);
 
  576template<
typename T, 
typename int_type>
 
  579          bool column_permutation )
 
  584  if (!column_permutation) {
 
  585    return( 
operator()(orig) );
 
  590    std::cerr << 
"Permutation: column-permutation only implemented for" 
  591   << 
"CrsMatrix and CrsGraph." << std::endl;
 
 
 
 
 
Permutation stores and describes a permutation matrix P.
 
EpetraExt::SameTypeTransform< T >::TransformTypeRef InputRef
 
EpetraExt::SameTypeTransform< T >::TransformTypeRef OutputRef
 
TPermutation(Epetra_DataAccess CV, const Epetra_BlockMap &map, int_type *permutation)
Constructor.
 
virtual ~TPermutation()
Destructor.
 
OutputRef operator()(InputRef orig)
This method creates a new object which is a permuted copy of the input argument.
 
bool PointSameAs(const Epetra_BlockMap &Map) const
 
int NumMyElements() const
 
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
 
const Epetra_BlockMap & RowMap() const
 
int ExtractGlobalRowCopy(int GlobalRow, int LenOfIndices, int &NumIndices, int *Indices) const
 
int NumGlobalIndices(long long Row) const
 
const Epetra_BlockMap & ColMap() const
 
int ReplaceRowMap(const Epetra_BlockMap &newmap)
 
int NumGlobalEntries(long long Row) const
 
const Epetra_Map & RowMap() const
 
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
 
int FillComplete(bool OptimizeDataStorage=true)
 
int ReplaceRowMap(const Epetra_BlockMap &newmap)
 
int ExtractGlobalRowCopy(int GlobalRow, int Length, int &NumEntries, double *Values, int *Indices) const
 
const Epetra_Map & ColMap() const
 
const Epetra_BlockMap & Map() const
 
int ReplaceMap(const Epetra_BlockMap &map)
 
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
 
static void replaceMap(Epetra_CrsGraph *graph, const Epetra_BlockMap &map)
replaceMap implementation
 
static Epetra_CrsGraph * produceColumnPermutation(TPermutation< Epetra_CrsGraph, long long > *perm, Epetra_CrsGraph *srcObj)
return new object which is a column-permutation of srcObj
 
static Epetra_CrsGraph * clone(Epetra_CrsGraph *example, Epetra_DataAccess CV, const Epetra_BlockMap &map, int rowLength)
clone implementation
 
static Epetra_CrsGraph * TproduceColumnPermutation(TPermutation< Epetra_CrsGraph, int_type > *perm, Epetra_CrsGraph *srcObj)
return new object which is a column-permutation of srcObj
 
static Epetra_CrsGraph * produceColumnPermutation(TPermutation< Epetra_CrsGraph, int > *perm, Epetra_CrsGraph *srcObj)
return new object which is a column-permutation of srcObj
 
static const char * typeName()
typeName implementation
 
static Epetra_CrsMatrix * produceColumnPermutation(TPermutation< Epetra_CrsMatrix, long long > *perm, Epetra_CrsMatrix *srcObj)
return new object, which is a column-permutation of srcObj
 
static Epetra_CrsMatrix * TproduceColumnPermutation(TPermutation< Epetra_CrsMatrix, int_type > *perm, Epetra_CrsMatrix *srcObj)
return new object, which is a column-permutation of srcObj
 
static void replaceMap(Epetra_CrsMatrix *mat, const Epetra_BlockMap &map)
replaceMap implementation
 
static Epetra_CrsMatrix * clone(Epetra_CrsMatrix *example, Epetra_DataAccess CV, const Epetra_BlockMap &map, int rowLength)
clone implementation
 
static Epetra_CrsMatrix * produceColumnPermutation(TPermutation< Epetra_CrsMatrix, int > *perm, Epetra_CrsMatrix *srcObj)
return new object, which is a column-permutation of srcObj
 
static const char * typeName()
typeName implementation
 
static void replaceMap(Epetra_MultiVector *mvec, const Epetra_BlockMap &map)
replaceMap implementation
 
static const char * typeName()
typeName implementation
 
static Epetra_MultiVector * clone(Epetra_MultiVector *example, Epetra_DataAccess, const Epetra_BlockMap &map, int)
clone implementation
 
static Epetra_MultiVector * produceColumnPermutation(Permutation64< Epetra_MultiVector > *, Epetra_MultiVector *)
permute column-indices within a specified row, if applicable
 
static Epetra_MultiVector * produceColumnPermutation(Permutation< Epetra_MultiVector > *, Epetra_MultiVector *)
permute column-indices within a specified row, if applicable
 
Define some traits to make it easier to deal with template-parameters which are objects to be permute...
 
static void replaceMap(T *obj, const Epetra_BlockMap &map)
replace the object's row-map (or if it's not a matrix, replace its only map)
 
static T * produceColumnPermutation(TPermutation< T, int_type > *perm, T *srcObj)
return new object, which is a column-permutation of srcObj
 
static T * clone(T *example, Epetra_DataAccess CV, const Epetra_BlockMap &map, int int_argument)
clone function accepts an example of the object being cloned, and enough constructor arguments to be ...
 
static const char * typeName()
return a std::string name for the object type