SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
lib
computation
aggregator
StoreScalarAggregator.cpp
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2013 Soumyajit De
8
*/
9
10
#include <
shogun/lib/config.h
>
11
#include <
shogun/lib/computation/jobresult/ScalarResult.h
>
12
#include <
shogun/lib/computation/aggregator/StoreScalarAggregator.h
>
13
14
namespace
shogun
15
{
16
template
<
class
T>
17
CStoreScalarAggregator<T>::CStoreScalarAggregator
()
18
:
CJobResultAggregator
()
19
{
20
init();
21
}
22
23
template
<
class
T>
24
void
CStoreScalarAggregator<T>::init
()
25
{
26
m_aggregate=
static_cast<
T
>
(0);
27
28
set_generic<T>();
29
30
SG_ADD
(&m_aggregate,
"current_aggregate"
,
31
"Aggregation of computation job results"
,
MS_NOT_AVAILABLE
);
32
}
33
34
template
<
class
T>
35
CStoreScalarAggregator<T>::~CStoreScalarAggregator
()
36
{
37
}
38
39
template
<
class
T>
40
void
CStoreScalarAggregator<T>::submit_result
(
CJobResult
* result)
41
{
42
SG_GCDEBUG
(
"Entering\n"
)
43
44
// check for proper typecast
45
CScalarResult<T>
* new_result=
dynamic_cast<
CScalarResult<T>
*
>
(result);
46
if
(!new_result)
47
SG_ERROR
(
"result is not of CScalarResult type!\n"
);
48
// aggregate it with previous
49
m_aggregate+=new_result->
get_result
();
50
51
SG_GCDEBUG
(
"Leaving\n"
)
52
}
53
54
template
<>
55
void
CStoreScalarAggregator<bool>::submit_result
(
CJobResult
* result)
56
{
57
SG_NOTIMPLEMENTED
58
}
59
60
template
<>
61
void
CStoreScalarAggregator<char>::submit_result
(
CJobResult
* result)
62
{
63
SG_NOTIMPLEMENTED
64
}
65
66
template
<
class
T>
67
void
CStoreScalarAggregator<T>::finalize
()
68
{
69
m_result=(
CJobResult
*)(
new
CScalarResult<T>
(m_aggregate));
70
SG_REF
(m_result);
71
}
72
73
template
class
CStoreScalarAggregator<bool>
;
74
template
class
CStoreScalarAggregator<char>
;
75
template
class
CStoreScalarAggregator<int8_t>
;
76
template
class
CStoreScalarAggregator<uint8_t>
;
77
template
class
CStoreScalarAggregator<int16_t>
;
78
template
class
CStoreScalarAggregator<uint16_t>
;
79
template
class
CStoreScalarAggregator<int32_t>
;
80
template
class
CStoreScalarAggregator<uint32_t>
;
81
template
class
CStoreScalarAggregator<int64_t>
;
82
template
class
CStoreScalarAggregator<uint64_t>
;
83
template
class
CStoreScalarAggregator<float32_t>
;
84
template
class
CStoreScalarAggregator<float64_t>
;
85
template
class
CStoreScalarAggregator<floatmax_t>
;
86
template
class
CStoreScalarAggregator<complex128_t>
;
87
}
SHOGUN
Machine Learning Toolbox - Documentation