SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StreamingDotFeatures.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) 2011 Shashwat Lal Das
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
11 
12 using namespace shogun;
13 
15 {
17 }
18 
20  float64_t* lab)
21 {
23  return;
24 }
25 
27 {
28 }
29 
31  float32_t* vec, int32_t dim, float32_t b, int32_t num_vec)
32 {
33  ASSERT(num_vec>=0)
34 
35  int32_t counter=0;
36  start_parser();
37  while (get_next_example())
38  {
39  if (alphas)
40  output[counter]=alphas[counter]*dense_dot(vec, dim)+b;
41  else
42  output[counter]=dense_dot(vec, dim)+b;
43 
45 
46  counter++;
47  if ((counter>=num_vec) && (num_vec>0))
48  break;
49  }
50  end_parser();
51 }
52 
54 {
55  int32_t dim = get_dim_feature_space();
56  if (dim > len)
57  {
58  vec = SG_REALLOC(float32_t, vec, len, dim);
59  memset(&vec[len], 0, (dim-len) * sizeof(float32_t));
60  len = dim;
61  }
62 }
63 
65 {
66  int32_t dim = get_dim_feature_space();
67  if (dim > len)
68  {
69  vec = SG_REALLOC(float64_t, vec, len, dim);
70  memset(&vec[len], 0, (dim-len) * sizeof(float64_t));
71  len = dim;
72  }
73 }
74 
76 {
78  return NULL;
79 }
80 
82 {
84  return -1;
85 }
86 
87 bool CStreamingDotFeatures::get_next_feature(int32_t& index, float32_t& value, void* iterator)
88 {
90  return false;
91 }
92 
94 {
96  return;
97 }
virtual void start_parser()=0
virtual float32_t dense_dot(const float32_t *vec2, int32_t vec2_len)=0
virtual void free_feature_iterator(void *iterator)
void set_property(EFeatureProperty p)
Definition: Features.cpp:300
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:139
virtual void dense_dot_range(float32_t *output, float32_t *alphas, float32_t *vec, int32_t dim, float32_t b, int32_t num_vec=0)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual bool get_next_feature(int32_t &index, float32_t &value, void *iterator)
virtual int32_t get_dim_feature_space() const =0
virtual bool get_next_example()=0
#define ASSERT(x)
Definition: SGIO.h:201
double float64_t
Definition: common.h:50
virtual void expand_if_required(float32_t *&vec, int32_t &len)
float float32_t
Definition: common.h:49
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual void end_parser()=0
virtual void release_example()=0
Streaming features are features which are used for online algorithms.
virtual int32_t get_nnz_features_for_vector()

SHOGUN Machine Learning Toolbox - Documentation