Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

Detector.h

Go to the documentation of this file.
00001 // Detector.h
00002 //////////////////////////////////////////////////////////////////////
00003 //          (c) Copyright 2000-2002 Brown Deer Technology, LLC.     
00004 //                        All rights reserved.                   
00005 //////////////////////////////////////////////////////////////////////
00006 
00007 #ifndef DETECTOR_H
00008 #define DETECTOR_H
00009 
00010 #include "Rtrsmra.h"
00011 #include "Darray.h"
00012 #include "Fuzzy.h"
00013 
00014 template< class Rtrsmra_t, class Logic_t >
00015 class DetectorBase {
00016    public:
00017 
00018       typedef typename Rtrsmra_t::DataType DataType;
00019       typedef Logic_t LogicType;
00020       typedef Darray<Logic_t> DarrayType;
00021 
00022       DetectorBase( Rtrsmra_t& x ) { 
00023          _mmax = x.mmax(); 
00024          _x = &x; 
00025          _ta = new DataType[ _mmax + 1 ];
00026          _ha = new int[ _mmax + 1 ];
00027       }
00028 
00029       virtual ~DetectorBase() { 
00030         _x = 0; 
00031         if ( _ta != 0 ) { delete [] _ta; _ta = 0; }
00032         if ( _ha != 0 ) { delete [] _ha; _ha = 0; }
00033       }
00034 
00035       DarrayType Detectlt( const DataType* ta) {
00036          (*_x).detectlt( ta, _ha );
00037          Darray<Logic_t> da( _mmax + 1 );
00038          map( _ha, da );
00039          return da;
00040       }
00041 
00042       DarrayType Detectle(const DataType* ta) {
00043          (*_x).detectle( ta, _ha );
00044          Darray<Logic_t> da( _mmax + 1 );
00045          map( _ha, da );
00046          return da;
00047       }
00048 
00049       DarrayType Detectgt(const DataType* ta) {
00050          (*_x).detectgt(ta,_ha);
00051          Darray<Logic_t> da(_mmax+1);
00052          map(_ha,da);
00053          return da;
00054       }
00055 
00056       DarrayType Detectge(const DataType* ta) {
00057          (*_x).detectge(ta,_ha);
00058          Darray<Logic_t> da(_mmax+1);
00059          map(_ha,da);
00060          return da;
00061       }
00062 
00063       DarrayType Detectlt(const DataType t) {
00064          for(int m=0;m<=_mmax;m++) _ta[m]=t;
00065          (*_x).detectlt(_ta,_ha);
00066          Darray<Logic_t> da(_mmax+1);
00067          map(_ha,da);
00068          return da;
00069       }
00070 
00071       DarrayType Detectle(const DataType t) {
00072          for(int m=0;m<=_mmax;m++) _ta[m]=t;
00073          (*_x).detectle(_ta,_ha);
00074          Darray<Logic_t> da(_mmax+1);
00075          map(_ha,da);
00076          return da;
00077       }
00078 
00079       DarrayType Detectgt(const DataType t) {
00080          for(int m=0;m<=_mmax;m++) _ta[m]=t;
00081          (*_x).detectgt(_ta,_ha);
00082          Darray<Logic_t> da(_mmax+1);
00083          map(_ha,da);
00084          return da;
00085       }
00086 
00087       DarrayType Detectge(const DataType t) {
00088          for(int m=0;m<=_mmax;m++) _ta[m]=t;
00089          (*_x).detectge(_ta,_ha);
00090          Darray<Logic_t> da(_mmax+1);
00091          map(_ha,da);
00092          return da;
00093       }
00094 
00095       virtual void map(const int* ha, DarrayType& da) {
00096          for(int m=0;m<=_mmax;m++) da[m]=float(ha[m]);
00097       }
00098 
00099    protected:
00100       DataType* _ta;
00101       int* _ha;
00102       int _mmax;
00103       Rtrsmra_t* _x;
00104 };
00105 
00106 template<class Rtrsmra_t, class Logic_t>
00107 class Detector : public DetectorBase<Rtrsmra_t,Logic_t> {
00108    public:
00109       Detector(Rtrsmra_t& x) : DetectorBase<Rtrsmra_t,Logic_t>(x) {}
00110 };
00111 
00112 template<class Logic_t>
00113 class Detector< Rtrsmra<float,array>, Logic_t> 
00114   : public DetectorBase< Rtrsmra<float,array>, Logic_t > {
00115    public:
00116       typedef typename
00117         DetectorBase< Rtrsmra<float,array>, Logic_t >::DarrayType DarrayType;
00118       Detector( Rtrsmra<float,array>& x) 
00119         : DetectorBase< Rtrsmra<float,array>,Logic_t>(x) {}
00120       void map(const int* ha, DarrayType& da) {
00121          for(int m=0;m<=_mmax;m++) da[m]=float(ha[m])/float((*_x).amax()+1);
00122       }
00123 };
00124 
00125 template<class Logic_t>
00126 class Detector< Rtrsmra<double,array>, Logic_t> 
00127   : public DetectorBase< Rtrsmra<double,array>, Logic_t > {
00128    public:
00129       typedef typename
00130         DetectorBase< Rtrsmra<double,array>, Logic_t >::DarrayType DarrayType;
00131       Detector( Rtrsmra<double,array>& x) 
00132         : DetectorBase< Rtrsmra<double,array>,Logic_t>(x) {}
00133       void map(const int* ha, DarrayType& da) {
00134          for(int m=0;m<=_mmax;m++) da[m]=float(ha[m])/float((*_x).amax()+1);
00135       }
00136 };
00137 
00138 template<class Detector_T, class Thresh_T>
00139 typename Detector_T::DarrayType 
00140   operator<( Detector_T& d, Thresh_T& t ) { return d.Detectlt(t); }
00141 
00142 template<class Detector_T, class Thresh_T>
00143 typename Detector_T::DarrayType 
00144   operator<=( Detector_T& d, Thresh_T& t ) { return d.Detectle(t); }
00145 
00146 template<class Detector_T, class Thresh_T>
00147 typename Detector_T::DarrayType 
00148   operator>( Detector_T& d, Thresh_T& t ) { return d.Detectgt(t); }
00149 
00150 template<class Detector_T, class Thresh_T>
00151 typename Detector_T::DarrayType 
00152   operator>=( Detector_T& d, Thresh_T& t ) { return d.Detectge(t); }
00153 
00154 #endif
00155 

Generated on Mon May 31 21:38:44 2004 for SR2k4 Assembler by doxygen 1.3.6