36#include "irplib_match_cats.h"
44#define FILENAME_SZBUF 1024
51cpl_error_code irplib_match_cats_get_all_matching_pairs
52(cpl_table ** catalogues,
54 cpl_table * matching_sets,
55 int (*binary_match_condition)
56 (cpl_table * catalogue1,
57 cpl_table * catalogue2,
61cpl_error_code irplib_match_cats_get_all_matches_cresc
62(cpl_table ** catalogues,
63 cpl_array * cat_index_begin,
64 cpl_array * cats_idx_set,
66 cpl_table * matching_sets);
68cpl_error_code irplib_match_cats_iterate_on_cat
69(cpl_table ** catalogues,
70 cpl_array * cats_idx_set,
72 cpl_array * valid_iobjs,
74 cpl_table * matching_sets,
75 cpl_table * less_minmatch_sets);
77cpl_error_code irplib_match_cats_filter_obj_to_iter
78(cpl_array * cats_idx_set,
80 cpl_table * matches_set,
81 cpl_array * excluded_objs,
84int irplib_match_cats_match_condition
85(cpl_table ** catalogues,
86 int * cats_idx_set_ptr,
89int irplib_match_count_nonmatched
90(
int * cats_idx_set_ptr,
93int irplib_nCombinations;
126(cpl_table ** catalogues,
128 int (*binary_match_condition)
129 (cpl_table * catalogue1,
130 cpl_table * catalogue2,
134 cpl_table * matching_sets;
137 matching_sets = cpl_table_new(0);
138 cpl_table_new_column_array(matching_sets,
"MATCHING_SETS",
139 CPL_TYPE_INT, ncats);
141 irplib_match_cats_get_all_matching_pairs
142 (catalogues, ncats, matching_sets, binary_match_condition);
144 return matching_sets;
147cpl_error_code irplib_match_cats_get_all_matching_pairs
148(cpl_table ** catalogues,
150 cpl_table * matching_sets,
151 int (*binary_match_condition)
152 (cpl_table * catalogue1,
153 cpl_table * catalogue2,
160 irplib_nCombinations = 0;
163 for(icat1 = 0; icat1 < ncats ; ++icat1)
164 for(icat2 = icat1 + 1 ; icat2 < ncats ; ++icat2)
171 nobj1 = cpl_table_get_nrow(catalogues[icat1]);
172 nobj2 = cpl_table_get_nrow(catalogues[icat2]);
174 for(iobj1 = 0; iobj1 < nobj1 ; ++iobj1)
175 for(iobj2 = 0 ; iobj2 < nobj2 ; ++iobj2)
177 ++irplib_nCombinations;
178 if(binary_match_condition(catalogues[icat1],
182 cpl_array * cats_idx_set;
186 cats_idx_set = cpl_array_new(ncats, CPL_TYPE_INT);
187 for(icat = 0; icat < ncats; ++icat)
190 cpl_array_set_int(cats_idx_set, icat, iobj1);
191 else if(icat == icat2)
192 cpl_array_set_int(cats_idx_set, icat, iobj2);
194 cpl_array_set_int(cats_idx_set, icat, -1);
197 cpl_table_set_size(matching_sets,
198 cpl_table_get_nrow(matching_sets)+1);
199 cpl_table_set_array(matching_sets,
"MATCHING_SETS",
200 cpl_table_get_nrow(matching_sets)-1,
202 cpl_array_delete(cats_idx_set);
207 return CPL_ERROR_NONE;
cpl_table * irplib_match_cat_pairs(cpl_table **catalogues, int ncats, int(*binary_match_condition)(cpl_table *catalogue1, cpl_table *catalogue2, int iobj1, int iobj2))
Finds all the objects that appear at least in some of the catalogues.