17 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 #endif // DOXYGEN_SHOULD_SKIP_THIS
40 void CDistanceMachine::init()
64 param.idx_r_start=idx_a1;
65 param.idx_start=idx_a1;
66 param.idx_stop=idx_a2+1;
74 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
76 int32_t num_vec=idx_a2-idx_a1+1;
77 int32_t step= num_vec/num_threads;
81 pthread_attr_init(&attr);
82 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
84 for (t=0; t<num_threads-1; t++)
88 params[t].idx_r_start=t*step;
89 params[t].idx_start = (t*step)+idx_a1;
90 params[t].idx_stop = ((t+1)*step)+idx_a1;
91 params[t].idx_comp=idx_b;
97 params[t].idx_r_start=t*step;
98 params[t].idx_start = (t*step)+idx_a1;
99 params[t].idx_stop = idx_a2+1;
100 params[t].idx_comp=idx_b;
104 for (t=0; t<num_threads-1; t++)
105 pthread_join(threads[t], NULL);
107 pthread_attr_destroy(&attr);
126 param.idx_r_start=idx_b1;
127 param.idx_start=idx_b1;
128 param.idx_stop=idx_b2+1;
129 param.idx_comp=idx_a;
136 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
138 int32_t num_vec=idx_b2-idx_b1+1;
139 int32_t step= num_vec/num_threads;
143 pthread_attr_init(&attr);
144 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
146 for (t=0; t<num_threads-1; t++)
149 params[t].r = result;
150 params[t].idx_r_start=t*step;
151 params[t].idx_start = (t*step)+idx_b1;
152 params[t].idx_stop = ((t+1)*step)+idx_b1;
153 params[t].idx_comp=idx_a;
158 params[t].r = result;
159 params[t].idx_r_start=t*step;
160 params[t].idx_start = (t*step)+idx_b1;
161 params[t].idx_stop = idx_b2+1;
162 params[t].idx_comp=idx_a;
166 for (t=0; t<num_threads-1; t++)
167 pthread_join(threads[t], NULL);
169 pthread_attr_destroy(&attr);
181 int32_t idx_res_start=params->idx_r_start;
182 int32_t idx_act=params->idx_start;
183 int32_t idx_stop=params->idx_stop;
184 int32_t idx_c=params->idx_comp;
186 for (int32_t i=idx_res_start; idx_act<idx_stop; i++,idx_act++)
187 res[i] =distance->
distance(idx_act,idx_c);
197 int32_t idx_res_start=params->idx_r_start;
198 int32_t idx_act=params->idx_start;
199 int32_t idx_stop=params->idx_stop;
200 int32_t idx_c=params->idx_comp;
202 for (int32_t i=idx_res_start; idx_act<idx_stop; i++,idx_act++)
203 res[i] =distance->
distance(idx_c,idx_act);
248 for (
index_t i=1; i<num_clusters; ++i)
278 SG_ERROR(
"store_model_features not yet implemented for %s!\n",
CDistance * get_distance() const
Class Distance, a base class for all the distances used in the Shogun toolbox.
int32_t get_num_threads() const
virtual void store_model_features()
virtual ~CDistanceMachine()
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
virtual int32_t get_num_vectors() const =0
void distances_lhs(float64_t *result, int32_t idx_a1, int32_t idx_a2, int32_t idx_b)
static void * run_distance_thread_lhs(void *p)
virtual const char * get_name() const
A generic learning machine interface.
bool set_label(int32_t idx, float64_t label)
Multiclass Labels for multi-class classification.
void add(bool *param, const char *name, const char *description="")
virtual void set_store_model_features(bool store_model)
Class SGObject is the base class of all shogun objects.
virtual float64_t apply_one(int32_t num)
void distances_rhs(float64_t *result, int32_t idx_b1, int32_t idx_b2, int32_t idx_a)
virtual float64_t distance(int32_t idx_a, int32_t idx_b)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
void set_distance(CDistance *d)
static void * run_distance_thread_rhs(void *p)
virtual bool init(CFeatures *lhs, CFeatures *rhs)