[5c867e] | 1 | /*
|
---|
| 2 | * Eigenvalues.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Mar 8, 2013
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef EIGENVALUES_HPP_
|
---|
| 9 | #define EIGENVALUES_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include <iosfwd>
|
---|
| 17 | #include <set>
|
---|
| 18 | #include <vector>
|
---|
| 19 |
|
---|
| 20 | class Eigenvalues
|
---|
| 21 | {
|
---|
| 22 | public:
|
---|
| 23 | //!> named type for a vector of sample values
|
---|
| 24 | typedef std::vector<double> samples_t;
|
---|
| 25 | //!> grant output operator access
|
---|
| 26 | friend std::ostream & operator<<(std::ostream &ost, const Eigenvalues &eigenvalues);
|
---|
| 27 | public:
|
---|
| 28 | /** Default constructor for class Eigenvalues.
|
---|
| 29 | *
|
---|
| 30 | */
|
---|
| 31 | Eigenvalues()
|
---|
| 32 | {}
|
---|
| 33 |
|
---|
| 34 | /** Constructor with a given vector of eigenvalues.
|
---|
| 35 | *
|
---|
| 36 | * \param _samples set of eigenvalues
|
---|
| 37 | */
|
---|
| 38 | Eigenvalues(const samples_t &_samples)
|
---|
| 39 | {
|
---|
[eb32b6] | 40 | addedsamples.insert(_samples.begin(), _samples.end());
|
---|
[5c867e] | 41 | }
|
---|
| 42 |
|
---|
| 43 | /** Default destructor for Eigenvalues.
|
---|
| 44 | *
|
---|
| 45 | */
|
---|
| 46 | ~Eigenvalues()
|
---|
| 47 | {}
|
---|
| 48 |
|
---|
| 49 | /** Adding another set of eigenvalues onto this one.
|
---|
| 50 | *
|
---|
| 51 | *
|
---|
| 52 | * @param other other Eigenvalues
|
---|
| 53 | * @return ref to this instance
|
---|
| 54 | */
|
---|
[eb32b6] | 55 | Eigenvalues& operator+=(const Eigenvalues &other)
|
---|
| 56 | {
|
---|
| 57 | addedsamples.insert(other.addedsamples.begin(), other.addedsamples.end());
|
---|
| 58 | subtractedsamples.insert(other.subtractedsamples.begin(), other.subtractedsamples.end());
|
---|
[5c867e] | 59 | return *this;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /** Subtracting another set of eigenvalues from this one.
|
---|
| 63 | *
|
---|
| 64 | * @param other other Eigenvalues
|
---|
| 65 | * @return ref to this instance
|
---|
| 66 | */
|
---|
[eb32b6] | 67 | Eigenvalues& operator-=(const Eigenvalues &other);
|
---|
| 68 | // {
|
---|
| 69 | // subtractedsamples.insert(other.addedsamples.begin(), other.addedsamples.end());
|
---|
| 70 | // return *this;
|
---|
| 71 | // }
|
---|
[5c867e] | 72 |
|
---|
| 73 | private:
|
---|
| 74 | //!> typedef for the internal container format
|
---|
| 75 | typedef std::set<double> sorted_samples_t;
|
---|
| 76 | //!> internally we store a set of sorted samples
|
---|
[eb32b6] | 77 | sorted_samples_t addedsamples;
|
---|
| 78 | sorted_samples_t subtractedsamples;
|
---|
[5c867e] | 79 | };
|
---|
| 80 |
|
---|
| 81 | /** Function to print eigenvalues to ostream.
|
---|
| 82 | *
|
---|
| 83 | * @param ost output stream
|
---|
| 84 | * @param eigenvalues set of eigenvalues to print
|
---|
| 85 | * @return ref to given ostream for concatenation
|
---|
| 86 | */
|
---|
| 87 | std::ostream & operator<<(std::ostream &ost, const Eigenvalues &eigenvalues);
|
---|
| 88 |
|
---|
| 89 | template<typename T> T ZeroInstance();
|
---|
| 90 | template<> Eigenvalues ZeroInstance<Eigenvalues>();
|
---|
| 91 |
|
---|
| 92 | #endif /* EIGENVALUES_HPP_ */
|
---|