quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <Calculus.h> Calculus(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER, long delta_win = DEF_DELTAWIN); boolean setAlgorithm(ALGORITHM algorithm); boolean setImplementation(IMPLEMENTATION implementation); boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type);
description:VectorFloat input(L"1.0, 2.0, 0.0, -1.0, -2.0"); VectorFloat output; Calculus calc; calc.setAlgorithm(Calculus::DIFFERENTIATION); calc.setImplementation(Calculus::REGRESSION); calc.setOrder(1); calc.setDeltaWindow(2); calc.compute(output, input);
static const String CLASS_NAME = L"Calculus";
enum ALGORITHM { DIFFERENTIATION = 0, INTEGRATION, DEF_ALGORITHM = DIFFERENTIATION };
enum IMPLEMENTATION { REGRESSION = 0, CENTRAL_DIFFERENCE, BACKWARD_DIFFERENCE, DEF_IMPLEMENTATION = REGRESSION };
static const NameMap Calculus::ALGO_MAP(L"DIFFERENTIATION, INTEGRATION");
static const NameMap Calculus::IMPL_MAP(L"REGRESSION, CENTRAL_DIFFERENCE, BACKWARD_DIFFERENCE");
static const String Calculus::DEF_PARAM = L"";
static const String Calculus::PARAM_ALGORITHM = L"algorithm";
static const String Calculus::PARAM_IMPLEMENTATION = L"implementation";
static const String Calculus::PARAM_MODE = L"mode";
static const String Calculus::PARAM_ORDER = L"order";
static const String Calculus::PARAM_DELTAWIN = L"delta_win";
static const long DEF_ORDER = 1;
static const long DEF_DELTAWIN = 2;
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::GENERIC;
static const long ERR = 70200;
static const long ERR_ZERODENOM = 70201;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
Long order_d;
static MemoryManager mgr_d;
Long delta_win_d;
double denom_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Calculus();
Calculus(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER, long delta_win = DEF_DELTAWIN);
Calculus(const Calculus& arg);
boolean assign(const Calculus& arg);
Calculus& operator= (const Calculus& 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 Calculus& 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 setOrder(long order);
boolean setDeltaWindow(long delta_win);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER, long delta_win = DEF_DELTAWIN);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
long getOrder() const;
long getDeltaWindow() const;
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, long& order, long& delta_win) const;
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean compute(VectorComplexFloat& output, const VectorComplexFloat& input, AlgorithmData::COEF_TYPE 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);
long getLeadingPad() const;
long getTrailingPad() const;
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 computeInternal(VectorFloat& output, const CircularBuffer<AlgorithmData>& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long channel_index = DEF_CHANNEL_INDEX);
boolean computeCross(VectorFloat& output, const CircularBuffer<AlgorithmData>& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long channel_index = DEF_CHANNEL_INDEX);
boolean computeDifRegression(VectorFloat& output, const VectorFloat& input);
boolean computeDifCentral(VectorFloat& output, const VectorFloat& input);
boolean computeDifBackward(VectorFloat& output, const VectorFloat& input);
// configure a Calculus object // Calculus calc; calc.setAlgorithm(Calculus::DIFFERENTIATION); calc.setImplementation(Calculus::REGRESSION); calc.setOrder(1); calc.setDeltaWindow(2); // create input and output data // VectorFloat input(L"1.0, 2.0, 0.0, -1.0, -2.0"); VectorFloat output; // calculate the result // calc.compute(output, input); output.debug(L"output");
// configure a Calculus object // Calculus calc; calc.setAlgorithm(Calculus::DIFFERENTIATION); calc.setImplementation(Calculus::BACKWARD_DIFFERENCE); calc.setOrder(1); calc.setDeltaWindow(2); // create input and output data // VectorFloat input(L"1.0, 2.0, 0.0"); VectorFloat output; // calculate the result // calc.compute(output, input); output.debug(L"output");