61 int32_t num_vectors=stop-start;
68 #pragma omp parallel shared(num_threads, step) 73 num_threads=omp_get_num_threads();
74 step=num_vectors/num_threads;
77 int32_t thread_num=omp_get_thread_num();
85 int32_t t_start=thread_num*step;
86 int32_t t_stop=(thread_num==num_threads) ? stop : (thread_num+1)*step;
89 for (int32_t i=t_start; i<t_stop; i++)
91 for (int32_t i=t_start; i<t_stop &&
96 output[i]=alphas[i]*this->
dense_dot(i, vec, dim)+b;
106 SG_INFO(
"prematurely stopped. \n")
119 #pragma omp parallel shared(num_threads, step) 124 num_threads=omp_get_num_threads();
125 step=num/num_threads;
128 int32_t thread_num=omp_get_thread_num();
132 int32_t thread_num=0;
136 int32_t t_start=thread_num*step;
137 int32_t t_stop=(thread_num==num_threads) ? num : (thread_num+1)*step;
140 for (int32_t i=t_start; i<t_stop; i++)
142 for (int32_t i=t_start; i<t_stop &&
147 output[i]=alphas[sub_index[i]]*this->
dense_dot(sub_index[i], vec, dim)+b;
149 output[i]=this->
dense_dot(sub_index[i], vec, dim)+b;
157 SG_INFO(
"prematurely stopped. \n")
173 for (int32_t i=0; i<num; i++)
205 for (int32_t r=0; r<repeats; r++)
207 for (int32_t i=0; i<num; i++)
211 SG_PRINT(
"Time to process %d x num=%d add_to_dense_vector ops: cputime %fs walltime %fs\n",
234 for (int32_t r=0; r<repeats; r++)
237 #ifdef DEBUG_DOTFEATURES 238 CMath::display_vector(out, 40,
"dense_dot_range");
241 for (int32_t r=0; r<repeats; r++)
243 CMath::fill_vector(out2, num, 0.0);
244 for (int32_t i=0; i<num; i++)
245 out2[i]+=
dense_dot(i, w, d)*alphas[i]+23;
247 CMath::display_vector(out2, 40,
"dense_dot");
248 for (int32_t i=0; i<num; i++)
250 CMath::display_vector(out2, 40,
"diff");
252 SG_PRINT(
"Time to process %d x num=%d dense_dot_range ops: cputime %fs walltime %fs\n",
271 for (
int i = 0; i < num; i++)
273 for (
int j = 0; j < dim; j++)
294 for (
int i = 0; i < num_lhs; i++)
296 for (
int i = 0; i < num_rhs; i++)
298 for (
int j = 0; j < dim; j++)
299 mean.
vector[j] /= (num_lhs+num_rhs);
317 for (
int i = 0; i < num; i++)
321 for (
int m = 0; m < v.
vlen; m++)
323 for (
int n = 0; n <= m ; n++)
329 for (
int m = 0; m < dim; m++)
331 for (
int n = 0; n <= m ; n++)
333 (cov.
matrix)[m*dim+n] /= num;
336 for (
int m = 0; m < dim-1; m++)
338 for (
int n = m+1; n < dim; n++)
352 int32_t nums[2], dims[2], num=0;
354 for (
int i = 0; i < 2; i++)
364 int32_t dim = dims[0];
372 for (
int i = 0; i < 2; i++)
374 for (
int j = 0; j < nums[i]; j++)
378 for (
int m = 0; m < v.
vlen; m++)
380 for (
int n = 0; n <= m; n++)
387 for (
int m = 0; m < dim; m++)
389 for (
int n = 0; n <= m; n++)
391 (cov.
matrix)[m*dim+n] /= num;
394 for (
int m = 0; m < dim-1; m++)
396 for (
int n = m+1; n < dim; n++)
407 int32_t num_vectors=stop-start;
410 if ( (i% (num_vectors/100+1))== 0)
414 void CDotFeatures::init()
418 "Feature weighting in combined dot features.");
Class Time that implements a stopwatch based on either cpu time or wall clock time.
static void range_fill_vector(T *vec, int32_t len, T start=0)
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)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)=0
CDotFeatures(int32_t size=0)
static float64_t get_runtime()
virtual int32_t get_num_vectors() const =0
void set_property(EFeatureProperty p)
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)
std::enable_if<!std::is_same< T, complex128_t >::value, float64_t >::type mean(const Container< T > &a)
Features that support dot products among other operations.
void add(const SGVector< T > x)
virtual int32_t get_dim_feature_space() const =0
static float64_t get_curtime()
virtual SGVector< float64_t > get_mean()
static SGMatrix< float64_t > compute_cov(CDotFeatures *lhs, CDotFeatures *rhs)
void add(bool *param, const char *name, const char *description="")
static void clear_cancel()
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)
A File access base class.
void benchmark_add_to_dense_vector(int32_t repeats=5)
static void fill_vector(T *vec, int32_t len, T value)
static bool cancel_computations()
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
SGVector< float64_t > get_computed_dot_feature_vector(int32_t num)
void display_progress(int32_t start, int32_t stop, int32_t v)
float64_t combined_weight
feature weighting in combined dot features
SGMatrix< float64_t > get_computed_dot_feature_matrix()
virtual SGMatrix< float64_t > get_cov()