121 int32_t tmp_len = len;
122 ST* tmp_feat_before = feat;
123 ST* tmp_feat_after = NULL;
132 tmp_feat_after = applied.
vector;
136 SG_FREE(tmp_feat_before);
137 tmp_feat_before = tmp_feat_after;
143 memcpy(feat, tmp_feat_after,
sizeof(ST) * tmp_len);
144 SG_FREE(tmp_feat_after);
159 SG_ERROR(
"Index out of bounds (number of vectors %d, you " 164 SG_ERROR(
"Requires a in-memory feature matrix\n")
181 SG_ERROR(
"Index out of bounds (number of vectors %d, you " 209 SG_ERROR(
"A subset is set, cannot call vector_subset\n")
219 for (int32_t i = 0; i < idx_len; i++)
224 if (ii < 0 || ii >= num_vec)
225 SG_ERROR(
"Index out of range: should be 0<%d<%d\n", ii, num_vec)
240 SG_ERROR(
"A subset is set, cannot call feature_subset\n")
253 for (int32_t j = 0; j < idx_len; j++)
257 if (jj < 0 || jj >= num_feat)
259 "Index out of range: should be 0<%d<%d\n", jj, num_feat);
275 for (int32_t i=0; i<submatrix.
num_cols; ++i)
293 return st_feature_matrix;
328 ST* fm = SG_MALLOC(ST, int64_t(num_feat) * num_vec);
330 for (int32_t i=0; i<old_num_vec; i++)
334 for (int32_t j=0; j<vec.
vlen; j++)
335 fm[j*int64_t(old_num_vec)+i]=vec.
vector[j];
346 SG_ERROR(
"A subset is set, cannot call copy_feature_matrix\n")
362 ASSERT(num_feat>0 && num_vec>0)
367 for (int32_t i = 0; i < num_vec; i++)
372 for (int32_t j = 0; j < num_feat; j++)
382 SG_ERROR(
"A subset is set, cannot call apply_preproc\n")
384 SG_DEBUG(
"force: %d\n", force_preprocessing)
415 SG_ERROR(
"no preprocessors available\n")
437 SG_ERROR(
"A subset is set, cannot call set_num_vectors\n")
446 SG_ERROR(
"A subset is set, cannot call initialize_cache\n")
462 SG_ERROR(
"A subset is set, cannot call reshape\n")
464 if (p_num_features * p_num_vectors
468 num_vectors = p_num_vectors;
488 ST* vec2 = sf->get_feature_vector(vec_idx2, len2, free2);
493 sf->free_feature_vector(vec2, vec_idx2, free2);
499 float64_t* vec2, int32_t vec2_len,
bool abs_val)
517 vec2[i] += alpha * vec1[i];
525 float64_t* vec2, int32_t vec2_len,
bool abs_val)
557 SG_ERROR(
"Index out of bounds (number of vectors %d, you " 561 dense_feature_iterator* iterator = SG_MALLOC(dense_feature_iterator, 1);
564 iterator->vidx = vector_index;
572 dense_feature_iterator* it = (dense_feature_iterator*) iterator;
573 if (!it || it->index >= it->vlen)
587 dense_feature_iterator* it = (dense_feature_iterator*) iterator;
601 num_features*
sizeof(ST));
634 #define GET_FEATURE_TYPE(f_type, sg_type) \ 635 template<> EFeatureType CDenseFeatures<sg_type>::get_feature_type() const \ 653 #undef GET_FEATURE_TYPE 668 result += vec1[i] ? vec2[i] : 0;
688 result += vec1[i] * vec2[i];
708 result += vec1[i] * vec2[i];
716 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
728 result += vec1[i] * vec2[i];
736 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
748 result += vec1[i] * vec2[i];
756 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
768 result += vec1[i] * vec2[i];
776 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
788 result += vec1[i] * vec2[i];
796 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
808 result += vec1[i] * vec2[i];
816 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
828 result += vec1[i] * vec2[i];
836 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
848 result += vec1[i] * vec2[i];
856 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
868 result += vec1[i] * vec2[i];
876 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
893 int32_t vec_idx1,
const float64_t* vec2, int32_t vec2_len)
905 result += vec1[i] * vec2[i];
919 int32_t v1len, v2len;
920 bool v1free, v2free, stop =
false;
930 for (int32_t j=0; j<v1len; j++)
932 if (vec1[j]!=vec2[j])
963 SG_ERROR(
"%s::create_merged_copy(): Could not cast object of %s to " 971 SG_ERROR(
"%s::create_merged_copy(): Features are of different type!\n",
977 SG_ERROR(
"%s::create_merged_copy(): Provided feature object has " 978 "different dimension than this one\n");
993 SG_DEBUG(
"copying matrix of this instance\n")
1007 SG_DEBUG(
"copying matrix of provided instance\n")
1047 matrix.
load(loader);
1060 "base_features must be of dynamic type CDenseFeatures\n")
virtual const char * get_name() const =0
CSubsetStack * m_subset_stack
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
virtual int32_t get_dim_feature_space() const
SGMatrix< ST > get_feature_matrix()
void set_feature_matrix(SGMatrix< ST > matrix)
CSGObject * get_next_element()
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual CFeatures * copy_subset(SGVector< index_t > indices)
void set_num_vectors(int32_t num)
int32_t num_features
number of features in cache
void set_preprocessed(int32_t num)
CDenseFeatures(int32_t size=0)
void set_feature_vector(SGVector< ST > vector, int32_t num)
void feature_subset(int32_t *idx, int32_t idx_len)
void obtain_from_dot(CDotFeatures *df)
virtual int32_t get_num_vectors() const =0
virtual void * get_feature_iterator(int32_t vector_index)
virtual bool reshape(int32_t p_num_features, int32_t p_num_vectors)
#define SG_NOTIMPLEMENTED
void free_feature_matrix()
CPreprocessor * get_preprocessor(int32_t num) const
virtual EFeatureType get_feature_type() const
virtual bool is_equal(CDenseFeatures *rhs)
int32_t get_num_features() const
Features that support dot products among other operations.
void unlock_entry(int64_t number)
EFeatureClass
shogun feature class
ST * get_feature_vector(int32_t num, int32_t &len, bool &dofree)
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
virtual int32_t get_dim_feature_space() const =0
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
int32_t get_num_preprocessors() const
T * set_entry(int64_t number)
CSGObject * get_first_element()
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
Class SGObject is the base class of all shogun objects.
int32_t num_vectors
number of vectors in cache
virtual void remove_all_subsets()
Template class DensePreprocessor, base class for preprocessors (cf. CPreprocessor) that apply to CDen...
SGMatrix< ST > feature_matrix
bool is_preprocessed(int32_t num) const
virtual const char * get_name() const
virtual void copy_feature_matrix(SGMatrix< ST > src)
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
A File access base class.
virtual bool apply_preprocessor(bool force_preprocessing=false)
index_t subset_idx_conversion(index_t idx) const
virtual EFeatureClass get_feature_class() const =0
T * lock_entry(int64_t number)
CCache< ST > * feature_cache
CDenseFeatures< ST > * get_transposed()
SGMatrix< ST > steal_feature_matrix()
virtual CFeatures * duplicate() const
void set_num_features(int32_t num)
The class DenseFeatures implements dense feature matrices.
virtual EFeatureClass get_feature_class() const
all of classes and functions are contained in the shogun namespace
static CDenseFeatures * obtain_from_generic(CFeatures *const base_features)
int32_t get_cache_size() const
void vector_subset(int32_t *idx, int32_t idx_len)
The class Features is the base class of all feature objects.
virtual SGMatrix< ST > apply_to_feature_matrix(CFeatures *features)=0
bool append_element(CSGObject *data)
SGVector< float64_t > get_computed_dot_feature_vector(int32_t num)
virtual bool has_subsets() const
virtual void save(CFile *saver)
virtual void load(CFile *loader)
virtual ~CDenseFeatures()
void clean_preprocessors()
virtual ST * compute_feature_vector(int32_t num, int32_t &len, ST *target=NULL)
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual SGVector< ST > apply_to_feature_vector(SGVector< ST > vector)=0
virtual int32_t get_num_vectors() const
CFeatures * create_merged_copy(CList *other)
virtual EFeatureType get_feature_type() const =0
Class List implements a doubly connected list for low-level-objects.
static void vec1_plus_scalar_times_vec2(T *vec1, const T scalar, const T *vec2, int32_t n)
x=x+alpha*y
#define GET_FEATURE_TYPE(f_type, sg_type)
static T abs(T a)
return the absolute value of a number
virtual void free_feature_iterator(void *iterator)