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)(cpl_table *catalogue1,
56 cpl_table *catalogue2,
61irplib_match_cats_get_all_matches_cresc(cpl_table **catalogues,
62 cpl_array *cat_index_begin,
63 cpl_array *cats_idx_set,
65 cpl_table *matching_sets);
67cpl_error_code irplib_match_cats_iterate_on_cat(cpl_table **catalogues,
68 cpl_array *cats_idx_set,
70 cpl_array *valid_iobjs,
72 cpl_table *matching_sets,
73 cpl_table *less_minmatch_sets);
75cpl_error_code irplib_match_cats_filter_obj_to_iter(cpl_array *cats_idx_set,
77 cpl_table *matches_set,
78 cpl_array *excluded_objs,
81int irplib_match_cats_match_condition(cpl_table **catalogues,
82 int *cats_idx_set_ptr,
85int irplib_match_count_nonmatched(
int *cats_idx_set_ptr,
int ncats);
87int irplib_nCombinations;
122 int (*binary_match_condition)(cpl_table *catalogue1,
123 cpl_table *catalogue2,
127 cpl_table *matching_sets;
130 matching_sets = cpl_table_new(0);
131 cpl_table_new_column_array(matching_sets,
"MATCHING_SETS", CPL_TYPE_INT,
134 irplib_match_cats_get_all_matching_pairs(catalogues, ncats, matching_sets,
135 binary_match_condition);
137 return matching_sets;
141irplib_match_cats_get_all_matching_pairs(
142 cpl_table **catalogues,
144 cpl_table *matching_sets,
145 int (*binary_match_condition)(cpl_table *catalogue1,
146 cpl_table *catalogue2,
153 irplib_nCombinations = 0;
156 for (icat1 = 0; icat1 < ncats; ++icat1)
157 for (icat2 = icat1 + 1; icat2 < ncats; ++icat2) {
163 nobj1 = cpl_table_get_nrow(catalogues[icat1]);
164 nobj2 = cpl_table_get_nrow(catalogues[icat2]);
166 for (iobj1 = 0; iobj1 < nobj1; ++iobj1)
167 for (iobj2 = 0; iobj2 < nobj2; ++iobj2) {
168 ++irplib_nCombinations;
169 if (binary_match_condition(catalogues[icat1],
170 catalogues[icat2], iobj1,
172 cpl_array *cats_idx_set;
176 cats_idx_set = cpl_array_new(ncats, CPL_TYPE_INT);
177 for (icat = 0; icat < ncats; ++icat) {
179 cpl_array_set_int(cats_idx_set, icat, iobj1);
180 else if (icat == icat2)
181 cpl_array_set_int(cats_idx_set, icat, iobj2);
183 cpl_array_set_int(cats_idx_set, icat, -1);
186 cpl_table_set_size(matching_sets,
187 cpl_table_get_nrow(matching_sets) +
189 cpl_table_set_array(matching_sets,
"MATCHING_SETS",
190 cpl_table_get_nrow(matching_sets) -
193 cpl_array_delete(cats_idx_set);
198 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.