00001
00002 #ifndef _COSTTHRESH_H_
00003 #define _COSTTHRESH_H_
00004
00005 #include "costbase.h"
00006 #include "packnode.h"
00007
00039
00040
00041
00054 class costthresh : public costbase
00055 {
00056 private:
00058 double thresh;
00059
00061 double abs(const double x)
00062 {
00063 double retval = x;
00064 if (retval < 0.0)
00065 retval = -retval;
00066 return retval;
00067 }
00068
00069 protected:
00070
00076 double costCalc(packnode<double> *node)
00077 {
00078 double count = 0.0;
00079 if (node != 0) {
00080 size_t len = node->length();
00081 for (int i = 0; i < len; i++) {
00082 if (abs((*node)[i]) > thresh) {
00083 count = count + 1.0;
00084 }
00085 }
00086 }
00087 return count;
00088 }
00089
00090 public:
00093 costthresh(packnode<double> *node, double t )
00094 {
00095 thresh = t;
00096 traverse( node );
00097 }
00098 };
00099
00100 #endif