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);
74 D_THREAD_PARAM* params =
SG_MALLOC(D_THREAD_PARAM, num_threads);
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);
122 D_THREAD_PARAM param;
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);
136 D_THREAD_PARAM* params =
SG_MALLOC(D_THREAD_PARAM, num_threads);
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);
177 D_THREAD_PARAM* params= (D_THREAD_PARAM*) p;
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);
193 D_THREAD_PARAM* params= (D_THREAD_PARAM*) p;
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)