SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndividualJobResultAggregator.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 
12 #ifdef HAVE_EIGEN3
13 #include <shogun/lib/SGVector.h>
15 #include <shogun/base/Parameter.h>
19 
20 using namespace Eigen;
21 
22 namespace shogun
23 {
24 CIndividualJobResultAggregator::CIndividualJobResultAggregator()
26  m_const_multiplier(0.0)
27 {
28  init();
29 
30  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
31 }
32 
35  SGVector<float64_t> vector,
36  const float64_t& const_multiplier)
37  : CStoreVectorAggregator<complex128_t>(vector.vlen),
38  m_const_multiplier(const_multiplier)
39 {
40  init();
41 
42  m_vector=vector;
43 
44  m_linear_operator=linear_operator;
45  SG_REF(m_linear_operator);
46 
47  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
48 }
49 
50 void CIndividualJobResultAggregator::init()
51 {
52  m_linear_operator=NULL;
53 
54  SG_ADD(&m_vector, "sample_vector",
55  "The sample vector to perform final dot product", MS_NOT_AVAILABLE);
56 
57  SG_ADD((CSGObject**)&m_linear_operator, "linear_operator",
58  "The linear operator to apply on the aggregation", MS_NOT_AVAILABLE);
59 }
60 
62 {
63  SG_UNREF(m_linear_operator);
64 
65  SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this)
66 }
67 
69 {
70  // take out the imaginary part of the aggegation before
71  // applying linear operator
73  SGVector<float64_t> agg=m_linear_operator->apply(imag_agg);
74 
75  // perform dot product
76  Map<VectorXd> map_agg(agg.vector, agg.vlen);
77  Map<VectorXd> map_vector(m_vector.vector, m_vector.vlen);
78  float64_t result=map_vector.dot(map_agg);
79 
80  result*=m_const_multiplier;
81 
82  // form the final result into a scalar result
85 }
86 
87 }
88 #endif // HAVE_EIGEN3

SHOGUN Machine Learning Toolbox - Documentation