// file: $isip/class/stat/UniformModel/UniformModel.h // version: $Id: UniformModel.h 8756 2002-10-18 21:47:07Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_UNIFORM_MODEL #define ISIP_UNIFORM_MODEL // isip include files // #ifndef ISIP_VECTOR_FLOAT #include #endif #ifndef ISIP_VECTOR_DOUBLE #include #endif #ifndef ISIP_MATRIX_FLOAT #include #endif #ifndef ISIP_FLOAT #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif #ifndef ISIP_STATISTICAL_MODEL_BASE #include #endif // UniformModel: generates a constant score for any test vector input // class UniformModel : public StatisticalModelBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_MIN; static const String PARAM_MAX; //---------------------------------------- // // default values and arguments // //---------------------------------------- //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 60400; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // declare variables to describe the range // VectorFloat min_d; VectorFloat max_d; // probability distribution scale factor // float32 scale_d; // memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // setDebug inherited from base class // bool8 debug(const unichar* msg) const; // method: destructor // ~UniformModel() {} // method: default constructor // UniformModel(MODE mode = DEF_MODE) { mode_d = mode; is_valid_d = false; } // method: copy constructor // UniformModel(const UniformModel& arg) { assign(arg); } // method: assign // bool8 assign(const UniformModel& arg) { mode_d = arg.mode_d; min_d.assign(arg.min_d); max_d.assign(arg.max_d); is_valid_d = false; return true; } // method: operator= // UniformModel& operator=(const UniformModel& arg) { assign(arg); return *this; } // method: sofSize // int32 sofSize() const { return (min_d.sofSize() + max_d.sofSize()); } // method: sofAccumulatorSize // int32 sofAccumulatorSize() const { return 0; } // method: sofOccupanciesSize // int32 sofOccupanciesSize() const { return 0; } // other i/o methods // bool8 read(Sof& sof, int32 tag, const String& name = CLASS_NAME); bool8 write(Sof& sof, int32 tag, const String& name = CLASS_NAME) const; bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: readAccumulator // bool8 readAccumulator(Sof& sof, int32 tag, const String& name = CLASS_NAME) { return true; } // method: writeAccumulator // bool8 writeAccumulator(Sof& sof, int32 tag, const String& name = CLASS_NAME) const { return true; } // method: readAccumulatorData // bool8 readAccumulatorData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return true; } // method: writeAccumulatorData // bool8 writeAccumulatorData(Sof& sof, const String& pname = DEF_PARAM) const { return true; } // method: readOccupancies // bool8 readOccupancies(Sof& sof, int32 tag, const String& name = CLASS_NAME) { return true; } // method: writeOccupancies // bool8 writeOccupancies(Sof& sof, int32 tag, const String& name = CLASS_NAME) const { return true; } // method: readOccupanciesData // bool8 readOccupanciesData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return true; } // method: writeOccupanciesData // bool8 writeOccupanciesData(Sof& sof, const String& pname = DEF_PARAM) const { return true; } // method: eq // bool8 eq(const UniformModel& arg) const { return (min_d.eq(arg.min_d) && max_d.eq(arg.max_d)); } // method: operator new // static void* operator new(size_t size) { return mgr_d.get(); } // method: operator new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: operator delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: operator delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // method: clear // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE) { min_d.clear(cmode); max_d.clear(cmode); is_valid_d = false; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // additional methods unique to this class needed to support the // interface contract // //-------------------------------------------------------------------------- // method: constructor // UniformModel(VectorFloat min, VectorFloat max, MODE mode = DEF_MODE) { min_d.assign(min); max_d.assign(max); mode_d = mode; is_valid_d = false; } // method: constructor // UniformModel(float32 min, float32 max, MODE mode = DEF_MODE) { VectorFloat vmin(1, min); min_d.assign(vmin); VectorFloat vmax(1, max); max_d.assign(vmax); mode_d = mode; is_valid_d = false; } // method: setMin // bool8 setMin(VectorFloat& arg) { min_d.assign(arg); is_valid_d = false; return true; } // method: setMin // bool8 setMin(float32 arg) { VectorFloat varg(1, arg); min_d.assign(varg); is_valid_d = false; return true; } // method: setMax // bool8 setMax(VectorFloat& arg) { max_d.assign(arg); is_valid_d = false; return true; } // method: setMax // bool8 setMax(float32 arg) { VectorFloat varg(1, arg); max_d.assign(varg); is_valid_d = false; return true; } // method: getMin // bool8 getMin(VectorFloat& min) const { return min.assign(min_d); } // method: getMax // bool8 getMax(VectorFloat& max) const { return max.assign(max_d); } //--------------------------------------------------------------------------- // // class-specific public methods: // required by the interface contract // setMode is inherited from StatisticalModelBase // //-------------------------------------------------------------------------- // StatisticalModelBase required methods // bool8 assign(const StatisticalModelBase& arg); bool8 eq(const StatisticalModelBase& arg) const; // method: className // const String& className() const { return CLASS_NAME; } // initialization methods // bool8 init(); // method: getMean // bool8 getMean(VectorFloat& mean); // method: getCovariance // bool8 getCovariance(MatrixFloat& cov); // likelihood calculcation methods // float32 getLikelihood(const VectorFloat& input); float32 getLogLikelihood(const VectorFloat& input); //--------------------------------------------------------------------------- // // class-specific public methods: // model reestimation methods // //--------------------------------------------------------------------------- // method: resetAccumulators // bool8 resetAccumulators() { return Error::handle(name(), L"resetAccumulators", Error::ARG, __FILE__, __LINE__); } // method: getOccupancy // float64 getOccupancy() { return Error::handle(name(), L"getOccupancy", Error::ARG, __FILE__, __LINE__); } // method: setOccupancy // bool8 setOccupancy(float64 arg) { Error::handle(name(), L"getOccupancy", Error::ARG, __FILE__, __LINE__); return false; } // method: getAccessCount // int32 getAccessCount() { return Error::handle(name(), L"getAccessCount", Error::ARG, __FILE__, __LINE__); } // method: setAccessCount // bool8 setAccessCount(int32 arg) { return Error::handle(name(), L"setAccessCount", Error::ARG, __FILE__, __LINE__); } // method: initialize // bool8 initialize(VectorFloat& param) { return Error::handle(name(), L"initialize", Error::ARG, __FILE__, __LINE__); } // method: accumulate // bool8 accumulate(VectorFloat& data) { return Error::handle(name(), L"initialize", Error::ARG, __FILE__, __LINE__); } // method: accumulate // bool8 accumulate(VectorDouble& param, VectorFloat& data, bool8 precomp) { return Error::handle(name(), L"accumulate", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: update // bool8 update(VectorFloat& varfloor, int32 min_count) { return Error::handle(name(), L"update", Error::NOT_IMPLEM, __FILE__, __LINE__); } //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // initialization methods // float32 initScale(); }; // end of include file // #endif