EpetraExt Development

Permutation stores and describes a permutation matrix P. More...
#include <EpetraExt_Permutation.h>
Public Types  
typedef EpetraExt::SameTypeTransform < T >::TransformTypeRef  OutputRef 
typedef EpetraExt::SameTypeTransform < T >::TransformTypeRef  InputRef 
typedef EpetraExt::SameTypeTransform < T >::TransformTypePtr  OutputPtr 
typedef EpetraExt::SameTypeTransform < T >::TransformTypePtr  InputPtr 
Public Member Functions  
Permutation (Epetra_DataAccess CV, const Epetra_BlockMap &map, int *permutation)  
Constructor.  
Permutation (const Epetra_BlockMap &map)  
Constructor.  
Permutation (const Permutation< T > &src)  
Copy Constructor.  
virtual  ~Permutation () 
Destructor.  
OutputRef  operator() (InputRef orig) 
This method creates a new object which is a permuted copy of the input argument.  
OutputRef  operator() (InputRef orig, bool column_permutation) 
This method creates a new object which is a permuted copy of the input argument. 
Permutation stores and describes a permutation matrix P.
As described in "Matrix Computations" (Golub and Van Loan), a permutation matrix is the identity matrix with its rows reordered. The permutation is internally stored as an integer vector p, where p[i] is the columnindex of the "1" in P's ith row. Consider the example of permuting a matrix A by applying the permutation matrix P to form the result B. i.e., B = PA. If p[i] = j, then row j of A becomes row i of B.
This Permutation class is templated on the type of the object to be permuted. However, not all objects are eligible to be template parameters. Currently the following objects may be used: Epetra_CrsMatrix, Epetra_CrsGraph and Epetra_MultiVector.
A test program which exercises this Permutation class is located in the directory packages/epetraext/test/Permutation.
Implementation Notes: Permutation currently inherits StructuralSameTypeTransform, which in turn inherits Transform through SameTypeTransform. Permutation, and its base classes, are templates. A couple of noteworthy consequences result from this:
1. A separate instantiation of Permutation must be created for each type of object to be permuted. Example: Epetra_CrsGraph& graph = ... Epetra_CrsMatrix& A = ... Permutation<Epetra_CrsGraph> graph_perm(...); Permutation<Epetra_CrsMatrix> matrix_perm(...);
Epetra_CrsMatrix& PA = matrix_perm(A); Epetra_CrsGraph& Pgraph = graph_perm(graph);
2. Following the semantics of Transform, when the Permutation class is used to create a new permuted copy of an object, ownership of the new copy is retained by Permutation. Permutation will destroy the new object. This means that only one object should be permuted by a Permutation instance.
It is not clear that these are desirable behaviors for permutations. It is possible that Permutation will be altered to remove these limitations, as follows:
1. If Permutation doesn't inherit Transform, then Permutation need not be a template and instead we could either overload or templateize the operator() method member. This would allow a single instantiation of Permutation to be used for permuting all of the eligible target types.
2. Allowing the caller (user) to take ownership of the newlyproduced permuted objects would allow a single Permutation instance to be used repeatedly since it would no longer need to hold a pointer to the new object for later deletion.
Then, example usage could look like this: Epetra_CrsMatrix& A = ... Epetra_MultiVector& v = ... Permutation P(...);
Epetra_CrsMatrix PA = P(A); Epetra_MultiVector Pv = P(v);
Questions and comments about this class may be directed to Alan Williams.
Definition at line 116 of file EpetraExt_Permutation.h.
typedef EpetraExt::SameTypeTransform<T>::TransformTypeRef EpetraExt::Permutation< T >::OutputRef 
Definition at line 147 of file EpetraExt_Permutation.h.
typedef EpetraExt::SameTypeTransform<T>::TransformTypeRef EpetraExt::Permutation< T >::InputRef 
Definition at line 148 of file EpetraExt_Permutation.h.
typedef EpetraExt::SameTypeTransform<T>::TransformTypePtr EpetraExt::Permutation< T >::OutputPtr 
Definition at line 149 of file EpetraExt_Permutation.h.
typedef EpetraExt::SameTypeTransform<T>::TransformTypePtr EpetraExt::Permutation< T >::InputPtr 
Definition at line 150 of file EpetraExt_Permutation.h.
EpetraExt::Permutation< T >::Permutation  (  Epetra_DataAccess  CV, 
const Epetra_BlockMap &  map,  
int *  permutation  
) 
Constructor.
CV  Set to either Copy or View. 
map  Defines the index space to be permuted. 
permutation  Array defining the permutation. The length of this array must be 'map.NumMyElements()'. This array is the local portion of the 'p' vector described in the 'Detailed Description' section. 
Definition at line 376 of file EpetraExt_Permutation_impl.h.
EpetraExt::Permutation< T >::Permutation  (  const Epetra_BlockMap &  map  ) 
Constructor.
This constructor creates an empty permutation object. The contents must then be set using regular Epetra_IntVector methods.
map  Defines the index space to be permuted. 
Definition at line 390 of file EpetraExt_Permutation_impl.h.
EpetraExt::Permutation< T >::Permutation  (  const Permutation< T > &  src  ) 
Copy Constructor.
Definition at line 402 of file EpetraExt_Permutation_impl.h.
EpetraExt::Permutation< T >::~Permutation  (  )  [virtual] 
Destructor.
Definition at line 414 of file EpetraExt_Permutation_impl.h.
OutputRef EpetraExt::Permutation< T >::operator()  (  InputRef  orig  )  [virtual] 
This method creates a new object which is a permuted copy of the input argument.
Notes:
orig  Input Object to be permuted. 
Implements EpetraExt::Transform< T, T >.
OutputRef EpetraExt::Permutation< T >::operator()  (  InputRef  orig, 
bool  column_permutation  
) 
This method creates a new object which is a permuted copy of the input argument.
The same notes apply to this method (regarding collective communications etc.) as to the rowpermutation operator method above.
orig  Input Object to be permuted. 
column_permutation  Optional Input, defaults to false if not provided. A value of false means that a rowpermutation will be performed (result = P*orig), a value of true means that a columnpermutation will be performed (result = orig*P). 