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