SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MeanShiftDataGenerator.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) 2012-2013 Heiko Strathmann
8  */
9 
10 #include <shogun/lib/common.h>
12 
13 using namespace shogun;
14 
17 {
18  init();
19 }
20 
22  index_t dimension, index_t dimension_shift) :
24 {
25  init();
26  set_mean_shift_model(mean_shift, dimension, dimension_shift);
27 }
28 
30 {
31 }
32 
34  index_t dimension, index_t dimension_shift)
35 {
36  REQUIRE(dimension_shift<dimension, "%s::set_mean_shift_model(%f,%d,%d): "
37  "Dimension of shift is larger than number of dimensions!\n",
38  mean_shift, dimension, dimension_shift);
39 
40  m_dimension=dimension;
41  m_mean_shift=mean_shift;
42  m_dimension_shift=dimension_shift;
43 }
44 
45 void CMeanShiftDataGenerator::init()
46 {
47  SG_ADD(&m_dimension, "dimension", "Dimension of data", MS_NOT_AVAILABLE);
48  SG_ADD(&m_mean_shift, "mean_shift", "Mean shift in one dimension",
50  SG_ADD(&m_dimension_shift, "m_dimension_shift", "Dimension of mean shift",
52 
53  m_dimension=0;
54  m_mean_shift=0;
56 
57  unset_generic();
58 }
59 
61 {
62  SG_SDEBUG("entering\n");
63 
64  /* allocate space */
66 
67  /* fill with std normal data */
68  for (index_t i=0; i<m_dimension; ++i)
69  result[i]=CMath::randn_double();
70 
71  /* mean shift in selected dimension */
73 
74  /* save example back to superclass */
76 
77  SG_SDEBUG("leaving\n");
78  return true;
79 }
80 
82 {
85 }
This class implements streaming features with dense feature vectors.
int32_t index_t
Definition: common.h:62
void unset_generic()
Definition: SGObject.cpp:336
static float64_t randn_double()
Definition: Math.h:1132
#define REQUIRE(x,...)
Definition: SGIO.h:206
SGVector< float64_t > current_vector
The current example's feature vector as an SGVector
double float64_t
Definition: common.h:50
void set_mean_shift_model(float64_t mean_shift, index_t dimension, index_t m_dimension_shift=0)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define SG_SDEBUG(...)
Definition: SGIO.h:168
#define SG_ADD(...)
Definition: SGObject.h:84

SHOGUN Machine Learning Toolbox - Documentation