00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _plKernelTable_h_
00020 #define _plKernelTable_h_
00021
00022 #include <plKernelDictionary.h>
00023
00024
00025
00026
00027
00028 class kplVariable;
00029
00030
00031
00032
00033
00034
00035
00045 class plKernelTable : public plKernelDictionary
00046 {
00047
00048 list <kplVariable *> index_variables;
00049
00051 void set(const plVariablesConjunction& left,
00052 const plVariablesConjunction& right);
00053
00054 void check_pushed_object_variables(const plComputableObject &compObj)const;
00055
00056 void check_variables(const plVariablesConjunction& left,
00057 const plVariablesConjunction& right,
00058 const plVariablesConjunction& right_index)const;
00059
00060
00061 public:
00075 plKernelTable();
00076
00078 plKernelTable (const plVariablesConjunction& left,
00079 const plVariablesConjunction& right);
00080
00081
00084 plKernelTable (const plVariablesConjunction& left,
00085 const plVariablesConjunction& right,
00086 const plVariablesConjunction& right_index);
00087
00088
00094 plKernelTable (const plVariablesConjunction& left,
00095 const plVariablesConjunction& right,
00096 const plProbValue *table,
00097 bool normalise_for_me = true);
00098
00108 plKernelTable(const plVariablesConjunction& left,
00109 const plVariablesConjunction& right,
00110 plProbValue (*f) (const plValues &left_values, const plValues& right_values),
00111 bool normalise_for_me = true);
00112
00122 template<typename T>
00123 plKernelTable(const plVariablesConjunction& left,
00124 const plVariablesConjunction& right,
00125 T *obj,
00126 plProbValue (T::*method) (const plValues &left_values, const plValues& right_values),
00127 bool normalise_for_me = true)
00128 {
00131 set(left, right);
00132
00133 plValues v_left(left);
00134 plValues v_right(right);
00135
00136 vector<plProbValue> column_values;
00137
00138 int count_total = 0;
00139
00140 v_right.reset();
00141 do {
00142 column_values.clear();
00143
00144 v_left.reset();
00145 do {
00146 ++count_total;
00147 column_values.push_back((obj->*method)(v_left, v_right));
00148 } while (v_left.next());
00149
00150 plProbTable column(left, column_values, normalise_for_me);
00151
00152 push(column, v_right);
00153
00154 } while (v_right.next());
00155 };
00156
00157
00158
00160 virtual ~plKernelTable(){};
00161
00174 void push(const plValues & values,
00175 const plComputableObject &compObj);
00176
00177 void push(const plComputableObject &compObj,
00178 const plValues & values);
00179
00180
00181
00182 void push(const plValues & values,
00183 const vector <plProbValue> &probVector);
00184
00185
00186
00187 void push(const vector <plProbValue> &probVector,
00188 const plValues & values);
00189
00192 void push(int value, const plComputableObject &compObj);
00193
00194 void push(const plComputableObject &compObj, int value);
00195
00196
00200 void push(plFloat value, const plComputableObject &compObj);
00201
00202 void push(const plComputableObject &compObj, plFloat value);
00203
00206 void push_default(const plComputableObject &compObj);
00207
00210 bool find(const plValues & values) const;
00211
00212
00213 };
00214
00215 #endif
00216
00217
00218
00219
00220