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