00001 #ifndef SENSITIVITYEVALUATOR_H 00002 #define SENSITIVITYEVALUATOR_H 00003 00004 #include "SundanceDefs.h" 00005 #include "TSFHashtable.h" 00006 #include "Expr.h" 00007 #include "CellSet.h" 00008 #include "QuadratureFamily.h" 00009 #include "StaticLinearProblem.h" 00010 00011 namespace Sundance 00012 { 00013 00014 using namespace TSF; 00015 using std::string; 00016 00017 using std::ostream; 00018 00019 /** \ingroup LowLevelFE 00020 */ 00021 00022 class SensitivityEvaluator 00023 { 00024 public: 00025 /** */ 00026 Expr evaluate(const Expr& u0) const ; 00027 00028 /** */ 00029 string toString() const {return "SensitivityEvaluator";} 00030 00031 /** */ 00032 static SensitivityEvaluator& createAndCache(const Expr& integral, 00033 const Expr& u, 00034 const Expr& u0, 00035 int& key); 00036 /** */ 00037 static SensitivityEvaluator& getEvaluator(int key, const Expr& u); 00038 00039 /** */ 00040 static bool hasEvaluator(int key, const Expr& u); 00041 00042 /** */ 00043 static bool& verboseInit() {static bool rtn = false; return rtn;} 00044 00045 /** */ 00046 static bool& verboseCalculations() {static bool rtn = false; return rtn;} 00047 private: 00048 /** Ctor is private. Construction of SensitivityEvaluators should be done through the 00049 * createAndCache() method */ 00050 SensitivityEvaluator(const Expr& functional, const Expr& u, const Expr& u0); 00051 00052 00053 static TSFArray<TSFHashtable<string, TSFSmartPtr<SensitivityEvaluator> > >& cache(); 00054 static int& topKey(); 00055 00056 mutable StaticLinearProblem prob_; 00057 mutable Expr u0_; 00058 }; 00059 } 00060 00061 namespace TSF 00062 { 00063 inline string toString(const Sundance::SensitivityEvaluator& s) 00064 { 00065 return s.toString(); 00066 } 00067 } 00068 00069 #endif