Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JTRIGGER::reverse_clusterize Struct Reference

Anonymous structure for reverse clustering of hits. More...

#include <JAlgorithm.hh>

Public Member Functions

template<class JHitIterator_t , class JMatch_t >
JHitIterator_t operator() (JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match) const
 Partition data according given binary match operator.
 

Private Member Functions

template<class JHitIterator_t , class JMatch_t >
JHitIterator_t operator() (JHitIterator_t buffer, const int N, const JMatch_t &match, std::random_access_iterator_tag tag) const
 Implementation of method reverse_clusterize for random access iterators.
 

Private Attributes

std::vector< int > count
 

Detailed Description

Anonymous structure for reverse clustering of hits.

Definition at line 188 of file JAlgorithm.hh.

Member Function Documentation

◆ operator()() [1/2]

template<class JHitIterator_t , class JMatch_t >
JHitIterator_t JTRIGGER::reverse_clusterize::operator() ( JHitIterator_t __begin,
JHitIterator_t __end,
const JMatch_t & match ) const
inline

Partition data according given binary match operator.

The underlying algorithm is known in literature as reverse 'clique'. The result is (likely to be) the maximal sub-set with all elements matched to each other. The complexity is quadratic, i.e. at most (number of elements x number of elements) operations. The algorithm will sort the data such that all clusterized hits are at the front. The return value points the first non clusterized hit.

The hit iterator refers to a data structure which should conform with the match operator.

Parameters
__beginbegin of data
__endend of data
matchbinary match operator
Returns
end of data

Definition at line 207 of file JAlgorithm.hh.

210 {
211 return (*this)(__begin, std::distance(__begin,__end), match, typename std::iterator_traits<JHitIterator_t>::iterator_category());
212 }

◆ operator()() [2/2]

template<class JHitIterator_t , class JMatch_t >
JHitIterator_t JTRIGGER::reverse_clusterize::operator() ( JHitIterator_t buffer,
const int N,
const JMatch_t & match,
std::random_access_iterator_tag tag ) const
inlineprivate

Implementation of method reverse_clusterize for random access iterators.

Parameters
bufferpointer to data
Nnumber of hits
matchbinary match operator
tagiterator tag
Returns
pointer to end of data

Definition at line 225 of file JAlgorithm.hh.

229 {
230 using namespace std;
231
232 if (N != 0) {
233
234 int i, j;
235
236 // Determine number of associated hits for each hit.
237
238 count.resize(N);
239
240 for (vector<int>::iterator __i = count.begin(); __i != count.end(); ++__i) {
241 *__i = 1; // Assume always a match with itself.
242 }
243
244 for (i = 0; i != N; ++i) {
245 for (j = 0; j != i; ++j) {
246 if (match(buffer[i], buffer[j])) {
247 ++count[i];
248 ++count[j];
249 }
250 }
251 }
252
253 // Keep hit with the largest number of associated hits.
254 // This procedure stops when the number of associated hits is equal to one.
255
256 for (int n = 0; ; ++n) {
257
258 j = n;
259
260 for (i = j; ++i != N; ) {
261 if (count[i] > count[j]) {
262 j = i;
263 }
264 }
265
266 // Ready?
267
268 if (count[j] == 1) {
269 return buffer + n;
270 }
271
272 // Swap the selected hit to begin.
273
274 swap(buffer[j], buffer[n]);
275 swap(count [j], count [n]);
276
277 // Decrease number of associated hits for each associated hit.
278
279 for (i = n; ++i != N; ) {
280 if (match(buffer[i], buffer[n])) {
281 --count[i];
282 --count[n];
283 }
284 }
285 }
286 }
287
288 return buffer;
289 }
const int n
Definition JPolint.hh:786
int j
Definition JPolint.hh:792
std::vector< int > count

Member Data Documentation

◆ count

std::vector<int> JTRIGGER::reverse_clusterize::count
mutableprivate

Definition at line 292 of file JAlgorithm.hh.


The documentation for this struct was generated from the following file: