SHOGUN  6.1.3
DotFeatures.h
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) 2009-2010 Soeren Sonnenburg
8  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  * Copyright (C) 2010 Berlin Institute of Technology
10  */
11 
12 #ifndef _DOTFEATURES_H___
13 #define _DOTFEATURES_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
19 #include <shogun/lib/SGMatrix.h>
20 
21 namespace shogun
22 {
44 class CDotFeatures : public CFeatures
45 {
46  public:
47 
52  CDotFeatures(int32_t size=0);
53 
55  CDotFeatures(const CDotFeatures & orig);
56 
61  CDotFeatures(CFile* loader);
62 
63  virtual ~CDotFeatures() { }
64 
72  virtual int32_t get_dim_feature_space() const=0;
73 
81  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2)=0;
82 
88  virtual float64_t dense_dot_sgvec(int32_t vec_idx1, const SGVector<float64_t> vec2);
89 
96  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len)=0;
97 
106  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false)=0;
107 
121  virtual void dense_dot_range(float64_t* output, int32_t start, int32_t stop, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
122 
134  virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
135  float64_t* output, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
136 
144  virtual int32_t get_nnz_features_for_vector(int32_t num)=0;
145 
151 
157 
163 
169 
171  void benchmark_add_to_dense_vector(int32_t repeats=5);
172 
174  void benchmark_dense_dot_range(int32_t repeats=5);
175 
185  virtual void* get_feature_iterator(int32_t vector_index)=0;
186 
197  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)=0;
198 
204  virtual void free_feature_iterator(void* iterator)=0;
205 
210  virtual SGVector<float64_t> get_mean();
211 
216  static SGVector<float64_t>
218 
231  virtual SGMatrix<float64_t> get_cov(bool copy_data_for_speed = true);
232 
239  CDotFeatures* lhs, CDotFeatures* rhs,
240  bool copy_data_for_speed = true);
241 
242  private:
243  void init();
244 
245  protected:
246 
249 };
250 }
251 #endif // _DOTFEATURES_H___
virtual void dense_dot_range(float64_t *output, int32_t start, int32_t stop, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
Definition: DotFeatures.cpp:53
virtual int32_t get_nnz_features_for_vector(int32_t num)=0
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)=0
virtual SGMatrix< float64_t > get_cov(bool copy_data_for_speed=true)
CDotFeatures(int32_t size=0)
Definition: DotFeatures.cpp:28
static SGMatrix< float64_t > compute_cov(CDotFeatures *lhs, CDotFeatures *rhs, bool copy_data_for_speed=true)
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)=0
virtual ~CDotFeatures()
Definition: DotFeatures.h:63
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)=0
void benchmark_dense_dot_range(int32_t repeats=5)
virtual float64_t dense_dot_sgvec(int32_t vec_idx1, const SGVector< float64_t > vec2)
Definition: DotFeatures.cpp:48
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual int32_t get_dim_feature_space() const =0
virtual SGVector< float64_t > get_mean()
static SGVector< float64_t > compute_mean(CDotFeatures *lhs, CDotFeatures *rhs)
virtual void dense_dot_range_subset(int32_t *sub_index, int32_t num, float64_t *output, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
double float64_t
Definition: common.h:60
virtual void free_feature_iterator(void *iterator)=0
A File access base class.
Definition: File.h:34
void benchmark_add_to_dense_vector(int32_t repeats=5)
virtual void * get_feature_iterator(int32_t vector_index)=0
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)=0
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:69
SGVector< float64_t > get_computed_dot_feature_vector(int32_t num)
void set_combined_feature_weight(float64_t nw)
Definition: DotFeatures.h:156
float64_t combined_weight
feature weighting in combined dot features
Definition: DotFeatures.h:248
SGMatrix< float64_t > get_computed_dot_feature_matrix()
float64_t get_combined_feature_weight()
Definition: DotFeatures.h:150

SHOGUN Machine Learning Toolbox - Documentation