quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <MutualInformation.h> MutualInformation(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, NORMALIZATION normalization = DEF_NORMALIZATION, long order = DEF_ORDER, long num_bins = DEF_NUM_BINS); boolean eq(const MutualInformation& arg); boolean assign(const MutualInformation& arg); boolean setAlgorithm(ALGORITHM algorithm); boolean setNormalization(NORMALIZATION normalization); boolean setOrder(long order); boolean setNumBins(long num_bins); boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE); boolean compute(VectorFloat& output, const VectorFloat& input1, const VectorFloat& input2, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE);
description:VectorFloat input(L"1.0, 2.0, 3.0, 4.0, 5.0, 9.0, 1.23, 2.3"); VectorFloat output; MutualInformation mi; mi.compute(output, input);
static const String CLASS_NAME = L"MutualInformation";
enum ALGORITHM { AUTO = 0, CROSS, DEF_ALGORITHM = AUTO };
enum IMPLEMENTATION { HISTOGRAM = 0, DEF_IMPLEMENTATION = HISTOGRAM };
the mode choices are defined in an enumeration in the base class
enum NORMALIZATION { NONE = 0, DEF_NORMALIZATION = NONE };
static const NameMap ALGO_MAP = L"AUTO, CROSS";
static const NameMap IMPL_MAP = L"HISTOGRAM";
static const NameMap NORM_MAP = L"NONE";
static const String MutualInformation::DEF_PARAM = L"";
static const String MutualInformation::PARAM_ALGORITHM = L"algorithm";
static const String MutualInformation::PARAM_IMPLEMENTATION = L"implementation";
static const String MutualInformation::PARAM_NORMALIZATION = L"normalization";
static const String MutualInformation::PARAM_MODE = L"mode";
static const String MutualInformation::PARAM_ORDER = L"order";
static const String MutualInformation::PARAM_NUM_BINS = L"num_bins";
static const long DEF_ORDER = -1;
static const long DEF_NUM_BINS = -1;
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SIGNAL;
static const long ERR = 73700;
static const long ERR_INPUT = 73701;
static const long ERR_DATA = 73702;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
NORMALIZATION normalization_d;
Long order_d;
Long num_bins_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~MutualInformation();
MutualInformation(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, NORMALIZATION normalization = DEF_NORMALIZATION, long order = DEF_ORDER, long num_bins = DEF_NUM_BINS);
MutualInformation(const MutualInformation& arg);
boolean assign(const MutualInformation& arg);
MutualInformation& operator= (const MutualInformation& 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 MutualInformation& 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 setNormalization(NORMALIZATION normalization);
boolean setOrder(long order);
boolean setNumBins(long num_bins);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, NORMALIZATION normalization = DEF_NORMALIZATION, long order = DEF_ORDER, long num_bins = DEF_NUM_BINS);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
NORMALIZATION getNormalization() const;
long getOrder() const;
long getNumBins() const;
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, NORMALIZATION& normalization, long& order, long& num_bins);
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long channel_index = DEF_CHANNEL_INDEX);
boolean compute(VectorFloat& output, const VectorFloat& input1, const VectorFloat& input2, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long channel_index = DEF_CHANNEL_INDEX);
boolean assign(const AlgorithmBase& arg);
boolean eq(const AlgorithmBase& arg) const;
const String& className() const;
boolean apply(Vector<AlgorithmData>& output, const Vector< CircularBuffer<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 computeAutoMutualInformation(VectorFloat& mi, const VectorFloat& time_series);
boolean computeCrossMutualInformation(VectorFloat& mi, const VectorFloat& time_series_1, const VectorFloat& time_series_2);
// declare the MutualInformation object // MutualInformation mi; // declare the input and output vectors // VectorFloat input(L"1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0"); VectorFloat output; // set the algorithm, implementation, normalization, and order // mi.setAlgorithm(MutualInformation::AUTO); mi.setImplementation(MutualInformation::HISTOGRAM); mi.setOrder(3); mi.setNumBins(3); // compute the autocorrelation output // mi.compute(output, input);
// declare the MutualInformation object // MutualInformation cmi; // declare the input and output vectors // VectorFloat ref(L"1, 1, 2, 3, 2, 1, 1, 1"); VectorFloat tst(L"2, 3, 2"); VectorFloat output; // set the algorithm, implementation, normalization, and order // cmi.setAlgorithm(MutualInformation::CROSS); cmi.setImplementation(MutualInformation::HISTOGRAM); cmi.setOrder(3); cmi.setNumBins(4); // compute the cross-correlation // cmi.compute(output, ref, tst);