62 template <
typename ST>
73 result+=
static_cast<T
>(vec[
features[i].feat_index])
119 int32_t dimensions = -1;
122 if (
features[i].feat_index > dimensions)
124 dimensions =
features[i].feat_index;
152 "sort_features(): failed sanity check %d <= %d after sorting (comparing indices features[%d] <= features[%d], features=%d)\n",
153 features[j-1].feat_index,
features[j].feat_index, j-1, j, num_feat_entries);
157 int32_t last_index = 0;
162 "sort_features(): target index %d must not exceed source index j=%d",
165 "sort_features(): failed sanity check %d = features[%d].feat_index <= features[%d].feat_index = %d\n",
176 if (
features[last_index].entry != 0.0)
185 if (
features[last_index].entry == 0.0)
190 int32_t new_feat_count = last_index+1;
191 ASSERT(new_feat_count <= num_feat_entries);
196 SG_SINFO(
"shrinking vector from %d to %d\n", num_feat_entries, new_feat_count);
199 num_feat_entries = new_feat_count;
204 "sort_features(): failed sanity check %d < %d after sorting (comparing indices features[%d] < features[%d], features=%d)\n",
205 features[j-1].feat_index,
features[j].feat_index, j-1, j, num_feat_entries);
209 if (stable_pointer) {
298 SG_SERROR(
"SGSparseVector::load():: Not supported for complex128_t\n");
304 SG_SERROR(
"SGSparseVector::save():: Not supported for complex128_t\n");
347 const T tmp = b.
features[b_idx].entry;
353 dot_prod += tmp * a.
features[a_idx].entry;
516 SG_SPRINT(
"%s%s%d:(%.18lg+i%.18lg)", prefix, i==0 ?
"" :
" ",
features[i].feat_index,
T get_feature(int32_t index)
void sort_features(bool stable_pointer=false)
std::complex< float64_t > complex128_t
static T dot_prod_symmetric(const SGSparseVector< T > &a, const SGSparseVector< T > &b)
virtual void copy_data(const SGReferencedData &orig)
int32_t get_num_dimensions()
static void qsort_index(T1 *output, T2 *index, uint32_t size)
virtual void set_sparse_vector(const SGSparseVectorEntry< bool > *entries, int32_t num_feat)
T sparse_dot(const SGSparseVector< T > &v)
SGVector< T > get_dense()
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry<T>* vector is orde...
shogun reference count managed data
SGSparseVector< T > clone() const
A File access base class.
virtual void get_sparse_vector(SGSparseVectorEntry< bool > *&entries, int32_t &num_feat)
static int32_t cmp_dot_prod_symmetry_fast(index_t alen, index_t blen)
void display_vector(const char *name="vector", const char *prefix="")
static T dot_prod_asymmetric(const SGSparseVector< T > &a, const SGSparseVector< T > &b)
all of classes and functions are contained in the shogun namespace
T dense_dot(T alpha, T *vec, int32_t dim, T b)
template class SGSparseVectorEntry
virtual ~SGSparseVector()
void resize_vector(int32_t n)
static index_t floor_log(index_t n)
log(x), x being a complex128_t
SGSparseVectorEntry< T > * features