| 1 | /*
|
|---|
| 2 | * Eigenspace.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Nov 22, 2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef EIGENSPACE_HPP_
|
|---|
| 9 | #define EIGENSPACE_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | #include <boost/shared_ptr.hpp>
|
|---|
| 18 |
|
|---|
| 19 | #include <iosfwd>
|
|---|
| 20 | #include <set>
|
|---|
| 21 | #include <vector>
|
|---|
| 22 | #include "MatrixContent.hpp"
|
|---|
| 23 | #include "VectorContent.hpp"
|
|---|
| 24 |
|
|---|
| 25 | /** Container for a matrix and its eigenvectors and -values.
|
|---|
| 26 | *
|
|---|
| 27 | * Note that a set of eigenvectors always forms a subspace within a vector
|
|---|
| 28 | * space, the so-called eigenspace. Hence, the name of this class is
|
|---|
| 29 | * eigenspace.
|
|---|
| 30 | *
|
|---|
| 31 | * Eigenvector are stored internally as a matrix. A returned set of
|
|---|
| 32 | * eigenvectors is just a set of VectorViewContent on row vectors in
|
|---|
| 33 | * this matrix.
|
|---|
| 34 | */
|
|---|
| 35 | class Eigenspace
|
|---|
| 36 | {
|
|---|
| 37 | friend std::ostream & operator<<(std::ostream &ost, const Eigenspace &_s);
|
|---|
| 38 | public:
|
|---|
| 39 | typedef std::vector< boost::shared_ptr<VectorContent> > eigenvectorset;
|
|---|
| 40 | typedef std::vector< double > eigenvalueset;
|
|---|
| 41 | typedef std::set<size_t> indexset;
|
|---|
| 42 |
|
|---|
| 43 | Eigenspace(const indexset &_Indices);
|
|---|
| 44 | Eigenspace(const indexset &_Indices, const MatrixContent &_matrix);
|
|---|
| 45 | virtual ~Eigenspace();
|
|---|
| 46 |
|
|---|
| 47 | void calculateEigenSubspace();
|
|---|
| 48 |
|
|---|
| 49 | // accessors
|
|---|
| 50 | const MatrixContent & getEigenspaceMatrix() const;
|
|---|
| 51 | const VectorContent & getEigenvector(const size_t i) const;
|
|---|
| 52 | const MatrixContent & getEigenvectorMatrix() const;
|
|---|
| 53 | const double getEigenvalue(const size_t i) const;
|
|---|
| 54 | const eigenvalueset & getEigenvalues() const;
|
|---|
| 55 | const indexset & getIndices() const;
|
|---|
| 56 | void setEigenspaceMatrix(const MatrixContent &_content);
|
|---|
| 57 |
|
|---|
| 58 | void setEigenpairs(const eigenvectorset &CurrentEigenvectors, const eigenvalueset &CurrentEigenvalues);
|
|---|
| 59 |
|
|---|
| 60 | bool contains(const Eigenspace &_indexset);
|
|---|
| 61 |
|
|---|
| 62 | protected:
|
|---|
| 63 | const indexset Indices;
|
|---|
| 64 | eigenvectorset Eigenvectors;
|
|---|
| 65 | eigenvalueset Eigenvalues;
|
|---|
| 66 | MatrixContent EigenspaceMatrix;
|
|---|
| 67 | MatrixContent EigenvectorMatrix;
|
|---|
| 68 |
|
|---|
| 69 | private:
|
|---|
| 70 | void createEigenvectorViews();
|
|---|
| 71 |
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 | std::ostream & operator<<(std::ostream &ost, const Eigenspace &_s);
|
|---|
| 75 |
|
|---|
| 76 | #endif /* EIGENSPACE_HPP_ */
|
|---|