| [9c5296] | 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 | 
 | 
|---|
| [56f73b] | 11 | // include config.h
 | 
|---|
 | 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 13 | #include <config.h>
 | 
|---|
 | 14 | #endif
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | 
 | 
|---|
| [9c5296] | 17 | #include <map>
 | 
|---|
 | 18 | #include <set>
 | 
|---|
 | 19 | #include <vector>
 | 
|---|
 | 20 | #include "Eigenspace.hpp"
 | 
|---|
 | 21 | #include "MatrixContent.hpp"
 | 
|---|
 | 22 | #include "VectorContent.hpp"
 | 
|---|
| [f844ef] | 23 | #include "unittests/SubspaceFactorizerUnitTest.hpp"
 | 
|---|
| [9c5296] | 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 | {
 | 
|---|
| [a06042] | 40 |   // TODO: Remove if not needed anymore
 | 
|---|
 | 41 |   friend void SubspaceFactorizerUnittest::SubspaceTest();
 | 
|---|
| [9c5296] | 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 | 
 | 
|---|
| [e828c0] | 53 |   // solving
 | 
|---|
| [9c5296] | 54 |   void calculateEigenSubspace();
 | 
|---|
| [e828c0] | 55 | 
 | 
|---|
 | 56 |   // accessing
 | 
|---|
| [286af5f] | 57 |   const MatrixContent & getEigenvectorMatrixInFullSpace();
 | 
|---|
 | 58 |   const eigenvectorset & getEigenvectorsInFullSpace();
 | 
|---|
 | 59 |   const VectorContent getEigenvectorParallelToFullOne(size_t i);
 | 
|---|
 | 60 |   const double getEigenvalueOfEigenvectorParallelToFullOne(size_t i);
 | 
|---|
| [e828c0] | 61 |   const subset & getSubIndices() const;
 | 
|---|
| [9c5296] | 62 | 
 | 
|---|
 | 63 | private:
 | 
|---|
 | 64 | 
 | 
|---|
| [e828c0] | 65 |   void createLocalMapping();
 | 
|---|
| [9c5296] | 66 |   void invertLocalToGlobalMapping();
 | 
|---|
 | 67 |   void getSubspacematrixFromBigmatrix(const MatrixContent & bigmatrix);
 | 
|---|
| [e828c0] | 68 |   void sortEigenvectors();
 | 
|---|
 | 69 |   void correctEigenvectorsFromSubIndices();
 | 
|---|
 | 70 |   void correctProjectionMatricesFromSubIndices();
 | 
|---|
 | 71 |   void scaleEigenvectorsbyEigenvalue();
 | 
|---|
 | 72 |   void getNormofEigenvectorAsEigenvalue();
 | 
|---|
| [a06042] | 73 |   void createProjectionMatrices();
 | 
|---|
| [e828c0] | 74 |   const MatrixContent projectFullspaceMatrixToSubspace(const MatrixContent &_fullmatrix) const;
 | 
|---|
 | 75 |   const MatrixContent projectSubspaceMatrixToFullspace(const MatrixContent &_subspacematrix) const;
 | 
|---|
| [9c5296] | 76 | 
 | 
|---|
 | 77 |   mapping LocalToGlobal;
 | 
|---|
 | 78 |   mapping GlobalToLocal;
 | 
|---|
 | 79 |   subset SubIndices;
 | 
|---|
 | 80 |   MatrixContent ProjectToSubspace;
 | 
|---|
 | 81 |   MatrixContent ProjectFromSubspace;
 | 
|---|
 | 82 |   Eigenspace &FullSpace;
 | 
|---|
| [286af5f] | 83 | 
 | 
|---|
 | 84 |   const VectorContent ZeroVector;
 | 
|---|
| [9c5296] | 85 | };
 | 
|---|
 | 86 | 
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | #endif /* SUBSPACE_HPP_ */
 | 
|---|