Go to the documentation of this file.00001 #include "MOR_BasisOps.hpp"
00002
00003 #include "MOR_EpetraMVDenseMatrixView.hpp"
00004
00005 #include "Epetra_BlockMap.h"
00006 #include "Epetra_LocalMap.h"
00007
00008 #include "Epetra_Operator.h"
00009
00010 #include "Epetra_SerialDenseMatrix.h"
00011 #include "Epetra_SerialDenseSolver.h"
00012
00013 #include "Teuchos_Assert.hpp"
00014
00015 namespace MOR {
00016
00017 Epetra_LocalMap createComponentMap(const Epetra_MultiVector &projector)
00018 {
00019 return Epetra_LocalMap(projector.NumVectors(), 0, projector.Comm());
00020 }
00021
00022 void dualize(const Epetra_MultiVector &primal, Epetra_MultiVector &dual)
00023 {
00024
00025 const Epetra_LocalMap componentMap = createComponentMap(dual);
00026 Epetra_MultiVector product(componentMap, primal.NumVectors(), false);
00027 {
00028 const int ierr = reduce(dual, primal, product);
00029 TEUCHOS_ASSERT(ierr == 0);
00030 }
00031
00032
00033 {
00034 Epetra_SerialDenseMatrix matrix = localDenseMatrixView(product);
00035 Epetra_SerialDenseSolver solver;
00036 {
00037 const int ierr = solver.SetMatrix(matrix);
00038 TEUCHOS_ASSERT(ierr == 0);
00039 }
00040 {
00041 const int ierr = solver.Invert();
00042 TEUCHOS_ASSERT(ierr == 0);
00043 }
00044 }
00045
00046
00047 const Epetra_MultiVector dual_copy(dual);
00048 dual.Multiply('N', 'N', 1.0, dual_copy, product, 0.0);
00049 }
00050
00051 void dualize(const Epetra_MultiVector &primal, const Epetra_Operator &metric, Epetra_MultiVector &result)
00052 {
00053 const int ierr = metric.Apply(primal, result);
00054 TEUCHOS_ASSERT(ierr == 0);
00055 dualize(primal, result);
00056 }
00057
00058 }