39#define COMPUTE_FILES 0
44 if ((array_1 == NULL) || (array_2 == NULL))
53 cpl_type type_array_1 = cpl_array_get_type(array_1);
54 cpl_type type_array_2 = cpl_array_get_type(array_2);
56 if (strcmp(cpl_type_get_name (type_array_1), cpl_type_get_name (type_array_2))){
57 cpl_msg_info(cpl_func,
"The arrays have not the same type type1 = %s and type2 = %s\n",
58 cpl_type_get_name (type_array_1), cpl_type_get_name (type_array_2));
62 if (cpl_array_get_size(array_1) != cpl_array_get_size(array_2)){
63 cpl_msg_info(cpl_func,
"the arrays don't have the same size\n");
67 int size = cpl_array_get_size(array_1);
71 double * array_double_1;
72 double * array_double_2;
73 double complex * array_complex_1;
74 double complex * array_complex_2;
77 float * array_float_1;
78 float * array_float_2;
79 char ** array_string_1;
80 char ** array_string_2;
83 case CPL_TYPE_DOUBLE :
85 array_double_1 = cpl_array_get_data_double(array_1);
86 array_double_2 = cpl_array_get_data_double(array_2);
87 for (j = 0; j < size ; j++){
88 if (array_double_1[j] > 1e-10){
89 if (fabs((array_double_1[j] - array_double_2[j]) / array_double_1[j]) > 0.1){
90 cpl_msg_info(cpl_func,
"The arrays are not the same on the %d nd index:"
91 " %e and %e\n", j, array_double_1[j], array_double_2[j]);
96 if (array_double_2[j] > 1e-10){
97 cpl_msg_info(cpl_func,
"The arrays are not equal at zero on the %d nd index:"
98 " %e and %e\n", j, array_double_1[j], array_double_2[j]);
108 case CPL_TYPE_DOUBLE_COMPLEX :
110 array_complex_1 = cpl_array_get_data_double_complex(array_1);
111 array_complex_2 = cpl_array_get_data_double_complex(array_2);
112 for (j = 0; j < size ; j++){
113 if (cabs(array_complex_1[j]) > 1e-10){
114 if ((carg(array_complex_1[j]) - carg(array_complex_2[j])) > 0.1){
115 cpl_msg_info(cpl_func,
"The argument of complex arrays are not the same on the %d nd index:"
116 " %e and %e\n", j,carg( array_complex_1[j]), carg(array_complex_2[j]));
119 if (fabs((cabs(array_complex_1[j]) - cabs(array_complex_2[j]))) /
120 cabs(array_complex_1[j]) > 0.1){
121 cpl_msg_info(cpl_func,
"The module of complex arrays are not the same on the %d nd index:"
122 " %e and %e\n", j, cabs(array_complex_1[j]), cabs(array_complex_2[j]));
127 if (cabs(array_complex_2[j]) > 1e-10) {
128 cpl_msg_info(cpl_func,
"The module of complex arrays are not equal at zero on the %d nd index:"
129 " %e and %e\n", j, cabs(array_complex_1[j]), cabs(array_complex_2[j]));
138 array_int_1 = cpl_array_get_data_int(array_1);
139 array_int_2 = cpl_array_get_data_int(array_2);
140 for (j = 0; j < size ; j++){
141 if (array_int_1[j] != 0) {
142 if ((abs(array_int_1[j] - array_int_2[j]) / array_int_1[j]) > 1){
143 cpl_msg_info(cpl_func,
"The arrays are not the same on the %d nd index: "
144 "%d and %d\n", j, array_int_1[j], array_int_2[j]);
149 if (array_int_2[j] > 1e-10){
150 cpl_msg_info(cpl_func,
"The arrays are not equal at zero on the %d nd index: "
151 "%d and %d\n", j, array_int_1[j], array_int_2[j]);
162 case CPL_TYPE_FLOAT :
164 array_float_1 = cpl_array_get_data_float(array_1);
165 array_float_2 = cpl_array_get_data_float(array_2);
166 for (j = 0; j < size ; j++){
167 if (array_float_1[j] > 1e-10){
168 if (fabs((array_float_1[j] - array_float_2[j]) / array_float_1[j])> 0.1){
169 cpl_msg_info(cpl_func,
"The arrays are not the same on the %d nd index: "
170 "%e and %e\n", j, array_float_1[j], array_float_2[j]);
175 if (array_float_2[j] > 1e-10){
176 cpl_msg_info(cpl_func,
"The arrays are not equal at zero on the %d nd index: "
177 "%e and %e\n", j, array_float_1[j], array_float_2[j]);
186 case CPL_TYPE_STRING :
187 array_string_1 = cpl_array_get_data_string(array_1);
188 array_string_2 = cpl_array_get_data_string(array_2);
189 for (j = 0; j < size; j++){
190 if(strcmp(*(array_string_1 + j), *(array_string_2 + j))){
191 cpl_msg_info(cpl_func,
"The arrays are not the same on the %d nd index: "
192 "%s and %s\n", j, array_string_1[j], array_string_2[j]);
200 cpl_msg_info(cpl_func,
"invalid type of array %s\n", cpl_type_get_name (type_array_2));
212 if (cpl_table_compare_structure(table1, table2) == 0){
213 int ncol = cpl_table_get_ncol(table1);
214 int nrow = cpl_table_get_nrow(table1);
215 cpl_array * table_names = cpl_table_get_column_names (table1);
217 for (i = 0; i < ncol; i++){
218 const char * col_name = cpl_array_get_string(table_names, i);
221 int type = cpl_table_get_column_type(table1, col_name);
222 cpl_array ** array_table1;
223 cpl_array ** array_table2;
224 double * double_table1;
225 double * double_table2;
228 float * float_table1;
229 float * float_table2;
230 char ** string_table1;
231 char ** string_table2;
234 case CPL_TYPE_DOUBLE | CPL_TYPE_POINTER :
235 case CPL_TYPE_POINTER | CPL_TYPE_INT:
236 case CPL_TYPE_FLOAT | CPL_TYPE_POINTER :
237 case CPL_TYPE_DOUBLE_COMPLEX | CPL_TYPE_POINTER :
238 case CPL_TYPE_FLOAT_COMPLEX | CPL_TYPE_POINTER :
239 array_table1 = cpl_table_get_data_array(table1, col_name);
240 array_table2 = cpl_table_get_data_array(table2, col_name);
241 for (j = 0; j < nrow; j++){
243 , array_table2[j]) != 1){
244 cpl_msg_info(cpl_func,
"Case array : on the column %s and in the row %d"
245 " the arrays are different", col_name, j);
250 case CPL_TYPE_DOUBLE :
251 double_table1 = cpl_table_get_data_double(table1, col_name);
252 double_table2 = cpl_table_get_data_double(table2, col_name);
253 for (j = 0; j < nrow; j++){
254 if (double_table1[j] > 1e-10){
255 if (fabs((double_table1[j] - double_table2[j]) / double_table1[j]) > 0.1){
256 cpl_msg_info(cpl_func,
"Case double : on the column %s and in the row %d"
257 " the double are different", col_name, j);
262 if (double_table2[j] > 1e-10){
263 cpl_msg_info(cpl_func,
"Case double : on the column %s and in the row %d"
264 " the double are different", col_name, j);
272 int_table1 = cpl_table_get_data_int(table1, col_name);
273 int_table2 = cpl_table_get_data_int(table2, col_name);
274 for (j = 0; j < nrow; j++){
275 if (int_table1[j] != 0){
276 if (abs(int_table1[j] - int_table2[j]) / int_table1[j] > 1){
277 cpl_msg_info(cpl_func,
"Case int : on the column %s and in the row %d"
278 " the integers are different\n", col_name, j);
283 if (int_table2[j] != 0){
284 cpl_msg_info(cpl_func,
"Case int : on the column %s and in the row %d"
285 " the integers are different\n", col_name, j);
293 case CPL_TYPE_FLOAT :
294 float_table1 = cpl_table_get_data_float(table1, col_name);
295 float_table2 = cpl_table_get_data_float(table2, col_name);
296 for (j = 0; j < nrow; j++){
297 if (float_table1[j] > 1e-10){
298 if (fabs((float_table1[j] - float_table2[j]) / float_table1[j]) > 0.1){
299 cpl_msg_info(cpl_func,
"Case int : on the column %s and in the row %d"
300 " the integers are different\n", col_name, j);
305 if (float_table2[j] > 1e-10){
306 cpl_msg_info(cpl_func,
"Case int : on the column %s and in the row %d"
307 " the integers are different\n", col_name, j);
314 case CPL_TYPE_STRING :
315 string_table1 = cpl_table_get_data_string(table1, col_name);
316 string_table2 = cpl_table_get_data_string(table2, col_name);
317 for (j = 0; j < nrow; j++){
318 if (strcmp(string_table1[j], string_table2[j]) != 0){
319 cpl_msg_info(cpl_func,
"Case string : on the column %s and in the row %d"
320 " the strings are different\n", col_name, j);
328 cpl_msg_info(cpl_func,
"invalid type %s\n", cpl_type_get_name (type));
333 cpl_array_delete(table_names);
338 cpl_msg_info(cpl_func,
"The tables don't have the same number of columns, "
339 "with the same names or the same types\n");
348 int size = cpl_propertylist_get_size (plist1);
349 if ( size != cpl_propertylist_get_size(plist2)){
350 cpl_msg_info(cpl_func,
"the property lists don't have the same size\n");
357 for (i = 0; i < size; i++){
358 p = cpl_propertylist_get(plist1, i);
359 name = cpl_property_get_name(p);
360 if(!cpl_propertylist_has (plist2, name)){
361 cpl_msg_info(cpl_func,
"The property %s is not present on the second "
362 "property list \n", name);
366 cpl_type type1 = cpl_propertylist_get_type (plist1, name);
367 cpl_type type2 = cpl_propertylist_get_type (plist2, name);
368 if (strcmp(cpl_type_get_name(type1), cpl_type_get_name(type2))){
369 cpl_msg_info(cpl_func,
"The property %s in the first property list "
370 "have not the same type as in the second property list \n"
378 const char * p_string;
382 case CPL_TYPE_DOUBLE :
383 p_double = cpl_propertylist_get_double(plist1, name);
384 if (p_double != cpl_propertylist_get_double(plist2, name)){
385 cpl_msg_info(cpl_func,
"case Double : the property %s have not the same value\n", name);
390 p_int = cpl_propertylist_get_int(plist1, name);
391 if (p_int != cpl_propertylist_get_int(plist2, name)){
392 cpl_msg_info(cpl_func,
"case interger : the property %s have not the same value\n", name);
396 case CPL_TYPE_FLOAT :
397 p_float = cpl_propertylist_get_float(plist1, name);
398 if (p_float != cpl_propertylist_get_float(plist2, name)){
399 cpl_msg_info(cpl_func,
"case float : the property %s have not the same value\n", name);
403 case CPL_TYPE_STRING :
404 p_string = cpl_propertylist_get_string(plist1, name);
405 if (strcmp(p_string, cpl_propertylist_get_string(plist2, name))){
406 cpl_msg_info(cpl_func,
"case string : the property %s have not the same value\n", name);
411 p_long = cpl_propertylist_get_long(plist1, name);
412 if (p_long != cpl_propertylist_get_long(plist2, name)){
413 cpl_msg_info(cpl_func,
"case long : the property %s have not the same value\n", name);
418 p_char = cpl_propertylist_get_char(plist1, name);
419 if (p_char != cpl_propertylist_get_char(plist2, name)){
420 cpl_msg_info(cpl_func,
"case char : the property %s have not the same value\n", name);
425 cpl_msg_info(cpl_func,
"invalid type of property %s\n", cpl_type_get_name (type1));
441 cpl_msg_info(cpl_func,
"The elements don't have the same size\n");
444 cpl_propertylist * p1;
446 cpl_propertylist * p2;
449 cpl_msg_info(cpl_func,
"The %s property list is diffetent "
456 for(i = 0; i < size; i++){
458 name = cpl_propertylist_get_string(p1,
"EXTNAME");
460 while( ext != size ){
462 if (!strcmp(name, cpl_propertylist_get_string(p2,
"EXTNAME"))){
468 cpl_msg_info(cpl_func,
"The seconde element don't contain the %s "
469 "property list\n", name);
475 cpl_msg_info(cpl_func,
"The %s property list is not the same for the "
476 "twe elements\n", name);
482 cpl_msg_info(cpl_func,
"The table associated to %s property list is not"
483 " the same for the two elements\n", name);
int gravi_propertylist_compare(cpl_propertylist *plist1, cpl_propertylist *plist2)
int gravi_table_compare(cpl_table *table1, cpl_table *table2)
int gravi_data_compare(gravi_data *data1, gravi_data *data2)
int gravi_array_compare(cpl_array *array_1, cpl_array *array_2)
#define GRAVI_PRIMARY_HDR_EXT
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
cpl_propertylist * gravi_data_get_plist(gravi_data *self, const char *extname)
Get the propertylist from EXTNAME.
cpl_propertylist * gravi_data_get_plist_x(gravi_data *self, int i)
Get the propertylist of an extension by position.
int gravi_data_get_size(const gravi_data *self)
Get the number of extension in a gravi_data.
cpl_table * gravi_data_get_table_x(gravi_data *self, int i)
Get the table of an extension by position.