SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
OperatorFunction.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2013 Soumyajit De
00008  */
00009 
00010 #ifndef OPERATOR_FUNCTION_H_
00011 #define OPERATOR_FUNCTION_H_
00012 
00013 #include <shogun/lib/config.h>
00014 #include <shogun/base/SGObject.h>
00015 #include <shogun/base/Parameter.h>
00016 #include <shogun/mathematics/linalg/linop/LinearOperator.h>
00017 #include <shogun/lib/computation/engine/IndependentComputationEngine.h>
00018 
00019 namespace shogun
00020 {
00021 
00023 enum EOperatorFunction
00024 {
00025     OF_SQRT=0,
00026     OF_LOG=1,
00027     OF_POLY=2,
00028     OF_UNDEFINED=3
00029 };
00030 
00031 template<class T> class SGVector;
00032 class CJobResultAggregator;
00033 template<class T> class CLinearOperator;
00034 
00040 template<class T> class COperatorFunction : public CSGObject
00041 {
00042 public:
00044     COperatorFunction()
00045     : CSGObject(),
00046       m_function_type(OF_UNDEFINED)
00047     {
00048         init();
00049     }
00050 
00058     COperatorFunction(CLinearOperator<T>* op,
00059         CIndependentComputationEngine* engine,
00060         EOperatorFunction type=OF_UNDEFINED)
00061     : CSGObject(),
00062       m_function_type(type)
00063     {
00064         init();
00065 
00066         m_linear_operator=op;
00067         SG_REF(m_linear_operator);
00068 
00069         m_computation_engine=engine;
00070         SG_REF(m_computation_engine);
00071     }
00072 
00074     virtual ~COperatorFunction()
00075     {
00076         SG_UNREF(m_linear_operator);
00077         SG_UNREF(m_computation_engine);
00078     }
00079 
00081     CLinearOperator<T>* get_operator() const
00082     {
00083         return m_linear_operator;
00084     }
00085 
00091     virtual void precompute() = 0;
00092 
00103     virtual CJobResultAggregator* submit_jobs(SGVector<T> sample) = 0;
00104 
00106     virtual const char* get_name() const
00107     {
00108         return "OperatorFunction";
00109     }
00110 protected:
00112     CLinearOperator<T>* m_linear_operator;
00113 
00115     CIndependentComputationEngine* m_computation_engine;
00116 
00118     const EOperatorFunction m_function_type;
00119 
00120 private:
00122     void init()
00123     {
00124       m_linear_operator=NULL;
00125       m_computation_engine=NULL;
00126 
00127         SG_ADD((CSGObject**)&m_linear_operator, "linear_operator",
00128             "Linear operator of this operator function", MS_NOT_AVAILABLE);
00129 
00130         SG_ADD((CSGObject**)&m_computation_engine, "computation_engine",
00131             "Computation engine for the jobs this will generate", MS_NOT_AVAILABLE);
00132     }
00133 };
00134 }
00135 
00136 #endif // OPERATOR_FUCNTION_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation