// file: $isip/class/math/vector/MVector/MVectorMethods.h // version: $Id: MVectorMethods.h 7799 2002-02-22 22:31:35Z wang $ // // make sure definitions are only made once // #ifndef ISIP_MVECTOR_METHODS #define ISIP_MVECTOR_METHODS // isip include files // #include #include // forward class definitions // template class MVector; // MVectorMethods: a friend class to MVector. Its purpose is mainly to // provide a mechanism to get source code out of the header file and into // implementation files. // class MVectorMethods { //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // static methods // template static bool8 diagnose(Integral::DEBUG level); // i/o methods // template static int32 sofSize(const MVector& obj); template static bool8 read(MVector& obj, Sof& sof, int32 tag, const String& name); template static bool8 write(const MVector& obj, Sof& sof, int32 tag, const String& name); template static bool8 readData(MVector& obj, Sof& sof, const String& pname, int32 size, bool8 param, bool8 nested); template static bool8 writeData(const MVector& obj, Sof& sof, const String& name); //------------------------------------------------------------------------- // // class-specific public methods // //------------------------------------------------------------------------- // array conversion methods // template static bool8 assign(MVector& obj, int32 num_elem, const TAIntegral* arg); template static bool8 assign(MVector& obj, int32 num_elem, const String* arg); // conversion from string using parsing // template static bool8 assign(MVector& obj, const String& arg, unichar delim); template static bool8 assign(MVector& obj, const unichar* arg, unichar delim); // conversion to string // template static bool8 get(const MVector& obj, String& output, const String& delim); // swap the current vector with the input vector // template static bool8 swap(MVector& obj, MVector& arg); // partial i/o methods // template static bool8 readStart(MVector& obj, Sof& sof, const String& pname, int32 size, bool8 param, bool8 nested); template static int32 readPartialData(MVector& obj, Sof& sof, int32 start_pos, int32 num_elem, const String& pname, int32 size, bool8 param, bool8 nested); template static bool8 writeStart(const MVector& obj, Sof& sof, const String& pname); template static int32 writePartialData(const MVector& obj, Sof& sof, int32 start_pos, int32 num_elem); template static bool8 writeTerminate(const MVector& obj, Sof& sof, const String& pname); // memory size methods // template static int32 memSize(const MVector& obj); // comparison methods // template static bool8 eq(const MVector& obj, TIntegral value); template static bool8 ne(const MVector& obj, const MVector& vector); template static bool8 ne(const MVector& obj, TIntegral value); template static bool8 gt(const MVector& obj, const MVector& vector); template static bool8 gt(const MVector& obj, TIntegral value); template static bool8 lt(const MVector& obj, const MVector& vector); template static bool8 lt(const MVector& obj, TIntegral value); template static bool8 ge(const MVector& obj, const MVector& vector); template static bool8 ge(const MVector& obj, TIntegral value); template static bool8 le(const MVector& obj, const MVector& vector); template static bool8 le(const MVector& obj, TIntegral value); // common mathematical functions // template static bool8 pow(MVector& obj, const MVector& x, float64 y); template static bool8 sort(MVector& obj, const MVector& vector, Integral::ORDER order = Integral::DEF_ORDER); template static bool8 index(MVector& obj, Integral::ORDER order, MVector& sort_index); template static bool8 randperm(MVector& obj, int32 size); // mathematical limits, ceiling, floor and rounding functions // template static TIntegral max(const MVector& obj, int32& position); template static TIntegral min(const MVector& obj, int32& position); template static float64 minMag(const MVector& obj, int32& position); template static float64 maxMag(const MVector& obj, int32& position); // function generation methods // template static bool8 ramp(MVector& obj, TIntegral offset, TIntegral incr); template static bool8 ramp(MVector& obj, TIntegral offset, TIntegral incr, TIntegral end); // vector to scalar mathematical methods // template static TIntegral sum(const MVector& obj); template static TIntegral sumSquare(const MVector& obj); template static TIntegral mean(const MVector& obj); template static TIntegral median(const MVector& obj); template static TIntegral rms(const MVector& obj); template static TIntegral var(const MVector& obj); template static TIntegral stdev(const MVector& obj); template static TIntegral dotProduct(const MVector& obj, const MVector& vector); template static TIntegral distanceSquare(const MVector& obj, const MVector& vector); template static int32 numEqual(const MVector& obj, TIntegral test_value); template static int32 numNotEqual(const MVector& obj, TIntegral test_value); // dsp methods // template static bool8 limit(MVector& obj, TIntegral min_val, TIntegral max_val, const MVector& vector); template static bool8 limitMin(MVector& obj, TIntegral min_val, const MVector& vector); template static bool8 limitMax(MVector& obj, TIntegral max_val, const MVector& vector); template static bool8 limitMag(MVector& obj, TIntegral cmp_val, TIntegral new_val, const MVector& vector); template static bool8 centerClip(MVector& obj, TIntegral min_val, TIntegral max_val, const MVector& vector); // random number generation methods // template static bool8 rand(MVector& obj, Random& generator); template static bool8 rand(MVector& obj, TIntegral min_val, TIntegral max_val, Random& generator); template static bool8 grand(MVector& obj, TIntegral mean, TIntegral stdev, Random& generator); // position operation methods // template static bool8 move(MVector& obj, const MVector& source_vector, int32 num_elements, int32 source_offset, int32 dest_offset); template static bool8 shift(MVector& obj, int32 delta); template static bool8 shift(MVector& obj, const MVector& source_vector, int32 delta); template static bool8 concat(MVector& obj, const MVector& v2); template static bool8 concat(MVector& obj, const MVector& v1, const MVector& v2); template static bool8 deleteRange(MVector& obj, const MVector& source_vector, int32 offset, int32 num_elements); template static bool8 setRange(MVector& obj, int32 offset, int32 num_elements, TIntegral value); // element location and ordering methods // template static int32 first(MVector& obj, TIntegral value, int32 start_pos); template static int32 last(MVector& obj, TIntegral value, int32 end_pos); template static bool8 reorder(MVector& obj, const MVector& indexes); template static bool8 reorder(MVector& obj, const MVector& arg, const MVector& indexes); template static bool8 reverse(MVector& obj); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // destructor/constructor(s): // the constructors and destructors are declared private so that a // compilation error will be generated if the user tries to construct an // object of this type // ~MVectorMethods(); MVectorMethods(); MVectorMethods(const MVectorMethods& arg); // additional diagnose methods: because of the complexity of diagnose, // we break it into smaller functions. // template static bool8 diagnose1(Integral::DEBUG level); template static bool8 diagnose2(Integral::DEBUG level); template static bool8 diagnose3(Integral::DEBUG level); template static bool8 diagnose4(Integral::DEBUG level); template static bool8 diagnose5(Integral::DEBUG level); template static bool8 diagnose6(Integral::DEBUG level); template static bool8 diagnose7(Integral::DEBUG level); template static bool8 diagnose8(Integral::DEBUG level); template static bool8 diagnose9(Integral::DEBUG level); // dummy name methods // static const String& name(); }; // end of include file // #endif