00001 #ifndef __SingleUnitFastIca__
00002 #define __SingleUnitFastIca__
00003
00027 #include "AContrastFunction.hpp"
00028 #include "RealVector.hpp"
00029 #include "RealSMatrix.hpp"
00030
00031 class SingleUnitFastIca
00032 {
00033 protected:
00034
00035 AContrastFunction* contrast;
00036
00037 RealVector* wold;
00038 RealVector* w;
00039
00040 int count;
00041 RealVector* evg;
00042 RealVector* evg_Cinv;
00043 double evgdiff;
00044
00045 double epsilon;
00046
00047 public:
00048
00049 SingleUnitFastIca(double eps=1.0e-4);
00050 SingleUnitFastIca(AContrastFunction* func, double eps)
00051 {contrast=func; w=0; wold=0; evg=0; evgdiff=0.0; count=0; epsilon=eps; }
00052 virtual ~SingleUnitFastIca()
00053 {
00054 if( w != 0 )
00055 {
00056 delete w;
00057 delete wold;
00058
00059 delete evg;
00060 }
00061 }
00062
00063 virtual void set(AContrastFunction* func){contrast= func;}
00064
00065 virtual RealVector* getW(){return w;}
00066
00067
00068 virtual void init(int size);
00069
00070 virtual void startLearning()
00071 { count=0; evg->setAll(0.0); evg_Cinv->setAll(0.0); evgdiff=0.0; }
00072 virtual void learn(RealVector* sample);
00073 virtual bool endLearning();
00074 virtual bool endLearning(RealSMatrix* C, RealSMatrix* Cinv);
00075
00076 virtual void normalizeW();
00077 virtual void normalizeW(RealSMatrix* C);
00078
00079
00080 virtual double forward(RealVector* src);
00081
00082 virtual void output()
00083 {
00084 printf("Single Unit FastICA");
00085 }
00086 };
00087
00088 #endif