SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StoreVectorAggregator.cpp
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 #include <shogun/lib/config.h>
00011 #include <shogun/lib/SGVector.h>
00012 #include <shogun/lib/computation/jobresult/VectorResult.h>
00013 #include <shogun/lib/computation/aggregator/StoreVectorAggregator.h>
00014 #include <shogun/base/Parameter.h>
00015 
00016 namespace shogun
00017 {
00018 template<class T>
00019 CStoreVectorAggregator<T>::CStoreVectorAggregator()
00020     : CJobResultAggregator()
00021     {
00022         init();
00023         SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
00024     }
00025 
00026 template<class T>
00027 CStoreVectorAggregator<T>::CStoreVectorAggregator(index_t dimension)
00028     : CJobResultAggregator()
00029     {
00030         init();
00031 
00032         m_aggregate=SGVector<T>(dimension);
00033         m_aggregate.set_const(static_cast<T>(0));
00034     }
00035 
00036 template<class T>
00037 void CStoreVectorAggregator<T>::init()
00038     {
00039         SG_ADD(&m_aggregate, "current_aggregate",
00040             "Aggregation of computation job results", MS_NOT_AVAILABLE);
00041     }
00042 
00043 template<class T>
00044 CStoreVectorAggregator<T>::~CStoreVectorAggregator()
00045     {
00046     }
00047 
00048 template<class T>
00049 void CStoreVectorAggregator<T>::submit_result(CJobResult* result)
00050     {
00051         SG_GCDEBUG("Entering\n")
00052 
00053         // check for proper typecast
00054         CVectorResult<T>* new_result=dynamic_cast<CVectorResult<T>*>(result);
00055         if (!new_result)
00056             SG_ERROR("result is not of CVectorResult type!\n");
00057         // aggregate it with previous
00058         m_aggregate+=new_result->get_result();
00059 
00060         SG_GCDEBUG("Leaving\n")
00061     }
00062 
00063 template<>
00064 void CStoreVectorAggregator<bool>::submit_result(CJobResult* result)
00065     {
00066         SG_NOTIMPLEMENTED
00067     }
00068 
00069 template<>
00070 void CStoreVectorAggregator<char>::submit_result(CJobResult* result)
00071     {
00072         SG_NOTIMPLEMENTED
00073     }
00074 
00075 template class CStoreVectorAggregator<bool>;
00076 template class CStoreVectorAggregator<char>;
00077 template class CStoreVectorAggregator<int8_t>;
00078 template class CStoreVectorAggregator<uint8_t>;
00079 template class CStoreVectorAggregator<int16_t>;
00080 template class CStoreVectorAggregator<uint16_t>;
00081 template class CStoreVectorAggregator<int32_t>;
00082 template class CStoreVectorAggregator<uint32_t>;
00083 template class CStoreVectorAggregator<int64_t>;
00084 template class CStoreVectorAggregator<uint64_t>;
00085 template class CStoreVectorAggregator<float32_t>;
00086 template class CStoreVectorAggregator<float64_t>;
00087 template class CStoreVectorAggregator<floatmax_t>;
00088 template class CStoreVectorAggregator<complex128_t>;
00089 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation