1 /********************************************************************* 2 blank -- Deal with blank values in a datasets 3 This is part of GNU Astronomy Utilities (Gnuastro) package. 4 5 Original author: 6 Mohammad Akhlaghi <mohammad@akhlaghi.org> 7 Contributing author(s): 8 Copyright (C) 2017-2021, Free Software Foundation, Inc. 9 10 Gnuastro is free software: you can redistribute it and/or modify it 11 under the terms of the GNU General Public License as published by the 12 Free Software Foundation, either version 3 of the License, or (at your 13 option) any later version. 14 15 Gnuastro is distributed in the hope that it will be useful, but 16 WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>. 22 **********************************************************************/ 23 #ifndef __GAL_BLANK_H__ 24 #define __GAL_BLANK_H__ 25 26 /* Include other headers if necessary here. Note that other header files 27 must be included before the C++ preparations below */ 28 #include <gnuastro/data.h> 29 30 /* When we are within Gnuastro's building process, 'IN_GNUASTRO_BUILD' is 31 defined. In the build process, installation information (in particular 32 'GAL_CONFIG_SIZEOF_SIZE_T' that we need below) is kept in 33 'config.h'. When building a user's programs, this information is kept in 34 'gnuastro/config.h'. Note that all '.c' files in Gnuastro's source must 35 start with the inclusion of 'config.h' and that 'gnuastro/config.h' is 36 only created at installation time (not present during the building of 37 Gnuastro). */ 38 #ifndef IN_GNUASTRO_BUILD 39 #include <gnuastro/config.h> 40 #endif 41 42 #include <gnuastro/list.h> 43 44 /* C++ Preparations */ 45 #undef __BEGIN_C_DECLS 46 #undef __END_C_DECLS 47 #ifdef __cplusplus 48 # define __BEGIN_C_DECLS extern "C" { 49 # define __END_C_DECLS } 50 #else 51 # define __BEGIN_C_DECLS /* empty */ 52 # define __END_C_DECLS /* empty */ 53 #endif 54 /* End of C++ preparations */ 55 56 57 58 /* Actual header contants (the above were for the Pre-processor). */ 59 __BEGIN_C_DECLS /* From C++ preparations */ 60 61 62 /* Macros: */ 63 64 /* Blank values: Note that for the unsigned types or small types (like 65 char), the maximum value is considered as a blank value, since the 66 minimum value of an unsigned type is zero and zero is often meaningful 67 in contexts were unsigned values are used. */ 68 #define GAL_BLANK_UINT8 UINT8_MAX 69 #define GAL_BLANK_INT8 INT8_MIN 70 #define GAL_BLANK_UINT16 UINT16_MAX 71 #define GAL_BLANK_INT16 INT16_MIN 72 #define GAL_BLANK_UINT32 UINT32_MAX 73 #define GAL_BLANK_INT32 INT32_MIN 74 #define GAL_BLANK_UINT64 UINT64_MAX 75 #define GAL_BLANK_INT64 INT64_MIN 76 #define GAL_BLANK_FLOAT32 NAN 77 #define GAL_BLANK_FLOAT64 NAN 78 #define GAL_BLANK_STRING "n/a" 79 80 #if GAL_CONFIG_SIZEOF_SIZE_T == 4 81 #define GAL_BLANK_SIZE_T GAL_BLANK_UINT32 82 #else 83 #define GAL_BLANK_SIZE_T GAL_BLANK_UINT64 84 #endif 85 86 #if GAL_CONFIG_SIZEOF_LONG == 4 87 #define GAL_BLANK_LONG GAL_BLANK_INT32 88 #define GAL_BLANK_ULONG GAL_BLANK_UINT32 89 #elif GAL_CONFIG_SIZEOF_LONG == 8 90 #define GAL_BLANK_LONG GAL_BLANK_INT64 91 #define GAL_BLANK_ULONG GAL_BLANK_UINT64 92 #endif 93 94 #if GAL_CONFIG_SIZEOF_INT == 4 95 #define GAL_BLANK_INT GAL_BLANK_INT32 96 #define GAL_BLANK_UINT GAL_BLANK_UINT32 97 #elif GAL_CONFIG_SIZEOF_INT == 2 98 #define GAL_BLANK_INT GAL_BLANK_INT16 99 #define GAL_BLANK_UINT GAL_BLANK_UINT16 100 #endif 101 102 103 /* Functions. */ 104 void 105 gal_blank_write(void *pointer, uint8_t type); 106 107 void * 108 gal_blank_alloc_write(uint8_t type); 109 110 void 111 gal_blank_initialize(gal_data_t *input); 112 113 void 114 gal_blank_initialize_array(void *array, size_t size, uint8_t type); 115 116 char * 117 gal_blank_as_string(uint8_t type, int width); 118 119 int 120 gal_blank_is(void *pointer, uint8_t type); 121 122 int 123 gal_blank_present(gal_data_t *input, int updateflag); 124 125 size_t 126 gal_blank_number(gal_data_t *input, int updateflag); 127 128 gal_data_t * 129 gal_blank_flag(gal_data_t *data); 130 131 void 132 gal_blank_flag_apply(gal_data_t *input, gal_data_t *flag); 133 134 void 135 gal_blank_remove(gal_data_t *data); 136 137 void 138 gal_blank_remove_realloc(gal_data_t *input); 139 140 gal_data_t * 141 gal_blank_remove_rows(gal_data_t *columns, gal_list_sizet_t *column_indexs); 142 143 __END_C_DECLS /* From C++ preparations */ 144 145 #endif /* __GAL_DATA_H__ */ 146