11 parser.set_free_vector_after_release(
false);
19 init(file, is_labelled, size);
21 parser.set_free_vector_after_release(
false);
45 init(file, is_labelled, size);
47 parser.set_free_vector_after_release(
false);
48 parser.set_free_vectors_on_destruct(
false);
63 parser.init(working_file, has_labels, 1);
64 parser.set_free_vector_after_release(
false);
65 parser.start_parser();
71 ASSERT(vec2_len==current_length);
74 for (int32_t i=0; i<current_length; i++)
75 result+=current_vector[i]*vec2[i];
82 ASSERT(vec2_len==current_length);
85 for (int32_t i=0; i<current_length; i++)
86 result+=current_vector[i]*vec2[i];
93 ASSERT(vec2_len==current_length);
97 for (int32_t i=0; i<current_length; i++)
102 for (int32_t i=0; i<current_length; i++)
103 vec2[i]+=alpha*current_vector[i];
109 ASSERT(vec2_len==current_length);
113 for (int32_t i=0; i<current_length; i++)
118 for (int32_t i=0; i<current_length; i++)
119 vec2[i]+=alpha*current_vector[i];
125 return current_length;
157 #define GET_FEATURE_TYPE(f_type, sg_type) \
158 template<> EFeatureType CStreamingSimpleFeatures<sg_type>::get_feature_type() \
176 #undef GET_FEATURE_TYPE
180 void CStreamingSimpleFeatures<T>::init()
189 void CStreamingSimpleFeatures<T>::init(CStreamingFile* file,
194 has_labels = is_labelled;
196 parser.init(file, is_labelled, size);
203 if (!parser.is_running())
204 parser.start_parser();
217 ret_value = (bool) parser.get_next_example(current_vector,
227 current_sgvector.vector=current_vector;
228 current_sgvector.vlen=current_length;
230 return current_sgvector;
238 return current_label;
244 parser.finalize_example();
250 return current_length;
274 if (len1 != current_length)
275 SG_ERROR(
"Lengths %d and %d not equal while computing dot product!\n", len1, current_length);
284 return current_length;
virtual float32_t dot(SGVector< T > vec)
virtual int32_t get_size()
int32_t get_num_features()
virtual void release_example()
virtual EFeatureType get_feature_type()=0
virtual float64_t get_label()
CInputParser< T > parser
The parser object, which reads from input and returns parsed example objects.
virtual void get_vector(bool *&vector, int32_t &len)
virtual CFeatures * duplicate() const
EFeatureClass
shogun feature class
virtual void set_vector_reader()
A Streaming File access class.
virtual int32_t get_nnz_features_for_vector()
virtual EFeatureClass get_feature_class()=0
virtual int32_t get_num_vectors() const
virtual void start_parser()
virtual void end_parser()
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
static SGVector get_vector(SGVector &src, bool own=true)
virtual void set_vector_and_label_reader()
Streaming features that support dot products among other operations.
virtual float32_t dense_dot(const float32_t *vec2, int32_t vec2_len)
virtual void get_vector_and_label(bool *&vector, int32_t &len, float64_t &label)
#define GET_FEATURE_TYPE(f_type, sg_type)
SGVector< T > get_vector()
CStreamingSimpleFeatures()
void set_read_functions()
bool seekable
Whether the stream is seekable.
The class Features is the base class of all feature objects.
Class CStreamingFileFromSimpleFeatures is a derived class of CStreamingFile which creates an input so...
~CStreamingSimpleFeatures()
virtual int32_t get_dim_feature_space() const
virtual bool get_next_example()
virtual EFeatureClass get_feature_class()
virtual void add_to_dense_vec(float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual void reset_stream()
This class implements streaming features with dense feature vectors.
static T abs(T a)
return the absolute value of a number