14 using namespace shogun;
16 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 #endif // DOXYGEN_SHOULD_SKIP_THIS
39 void CDistanceMachine::init()
63 param.idx_r_start=idx_a1;
64 param.idx_start=idx_a1;
65 param.idx_stop=idx_a2+1;
73 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
75 int32_t num_vec=idx_a2-idx_a1+1;
76 int32_t step= num_vec/num_threads;
80 pthread_attr_init(&attr);
81 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
83 for (t=0; t<num_threads-1; t++)
87 params[t].idx_r_start=t*step;
88 params[t].idx_start = (t*step)+idx_a1;
89 params[t].idx_stop = ((t+1)*step)+idx_a1;
90 params[t].idx_comp=idx_b;
96 params[t].idx_r_start=t*step;
97 params[t].idx_start = (t*step)+idx_a1;
98 params[t].idx_stop = idx_a2+1;
99 params[t].idx_comp=idx_b;
103 for (t=0; t<num_threads-1; t++)
104 pthread_join(threads[t], NULL);
106 pthread_attr_destroy(&attr);
125 param.idx_r_start=idx_b1;
126 param.idx_start=idx_b1;
127 param.idx_stop=idx_b2+1;
128 param.idx_comp=idx_a;
135 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
137 int32_t num_vec=idx_b2-idx_b1+1;
138 int32_t step= num_vec/num_threads;
142 pthread_attr_init(&attr);
143 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
145 for (t=0; t<num_threads-1; t++)
148 params[t].r = result;
149 params[t].idx_r_start=t*step;
150 params[t].idx_start = (t*step)+idx_b1;
151 params[t].idx_stop = ((t+1)*step)+idx_b1;
152 params[t].idx_comp=idx_a;
157 params[t].r = result;
158 params[t].idx_r_start=t*step;
159 params[t].idx_start = (t*step)+idx_b1;
160 params[t].idx_stop = idx_b2+1;
161 params[t].idx_comp=idx_a;
165 for (t=0; t<num_threads-1; t++)
166 pthread_join(threads[t], NULL);
168 pthread_attr_destroy(&attr);
180 int32_t idx_res_start=params->idx_r_start;
181 int32_t idx_act=params->idx_start;
182 int32_t idx_stop=params->idx_stop;
183 int32_t idx_c=params->idx_comp;
185 for (int32_t i=idx_res_start; idx_act<idx_stop; i++,idx_act++)
186 res[i] =distance->
distance(idx_act,idx_c);
196 int32_t idx_res_start=params->idx_r_start;
197 int32_t idx_act=params->idx_start;
198 int32_t idx_stop=params->idx_stop;
199 int32_t idx_c=params->idx_comp;
201 for (int32_t i=idx_res_start; idx_act<idx_stop; i++,idx_act++)
202 res[i] =distance->
distance(idx_c,idx_act);
247 for (
index_t i=1; i<num_clusters; ++i)
277 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)
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)