name: Algorithm : public AlgorithmBase
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a

>     #include <Algorithm.h>

>     Algorithm alg;
>     boolean assign(const AlgorithmBase* arg);
>     boolean setType(TYPES type);
>     boolean apply(AlgorithmData& output, const CircularBuffer& input, BUF_MODE mode = DEF_BUF_MODE);
>     boolean setSampleFrequency(float sf);
>     boolean setFrameDuration(float dur);
>     long getLeadingPad() const;
>     long getTrailingPad() const;
>     boolean init();

quick start:

>     Algorithm alg;

>     // test Window
>     //
>     alg.setType(Algorithm::WINDOW);
>     Window win;
>     win.setSize(5);
>     win.setAlgorithm(Window::RECTANGULAR);
>     alg.assign(win);

>     AlgorithmData uw_sig;
>     uw_sig.makeVectorFloat().assign(L"1, 2, 1, 3, 4, 2, 3, 1");

>     // need to produce a Vector<CircularBuffer<AlgorithmData>>
>     //
>     Vector<CircularBuffer<AlgorithmData>>tmp_buf(1);
>     tmp_buf(0).append(uw_sig);

>     alg.apply(output, tmp_buf);

description:
Algorithm is a class that transforms data by invoking any of the algorithms included in the Algorithm library using a virtual function interface. It inherits the AlgorithmBase class, which is an abstract base class having virtual functions. The virtual functions allow the derived class to replace the functionality provided by the base class. The AlgorithmBase class defines the interface contract for all Algorithm class (e.g., Energy). The AlgorithmData class is simply a container class for data passed by the algorithm classes.
dependencies:

- AlgorithmBase
- AlgorithmUndefined
- CoefficientLabel
- Output
- MemoryManager
- NameMap

public constants:

- define the class name:

      static const String CLASS_NAME = L"Algorithm";

- define the enumeration for data type:

      enum TYPES {ALGORITHM_CONTAINER = 0, CALCULUS, CEPSTRUM, COEFFICIENT_LABEL,
      	    CONNECTION, CONSTANT, CORRELATION, COVARIANCE,
      	    DISPLAY_DATA, ENERGY, FILTER, FILTER_BANK, FOURIER_TRANSFORM,
      	    GENERATOR, LOG_AREA_RATIO, MASK, MATH, OUTPUT,
      	    PREDICTION, REFLECTION, SPECTRUM, STATISTICS, WINDOW,
                  CORRELATION_INTEGRAL, MUTUAL_INFORMATION, CORRELATION_DIMENSION, DEF_TYPES = CALCULUS};

- define the static NameMap objects:

      static const NameMap TYPES_MAP = L"AlgorithmContainer, Calculus, Cepstrum, CoefficientLabel, Connection, Constant, Correlation, Covariance, DisplayData, Energy, Filter, FilterBank, FourierTransform, Generator, LogAreaRatio, Mask, Math, Output, Prediction, Reflection, Spectrum, Statistics, Window, CorrelationIntegral, MutualInformation, CorrelationDimension";

- define i/o related constants:

      static const String DEF_PARAM = L"";

      static const String PARAM_TYPE = L"name";

error codes:

- general error codes:

      static const long ERR = 70050;

protected data:

- parameters related to the transform specification:

      AlgorithmBase* virtual_algo_d;

- an empty object used for uninitialized things

      static AlgorithmUndefined NO_ALGORITHM;

- static memory manager:

      static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

- debug methods: setDebug method is inherited from the base class

      boolean debug(const unichar* message) const;

- destructor/constructor(s):

      ~Algorithm();

      Algorithm();

      Algorithm(const Algorithm& arg);

- assign methods:

      boolean assign(const Algorithm& arg);

- i/o methods:

      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;

- equality methods:

      boolean eq(const Algorithm& arg) const;

- memory management methods:

      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);

class-specific public methods:

- set methods:

      boolean setInputFilename(String& filename);

      boolean setOutputDirectory(String& new_dir);

      boolean setOutputBasenmae(String& new_basename);

      boolean setOutputExtension(String& new_ext);

      boolean setOutputPreserve(long new_preserve_level);

      boolean setOutputSuffix(String& new_suffix);

      boolean setOutputType(File::TYPE new_type);

      boolean setSampleFrequency(float sf);

      boolean setGenSampleFrequency(float sf);

      boolean setFrameDuration(float dur);

      boolean setSignalDuration(float dur);

      boolean setLeftoverSamps(long samps);

      boolean setFrameIndex(long index);

      boolean setType(TYPES type);

- get methods:

      boolean getInputFilename(Filename& filename) const;

      boolean getInputFilename(String& filename) const;

      boolean getOutputFilename(String& filename) const;

      boolean getOutputDirectory(String& directory) const;

      boolean getOutputBasename(String basename) const;

      boolean getOutputExtension(String extension) const;

      boolean getOutputPreserve() const;

      boolean getOutputSuffix(String suffix) const;

      boolean getGenSampleFrequency(Float& sf) const;

- other miscellaneous get methods:

      TYPES getType() const;

      const String& getCLabelVariable() const;

      CoefficientLabel::TYPE getCLabelType() const;

      long getContainerGraphTag() const;

- AlgorithmBase interface contract methods:

      boolean assign(const AlgorithmBase& arg);

      boolean eq(const AlgorithmBase& arg) const;

      const String& className() const;

      boolean init();

      boolean apply(Vector<AlgorithmData>& output, const Vector< CircularBuffer<AlgorithmData> >& input);

      long getLeadingPad() const;

      long getTrailingPad() const;

private methods:

- none

examples:

- This example shows how to set the type of Algorithm to be Energy and then call the apply() method:

      // isip include files
      //
      #include <Energy.h>
      #include <Algorithm.h>

      // main program starts here
      //
      int main(int argc, const char** argv) {

        // declare an Energy object and an output vector
        //
        Energy egy;
        Vector<AlgorithmData> output(0);

        // declare a Algorithm object
        //
        Algorithm alg;

        // set the algo type to Energy and assign the object
        //
        alg.setType(Algorithm::ENERGY);
        alg.assign(egy);

        AlgorithmData uw_sig;

        uw_sig.makeVectorFloat().assign(L"1, 2, 1, 3, 4, 2, 3, 1");

        // need to produce a Vector<CircularBuffer<AlgoData>>
        //
        Vector< CircularBuffer<AlgorithmData> > tmp_buf(1);
        tmp_buf(0).append(uw_sig);

        alg.apply(output, tmp_buf);

        uw_sig.debug(L"uw_sig");
        output.debug(L"output");

        // exit gracefully
        //
        Integral::exit();
      }

notes:

- The primary use of this class is in isip_transform. Most programmers will not need to worry about the details of this class.