ReFRACtor
state_vector.h
Go to the documentation of this file.
1 #ifndef STATE_VECTOR_H
2 #define STATE_VECTOR_H
3 #include "printable.h"
4 #include "observer.h"
5 #include "array_ad.h"
6 #include "fp_exception.h"
7 #include <blitz/array.h>
8 
9 namespace FullPhysics {
10 
11 /****************************************************************/
16 class StateVector : public Printable<StateVector>, public Observable<StateVector> {
17 public:
19  : pstart(0)
20  {
21  }
22  virtual ~StateVector() { }
23 
24  virtual void add_observer(Observer<StateVector>& Obs)
25  { add_observer_do(Obs, *this);}
27  { remove_observer_do(Obs, *this);}
28  virtual void print(std::ostream& Os) const;
29 
30 //-----------------------------------------------------------------------
32 //-----------------------------------------------------------------------
33 
34  const blitz::Array<double, 1>& state() const { return x_.value(); }
35 
36 //-----------------------------------------------------------------------
43 //-----------------------------------------------------------------------
44 
45  const ArrayAd<double, 1>& state_with_derivative() const { return x_;}
46 
47  blitz::Array<std::string, 1> state_vector_name() const;
48 
49 //-----------------------------------------------------------------------
51 //-----------------------------------------------------------------------
52 
53  const blitz::Array<double, 2>& state_covariance() const {return cov_;}
54 
55  void update_state(const blitz::Array<double, 1>& X);
56  void update_state(const blitz::Array<double, 1>& X, const blitz::Array<double, 2>& Cov);
57  blitz::Array<bool, 1> used_flag() const;
58 
59 //-----------------------------------------------------------------------
66 //-----------------------------------------------------------------------
67 
68  int observer_claimed_size() const {return pstart;}
69 
70 //-----------------------------------------------------------------------
72 //-----------------------------------------------------------------------
73 
74  void observer_claimed_size(int Pstart) { pstart = Pstart; }
75 
76 private:
78  blitz::Array<double, 2> cov_;
79  // Helper value that says what portion of state vector has been
80  // claimed by observers. We don't do anything with this value in
81  // this class, except make it available to StateVectorObservers when
82  // they are attached.
83  int pstart;
84 };
85 }
86 
87 #endif
const ArrayAd< double, 1 > & state_with_derivative() const
Return the state vector as state() does, but also make each value a AutoDerivative.
Definition: state_vector.h:45
const blitz::Array< double, 1 > & state() const
Current state vector.
Definition: state_vector.h:34
blitz::Array< std::string, 1 > state_vector_name() const
Return name of each state vector element.
void add_observer_do(Observer< StateVector > &Obs, StateVector &t)
Add an observer.
Definition: observer.h:148
const blitz::Array< double, 2 > & state_covariance() const
Current covariance of the state vector.
Definition: state_vector.h:53
virtual void add_observer(Observer< StateVector > &Obs)
Add an observer.
Definition: state_vector.h:24
void remove_observer_do(Observer< StateVector > &Obs, StateVector &t)
Remove an observer.
Definition: observer.h:173
This is a Mixin for classes that can be printed.
Definition: printable.h:24
void observer_claimed_size(int Pstart)
Update claimed size of state vector.
Definition: state_vector.h:74
const blitz::Array< T, D > & value() const
Definition: array_ad.h:306
virtual void remove_observer(Observer< StateVector > &Obs)
Remove an observer.
Definition: state_vector.h:26
Mixin for a class that allows other classes to observe it state.
Definition: observer.h:12
void update_state(const blitz::Array< double, 1 > &X)
Update the state vector.
This handles informing a set of interested objects when the state vector has updated.
Definition: state_vector.h:16
int observer_claimed_size() const
Total "claimed" size of the state vector.
Definition: state_vector.h:68
virtual void print(std::ostream &Os) const
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
blitz::Array< bool, 1 > used_flag() const
Return a Array of boolean values.

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11