SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
Base class that stores the result of an independent job when the result is a scalar.
Definition: ScalarResult.h:24
std::complex< float64_t > complex128_t
Definition: common.h:67
Abstract template class that aggregates vector job results in each submit_result call, finalize is abstract.
SGVector< float64_t > get_imag()
Definition: SGVector.cpp:891
Definition: SGMatrix.h:20
#define SG_REF(x)
Definition: SGObject.h:51
index_t vlen
Definition: SGVector.h:494
#define SG_GCDEBUG(...)
Definition: SGIO.h:102
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
double float64_t
Definition: common.h:50
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
Abstract template base class that represents a linear operator, e.g. a matrix.
#define SG_ADD(...)
Definition: SGObject.h:81

SHOGUN Machine Learning Toolbox - Documentation