00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SACADO_PARAMETERVECTORBASE_HPP
00033 #define SACADO_PARAMETERVECTORBASE_HPP
00034
00035 #include <vector>
00036
00037 #include "Teuchos_Array.hpp"
00038
00039 #include "Sacado_ParameterFamilyBase.hpp"
00040
00041 namespace Sacado {
00042
00048 template <typename FamilyType, typename BaseValueType>
00049 class ParameterVectorBase {
00050
00051 public:
00052
00054 struct Entry {
00055
00057 Teuchos::RCP<FamilyType> family;
00058
00060 BaseValueType baseValue;
00061
00063 Entry(const Teuchos::RCP<FamilyType>& f, BaseValueType bv) :
00064 family(f), baseValue(bv) {}
00065
00066 };
00067
00068 protected:
00069
00071 typedef Teuchos::Array<Entry> EntryVector;
00072
00073 public:
00074
00076 typedef typename EntryVector::iterator iterator;
00077
00079 typedef typename EntryVector::const_iterator const_iterator;
00080
00082 ParameterVectorBase() {}
00083
00085 ParameterVectorBase(const ParameterVectorBase& source) :
00086 params(source.params) {}
00087
00089 virtual ~ParameterVectorBase() {}
00090
00092 ParameterVectorBase& operator = (const ParameterVectorBase& source) {
00093 params = source.params; return *this; }
00094
00096 void addParam(const Teuchos::RCP<FamilyType>& family,
00097 BaseValueType baseValue) {
00098 params.push_back(Entry(family, baseValue));
00099 }
00100
00102 unsigned int size() const { return params.size(); }
00103
00105 Entry& operator[] (int i) { return params[i]; }
00106
00108 const Entry& operator[] (int i) const { return params[i]; }
00109
00111 iterator begin() { return params.begin(); }
00112
00114 const_iterator begin() const { return params.begin(); }
00115
00117 iterator end() { return params.end(); }
00118
00120 const_iterator end() const { return params.end(); }
00121
00123 void
00124 filterParameters(ParameterVectorBase& ad,
00125 ParameterVectorBase& analytic,
00126 ParameterVectorBase& other,
00127 std::vector<int>& index_ad,
00128 std::vector<int>& index_analytic,
00129 std::vector<int>& index_other) {
00130 index_ad.resize(0);
00131 index_analytic.resize(0);
00132 index_other.resize(0);
00133
00134 typename EntryVector::iterator it;
00135 int i;
00136 for (it = params.begin(), i=0; it != params.end(); ++it, ++i) {
00137 if ((*it).family->supportsAD()) {
00138 ad.params.push_back(*it);
00139 index_ad.push_back(i);
00140 }
00141 else if ((*it).family->supportsAnalytic()) {
00142 analytic.params.push_back(*it);
00143 index_analytic.push_back(i);
00144 }
00145 else {
00146 other.params.push_back(*it);
00147 index_other.push_back(i);
00148 }
00149 }
00150 }
00151
00152 protected:
00153
00155 EntryVector params;
00156 };
00157 }
00158
00159 #endif