| 1 | /*
 | 
|---|
| 2 |  * Subspace.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Nov 22, 2010
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #ifndef SUBSPACE_HPP_
 | 
|---|
| 9 | #define SUBSPACE_HPP_
 | 
|---|
| 10 | 
 | 
|---|
| 11 | // include config.h
 | 
|---|
| 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 13 | #include <config.h>
 | 
|---|
| 14 | #endif
 | 
|---|
| 15 | 
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include <map>
 | 
|---|
| 18 | #include <set>
 | 
|---|
| 19 | #include <vector>
 | 
|---|
| 20 | #include "Eigenspace.hpp"
 | 
|---|
| 21 | #include "MatrixContent.hpp"
 | 
|---|
| 22 | #include "VectorContent.hpp"
 | 
|---|
| 23 | #include "unittests/SubspaceFactorizerUnitTest.hpp"
 | 
|---|
| 24 | 
 | 
|---|
| 25 | /** A subset of eigenvectors from an Eigenspace.
 | 
|---|
| 26 |  *
 | 
|---|
| 27 |  * In this class we regard a sub set of eigenvectors of an Eigenspace
 | 
|---|
| 28 |  * which span a subspace of the eigenspace. This is used for diagonalization
 | 
|---|
| 29 |  * of the Eigenspace's matrix in linear-scaling, subspace decomposition
 | 
|---|
| 30 |  * schemes.
 | 
|---|
| 31 |  *
 | 
|---|
| 32 |  * Here, beyond the contents of Eigenspace, we need projection matrices from
 | 
|---|
| 33 |  * and to this subspace and also mappings from the global indices to the local
 | 
|---|
| 34 |  * indices, to identify local eigenvectors in this Subspace with their
 | 
|---|
| 35 |  * counterparts in the full Eigenspace.
 | 
|---|
| 36 |  *
 | 
|---|
| 37 |  */
 | 
|---|
| 38 | class Subspace : public Eigenspace
 | 
|---|
| 39 | {
 | 
|---|
| 40 |   // TODO: Remove if not needed anymore
 | 
|---|
| 41 |   friend void SubspaceFactorizerUnittest::SubspaceTest();
 | 
|---|
| 42 | public:
 | 
|---|
| 43 |   typedef std::map<size_t, size_t> mapping;
 | 
|---|
| 44 |   typedef std::set< boost::shared_ptr<Subspace> > subset;
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   Subspace(indexset &_s, Eigenspace &_FullSpace);
 | 
|---|
| 47 |   ~Subspace();
 | 
|---|
| 48 | 
 | 
|---|
| 49 |   // manipulate subsets
 | 
|---|
| 50 |   bool addSubset(boost::shared_ptr<Subspace> &_s);
 | 
|---|
| 51 |   bool removeSubset(boost::shared_ptr<Subspace> &_s);
 | 
|---|
| 52 | 
 | 
|---|
| 53 |   // solving
 | 
|---|
| 54 |   void calculateEigenSubspace();
 | 
|---|
| 55 | 
 | 
|---|
| 56 |   // accessing
 | 
|---|
| 57 |   const MatrixContent & getEigenvectorMatrixInFullSpace();
 | 
|---|
| 58 |   const eigenvectorset & getEigenvectorsInFullSpace();
 | 
|---|
| 59 |   const VectorContent getEigenvectorParallelToFullOne(size_t i);
 | 
|---|
| 60 |   const double getEigenvalueOfEigenvectorParallelToFullOne(size_t i);
 | 
|---|
| 61 |   const subset & getSubIndices() const;
 | 
|---|
| 62 | 
 | 
|---|
| 63 | private:
 | 
|---|
| 64 | 
 | 
|---|
| 65 |   void createLocalMapping();
 | 
|---|
| 66 |   void invertLocalToGlobalMapping();
 | 
|---|
| 67 |   void getSubspacematrixFromBigmatrix(const MatrixContent & bigmatrix);
 | 
|---|
| 68 |   void sortEigenvectors();
 | 
|---|
| 69 |   void correctEigenvectorsFromSubIndices();
 | 
|---|
| 70 |   void correctProjectionMatricesFromSubIndices();
 | 
|---|
| 71 |   void scaleEigenvectorsbyEigenvalue();
 | 
|---|
| 72 |   void getNormofEigenvectorAsEigenvalue();
 | 
|---|
| 73 |   void createProjectionMatrices();
 | 
|---|
| 74 |   const MatrixContent projectFullspaceMatrixToSubspace(const MatrixContent &_fullmatrix) const;
 | 
|---|
| 75 |   const MatrixContent projectSubspaceMatrixToFullspace(const MatrixContent &_subspacematrix) const;
 | 
|---|
| 76 | 
 | 
|---|
| 77 |   mapping LocalToGlobal;
 | 
|---|
| 78 |   mapping GlobalToLocal;
 | 
|---|
| 79 |   subset SubIndices;
 | 
|---|
| 80 |   MatrixContent ProjectToSubspace;
 | 
|---|
| 81 |   MatrixContent ProjectFromSubspace;
 | 
|---|
| 82 |   Eigenspace &FullSpace;
 | 
|---|
| 83 | 
 | 
|---|
| 84 |   const VectorContent ZeroVector;
 | 
|---|
| 85 | };
 | 
|---|
| 86 | 
 | 
|---|
| 87 | 
 | 
|---|
| 88 | #endif /* SUBSPACE_HPP_ */
 | 
|---|