Go to the documentation of this file.00001
00002
00003
00004 #ifndef clusterF02_hh
00005 #define clusterF02_hh
00006
00007 #include "toolbox/scannerConnectors.hh"
00008 #include "toolbox/hashMap.hh"
00009 #include "cluster/expansion.hh"
00010 #include "cluster/f.hh"
00011
00012 namespace cluster {
00013
00014
00015
00020 template<class NodeX, class NodeY>
00021 class F02 : public ClstF<NodeX, NodeY> {
00022 public:
00024 typedef typename ClstF<NodeX, NodeY>::TraitsX TraitsX;
00025 typedef typename ClstF<NodeX, NodeY>::TraitsY TraitsY;
00026 typedef typename ClstF<NodeX, NodeY>::FX FX;
00027 typedef typename ClstF<NodeX, NodeY>::FY FY;
00028 typedef typename ClstF<NodeX, NodeY>::NfldNodes NfldNodes;
00029 typedef typename ClstF<NodeX, NodeY>::NfldScan NfldScan;
00030 private:
00033 class Ffld {
00035 Ffld* lnk_;
00037 const NodeX* clstX_;
00038 const NodeY* clstY_;
00040 uint m_;
00042 FColExp* val_;
00043
00044 public:
00045 inline Ffld(const NodeX* clstX, const NodeY* clstY,
00046 uint m, Ffld* lnk = 0)
00047 : lnk_(lnk), clstX_(clstX), clstY_(clstY), m_(m), val_(0) {}
00048 inline ~Ffld() {delete val_;}
00049
00050 inline Ffld* link() const {return lnk_;}
00051 inline uint sigma() const {return TraitsX::index(clstX_);}
00052 inline uint tau() const {return TraitsY::index(clstY_);}
00053 inline concepts::Real3d z() const {
00054 return TraitsY::center(clstY_) - TraitsX::center(clstX_);
00055 }
00056 inline uint m() const {return m_;}
00057 inline FColExp* val(uint blksz, const ExpansionF<FX>& exp) {
00058 delete val_; val_ = blksz ? exp.getCol(blksz) : 0; return val_;
00059 }
00060 inline FColExp* val() const {return val_;}
00061 };
00062
00064 const Tree<NodeX>& treeX_;
00065 const Tree<NodeY>& treeY_;
00066
00068 const ExpansionF<FX>& exp_;
00069
00071 uint m_;
00072 concepts::Real eps_;
00073 concepts::Real s_;
00075 uint minsz_;
00076
00078 Ffld* ffld_;
00080 uint nffld_;
00081 uint nffldval_;
00083 concepts::Joiner<NfldNodes, 1>* nfld_;
00085 uint nnfld_;
00086
00088 void constructor_(const NodeX* clstX, const NodeY* clstY);
00089 template<class Trts, class Nd>
00090 uint info_(uint idx, const Nd* clst,
00091 __gnu_cxx::hash_map<uint, uint>& nlf) const;
00092
00093 protected:
00095 std::ostream& info(std::ostream& os) const;
00096
00097 public:
00098 F02(const Tree<NodeX>& treeX, const Tree<NodeY>& treeY,
00099 const ExpansionF<FX>& exp, concepts::Real eps,
00100 concepts::Real s, uint minsz);
00101 ~F02();
00102
00104 void operator()(const ClstY<NodeY>& vecY, ClstX<NodeX>& vecX) const;
00105
00106 inline NfldScan* scan() const {
00107 return new concepts::ListScan<NfldNodes>(*nfld_);
00108 }
00110 inline float memory() const;
00111 std::ostream& info(std::ostream& os, uint idxX, uint idxY) const;
00112 };
00113
00114 template<class NodeX, class NodeY>
00115 inline float F02<NodeX, NodeY>::memory() const {
00116 return sizeof(F02<NodeX, NodeY>)
00117 + (float)nffld_ * sizeof(typename F02<NodeX, NodeY>::Ffld)
00118 + nffldval_ * (ffld_->val() ? ffld_->val()->memory(1)
00119 : ffld_->val(1, exp_)->memory(1))
00120 + (float)nnfld_ * sizeof(concepts::Joiner<NfldNodes, 1>);
00121 }
00122
00123 }
00124
00125 #endif // clusterF02_hh