quick start:g++ [flags ...] file ...-l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <Statistics.h> Statistics(ALGORITHM algorithm = DEF_ALGORITHM); Statistics(const Statistics& arg); boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE); boolean compute(Vector <VectorFloat>& output, const Vector <VectorFloat>& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE);
description:Statistics stat0; Statistics stat1(stat0); VectorFloat input(L"0, 1, 2, 3, 4"); VectorFloat output; stat1.setAlgorithm(Statistics::MEDIAN); stat1.compute(output, input);
static const String CLASS_NAME = L"Statistics";
enum ALGORITHM { MINIMUM = 0, MINIMUM_MAG, MAXIMUM, MAXIMUM_MAG, MEAN, MEDIAN, VARIANCE, STDEV, SKEW, KURTOSIS, DEF_ALGORITHM = MINIMUM };
enum IMPLEMENTATION { LINEAR = 0, DEF_IMPLEMENTATION = LINEAR};
static const NameMap ALGO_MAP = L"MINIMUM, MINIMUM_MAG, MAXIMUM, MAXIMUM_MAG, MEAN, MEDIAN, VARIANCE, STDEV, SKEW, KURTOSIS";
static const NameMap IMPL_MAP = L"LINEAR";
static const String Statistics::DEF_PARAM = L"";
static const String Statistics::PARAM_ALGORITHM = L"algorithm";
static const String Statistics::PARAM_IMPLEMENTATION = L"implementation";
static const String Statistics::PARAM_CMODE = L"compute_mode";
static const String Statistics::PARAM_DMODE = L"data_mode";
static const long DEF_DELAY = 0;
static const long DEF_NUM_FRAMES = 0;
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::DEF_CTYPE;
static const long ERR = 71800;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
static MemoryManager mgr_d;
Vector<AlgorithmData> accum_sumsqr_d;
Vector<AlgorithmData> accum_sum_d;
Vector<AlgorithmData> accum_result_d;
Vector<AlgorithmData> accum_frame_data_d;
long accum_samples_d;
long accum_frames_d;
long accum_samples_d;
long accum_frames_d;
boolean is_calculated_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Statistics();
Statistics(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
Statistics(const Statistics& arg);
boolean assign(const Statistics& arg);
Statistics& operator= (const Statistics& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean eq(const Statistics& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);
boolean setAlgorithm(ALGORITHM algorithm);
boolean setImplementation(IMPLEMENTATION implementation);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
boolean setAccumulateVar(long num_channel, long dimension);
ALGORITHM getAlgorithm();
IMPLEMENTATION getImplementation() const;
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation) const;
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean assign(const AlgorithmBase& arg);
boolean eq(const AlgorithmBase& arg) const;
const String& className() const;
boolean init();
boolean apply(Vector<AlgorithmData>& output, const Vector<AlgorithmData>& input);
boolean setParser(SofParser* parser);
boolean readDataCommon(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeDataCommon(Sof& sof, const String& pname) const;
boolean computeFrameInt(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean computeFrameAccumulate(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean computeSampleAccumulate(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean computeMin(VectorFloat& output, const VectorFloat& input);
boolean computeMax(VectorFloat& output, const VectorFloat& input);
boolean computeMinMag(VectorFloat& output, const VectorFloat& input);
boolean computeMaxMag(VectorFloat& output, const VectorFloat& input);
boolean computeMean(VectorFloat& output, const VectorFloat& input);
boolean computeMedian(VectorFloat& output, const VectorFloat& input);
boolean computeVar(VectorFloat& output, const VectorFloat& input);
boolean computeStdDev(VectorFloat& output, const VectorFloat& input);
// isip include files // #include <Statistics.h> #include <Console.h> // main program starts here // int main(int argc, const char **argv) { // declare input // VectorFloat input; input.assign(L"0, 1, 2, 3"); // declare output // VectorFloat output; // define the expected results // VectorFloat exp_median(L"1.5"); VectorFloat exp_max(L"3"); VectorFloat exp_max_mag(L"3"); VectorFloat exp_min(L"0"); VectorFloat exp_min_mag(L"0"); VectorFloat exp_mean(L"1.5"); VectorFloat exp_var(L"1.25"); VectorFloat exp_stddev(L"1.11803"); // compute minimum // stat2.setAlgorithm(MINIMUM); stat2.compute(output, input); if (!output.almostEqual(exp_min)) { Console::put(L"Error in minimum"); } // compute maximum // stat2.setAlgorithm(MAXIMUM); stat2.compute(output, input); if (!output.almostEqual(exp_max)) { Console::put(L"Error in maximum"); } // compute median // stat2.setAlgorithm(MEDIAN); stat2.compute(output, input); if (!output.almostEqual(exp_median)) { Console::put(L"Error in median"); } // exit gracefully // return true; }